/// <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> /// <param name="model"></param> public async void OnDeleteTag(TagInfoModel model) { //var showResult = this.ShowMessage("确定删除[" + model.Name + "]标签吗?", "提示", MessageBoxButton.OKCancel); //if (showResult == MessageBoxResult.Cancel) // return; var result = await DataApi.DeleteAsync(Hubs.Tag.T, new[] { model.Id }); if (result.IsOk) { PostilTagList.Remove(model); } }
public async void OnAddPostil() { var inputTagList = PostilTag.Split(',', ',').ToList().Select(t => t.Trim()).ToList(); var tagSet = new HashSet <string>(inputTagList.Where(t => t != "")); if (!File.Exists(_screenshotPicPath)) { return; } var result = await DataApi.UploadFilesAsync(new[] { _screenshotPicPath }, Mg.Get <IMgContext>().ProjectId); if (!result.IsOk) { Mg.Get <IMgLog>().Error("上传截图失败:" + result.Message); Mg.Get <IMgDialog>().ShowDesktopAlert("上传截图失败", result.Message); return; } var fileId = result.Data.AsList <Id>().FirstOrDefault(); var data = new DynamicRecord { [Hubs.Postil.ProjectId] = Mg.Get <IMgContext>().ProjectId, [Hubs.Postil.Title] = PostilTitle, [Hubs.Postil.CreateTime] = DateTime.Now, [Hubs.Postil.CreateUser] = Mg.Get <IMgContext>().UserId, [Hubs.Postil.Tags] = tagSet, [Hubs.Postil.IsPublic] = IsPublic, [Hubs.Postil.FileId] = fileId, [Hubs.Postil.CameraMatrix] = _matrixArray }; var createResult = await DataApi.AddAsync(Hubs.Postil.T, new IRecord[] { data }); if (!createResult.IsOk) { Mg.Get <IMgLog>().Error("添加批注失败:" + createResult.Message); Mg.Get <IMgDialog>().ShowDesktopAlert("添加批注失败", createResult.Message); return; } var originalTagList = PostilTagList.Select(tag => tag.Name.Trim()).ToList(); var tagData = (from tag in tagSet where !originalTagList.Contains(tag) select new DynamicRecord { [Hubs.Tag.ProjectId] = Mg.Get <IMgContext>().ProjectId, [Hubs.Tag.Name] = tag }).ToList(); await DataApi.AddAsync(Hubs.Tag.T, tagData.AsArray <IRecord>()); var addRecord = createResult.Data.AsList <DynamicRecord>().FirstOrDefault(); await Mg.Get <IMgWeb>().SendWebMsgAsync("demoPostil/add", addRecord?.Id.ToString(), BoardcastType.ProjectGroup);//发送广播 //Close(); }