public static async Task <WfiItem> Create( long p_atviID, DateTime p_date, bool p_isRole, long p_receiver, string p_note, bool p_isBack) { WfiItem item = new WfiItem( ID: await AtCm.NewID(), AtviID: p_atviID, AssignKind: (p_isBack ? WfiItemAssignKind.回退 : WfiItemAssignKind.普通指派), Status: WfiItemStatus.活动, IsAccept: false, Sender: Kit.UserName, Stime: p_date, Ctime: p_date, Mtime: p_date, Note: p_note, Dispidx: await AtCm.NewSeq("sq_wfi_item")); if (p_isRole) { item.RoleID = p_receiver; } else { item.UserID = p_receiver; } return(item); }
/// <summary> /// 执行插入方法 /// </summary> /// <param name="p_elem"></param> async void Insert(FrameworkElement p_elem) { _sketch.SetNodePos(p_elem, this.GetRelativePosition(_sketch)); if (p_elem is SNode node) { node.ID = await AtCm.NewID(); } _sketch.Insert(p_elem); }
async void OnUpload(object sender, Mi e) { var files = await Kit.PickFiles(); if (files == null || files.Count == 0) { return; } int cnt = 0; DateTime ctime = Kit.Now; foreach (var file in files) { Row row = new Row(); row.AddCell("id", await AtCm.NewID()); row.AddCell("parentid", _fileMgr.FolderID); row.AddCell("name", file.DisplayName); row.AddCell("isfolder", false); row.AddCell("extname", file.Ext.TrimStart('.')); row.AddCell <string>("info"); row.AddCell("ctime", ctime); _lv.Data.Add(row); FileList fl; var elem = _lv.GetRowUI(_lv.Data.Count - 1); if (elem == null || (fl = elem.FindChildByType <FileList>()) == null) { _lv.Data.Remove(row); continue; } bool suc = await fl.UploadFiles(new List <FileData> { file }); if (suc) { row["info"] = fl.Data; suc = await _fileMgr.SaveFile(row); } if (!suc) { _lv.Data.Remove(row); } else { cnt++; } } Kit.Msg($"成功上传{cnt}个文件"); }
async void AddMenu(bool p_isGroup) { var sel = _tv.Selected <Menu>(); Menu m = new Menu( ID: await AtCm.NewID(), Name: p_isGroup ? "新组" : "新菜单", Icon: p_isGroup ? "文件夹" : "文件", IsGroup: p_isGroup, ParentID: sel.ID > 0 ? (long?)sel.ID : null, Dispidx: await AtCm.NewSeq("sq_menu"), Ctime: Kit.Now, Mtime: Kit.Now); m.AddCell("parentname", sel.Name); _fv.Data = m; }
public static async Task <WfdPrc> New() { var prc = new WfdPrc( ID: await AtCm.NewID(), Name: "新流程", IsLocked: true, Dispidx: await AtCm.NewSeq("sq_wfd_prc"), Ctime: Kit.Now); prc.Atvs = Table <WfdAtv> .Create(); prc.Trss = Table <WfdTrs> .Create(); prc.AtvRoles = Table <WfdAtvrole> .Create(); prc.AttachEvent(); return(prc); }
public async Task<bool> SaveFolder(long p_id, string p_name) { Pubfile pf; if (p_id == -1) { pf = new Pubfile( ID: await AtCm.NewID(), ParentID: FolderID, Name: p_name, IsFolder: true, Ctime: Kit.Now); } else { pf = new Pubfile(ID: p_id); pf.IsAdded = false; pf["name"] = p_name; } return await AtCm.Save(pf); }
public async Task <bool> SaveFolder(long p_id, string p_name) { Myfile file; if (p_id == -1) { file = new Myfile( ID: await AtCm.NewID(), ParentID: FolderID == -1 ? (long?)null : FolderID, Name: p_name, IsFolder: true, Ctime: Kit.Now, UserID: Kit.UserID); } else { file = new Myfile(ID: p_id); file.IsAdded = false; file["name"] = p_name; } return(await AtCm.Save(file)); }
async void OnBackClick(object sender, RoutedEventArgs e) { if (_cbBack.IsChecked == true) { WfdTrs trs = new WfdTrs( ID: await AtCm.NewID(), PrcID: _curTrs.PrcID, IsRollback: true, SrcAtvID: _curTrs.TgtAtvID, TgtAtvID: _curTrs.SrcAtvID, TrsID: _curTrs.ID); _trss.Add(trs); } else { var trs = (from item in _trss.OfType <WfdTrs>() where item.TrsID == _curTrs.ID select item).FirstOrDefault(); if (trs != null) { _trss.Remove(trs); } } }
/// <summary> /// 执行发送 /// </summary> /// <param name="p_manualSend">是否手动选择接收者</param> async void DoSend(bool p_manualSend) { #region 后续活动 // 生成后续活动的活动实例、工作项、迁移实例,一个或多个 var tblAtvs = Table <WfiAtv> .Create(); var tblItems = Table <WfiItem> .Create(); var tblTrs = Table <WfiTrs> .Create(); DateTime time = Kit.Now; if (_info.NextRecvs.FinishedAtv != null && (!p_manualSend || _info.NextRecvs.FinishedAtv.IsSelected)) { // 完成 _info.PrcInst.Status = WfiAtvStatus.结束; _info.PrcInst.Mtime = time; } else { // 普通活动 foreach (AtvRecv ar in _info.NextRecvs.Atvs) { // 手动无选择时 if (p_manualSend && (ar.SelectedRecvs == null || ar.SelectedRecvs.Count == 0)) { continue; } var atvInst = new WfiAtv( ID: await AtCm.NewID(), PrciID: _info.PrcInst.ID, AtvdID: ar.Def.ID, Status: WfiAtvStatus.活动, Ctime: time, Mtime: time); tblAtvs.Add(atvInst); if (p_manualSend) { // 手动发送,已选择项可能为用户或角色 atvInst.InstCount = ar.SelectedRecvs.Count; foreach (var recvID in ar.SelectedRecvs) { var wi = await WfiItem.Create(atvInst.ID, time, ar.IsRole, recvID, ar.Note, false); tblItems.Add(wi); } } else { // 自动发送,按角色 atvInst.InstCount = ar.Recvs.Count; foreach (var row in ar.Recvs) { var wi = await WfiItem.Create(atvInst.ID, time, ar.IsRole, row.ID, ar.Note, false); tblItems.Add(wi); } } // 增加迁移实例 var trs = await _info.CreateAtvTrs(ar.Def.ID, atvInst.ID, time, false); tblTrs.Add(trs); } // 同步活动 var syncAtv = _info.NextRecvs.SyncAtv; if (syncAtv != null && (!p_manualSend || (syncAtv.SelectedRecvs != null && syncAtv.SelectedRecvs.Count > 0))) { // 同步实例 var syncInst = new WfiAtv( ID: await AtCm.NewID(), PrciID: _info.PrcInst.ID, AtvdID: syncAtv.SyncDef.ID, Status: WfiAtvStatus.步, InstCount: 1, Ctime: time, Mtime: time); tblAtvs.Add(syncInst); // 同步工作项 WfiItem item = new WfiItem( ID: await AtCm.NewID(), AtviID: syncInst.ID, AssignKind: WfiItemAssignKind.普通指派, Status: WfiItemStatus.步, IsAccept: false, UserID: Kit.UserID, Sender: Kit.UserName, Stime: time, Ctime: time, Mtime: time, Dispidx: await AtCm.NewSeq("sq_wfi_item")); tblItems.Add(item); // 同步迁移实例 Dict dt = new Dict(); dt["prcid"] = _info.PrcInst.PrcdID; dt["SrcAtvID"] = _info.AtvInst.AtvdID; dt["TgtAtvID"] = syncAtv.SyncDef.ID; dt["IsRollback"] = false; long trsdid = await AtCm.GetScalar <long>("流程-迁移模板ID", dt); var trs = new WfiTrs( ID: await AtCm.NewID(), TrsdID: trsdid, SrcAtviID: _info.AtvInst.ID, TgtAtviID: syncInst.ID, IsRollback: false, Ctime: time); tblTrs.Add(trs); // 同步活动的后续活动实例 var nextInst = new WfiAtv( ID: await AtCm.NewID(), PrciID: _info.PrcInst.ID, AtvdID: syncAtv.Def.ID, Status: WfiAtvStatus.活动, Ctime: time, Mtime: time); tblAtvs.Add(nextInst); if (p_manualSend) { // 手动发送,已选择项可能为用户或角色 nextInst.InstCount = syncAtv.SelectedRecvs.Count; foreach (var recvID in syncAtv.SelectedRecvs) { var wi = await WfiItem.Create(nextInst.ID, time, syncAtv.IsRole, recvID, "", false); tblItems.Add(wi); } } else { // 自动发送,按角色 nextInst.InstCount = syncAtv.Recvs.Count; foreach (var row in syncAtv.Recvs) { var wi = await WfiItem.Create(nextInst.ID, time, syncAtv.IsRole, row.ID, "", false); tblItems.Add(wi); } } // 增加迁移实例 dt = new Dict(); dt["prcid"] = _info.PrcInst.PrcdID; dt["SrcAtvID"] = syncAtv.SyncDef.ID; dt["TgtAtvID"] = syncAtv.Def.ID; dt["IsRollback"] = false; trsdid = await AtCm.GetScalar <long>("流程-迁移模板ID", dt); trs = new WfiTrs( ID: await AtCm.NewID(), TrsdID: trsdid, SrcAtviID: syncInst.ID, TgtAtviID: nextInst.ID, IsRollback: false, Ctime: time); tblTrs.Add(trs); } } // 发送是否有效 // 1. 只有'完成'时有效 // 2. 至少含有一个活动实例时有效 if (tblAtvs.Count == 0 && _info.PrcInst.Status != WfiAtvStatus.结束) { Kit.Msg("所有后续活动均无接收者,发送失败!"); return; } #endregion #region 整理待保存数据 List <object> data = new List <object>(); if (_info.PrcInst.IsChanged) { data.Add(_info.PrcInst); } _info.AtvInst.Finished(); data.Add(_info.AtvInst); _info.WorkItem.Finished(); data.Add(_info.WorkItem); if (tblAtvs.Count > 0) { data.Add(tblAtvs); data.Add(tblItems); data.Add(tblTrs); } #endregion if (await AtCm.BatchSave(data, false)) { Kit.Msg("发送成功!"); _info.CloseWin(); // 推送客户端提醒 } else { // 避免保存失败后,再次点击发送时和保存表单一起被保存,造成状态错误! _info.PrcInst.RejectChanges(); _info.AtvInst.RejectChanges(); _info.WorkItem.RejectChanges(); Kit.Warn("发送失败!"); } }
async void OnRetrieve(object sender, Mi e) { Row row = e.Row; var status = (WfiPrcStatus)row.Int("status"); if (status != WfiPrcStatus.活动) { Kit.Warn($"该任务已{status},无法追回"); return; } if (row.Int("reCount") > 0) { Kit.Warn("含回退,无法追回"); return; } var tbl = await AtCm.Query("流程-后续活动工作项", new { atvdid = row.Long("atvdid"), prciid = row.Long("prciid") }); if (tbl.Count == 0) { Kit.Warn("无后续活动,无法追回"); return; } HashSet <long> ls = new HashSet <long>(); foreach (var r in tbl) { var itemState = (WfiItemStatus)r.Int("Status"); if (itemState == WfiItemStatus.步) { Kit.Warn("后续活动包含同步,无法追回"); return; } if (itemState != WfiItemStatus.活动 || r.Bool("IsAccept")) { Kit.Warn("已签收无法追回!"); return; } ls.Add(r.Long("atviid")); } // 更新当前实例状态为活动 DateTime time = Kit.Now; WfiAtv curAtvi = await AtCm.GetByID <WfiAtv>(row.Long("atviid")); curAtvi.Status = WfiAtvStatus.活动; curAtvi.InstCount += 1; curAtvi.Mtime = time; // 根据当前工作项创建新工作项并更改指派方式 var curItem = await AtCm.GetByID <WfiItem>(row.Long("itemid")); var newItem = new WfiItem( ID: await AtCm.NewID(), AtviID: curItem.AtviID, Status: WfiItemStatus.活动, AssignKind: WfiItemAssignKind.追回, Sender: curItem.Sender, Stime: curItem.Stime, IsAccept: false, RoleID: curItem.RoleID, UserID: curItem.UserID, Note: curItem.Note, Dispidx: await AtCm.NewSeq("sq_wfi_item"), Ctime: time, Mtime: time); // 删除已发送的后续活动实例,关联删除工作项及迁移实例 Table <WfiAtv> nextAtvs = new Table <WfiAtv>(); nextAtvs.StartRecordDelRows(); foreach (var id in ls) { nextAtvs.DeletedRows.Add(new WfiAtv(id)); } // 一个事务批量保存 List <object> data = new List <object>(); data.Add(nextAtvs); data.Add(curAtvi); data.Add(newItem); bool suc = await AtCm.BatchSave(data, false); if (suc) { Kit.Msg("追回成功"); OnSearch(null, null); } else { Kit.Warn("追回失败"); } }
async void CreateRole() { _fv.Data = new Role( ID: await AtCm.NewID(), Name: "新角色"); }
async Task Rollback() { // 活动执行者多于一人时,不允许进行回退 if (_info.AtvInst.InstCount > 1) { Kit.Msg("该活动执行者多于一人,不允许回退!"); return; } // 获得前一活动实例 var pre = await _info.AtvInst.GetRollbackAtv(); if (pre == null) { Kit.Msg("该活动不允许回退!"); return; } if (!await Kit.Confirm("确认要回退吗?")) { return; } DateTime time = Kit.Now; var newAtvInst = new WfiAtv( ID: await AtCm.NewID(), PrciID: _info.PrcInst.ID, AtvdID: pre.AtvdID, Status: WfiAtvStatus.活动, InstCount: 1, Ctime: time, Mtime: time); // 创建迁移实例 var newTrs = await _info.CreateAtvTrs(pre.AtvdID, newAtvInst.ID, time, true); // 当前活动完成状态 _info.AtvInst.Finished(); // 当前工作项置成完成状态 _info.WorkItem.Finished(); Dict dict = new Dict(); dict["name"] = await GetSender(); long userId = await AtCm.GetScalar <long>("流程-获取用户ID", dict); var newItem = await WfiItem.Create(newAtvInst.ID, time, false, userId, null, true); List <object> ls = new List <object>(); if (_info.AtvInst.IsChanged) { ls.Add(_info.AtvInst); } ls.Add(_info.WorkItem); ls.Add(newAtvInst); ls.Add(newItem); ls.Add(newTrs); if (await AtCm.BatchSave(ls, false)) { Kit.Msg("回退成功!"); _info.CloseWin(); } else { Kit.Msg("回退失败!"); } }
async void CreateUser() { _fv.Data = new User( ID: await AtCm.NewID(), Name: "新用户"); }
async void OnAdd(object sender, Mi e) { _fv.Data = new Rpt( ID: await AtCm.NewID(), Name: "新报表"); }