public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) return; //MonitorCache.GetInstance().PushMessage(new CacheMessage { Message = "activityid:" + activity.Value.ID + " next activity status:" + activity.Value.Status.ToString() }, CacheEnum.FormMonitor); ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); //设置当前活动点状态 activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); var task = activity.GetUserProcessingTask(processor); if (task == null) throw new Exception("环节中没有你的任务,无法进行审批操作"); task.Status = (int)TaskProcessStatus.Processed; task.ProcessTime = DateTime.Now; task.LastUpdator = processor; //处理任务 taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List<string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { nextActivityModel.Tasks.Add(t); taskdao.Add(t); } } } }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) throw new Exception("审批意见不能为null"); if (string.IsNullOrEmpty(approval.Remark)) throw new Exception("审批意见不能为空"); //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) return; ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Started; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //处理当前流程所有任务,设置为已处理 var task = activity.GetUserProcessingTask(processor); if (task == null) throw new Exception("环节中没有你的任务,无法进行审批操作"); task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ActivityID = task.ActivityID }, }); //把所有活动点的状态清空 activity.OwnerWorkflow.Root.GetList().ForEach(t => t.Value.Status = activity.Value.Status); activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status }, ActivityQueryForm = new ActivityQueryForm { WorkflowID = activity.Value.WorkflowID } }); activity.OwnerWorkflow.Root.Value.Status = (int)ActivityProcessStatus.Processing; var root = activity.OwnerWorkflow.Root; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = root.Value.Status }, ActivityQueryForm = new ActivityQueryForm { ID = root.Value.ID }, }); //生成退回任务 Task roottask = new Task { ActivityID = root.Value.ID, Name = root.Value.Name, Title = root.Value.Title + "(退回)", UserID = activity.OwnerWorkflow.Value.Creator, WorkflowID = activity.OwnerWorkflow.Value.ID, Status = (int)TaskProcessStatus.Started, Creator = processor, }; root.Tasks.Add(roottask); taskdao.Add(roottask); }
public WorkflowModel StartNew(string creator, string processid, IWorkflowAuthority iauth) { var mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao aadd = new ActivityAuthDao(mapper); TaskDao taskdao = new TaskDao(mapper); WorkflowModel model = null; Workflow wf = this.value.ConvertTo <Workflow>(); wf.ID = null; wf.Creator = creator; wf.Status = (int)WorkflowProcessStatus.Started; wf.WorkflowDefinitionID = this.value.ID; wf.ProcessID = processid; workflowdao.Add(wf); var activites = this.ActivityDefinitionList; var links = this.LinkDefinitionList; List <Activity> activityEntities = new List <Activity>(); foreach (var a in activites) { Activity activity = a.Value.ConvertTo <Activity>(); activity.Creator = creator; activity.ID = null; activity.WorkflowID = wf.ID; activity.ActivityDefinitionID = a.Value.ID; activity.Title = a.Value.Title; activity.Status = (int)ActivityProcessStatus.Started; List <ActivityAuth> authList = new List <ActivityAuth>(); //如果是开始节点,就设置为已处理 if (this.Root.Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processed; activity.ProcessTime = DateTime.Now; } if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processing; } activitydao.Add(activity); activityEntities.Add(activity); //权限处理 foreach (var ad in a.AuthDefinition) { ActivityAuth auth = ad.ConvertTo <ActivityAuth>(); auth.Creator = creator; auth.WorkflowID = wf.ID; auth.ActivityID = activity.ID; auth.ID = null; auth.ActivityAuthDefinitionID = ad.ID; aadd.Add(auth); authList.Add(auth); } //如果是第二节点,就设置成正在处理 if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { ActivityModel activitymodel = new ActivityModel { Value = activity, }; var idlist = iauth.GetUserIDList(authList); var tasklist = activitymodel.GetTask(creator, idlist); foreach (var task in tasklist) { taskdao.Add(task); } } } foreach (var l in links) { Link link = l.Value.ConvertTo <Link>(); link.Creator = creator; link.WorkflowID = wf.ID; link.ID = null; link.LinkDefinitionID = l.Value.ID; var fromactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.FromActivityDefinitionID); var totactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.ToActivityDefinitionID); if (fromactivity != null) { link.FromActivityID = fromactivity.ID; } if (totactivity != null) { link.ToAcivityID = totactivity.ID; } linkdao.Add(link); } model = WorkflowModel.Load(wf.ID); return(model); }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) { throw new Exception("审批意见不能为null"); } if (string.IsNullOrEmpty(approval.Remark)) { throw new Exception("审批意见不能为空"); } //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) { return; } ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Started; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //处理当前流程所有任务,设置为已处理 var task = activity.GetUserProcessingTask(processor); if (task == null) { throw new Exception("环节中没有你的任务,无法进行审批操作"); } task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ActivityID = task.ActivityID }, }); //把所有活动点的状态清空 activity.OwnerWorkflow.Root.GetList().ForEach(t => t.Value.Status = activity.Value.Status); activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status }, ActivityQueryForm = new ActivityQueryForm { WorkflowID = activity.Value.WorkflowID } }); activity.OwnerWorkflow.Root.Value.Status = (int)ActivityProcessStatus.Processing; var root = activity.OwnerWorkflow.Root; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = root.Value.Status }, ActivityQueryForm = new ActivityQueryForm { ID = root.Value.ID }, }); //生成退回任务 Task roottask = new Task { ActivityID = root.Value.ID, Name = root.Value.Name, Title = root.Value.Title + "(退回)", UserID = activity.OwnerWorkflow.Value.Creator, WorkflowID = activity.OwnerWorkflow.Value.ID, Status = (int)TaskProcessStatus.Started, Creator = processor, }; root.Tasks.Add(roottask); taskdao.Add(roottask); }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) throw new Exception("审批意见不能为null"); if (string.IsNullOrEmpty(approval.Remark)) throw new Exception("审批意见不能为空"); //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) return; ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //处理任务 var task = activity.GetUserProcessingTask(processor); if (task == null) throw new Exception("环节中没有你的任务,无法进行审批操作"); task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = DateTime.Now, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List<string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { taskdao.Add(t); nextActivityModel.Tasks.Add(t); } } } }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { if (approval == null) { throw new Exception("审批意见不能为null"); } if (string.IsNullOrEmpty(approval.Remark)) { throw new Exception("审批意见不能为空"); } //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) { return; } ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; //新增审批意见 if (approval != null) { ApprovalDao ad = new ApprovalDao(mapper); approval.Creator = processor; approval.ActivityID = activity.Value.ID; approval.WorkflowID = activity.Value.WorkflowID; ad.Add(approval); activity.OwnerWorkflow.Approval.Add(approval); } //设置当前活动点状态 activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); //处理任务 var task = activity.GetUserProcessingTask(processor); if (task == null) { throw new Exception("环节中没有你的任务,无法进行审批操作"); } task.ProcessTime = DateTime.Now; task.Status = (int)TaskProcessStatus.Processed; task.LastUpdator = processor; taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = DateTime.Now, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List <string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { taskdao.Add(t); nextActivityModel.Tasks.Add(t); } } } }
public void Process(ActivityModel activity, Approval approval, string processor, IWorkflowAuthority auth) { //已经处理过就不能再处理 if (activity.Value.Status == (int)ActivityProcessStatus.Processed) { return; } //MonitorCache.GetInstance().PushMessage(new CacheMessage { Message = "activityid:" + activity.Value.ID + " next activity status:" + activity.Value.Status.ToString() }, CacheEnum.FormMonitor); ISqlMapper mapper = MapperHelper.GetMapper(); ActivityDao activitydao = new ActivityDao(mapper); TaskDao taskdao = new TaskDao(mapper); //设置当前活动点状态 activity.Value.Status = (int)ActivityProcessStatus.Processed; activity.Value.ProcessTime = DateTime.Now; activity.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = activity.Value.Status, ProcessTime = activity.Value.ProcessTime, LastUpdator = activity.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = activity.Value.ID } }); var task = activity.GetUserProcessingTask(processor); if (task == null) { throw new Exception("环节中没有你的任务,无法进行审批操作"); } task.Status = (int)TaskProcessStatus.Processed; task.ProcessTime = DateTime.Now; task.LastUpdator = processor; //处理任务 taskdao.Update(new TaskUpdateForm { Entity = new Task { ProcessTime = task.ProcessTime, Status = task.Status, LastUpdator = task.LastUpdator }, TaskQueryForm = new TaskQueryForm { ID = task.ID }, }); //设置下个活动点的状态 if (activity.Children.Count > 0) { foreach (var next in activity.Children) { string nextactivityid = next.Value.ID; var nextActivityModel = next as ActivityModel; nextActivityModel.Value.Status = (int)ActivityProcessStatus.Processing; nextActivityModel.Value.LastUpdator = processor; activitydao.Update(new ActivityUpdateForm { Entity = new Activity { Status = nextActivityModel.Value.Status, LastUpdator = nextActivityModel.Value.LastUpdator }, ActivityQueryForm = new ActivityQueryForm { ID = nextactivityid }, }); List <string> useridList = auth.GetUserIDList(nextActivityModel.Auth); //新增下个活动点的任务 var tasklist = nextActivityModel.GetTask(processor, useridList); foreach (var t in tasklist) { nextActivityModel.Tasks.Add(t); taskdao.Add(t); } } } }
public WorkflowModel StartNew(string creator, string processid, IWorkflowAuthority iauth) { var mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao aadd = new ActivityAuthDao(mapper); TaskDao taskdao = new TaskDao(mapper); WorkflowModel model = null; Workflow wf = this.value.ConvertTo<Workflow>(); wf.ID = null; wf.Creator = creator; wf.Status = (int)WorkflowProcessStatus.Started; wf.WorkflowDefinitionID = this.value.ID; wf.ProcessID = processid; workflowdao.Add(wf); var activites = this.ActivityDefinitionList; var links = this.LinkDefinitionList; List<Activity> activityEntities = new List<Activity>(); foreach (var a in activites) { Activity activity = a.Value.ConvertTo<Activity>(); activity.Creator = creator; activity.ID = null; activity.WorkflowID = wf.ID; activity.ActivityDefinitionID = a.Value.ID; activity.Title = a.Value.Title; activity.Status = (int)ActivityProcessStatus.Started; List<ActivityAuth> authList = new List<ActivityAuth>(); //如果是开始节点,就设置为已处理 if (this.Root.Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processed; activity.ProcessTime = DateTime.Now; } if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processing; } activitydao.Add(activity); activityEntities.Add(activity); //权限处理 foreach (var ad in a.AuthDefinition) { ActivityAuth auth = ad.ConvertTo<ActivityAuth>(); auth.Creator = creator; auth.WorkflowID = wf.ID; auth.ActivityID = activity.ID; auth.ID = null; auth.ActivityAuthDefinitionID = ad.ID; aadd.Add(auth); authList.Add(auth); } //如果是第二节点,就设置成正在处理 if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { ActivityModel activitymodel = new ActivityModel { Value = activity, }; var idlist = iauth.GetUserIDList(authList); var tasklist = activitymodel.GetTask(creator, idlist); foreach (var task in tasklist) { taskdao.Add(task); } } } foreach (var l in links) { Link link = l.Value.ConvertTo<Link>(); link.Creator = creator; link.WorkflowID = wf.ID; link.ID = null; link.LinkDefinitionID = l.Value.ID; var fromactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.FromActivityDefinitionID); var totactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.ToActivityDefinitionID); if (fromactivity != null) { link.FromActivityID = fromactivity.ID; } if (totactivity != null) { link.ToAcivityID = totactivity.ID; } linkdao.Add(link); } model = WorkflowModel.Load(wf.ID); return model; }