Exemplo n.º 1
0
        /// <summary>
        /// 【具体业务根据需要重写】工作流审批 任务节点 返回执行人 - 默认返回为工作流角色设置中的用户列表
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public virtual List <ICommunicationable> DoWorkFlowGetTaskUserList(WorkFlowDefLineDetail line)
        {
            var workflowRole = WorkFlowRole.GetInstance(line.ToStep.WorkFlowRoleId);
            var userIds      = workflowRole.GetDescripUserId();
            BaseResponseList <UserManager> userManagers = UserManager.searchList(new UserManagerSearchRequest()
            {
                cId = new BaseBatchRequest <string>()
                {
                    rows = userIds
                },
                page = 0
            });
            List <ICommunicationable> result = new List <ICommunicationable>();

            if (userManagers.rows != null)
            {
                if (userManagers.rows.Count > 0)
                {
                    foreach (var item in userManagers.rows)
                    {
                        result.Add(item);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新流程的工作流书签ID 保存为toStep.Id 用于下次流程启动时恢复到当前位置
 /// </summary>
 /// <param name="line">工作流关系线信息</param>
 protected void SetWorkFlowBookMark(WorkFlowDefLineDetail line)
 {
     using (var db = new DefaultContainer())
     {
         var row = db.Db_BaseWorkOrderSet.Single(p => p.Id == this.Id);
         row.WorkFlowBookMarkId = line.ToStep.Id;
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 记录到审批历史记录
 /// </summary>
 /// <param name="line"></param>
 private void LogToApprovalHistory(WorkFlowDefLineDetail line)
 {
     using (var db = new DefaultContainer()) {
         var dbRow = new Db_BaseWorkOrderApprovalHistory()
         {
             CreatedOn          = DateTime.Now,
             Db_BaseWorkOrderId = this.Id,
             Id = Guid.NewGuid().ToString(),
             WorkFlowDefLineId = line.Id
         };
         db.Db_BaseWorkOrderApprovalHistorySet.Add(dbRow);
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 【具体业务根据需要重写】选择下一步操作线路 与 其他附加的操作 - 默认返回后续多条分后续分支中默认的第一条
 /// </summary>
 /// <param name="line"></param>
 /// <param name="nextLines"></param>
 /// <returns></returns>
 public virtual WorkFlowDefLineDetail DoWorkFlowSelectLine(WorkFlowDefLineDetail line, List <WorkFlowDefLineDetail> nextLines)
 {
     //默认就是返回默认的那一个
     return(nextLines.First());
 }
Exemplo n.º 5
0
 /// <summary>
 /// 【具体业务根据需要重写】执行审批工作流前 - 一般 可进行一些验证 默认返回为True
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public virtual bool DoWorkFlowConfimBefore(WorkFlowDefLineDetail line)
 {
     return(true);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 执行工作流
        /// </summary>
        /// <param name="line"></param>
        public virtual void DoWorkFlowConfim(WorkFlowDefLineDetail line)
        {
            if (line.ToStep != null)
            {
                if (!DoWorkFlowConfimBefore(line))
                {
                    throw new ValiDataException("当前工作流无法执行");
                }

                LogToApprovalHistory(line);

                //记录流程走向
                //判断下一步 是否为结束节点 如果是 则完成工作流
                if (line.ToStep.type == WorkFlowStepType.end)
                {
                    SetWorkFlowToEndStatus();
                    UserLog.create("流程已结束", "工作流", adminUser, this);
                    DoWorkFlowEndAfter();
                    return;
                }
                else if (line.ToStep.type == WorkFlowStepType.task)
                {
                    SetWorkFlowBookMark(line);
                    //保存执行人
                    var           userList         = DoWorkFlowGetTaskUserList(line);
                    List <string> userIdList       = new List <string>();
                    List <string> userFullNameList = new List <string>();
                    foreach (var item in userList)
                    {
                        userIdList.Add(item.getIdString());
                        userFullNameList.Add(item.getFullNameString());
                    }

                    //if (!userIdList.Contains(adminUser.Id)) {
                    //    userList.Add(adminUser);
                    //}

                    //保存到数据库
                    using (var db = new DefaultContainer()) {
                        List <Db_BaseWorkOrderTaskUser> taskDbUsers = new List <Db_BaseWorkOrderTaskUser>();
                        foreach (var item in userList)
                        {
                            taskDbUsers.Add(new Db_BaseWorkOrderTaskUser()
                            {
                                Id                      = Guid.NewGuid().ToString(),
                                CreatedOn               = DateTime.Now,
                                IsConfirm               = false,
                                UserId                  = item.getIdString(),
                                Db_BaseWorkOrderId      = this.Id,
                                Db_WorkFlowDefLineId    = line.Id,
                                Db_WorkFlowDefinitionId = this.WorkFlowDefinitionId,
                                Db_WorkFlowDefStepId    = line.ToStep.Id,
                                userName                = item.getFullNameString()
                            });
                        }
                        db.Db_BaseWorkOrderTaskUserSet.AddRange(taskDbUsers);
                        db.SaveChanges();
                    }
                    DoWorkFlowSetTaskUserListAfter(userList);
                    string taskUsers = "未指定的审批用户";
                    if (userFullNameList.Count > 0)
                    {
                        taskUsers = string.Join(",", userFullNameList);
                    }
                    UserLog.create(string.Format("执行已到任务节点[{0}],等待用户[{1}]审批", line.ToStep.name, taskUsers), "工作流", adminUser, this);
                    return;
                }
                else
                {
                    string msg = string.Format("执行流程,步骤:[{0}]", line.ToStep.name);
                    UserLog.create(msg, "工作流", adminUser, this);
                    //获取下一步
                    var nextLines = line.ToStep.GetNextLineDetails();
                    if (nextLines.Count > 0)
                    {
                        var next = DoWorkFlowSelectLine(line, nextLines);
                        //递归继续
                        DoWorkFlowConfim(next);
                    }
                }
            }
        }