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);
        }
Esempio n. 3
0
        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);
                    }
                }
            }
        }
Esempio n. 5
0
        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);
                    }
                }
            }
        }