/// <summary> /// 加载批注标签数据 /// </summary> private async void LoadPostilTagData() { PostilTagList.Clear(); var listParams = new ListParams { Search = Query.Eq(Hubs.Tag.ProjectId, Mg.Get <IMgContext>().ProjectId) }; var result = await DataApi.GetListAsync(Hubs.Tag.T, listParams); if (!result.IsOk) { return; } var records = result.GetRecords(); foreach (var record in records) { var name = record[Hubs.Tag.Name].As <string>(); var model = new TagInfoModel { Id = record.Id, Name = $" {name} " }; PostilTagList.Add(model); } }
/// <summary> /// 加载指定页的批注信息 /// </summary> private async void LoadPostilInfosAsync(int pageIndex, Action action = null) { IsBusy = true; var listParams = new ListParams { Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId), Page = new ListParams.PageInfo(pageIndex, 8), Sort = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, false) } }; var dataResult = await DataApi.GetListAsync(Hubs.Postil.T, listParams); _listPostilInfoModel.Clear(); if (!dataResult.IsOk) { Mg.Get <IMgLog>().Error("获取批注信息失败" + dataResult.Message); Mg.Get <IMgDialog>().ShowDesktopAlert("获取批注信息失败", dataResult.Message); IsBusy = false; return; } var models = dataResult.GetRecords().Select(t => t.As <PostilInfoModel>()).ToList(); if (models.Count == 0) { IsBusy = false; return; } var urlDic = await Util.Data.GetPictureUrlsAsync(models.Select(t => t.FileId).ToArray()); var userDic = await Util.Data.GetUserInfosAsync(models.Select(t => t.CreateUser).ToArray()); foreach (var postilInfoModel in models) { postilInfoModel.ImageUrl = urlDic?[postilInfoModel.FileId]; postilInfoModel.PostilUser = userDic?[postilInfoModel.CreateUser]; _listPostilInfoModel.Add(postilInfoModel); } ViewPictureModels.Clear(); for (var index = 0; index < models.Count; index++) { var model = models[index]; ViewPictureModels.Add(new PictureModel { SelectedPicIndex = index, PostilId = model._id, ImageUrl = model.ImageUrl }); } SelectedViewPicModel = ViewPictureModels.FirstOrDefault(); action?.Invoke(); LoadNextPageCountAsync(); IsBusy = false; }
/// <summary> /// 读取下一页批注是否还有数据 /// </summary> private async void LoadNextPageCountAsync() { var listParams = new ListParams { Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId), Page = new ListParams.PageInfo(_currentPageIndex + 1, 8), Sort = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, true) }, Map = new[] { Id.Name } }; var result = await DataApi.GetListAsync(Hubs.Postil.T, listParams); if (!result.IsOk) { _canNextPage = false; return; } _canNextPage = result.GetRecords().Count > 0; }
/// <summary> /// 加载所有批注信息数据 /// </summary> private async void LoadPostilInfos() { IsBusy = true; PostilInfoModels.Clear(); _backupPostilInfoModels.Clear(); var listParams = new ListParams { Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId), Sort = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, false) } }; var result = await DataApi.GetListAsync(Hubs.Postil.T, listParams); if (!result.IsOk) { Mg.Get <IMgLog>().Error("获取批注信息失败" + result.Message); Mg.Get <IMgDialog>().ShowDesktopAlert("获取批注信息失败", result.Message); IsBusy = false; return; } var models = result.GetRecords().Select(t => t.As <PostilInfoModel>()).ToList(); if (models.Count == 0) { IsBusy = false; return; } var urlDic = await Util.Data.GetPictureUrlsAsync(models.Select(t => t.FileId).ToArray()); var userDic = await Util.Data.GetUserInfosAsync(models.Select(t => t.CreateUser).ToArray()); foreach (var postilInfoModel in models) { postilInfoModel.ImageUrl = urlDic?[postilInfoModel.FileId]; postilInfoModel.PostilUser = userDic?[postilInfoModel.CreateUser]; postilInfoModel.FirstTag = $" {postilInfoModel.Tags[0]} "; var dt1 = Convert.ToDateTime(postilInfoModel.CreateTime); var dt2 = DateTime.Now; postilInfoModel.LastTime = DateDiff(dt1, dt2); PostilInfoModels.Add(postilInfoModel); _backupPostilInfoModels.Add(postilInfoModel); } IsBusy = false; }