void bookmarkCallback(NativeActivityContext context, Bookmark bookmark, object value) { Dictionary <string, object> dic = value as Dictionary <string, object>; //dic.Add("model", value); User data = (User)(dic["model"]); string approver = dic["curApproveUser"].ToString(); context.SetValue(workflowModel, data); SaveApprovalHistoryToDB(data, approver); var dal = new WFCurrentNodeInfoDAL(); dal.UpdateExitTime(data.WorkflowInstId.ToString(), DateTime.Now); }
public string ExecuteWF(User user, bool reject = false) { string retMsg = "SuccessWF"; if (user == null || user.WorkflowInstId == Guid.Empty) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("model", user); instance = new WorkflowApplication(new AdminRights(), dic); this.InitWorkflowApplication(); instance.Run(); } else { AdminRights rights = new AdminRights(); instance = new WorkflowApplication(rights); this.InitWorkflowApplication(); instance.Load(user.WorkflowInstId); string approver = "SuperAdmin"; if (reject) { //更新状态 WFinstanceDAL wfDal = new WFinstanceDAL(); wfDal.Add(user.WorkflowInstId.ToString(), approver, "驳回"); WFCurrentNodeInfoDAL infoDal = new WFCurrentNodeInfoDAL(); infoDal.UpdateExitTime(user.WorkflowInstId.ToString(), DateTime.Now); instance.Cancel(); retMsg = "驳回成功"; } if (instance.GetBookmarks().Count > 0) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("model", user); dic.Add("curApproveUser", approver); instance.ResumeBookmark("BookmarkTest", dic); } } user.WorkflowInstId = instance.Id; //等待工作线程结束 idleEvent.WaitOne(); instance.Unload(); return(retMsg); }
void SaveApprovalHistoryToDB(User userInfo, string approver) { //WFinstanceDAL wfDal = new WFinstanceDAL(); //WFInstance inst = wfDal.Get(userInfo.WorkflowInstId.ToString()).FirstOrDefault(); //if (inst == null) //{ // inst = new WFInstance(); // inst.WfInstanceId = userInfo.WorkflowInstId; // inst.SubmitTime = DateTime.Now; //} //inst.State = "审核通过"; //inst.ApproveTime = DateTime.Now; //inst.ApproveUser = approver; //inst.CurrentNode = NodeName; //wfDal.Add(inst); WFinstanceDAL wfDal = new WFinstanceDAL(); wfDal.Add(userInfo.WorkflowInstId.ToString(), approver, "审核通过", NodeName); WFCurrentNodeInfoDAL infoDal = new WFCurrentNodeInfoDAL(); infoDal.UpdateExitTime(userInfo.WorkflowInstId.ToString(), DateTime.Now); }