当前位置: 首页 > news >正文

烟台网站建设设计智慧软文网站

烟台网站建设设计,智慧软文网站,做PPT哪个网站的素材多点,最近三天的国际新闻大事注意#xff1a;本实现与视频不一致。本实现中单独做了汇总接口#xff0c;而视频中则合并到国todo接口当中了。 添加汇总webapi接口添加汇总数据客户端接口总数据客户端接口对接3首页数据模型 添加数据汇总字段类 新建文件MyToDo.Share.Models.SummaryDto using System;…注意本实现与视频不一致。本实现中单独做了汇总接口而视频中则合并到国todo接口当中了。 添加汇总webapi接口添加汇总数据客户端接口总数据客户端接口对接3首页数据模型 添加数据汇总字段类 新建文件MyToDo.Share.Models.SummaryDto using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks;namespace MyToDo.Share.Models {public class SummaryDto:BaseDto{private int sum;public int Sum{get { return sum; }set { sum value; OnPropertyChanged(); }}private int compeleteCnt;public int CompeleteCnt{get { return compeleteCnt; }set { compeleteCnt value; OnPropertyChanged(); }}private int memoCnt;public int MemoCnt{get { return memoCnt; }set { memoCnt value; OnPropertyChanged(); }}private string? compeleteRatio;public string? CompeleteRatio{get { return compeleteRatio; }set { compeleteRatio value; OnPropertyChanged(); }}private ObservableCollectionToDoDto todoList;public ObservableCollectionToDoDto TodoList{get { return todoList; }set { todoList value; }}/// summary/// MemoList/// /summaryprivate ObservableCollectionMemoDto memoList;public ObservableCollectionMemoDto MemoList{get { return memoList; }set { memoList value; }}} } 添加汇总webapi接口 添加汇总接口 添加文件MyToDo.Api.Service.ISummary using MyToDo.Share.Parameters;namespace MyToDo.Api.Service {public interface ISummary{TaskApiReponse GetAllInfo(SummaryParameter parameter);} } 实现汇总接口 添加文件MyToDo.Api.Service.Summary using Arch.EntityFrameworkCore.UnitOfWork; using AutoMapper; using MyToDo.Api.Context; using MyToDo.Share.Models; using MyToDo.Share.Parameters; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Collections.ObjectModel;namespace MyToDo.Api.Service {public class Summary : ISummary{private readonly IUnitOfWork work;private readonly IMapper mapper;public Summary(IUnitOfWork work,IMapper mapper){this.work work;this.mapper mapper;}public async TaskApiReponse GetAllInfo(SummaryParameter parameter){try{SummaryDto sumdto new SummaryDto();//获取所有todo信息var Pagetodos await work.GetRepositoryTodo().GetPagedListAsync(pageIndex: parameter.PageIndex, pageSize: parameter.PageSize, orderBy: source source.OrderByDescending(t t.CreateDate));//获取所有memo信息var Pagememos await work.GetRepositoryMemo().GetPagedListAsync(pageIndex: parameter.PageIndex, pageSize: parameter.PageSize, orderBy: source source.OrderByDescending(t t.CreateDate));//汇总待办数量sumdto.Sum Pagetodos.TotalCount;//统计完成数量var todos Pagetodos.Items;sumdto.CompeleteCnt todos.Where(t t.Status 1).Count();//计算已完成比率sumdto.CompeleteRatio (sumdto.CompeleteCnt / (double)sumdto.Sum).ToString(0%);//统计备忘录数量var memos Pagememos.Items;sumdto.MemoCntPagememos.TotalCount;//获取todos项目与memos项目集合sumdto.TodoList new ObservableCollectionToDoDto(mapper.MapListToDoDto(todos.Where(t t.Status 0)));sumdto.MemoList new ObservableCollectionMemoDto(mapper.MapListMemoDto(memos));return new ApiReponse(true, sumdto);}catch (Exception ex){return new ApiReponse(false, ex);}}} } 添加控制器 添加文件MyToDo.Api.Controllers.SummaryController using Microsoft.AspNetCore.Mvc; using Microsoft.VisualBasic; using MyToDo.Api.Service; using MyToDo.Share.Models; using MyToDo.Share.Parameters;namespace MyToDo.Api.Controllers {[ApiController][Route(api/[controller]/[action])]public class SummaryController:ControllerBase{private readonly ISummary service;public SummaryController(ISummary tService){this.service tService;}[HttpGet]public async TaskApiReponse GetAllInfo([FromQuery] SummaryParameter parameter)await service.GetAllInfo(parameter);} } 依赖注入 文件webapi.Program.cs 添加 builder.Services.AddTransientISummary, Summary();添加客户端数据接口 添加接口 新建文件Mytodo.Service.ISummeryService.cs using MyToDo.Share; using MyToDo.Share.Contact; using MyToDo.Share.Models; using MyToDo.Share.Parameters; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Mytodo.Service {public interface ISummeryService{//public async TaskApiResponseSummaryDto GetAllInfo(SummaryParameter parameter)TaskApiResponseSummaryDto GetAllInfo(SummaryParameter parameter);} } 实现接口 添加文件Mytodo.Service.SummeryService using MyToDo.Share; using MyToDo.Share.Contact; using MyToDo.Share.Models; using MyToDo.Share.Parameters; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Mytodo.Service {public class SummeryService : ISummeryService{private readonly HttpRestClient client;private readonly string ServiceNameSummary;public SummeryService(HttpRestClient client){this.client client;}public async TaskApiResponseSummaryDto GetAllInfo(SummaryParameter parameter){BaseRequest request new BaseRequest();request.Method RestSharp.Method.GET;//如果查询字段为空request.Route $api/{ServiceName}/GetAllInfo?PageIndex{parameter.PageIndex} $PageSize{parameter.PageSize};//request.Route $api/{ServiceName}/GetAll?PageIndex{parameter.PageIndex} $PageSize{parameter.PageSize} $search{parameter.Search};return await client.ExecuteAsyncSummaryDto(request);}} } 依赖注入 修改文件App.xaml.cs 添加内容 containerRegistry.RegisterISummeryService, SummeryService();首页对接接口 修改UI层绑定 修改文件Mytodo.Views.IndexView.xaml 由 ItemsSource{Binding TodoDtos} ItemsSource{Binding MemoDtos}修改为 ItemsSource{Binding Summary.TodoList} ItemsSource{Binding Summary.MemoList}新建summary实例并初始化 修改文件Mytodo.ViewModels.IndexViewModel.cs public SummaryDto Summary {get { return summary; }set { summary value; RaisePropertyChanged(); } } private SummaryDto summary;新建summary服务实例并初始化 private readonly ISummeryService summService; public IndexViewModel(IContainerProvider provider,IDialogHostService dialog) : base(provider) {//实例化接口this.toDoService provider.ResolveITodoService();this.memoService provider.ResolveIMemoService();this.summService provider.ResolveISummeryService();//初始化命令EditMemoCmd new DelegateCommandMemoDto(Addmemo);EditTodoCmd new DelegateCommandToDoDto(Addtodo);ToDoCompltedCommand new DelegateCommandToDoDto(Compete);ExecuteCommand new DelegateCommandstring(Execute);this.dialog dialog;CreatBars(); }添加首页数据初始化函数 /// summary /// 更新首页所有信息 /// /summary private async void UpdateData() {UpdateLoding(true);var summaryResult await summService.GetAllInfo(new SummaryParameter() { PageIndex 0, PageSize 1000 });if (summaryResult.Status){Summary summaryResult.Result;Refresh();}UpdateLoding(false); } public override async void OnNavigatedTo(NavigationContext navigationContext) {UpdateData();base.OnNavigatedTo(navigationContext); }void Refresh() {TaskBars[0].Content summary.Sum.ToString();TaskBars[1].Content summary.CompeleteCnt.ToString();TaskBars[2].Content summary.CompeleteRatio;TaskBars[3].Content summary.MemoCnt.ToString(); }用summary的字段替换掉TodoDtos与MemoDtos 更新添加、编辑、完成命 修改后的代码为 using Mytodo.Common.Models; using MyToDo.Share.Parameters; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using MyToDo.Share.Models; using Prism.Commands; using Prism.Services.Dialogs; using Mytodo.Dialog; using Mytodo.ViewModels; using Mytodo.Service; using Prism.Ioc; using System.Diagnostics; using Microsoft.VisualBasic; using ImTools; using DryIoc; using MyToDo.Share; using System.Windows; using Prism.Regions;namespace Mytodo.ViewModels {public class IndexViewModel:NavigationViewModel{#region 定义命令/// summary/// Todo完成命令/// /summarypublic DelegateCommandToDoDto ToDoCompltedCommand { get; set; }public DelegateCommandstring ExecuteCommand { get; set; }/// summary/// 命令编辑备忘/// /summarypublic DelegateCommandMemoDto EditMemoCmd { get;private set; }/// summary/// 命令编辑待办/// /summarypublic DelegateCommandToDoDto EditTodoCmd { get; private set; }#endregion#region 定义属性public SummaryDto Summary{get { return summary; }set { summary value; RaisePropertyChanged(); }}public string Title { get; set; }/// summary/// 首页任务条/// /summarypublic ObservableCollectionTaskBar TaskBars{get { return taskBars; }set { taskBars value; RaisePropertyChanged(); }}#endregion#region 定义重要命令#endregion#region 定义重要字段private readonly IDialogHostService dialog;private readonly ITodoService toDoService;private readonly ISummeryService summService;private readonly IMemoService memoService;#endregion#region 定义普通字段private SummaryDto summary;private ObservableCollectionTaskBar taskBars;#endregion#region 命令相关方法/// summary/// togglebutoon 的命令/// /summary/// param namedto/param/// exception crefNotImplementedException/exceptionasync private void Compete(ToDoDto dto){if (dto null || string.IsNullOrEmpty(dto.Title) || (string.IsNullOrEmpty(dto.Content)))return;var updres await toDoService.UpdateAsync(dto);if (updres.Status){var todo Summary.TodoList.FirstOrDefault(x x.Id.Equals(dto.Id));//更新信息todo.Status dto.Status;}// 从数据库更新信息UpdateData();}/// summary/// 选择执行命令/// /summary/// param nameobj/paramvoid Execute(string obj){switch (obj){case 新增待办: Addtodo(null); break;case 新增备忘: Addmemo(null); break;}}/// summary/// 添加待办事项/// /summaryasync void Addtodo(ToDoDto model){DialogParameters param new DialogParameters();if (model ! null)param.Add(Value, model);var dialogres await dialog.ShowDialog(AddTodoView, param);var newtodo dialogres.Parameters.GetValueToDoDto(Value);if (newtodo null || string.IsNullOrEmpty(newtodo.Title) || (string.IsNullOrEmpty(newtodo.Content)))return;if (dialogres.Result ButtonResult.OK){try{if (newtodo.Id 0){var updres await toDoService.UpdateAsync(newtodo);if (updres.Status){var todo Summary.TodoList.FirstOrDefault(xx.Id.Equals(newtodo.Id));//更新信息todo.Content newtodo.Content;todo.Title newtodo.Title;todo.Status newtodo.Status;}}else{//添加内容 //更新数据库数据var addres await toDoService.AddAsync(newtodo);//更新UI数据if (addres.Status){Summary.TodoList.Add(addres.Result);}}}catch {}finally{UpdateLoding(false);}}// 从数据库更新信息UpdateData();}/// summary/// 添加备忘录/// /summaryasync void Addmemo(MemoDto model){DialogParameters param new DialogParameters();if (model ! null)param.Add(Value, model);var dialogres await dialog.ShowDialog(AddMemoView, param);if (dialogres.Result ButtonResult.OK){try{var newmemo dialogres.Parameters.GetValueMemoDto(Value);if (newmemo ! null string.IsNullOrWhiteSpace(newmemo.Content) string.IsNullOrWhiteSpace(newmemo.Title))return;if (newmemo.Id 0){var updres await memoService.UpdateAsync(newmemo);if (updres.Status){//var memo MemoDtos.FindFirst(predicate: x x.Id newmemo.Id);var memo Summary.MemoList.FirstOrDefault( x x.Id.Equals( newmemo.Id));//更新信息memo.Content newmemo.Content;memo.Title newmemo.Title;}}else{//添加内容var addres await memoService.AddAsync(newmemo);//更新UI数据if (addres.Status){Summary.MemoList.Add(addres.Result);}}}catch{}finally{UpdateLoding(false);}}// 从数据库更新信息UpdateData();}#endregion#region 其它方法/// summary/// 更新首页所有信息/// /summaryprivate async void UpdateData(){UpdateLoding(true);var summaryResult await summService.GetAllInfo(new SummaryParameter() { PageIndex 0, PageSize 1000 });if (summaryResult.Status){Summary summaryResult.Result;Refresh();}UpdateLoding(false);}#endregion#region 启动项相关void CreatBars(){Title 您好2022;TaskBars new ObservableCollectionTaskBar();TaskBars.Add(new TaskBar { Icon CalendarBlankOutline, Title 汇总, Color #FF00FF00, Content 27, Target });TaskBars.Add(new TaskBar { Icon CalendarMultipleCheck, Title 已完成, Color #6B238E, Content 24, Target });TaskBars.Add(new TaskBar { Icon ChartLine, Title 完成比例, Color #32CD99, Content 100%, Target });TaskBars.Add(new TaskBar { Icon CheckboxMarked, Title 备忘录, Color #5959AB, Content 13, Target });}public override async void OnNavigatedTo(NavigationContext navigationContext){UpdateData();base.OnNavigatedTo(navigationContext);}void Refresh(){TaskBars[0].Content summary.Sum.ToString();TaskBars[1].Content summary.CompeleteCnt.ToString();TaskBars[2].Content summary.CompeleteRatio;TaskBars[3].Content summary.MemoCnt.ToString();}#endregionpublic IndexViewModel(IContainerProvider provider,IDialogHostService dialog) : base(provider){//实例化接口this.toDoService provider.ResolveITodoService();this.memoService provider.ResolveIMemoService();this.summService provider.ResolveISummeryService();//初始化命令EditMemoCmd new DelegateCommandMemoDto(Addmemo);EditTodoCmd new DelegateCommandToDoDto(Addtodo);ToDoCompltedCommand new DelegateCommandToDoDto(Compete);ExecuteCommand new DelegateCommandstring(Execute);this.dialog dialog;CreatBars();}} }
http://www.hkea.cn/news/14576742/

相关文章:

  • 网站的风格有哪些东营做网站seo的
  • 做网站的网站犯法吗东莞网站设计建设公司
  • 网站响应速度多少合适wordpress安全设置
  • 南昌易动力网站建设公司it外包的优点不包括
  • 秦皇岛建设网站公司哪家好网站的pr
  • wordpress建站案例视频教程百度上如何做企业网站
  • wordpress如何发布文章做一个网站加优化排名得多少钱
  • 外国网站英语要求05网英语课课练答案
  • 教育网站建设 飞沐哪个网站可以做自由行地图
  • wordpress修改文字内容网站优化 合同
  • 哪个网站可以做装修效果图哪个网站是做韩国化妆品正品
  • 零基础自学做网站wordpress 图灵机器人
  • 公司网站转微信小程序北京注册公司查询
  • 西安做网站建设哪家好北京 网站建设 知乎
  • seo优缺点兰州优化网站
  • 泉州丰泽建设局网站手机端网页设计尺寸规范
  • wordpress全站备份互联网运营推广公司
  • 本地的番禺网站建设住房与城乡建设局网站
  • 四川省建设工程招投标网站宣传片制作网站
  • 深圳市研发网站建设哪家好网站游戏入口
  • asp access网站开发实例精讲哪些公司可以建设网站
  • 哪里做网站比较稳定如何做app推广
  • wp网站模板建设银行公积金网站
  • 淘宝客网站WordPress手机建设银行官方网站
  • 做微信公众号的网站有哪些内容电力建设期刊网站投稿
  • 阿里巴巴网站优化怎么做贵阳做网站需要多少钱
  • 各种网站底部图标代码邢台做网站改版
  • 专业网站建设制作公司哪家好网站托管 域名
  • vr网站开发技术网站开发需解决的难题
  • 做网站哪家网页制作软件visual