コード例 #1
0
        public int FreeAuditReject(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            IWorkFlowManager workFlowManager = this.GetWorkFlowManager(workFlowAuditInfo.Id);

            workFlowManager.SetUserInfo(this.UserInfo);
            return(FreeAuditReject(workFlowManager, workFlowAuditInfo));
        }
コード例 #2
0
        public string FreeAuditStatr(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            IWorkFlowManager workFlowManager = this.GetWorkFlowManager(workFlowAuditInfo);

            workFlowManager.SetUserInfo(this.UserInfo);
            return(FreeAuditStatr(workFlowManager, workFlowAuditInfo));
        }
コード例 #3
0
        public string FreeAuditComplete(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            workFlowAuditInfo.Id = this.GetCurrentId(workFlowAuditInfo.CategoryCode, workFlowAuditInfo.ObjectId);
            IWorkFlowManager workFlowManager = this.GetWorkFlowManager(workFlowAuditInfo.Id);

            workFlowManager.SetUserInfo(this.UserInfo);
            return(FreeAuditComplete(workFlowManager, workFlowAuditInfo));
        }
コード例 #4
0
        /// <summary>
        /// 审批流程自由提交之前的判断函数,可以写在这里
        /// </summary>
        /// <param name="workFlowAuditInfo">流转信息</param>
        /// <returns>成功</returns>
        public virtual bool BeforeAutoStatr(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            if (string.IsNullOrEmpty(workFlowAuditInfo.CallBackTable))
            {
                return(false);
            }

            // 3:按年生成单据编号。
            string sequenceCode = string.Empty;
            // 1:状态为空的、草稿状态、被退回状态的,才可以启动工作流
            string auditStatus = this.GetProperty(workFlowAuditInfo.Id, BaseBusinessLogic.FieldAuditStatus);

            if (string.IsNullOrEmpty(auditStatus) ||
                auditStatus.Equals(AuditStatus.Draft.ToString()))
            {
                /*
                 * if (!string.IsNullOrEmpty(entity.Source))
                 * {
                 *  if (newsEntity.Source.Equals("html"))
                 *  {
                 *      if (newsEntity.Contents.IndexOf("#DayCode#") > 0)
                 *      {
                 *          sequenceName = DateTime.Now.ToString("yyyyMMdd") + "_" + newsEntity.CategoryCode;
                 *          sequenceCode = DateTime.Now.ToString("yyyyMMdd") + "_" + sequenceManager.Increment(sequenceName, 1, 3, true);
                 *          entity.Contents = newsEntity.Contents.Replace("#DayCode#", sequenceCode);
                 *          entity.Code = sequenceCode;
                 *      }
                 *  }
                 * }
                 */
                BaseSequenceManager sequenceManager = new BaseSequenceManager(this.DbHelper, this.UserInfo);
                // 没系统编号,自己生成一个编号
                if (string.IsNullOrEmpty(sequenceCode))
                {
                    sequenceCode = sequenceManager.Increment(workFlowAuditInfo.ProcessCode, 1, 6, true);
                    // newsEntity.Code = sequenceCode;
                }
            }

            // 4:修改单据表的状态,这里是成功了,才可以修改状态
            // newsEntity.AuditStatus = AuditStatus.StartAudit.ToString();
            // newsEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription();
            // 5:这里需要重新走流程后才可以生效
            // newsEntity.Enabled = 0;
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldEnabled, 0));
            parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldDeletionStateCode, 0));
            parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldAuditStatus, AuditStatus.StartAudit.ToString()));
            if (!string.IsNullOrEmpty(sequenceCode))
            {
                parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldCode, sequenceCode));
            }
            this.SetProperty(new KeyValuePair <string, object>(this.PrimaryKey, workFlowAuditInfo.Id), parameters);
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// 审核通过(不需要再发给别人了是完成审批了)
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="toStepEntity">审核到第几步</param>
        /// <param name="workFlowAuditInfo">当前审核人信息</param>
        /// <returns>影响行数</returns>
        private int StepAuditPass(string currentId, string auditIdea, BaseWorkFlowStepEntity toStepEntity, BaseWorkFlowAuditInfo workFlowAuditInfo = null)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(currentId);

            // 初始化审核信息,这里是显示当前审核人,可以不是当前操作员的功能
            if (workFlowAuditInfo == null)
            {
                workFlowAuditInfo                   = new BaseWorkFlowAuditInfo(this.UserInfo);
                workFlowAuditInfo.AuditIdea         = auditIdea;
                workFlowAuditInfo.AuditDate         = DateTime.Now;
                workFlowAuditInfo.AuditUserId       = this.UserInfo.Id;
                workFlowAuditInfo.AuditUserRealName = this.UserInfo.RealName;
                workFlowAuditInfo.AuditStatus       = AuditStatus.AuditPass.ToString();
                workFlowAuditInfo.AuditStatusName   = AuditStatus.AuditPass.ToDescription();
            }
            else
            {
                workFlowAuditInfo.AuditIdea = auditIdea;
            }

            // 审核意见是什么?
            workFlowCurrentEntity.AuditIdea = workFlowAuditInfo.AuditIdea;
            // 1.记录当前的审核时间、审核人信息
            // 什么时间审核的?
            workFlowCurrentEntity.AuditDate = workFlowAuditInfo.AuditDate;
            // 审核的用户是谁?
            workFlowCurrentEntity.AuditUserId = workFlowAuditInfo.AuditUserId;
            // 审核人的姓名是谁?
            workFlowCurrentEntity.AuditUserRealName = workFlowAuditInfo.AuditUserRealName;
            // 审核状态是什么?
            workFlowCurrentEntity.AuditStatus = workFlowAuditInfo.AuditStatus;
            // 审核状态备注是什么?
            workFlowCurrentEntity.AuditStatusName = workFlowAuditInfo.AuditStatusName;
            if (!string.IsNullOrEmpty(workFlowCurrentEntity.ActivityFullName))
            {
                workFlowCurrentEntity.Description = string.Format("从{0}提交到{1}{2}", workFlowCurrentEntity.ActivityFullName, toStepEntity.FullName, !string.IsNullOrEmpty(toStepEntity.Description) ? "," + toStepEntity.Description : string.Empty);
            }

            workFlowCurrentEntity.ToUserId         = toStepEntity.AuditUserId;
            workFlowCurrentEntity.ToUserRealName   = toStepEntity.AuditUserRealName;
            workFlowCurrentEntity.ToRoleId         = toStepEntity.AuditRoleId;
            workFlowCurrentEntity.ToRoleRealName   = toStepEntity.AuditRoleRealName;
            workFlowCurrentEntity.ToDepartmentId   = toStepEntity.AuditDepartmentId;
            workFlowCurrentEntity.ToDepartmentName = toStepEntity.AuditDepartmentName;

            // 2.记录审核日志
            this.AddHistory(workFlowCurrentEntity);
            // 3.上一个审核结束了,新的审核又开始了,更新待审核情况
            workFlowCurrentEntity.ActivityId       = toStepEntity.ActivityId;
            workFlowCurrentEntity.ActivityCode     = toStepEntity.Code;
            workFlowCurrentEntity.ActivityFullName = toStepEntity.FullName;
            workFlowCurrentEntity.ActivityType     = toStepEntity.ActivityType;
            workFlowCurrentEntity.SortCode         = toStepEntity.SortCode;
            return(this.UpdateObject(workFlowCurrentEntity));
        }
コード例 #6
0
        /// <summary>
        /// 自由工作流审核通过
        /// </summary>
        /// <param name="result"></param>
        /// <param name="workFlowAuditInfo"></param>
        /// <returns></returns>
        public int FreeAuditPass(BaseUserInfo userInfo, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, (dbHelper) =>
            {
                var workFlowCurrentManager       = new BaseWorkFlowCurrentManager(dbHelper, userInfo);
                IWorkFlowManager workFlowManager = workFlowCurrentManager.GetWorkFlowManager(workFlowAuditInfo.Id);
                result = workFlowCurrentManager.FreeAuditPass(workFlowManager, workFlowAuditInfo);
            });
            return(result);
        }
コード例 #7
0
        //----------------------------------------------------------------------------
        //                                  自由流
        //----------------------------------------------------------------------------

        #region public string FreeAudit(BaseUserInfo userInfo, BaseWorkFlowAuditInfo workFlowAuditInfo)
        /// <summary>
        /// 提交审批(自由流)
        /// </summary>
        /// <param name="result"></param>
        /// <param name="workFlowAuditInfo"></param>
        /// <returns></returns>
        public string FreeAudit(BaseUserInfo userInfo, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessWorkFlowDbWithTransaction(userInfo, parameter, (dbHelper) =>
            {
                // 默认的都按单据来处理,特殊的直接调用,明确指定
                IWorkFlowManager workFlowManager = new BaseUserBillManager(userInfo);
                var workFlowCurrentManager       = new BaseWorkFlowCurrentManager(dbHelper, userInfo);
                result = workFlowCurrentManager.FreeAudit(workFlowManager, workFlowAuditInfo);
            });
            return(result);
        }
コード例 #8
0
        private string StepAuditStatr(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            string result = string.Empty;

            BaseWorkFlowCurrentEntity workFlowCurrentEntity = new BaseWorkFlowCurrentEntity();

            // 1.这个是工作流的第一个发出日期,需要全局保留,其实也是创建日期了,但是有重新审核的这个说法,若有2次重新审核的事项,的确需要保留这个字段
            // workFlowCurrentEntity.CallBack = workFlowManager.GetType().ToString();
            workFlowCurrentEntity.ProcessId        = workFlowAuditInfo.ProcessId;
            workFlowCurrentEntity.ActivityId       = int.Parse(workFlowAuditInfo.ActivityId);
            workFlowCurrentEntity.ActivityCode     = workFlowAuditInfo.ActivityCode;
            workFlowCurrentEntity.ActivityFullName = workFlowAuditInfo.ActivityFullName;
            workFlowCurrentEntity.ActivityType     = workFlowAuditInfo.ActivityType;
            // 这里是为了优化越级审核用的,按排序嘛进行先后顺序排序
            workFlowCurrentEntity.CategoryCode     = workFlowAuditInfo.CategoryCode;
            workFlowCurrentEntity.CategoryFullName = workFlowAuditInfo.CategoryFullName;
            workFlowCurrentEntity.ObjectId         = workFlowAuditInfo.ObjectId;
            workFlowCurrentEntity.ObjectFullName   = workFlowAuditInfo.ObjectFullName;
            // 2.当前审核人的信息写入当前工作流
            // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditIdea       = workFlowAuditInfo.AuditIdea;
            workFlowCurrentEntity.AuditStatus     = workFlowAuditInfo.AuditStatus;
            workFlowCurrentEntity.AuditStatusName = workFlowAuditInfo.AuditStatusName;
            workFlowCurrentEntity.SendDate        = DateTime.Now;
            // 3.接下来需要待审核的对象的信息
            workFlowCurrentEntity.ToUserId         = workFlowAuditInfo.ToUserId;
            workFlowCurrentEntity.ToUserRealName   = workFlowAuditInfo.ToUserRealName;
            workFlowCurrentEntity.ToDepartmentId   = workFlowAuditInfo.ToDepartmentId;
            workFlowCurrentEntity.ToDepartmentName = workFlowAuditInfo.ToDepartmentName;
            workFlowCurrentEntity.ToRoleId         = workFlowAuditInfo.ToRoleId;
            workFlowCurrentEntity.ToRoleRealName   = workFlowAuditInfo.ToRoleRealName;
            workFlowCurrentEntity.Description      = workFlowAuditInfo.Description;
            // 4.这些标志信息需要处理好,这里表示工作流还没完成生效,还在审批中的意思。
            workFlowCurrentEntity.SortCode          = int.Parse(new BaseSequenceManager(this.DbHelper).Increment("WorkFlow", 10000000));
            workFlowCurrentEntity.Enabled           = 0;
            workFlowCurrentEntity.DeletionStateCode = 0;

            // 添加当前待审核流程表
            result = this.AddObject(workFlowCurrentEntity);

            // 4.记录审核日志
            workFlowCurrentEntity.Id = result;
            this.AddHistory(workFlowCurrentEntity);

            return(result);
        }
コード例 #9
0
 /// <summary>
 /// 当自由工作流开始启动之后需要处理的工作,可以写在这里
 /// </summary>
 /// <param name="id">主键</param>
 /// <returns>影响行数</returns>
 public virtual bool AfterAutoStatr(BaseWorkFlowAuditInfo workFlowAuditInfo)
 {
     if (!string.IsNullOrEmpty(workFlowAuditInfo.ObjectId) && !string.IsNullOrEmpty(this.CurrentTableName))
     {
         // 这里是回写表的功能实现
         SQLBuilder sqlBuilder = new SQLBuilder(dbHelper);
         sqlBuilder.BeginUpdate(this.CurrentTableName);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldAuditStatus, AuditStatus.StartAudit.ToString());
         sqlBuilder.SetDBNow(BaseBusinessLogic.FieldModifiedOn);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedBy, this.UserInfo.RealName);
         sqlBuilder.SetWhere(BaseBusinessLogic.FieldId, workFlowAuditInfo.ObjectId);
         sqlBuilder.EndUpdate();
     }
     return(true);
 }
コード例 #10
0
        public IWorkFlowManager GetWorkFlowManager(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            IWorkFlowManager workFlowManager = null;
            // Type objType = Type.GetType(workFlowAuditInfo.CallBackClass, true);
            // workFlowManager = (IWorkFlowManager)Activator.CreateInstance(objType);
            string assemblyString = workFlowAuditInfo.CallBackClass.Substring(0, workFlowAuditInfo.CallBackClass.LastIndexOf('.'));

            workFlowManager = (IWorkFlowManager)Assembly.Load(assemblyString).CreateInstance(workFlowAuditInfo.CallBackClass);
            workFlowManager.SetUserInfo(this.UserInfo);
            if (!string.IsNullOrEmpty(workFlowAuditInfo.CallBackTable))
            {
                // 这里本来是想动态创建类库 编码外包[100]
                workFlowManager.CurrentTableName = workFlowAuditInfo.CallBackTable;
            }
            return(workFlowManager);
        }
コード例 #11
0
        /// <summary>
        /// 自由审批完成
        /// </summary>
        /// <param name="workFlowManager">流程控制管理器</param>
        /// <param name="workFlowAuditInfo">流程信息</param>
        /// <returns>影响行数</returns>
        public string FreeAuditComplete(IWorkFlowManager workFlowManager, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            // 返回值
            string result = string.Empty;

            // 这里用锁的机制,提高并发控制能力
            lock (WorkFlowCurrentLock)
            {
                try
                {
                    // 开始事务
                    this.DbHelper.BeginTransaction();
                    // 进行更新操作
                    this.StepAuditComplete(workFlowAuditInfo.Id, workFlowAuditInfo.AuditIdea);
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(workFlowAuditInfo.Id);
                    // 发送提醒信息
                    if (workFlowManager != null)
                    {
                        workFlowManager.OnAutoAuditComplete(workFlowCurrentEntity);
                        workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditComplete, new string[] { workFlowCurrentEntity.CreateUserId, workFlowAuditInfo.ToUserId }, workFlowAuditInfo.ToDepartmentId, workFlowAuditInfo.ToRoleId);
                    }
                    this.StatusMessage = this.GetStateMessage(this.StatusCode);
                    result             = workFlowAuditInfo.Id;
                    this.DbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    this.DbHelper.RollbackTransaction();
                    BaseExceptionManager.LogException(dbHelper, this.UserInfo, ex);
                    this.StatusCode = Status.Error.ToString();
                    // throw;
                }
                finally
                {
                    this.DbHelper.Close();
                }

                return(result);
            }
        }
コード例 #12
0
        private string StepAuditStatr(string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
        {
            BaseWorkFlowAuditInfo workFlowAuditInfo = new BaseWorkFlowAuditInfo();

            workFlowAuditInfo.CategoryCode     = categoryCode;
            workFlowAuditInfo.CategoryFullName = categoryFullName;
            workFlowAuditInfo.ObjectId         = objectId;
            workFlowAuditInfo.ObjectFullName   = objectFullName;
            workFlowAuditInfo.AuditIdea        = auditIdea;
            workFlowAuditInfo.ProcessId        = workFlowStepEntity.ProcessId;
            workFlowAuditInfo.ActivityId       = workFlowStepEntity.ActivityId.ToString();
            workFlowAuditInfo.ActivityCode     = workFlowStepEntity.ActivityCode;
            workFlowAuditInfo.ActivityType     = workFlowStepEntity.ActivityType;
            workFlowAuditInfo.ActivityFullName = workFlowStepEntity.FullName;
            workFlowAuditInfo.ToUserId         = workFlowStepEntity.AuditUserId;
            workFlowAuditInfo.ToUserRealName   = workFlowStepEntity.AuditUserRealName;
            workFlowAuditInfo.ToDepartmentId   = workFlowStepEntity.AuditDepartmentId;
            workFlowAuditInfo.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
            workFlowAuditInfo.ToRoleId         = workFlowStepEntity.AuditRoleId;
            workFlowAuditInfo.ToRoleRealName   = workFlowStepEntity.AuditRoleRealName;
            workFlowAuditInfo.AuditStatus      = AuditStatus.WaitForAudit.ToString();
            workFlowAuditInfo.AuditStatusName  = AuditStatus.WaitForAudit.ToDescription();
            return(StepAuditStatr(workFlowAuditInfo));
        }
コード例 #13
0
        /// <summary>
        /// 提交自由审批
        /// </summary>
        /// <param name="workFlowManager">流程控制管理器</param>
        /// <param name="workFlowAuditInfo">流程信息</param>
        /// <returns>主键</returns>
        public string FreeAuditStatr(IWorkFlowManager workFlowManager, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            // 当工作流开始启动,进入流程审批
            try
            {
                // 开始事务
                this.DbHelper.BeginTransaction();

                if (workFlowManager != null)
                {
                    workFlowManager.BeforeAutoStatr(workFlowAuditInfo);
                }

                workFlowAuditInfo.AuditStatus     = AuditStatus.StartAudit.ToString();
                workFlowAuditInfo.AuditStatusName = AuditStatus.StartAudit.ToDescription();
                workFlowAuditInfo.Description     = "申请登记";
                workFlowAuditInfo.Id = this.StepAuditStatr(workFlowAuditInfo);

                BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(workFlowAuditInfo.Id);

                // 获取当前处于什么状态
                // 如果还是开始审批状态的话,允许他再次提交把原来的覆盖掉
                // if (workFlowCurrentEntity.AuditStatus == AuditStatus.AuditReject.ToString())
                // {
                // 更新
                // this.UpdataAuditStatr(workFlowCurrentEntity.Id, categoryCode, categoryFullName, objectId, objectFullName, auditIdea, workFlowStepEntity);

                // 发送提醒信息,若发给指定的某个人了,就不发给部门的提示信息了
                if (workFlowManager != null)
                {
                    if (!string.IsNullOrEmpty(workFlowAuditInfo.ToUserId))
                    {
                        workFlowAuditInfo.ToDepartmentId = null;
                        workFlowAuditInfo.ToRoleId       = null;
                    }
                    workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.StartAudit, new string[] { workFlowCurrentEntity.CreateUserId, workFlowAuditInfo.ToUserId }, workFlowAuditInfo.ToDepartmentId, workFlowAuditInfo.ToRoleId);
                }
                // 成功工作流后的处理
                if (workFlowManager != null && !string.IsNullOrEmpty(workFlowAuditInfo.ObjectId))
                {
                    workFlowManager.AfterAutoStatr(workFlowAuditInfo);
                }

                this.DbHelper.CommitTransaction();
                // 运行成功
                this.StatusCode    = Status.OK.ToString();
                this.StatusMessage = this.GetStateMessage(this.StatusCode);
            }
            catch (Exception ex)
            {
                this.DbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, this.UserInfo, ex);
                this.StatusCode = Status.Error.ToString();
                // throw;
            }
            finally
            {
                this.DbHelper.Close();
            }

            return(workFlowAuditInfo.Id);
        }
コード例 #14
0
        /// <summary>
        /// 自由审批退回
        /// </summary>
        /// <param name="workFlowManager">流程控制管理器</param>
        /// <param name="workFlowAuditInfo">流程信息</param>
        /// <returns>影响行数</returns>
        public int FreeAuditReject(IWorkFlowManager workFlowManager, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            // 返回值
            int result = 0;

            // 这里用锁的机制,提高并发控制能力
            lock (WorkFlowCurrentLock)
            {
                try
                {
                    // 开始事务
                    this.DbHelper.BeginTransaction();
                    BaseWorkFlowStepEntity workFlowStepEntity = new BaseWorkFlowStepEntity();
                    if (!string.IsNullOrEmpty(workFlowAuditInfo.ActivityId))
                    {
                        workFlowStepEntity.ActivityId       = int.Parse(workFlowAuditInfo.ActivityId);
                        workFlowStepEntity.ActivityCode     = workFlowAuditInfo.ActivityCode;
                        workFlowStepEntity.ActivityFullName = workFlowAuditInfo.ActivityFullName;
                    }
                    // 是否提交给用户审批
                    if (!string.IsNullOrEmpty(workFlowAuditInfo.ToUserId))
                    {
                        workFlowStepEntity.AuditUserId       = workFlowAuditInfo.ToUserId;
                        workFlowStepEntity.AuditUserRealName = BaseUserManager.GetRealNameByCache(workFlowAuditInfo.ToUserId);
                    }
                    // 是否提交给部门审批
                    if (!string.IsNullOrEmpty(workFlowAuditInfo.ToDepartmentId))
                    {
                        workFlowStepEntity.AuditDepartmentId   = workFlowAuditInfo.ToDepartmentId;
                        workFlowStepEntity.AuditDepartmentName = BaseOrganizeManager.GetNameByCache(workFlowAuditInfo.ToDepartmentId);
                    }
                    // 是否提交给角色审批
                    if (!string.IsNullOrEmpty(workFlowAuditInfo.ToRoleId))
                    {
                        workFlowStepEntity.AuditRoleId       = workFlowAuditInfo.ToRoleId;
                        workFlowStepEntity.AuditRoleRealName = BaseRoleManager.GetRealNameByCache(this.UserInfo.SystemCode, workFlowAuditInfo.ToRoleId);
                    }
                    // 获取排序码
                    workFlowStepEntity.SortCode = int.Parse(new BaseSequenceManager().Increment("WorkFlow", 10000000));
                    // 进行更新操作
                    result = this.StepAuditReject(workFlowAuditInfo.Id, workFlowAuditInfo.AuditIdea, workFlowStepEntity);
                    if (result == 0)
                    {
                        // 数据可能被删除
                        this.StatusCode = Status.ErrorDeleted.ToString();
                    }
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(workFlowAuditInfo.Id);
                    // 发送提醒信息
                    if (workFlowManager != null)
                    {
                        if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                        {
                            workFlowStepEntity.AuditDepartmentId = null;
                            workFlowStepEntity.AuditRoleId       = null;
                        }
                        workFlowManager.OnAutoAuditReject(workFlowCurrentEntity);
                        workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditReject, new string[] { workFlowCurrentEntity.CreateUserId, workFlowStepEntity.AuditUserId }, workFlowStepEntity.AuditDepartmentId, workFlowStepEntity.AuditRoleId);
                    }
                    this.StatusMessage = this.GetStateMessage(this.StatusCode);
                    this.DbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    this.DbHelper.RollbackTransaction();
                    BaseExceptionManager.LogException(dbHelper, this.UserInfo, ex);
                    this.StatusCode = Status.Error.ToString();
                    // throw;
                }
                finally
                {
                    this.DbHelper.Close();
                }
                return(result);
            }
        }
コード例 #15
0
        /// <summary>
        /// 自由审批通过
        /// </summary>
        /// <param name="workFlowManager">流程控制管理器</param>
        /// <param name="workFlowAuditInfo">流程信息</param>
        /// <returns>影响行数</returns>
        public int FreeAuditPass(IWorkFlowManager workFlowManager, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            // 返回值
            int result = 0;

            // 这里用锁的机制,提高并发控制能力
            lock (WorkFlowCurrentLock)
            {
                try
                {
                    // 开始事务
                    this.DbHelper.BeginTransaction();

                    // 这里需要循环产生前面的没有审批的人的记录,默认都要让他们审批通过才可以?
                    // 在这里处理连续跳过好几个审批的,自动能生成审批记录的功能?
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = null;
                    workFlowCurrentEntity = this.GetObject(workFlowAuditInfo.Id);
                    // 当前是什么步骤主键?
                    int?startSortCode = BaseWorkFlowActivityManager.GetEntity(workFlowCurrentEntity.ActivityId).SortCode;
                    // 现在要到什么步骤主键?
                    int?endSortCode = BaseWorkFlowActivityManager.GetEntity(workFlowAuditInfo.ActivityId).SortCode;
                    // 中间还有几个步骤被跳过了?
                    var listEntity = BaseWorkFlowActivityManager.GetEntities().Where(entity => entity.SortCode > startSortCode && entity.SortCode <= endSortCode && entity.Enabled == 1 && entity.DeletionStateCode == 0).OrderBy(entity => entity.SortCode);
                    int i          = 0;
                    foreach (var entity in listEntity)
                    {
                        // 这里是需要自动模拟产生的审批用的
                        BaseWorkFlowAuditInfo workFlowInfo = new BaseWorkFlowAuditInfo();
                        // 是最后一步了
                        if (entity.SortCode == endSortCode)
                        {
                            workFlowInfo           = workFlowAuditInfo;
                            workFlowInfo.AuditDate = DateTime.Now.AddMinutes(i * 10);
                        }
                        else
                        {
                            workFlowInfo.Id               = workFlowAuditInfo.Id;
                            workFlowInfo.ActivityId       = entity.Id.ToString();
                            workFlowInfo.ActivityCode     = entity.Code;
                            workFlowInfo.ActivityFullName = entity.FullName;
                            // 这个是默认写入的审核意见
                            workFlowInfo.AuditIdea         = "通过";
                            workFlowInfo.AuditUserId       = entity.DefaultAuditUserId;
                            workFlowInfo.AuditUserCode     = BaseUserManager.GetUserCodeByCache(entity.DefaultAuditUserId);
                            workFlowInfo.AuditUserRealName = BaseUserManager.GetRealNameByCache(entity.DefaultAuditUserId);
                            i++;
                            // 这里是生成不一样的审核人日期的方法
                            workFlowInfo.AuditDate       = DateTime.Now.AddMinutes(i * 10);
                            workFlowInfo.AuditStatus     = AuditStatus.AuditPass.ToString();
                            workFlowInfo.AuditStatusName = AuditStatus.AuditPass.ToDescription();
                            // workFlowInfo.ToUserId = entity.DefaultAuditUserId;
                            // workFlowInfo.ToRoleId = string.Empty;
                            // workFlowInfo.ToDepartmentId = string.Empty;
                        }

                        BaseWorkFlowStepEntity workFlowStepEntity = new BaseWorkFlowStepEntity();
                        if (!string.IsNullOrEmpty(workFlowInfo.ActivityId))
                        {
                            workFlowStepEntity.ActivityId       = int.Parse(workFlowInfo.ActivityId);
                            workFlowStepEntity.ActivityCode     = workFlowInfo.ActivityCode;
                            workFlowStepEntity.ActivityFullName = workFlowInfo.ActivityFullName;
                        }
                        // 是否提交给用户审批
                        if (!string.IsNullOrEmpty(workFlowInfo.ToUserId))
                        {
                            workFlowStepEntity.AuditUserId       = workFlowInfo.ToUserId;
                            workFlowStepEntity.AuditUserCode     = BaseUserManager.GetUserCodeByCache(workFlowInfo.ToUserId);
                            workFlowStepEntity.AuditUserRealName = BaseUserManager.GetRealNameByCache(workFlowInfo.ToUserId);
                        }
                        // 是否提交给部门审批
                        if (!string.IsNullOrEmpty(workFlowInfo.ToDepartmentId))
                        {
                            workFlowStepEntity.AuditDepartmentId   = workFlowInfo.ToDepartmentId;
                            workFlowStepEntity.AuditDepartmentName = BaseOrganizeManager.GetNameByCache(workFlowInfo.ToDepartmentId);
                        }
                        // 是否提交给角色审批
                        if (!string.IsNullOrEmpty(workFlowInfo.ToRoleId))
                        {
                            workFlowStepEntity.AuditRoleId       = workFlowInfo.ToRoleId;
                            workFlowStepEntity.AuditRoleRealName = BaseRoleManager.GetRealNameByCache(this.UserInfo.SystemCode, workFlowInfo.ToRoleId);
                        }
                        // 获取排序码
                        workFlowStepEntity.SortCode = int.Parse(new BaseSequenceManager().Increment("WorkFlow", 10000000));
                        // 进行更新操作,这里有时候需要模拟别人登录
                        result = this.StepAuditPass(workFlowInfo.Id, workFlowInfo.AuditIdea, workFlowStepEntity, workFlowInfo);
                        if (result == 0)
                        {
                            // 数据可能被删除
                            this.StatusCode = Status.ErrorDeleted.ToString();
                        }
                        workFlowCurrentEntity = this.GetObject(workFlowInfo.Id);
                        // 发送提醒信息
                        if (workFlowManager != null)
                        {
                            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                            {
                                workFlowStepEntity.AuditDepartmentId = null;
                                workFlowStepEntity.AuditRoleId       = null;
                            }
                            workFlowManager.OnAutoAuditPass(workFlowCurrentEntity);
                            workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditPass, new string[] { workFlowCurrentEntity.CreateUserId, workFlowStepEntity.AuditUserId }, workFlowStepEntity.AuditDepartmentId, workFlowStepEntity.AuditRoleId);
                        }
                    }
                    this.StatusMessage = this.GetStateMessage(this.StatusCode);
                    this.DbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    this.DbHelper.RollbackTransaction();
                    BaseExceptionManager.LogException(dbHelper, this.UserInfo, ex);
                    this.StatusCode = Status.Error.ToString();
                    // throw;
                }
                finally
                {
                    this.DbHelper.Close();
                }

                return(result);
            }
        }
コード例 #16
0
        //-----------------------------------------------------
        //                  启动工作流 自由流
        //-----------------------------------------------------

        public string FreeAudit(BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            IWorkFlowManager workFlowManager = null;

            return(FreeAudit(workFlowManager, workFlowAuditInfo));
        }
コード例 #17
0
        /// <summary>
        /// 启动工作流(自由流转)
        /// </summary>
        /// <param name="workFlowManager"></param>
        /// <param name="activityId">丢到第几部审核哪里去了</param>
        /// <param name="objectId"></param>
        /// <param name="objectFullName"></param>
        /// <param name="categoryCode"></param>
        /// <param name="categoryFullName"></param>
        /// <param name="toUserId"></param>
        /// <param name="toDepartmentId"></param>
        /// <param name="toRoleId"></param>
        /// <param name="auditIdea"></param>
        /// <returns></returns>
        public string FreeAudit(IWorkFlowManager workFlowManager, BaseWorkFlowAuditInfo workFlowAuditInfo)
        {
            // 是否提交给用户审批
            if (!string.IsNullOrEmpty(workFlowAuditInfo.ToUserId))
            {
                workFlowAuditInfo.ToUserRealName = BaseUserManager.GetRealNameByCache(workFlowAuditInfo.ToUserId);
            }
            // 是否提交给部门审批
            if (!string.IsNullOrEmpty(workFlowAuditInfo.ToDepartmentId))
            {
                workFlowAuditInfo.ToDepartmentName = BaseOrganizeManager.GetNameByCache(workFlowAuditInfo.ToDepartmentId);
            }
            // 是否提交给角色审批
            if (!string.IsNullOrEmpty(workFlowAuditInfo.ToRoleId))
            {
                workFlowAuditInfo.ToRoleRealName = BaseRoleManager.GetRealNameByCache(this.UserInfo.SystemCode, workFlowAuditInfo.ToRoleId);
            }
            // 计算第几步审核
            if (!string.IsNullOrEmpty(workFlowAuditInfo.ActivityId))
            {
                BaseWorkFlowActivityEntity workFlowActivityEntity = new BaseWorkFlowActivityManager().GetObject(workFlowAuditInfo.ActivityId);
                workFlowAuditInfo.ProcessId        = workFlowActivityEntity.ProcessId;
                workFlowAuditInfo.ActivityCode     = workFlowActivityEntity.Code;
                workFlowAuditInfo.ActivityType     = workFlowActivityEntity.ActivityType;
                workFlowAuditInfo.ActivityFullName = workFlowActivityEntity.FullName;
                BaseWorkFlowProcessEntity workFlowProcessEntity = new BaseWorkFlowProcessManager().GetObject(workFlowActivityEntity.ProcessId.ToString());
                workFlowAuditInfo.ProcessCode   = workFlowProcessEntity.Code;
                workFlowAuditInfo.CallBackClass = workFlowProcessEntity.CallBackClass;
                workFlowAuditInfo.CallBackTable = workFlowProcessEntity.CallBackTable;
                // 若没有分类信息,分类信息可以按流程的信息保存
                if (string.IsNullOrEmpty(workFlowAuditInfo.CategoryCode))
                {
                    workFlowAuditInfo.CategoryCode     = workFlowProcessEntity.Code;
                    workFlowAuditInfo.CategoryFullName = workFlowProcessEntity.FullName;
                }

                // 不需要反复从数据库读取的方法
                workFlowManager = GetWorkFlowManager(workFlowAuditInfo);
            }

            // 获取当前工作流步骤
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObjectBy(workFlowAuditInfo.CategoryCode, workFlowAuditInfo.ObjectId);

            // 已经在审批里了,那不需要重新审批,直接进入另外一个审批流程
            if (workFlowCurrentEntity != null && !string.IsNullOrEmpty(workFlowCurrentEntity.Id))
            {
                workFlowAuditInfo.Id = workFlowCurrentEntity.Id;

                // 判断现在是在什么流程节点上?
                int?sortCode = BaseWorkFlowActivityManager.GetEntity(workFlowCurrentEntity.ActivityId.ToString()).SortCode;

                // 与现在发送的流程节点比,是前进了,还是倒退了?
                // 这里是判断是退回还是前进了?排序码小的,就是在前面的步骤里,是退回了,否则是继续通过前进了
                if (BaseWorkFlowActivityManager.GetEntity(workFlowAuditInfo.ActivityId).SortCode <= sortCode)
                {
                    // 自由审批退回
                    this.FreeAuditReject(workFlowManager, workFlowAuditInfo);
                }
                else
                {
                    // 自由审批通过
                    this.FreeAuditPass(workFlowManager, workFlowAuditInfo);
                }
                return(workFlowCurrentEntity.Id);
            }

            // 提交自由审批
            this.FreeAuditStatr(workFlowAuditInfo);

            return(workFlowAuditInfo.Id);
        }
コード例 #18
0
        //-----------------------------------------------------
        //                  启动工作流 步骤流
        //-----------------------------------------------------

        /// <summary>
        /// 启动工作流(步骤流转)
        /// </summary>
        /// <param name="workFlowManager">审批流程管理器</param>
        /// <param name="objectId">单据主键</param>
        /// <param name="objectFullName">单据名称</param>
        /// <param name="categoryCode">单据分类</param>
        /// <param name="categoryFullName">单据分类名称</param>
        /// <param name="workFlowCode">工作流程</param>
        /// <param name="auditIdea">审批意见</param>
        /// <param name="dtWorkFlowActivity">需要走的流程</param>
        /// <returns>主键</returns>
        public string AutoStatr(IWorkFlowManager workFlowManager, string objectId, string objectFullName, string categoryCode, string categoryFullName = null, string workFlowCode = null, string auditIdea = null, DataTable dtWorkFlowActivity = null)
        {
            if (workFlowManager == null && !string.IsNullOrEmpty(categoryCode))
            {
                if (string.IsNullOrEmpty(workFlowCode))
                {
                    workFlowCode = categoryCode;
                }
                workFlowManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo).GetWorkFlowManagerByCode(workFlowCode);
                // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo, categoryCode);
            }

            BaseWorkFlowAuditInfo workFlowAuditInfo = new BaseWorkFlowAuditInfo();

            workFlowAuditInfo.CategoryCode  = categoryCode;
            workFlowAuditInfo.ObjectId      = objectId;
            workFlowAuditInfo.CallBackTable = workFlowManager.CurrentTableName;
            workFlowAuditInfo.ProcessCode   = workFlowCode;

            string currentId = string.Empty;

            // 看审批流程是否被定义
            if (dtWorkFlowActivity == null || dtWorkFlowActivity.Rows.Count == 0)
            {
                BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
                var dt = workFlowProcessManager.GetDataTable(
                    new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowCode)
                    , new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), BaseWorkFlowProcessEntity.FieldSortCode);
                BaseWorkFlowProcessEntity workFlowProcessEntity = null;
                foreach (DataRow dr in dt.Rows)
                {
                    workFlowProcessEntity = BaseEntity.Create <BaseWorkFlowProcessEntity>(dr);
                    // 这里是进入条件,结束条件进行筛选
                    // 进入条件是否满足
                    if (!string.IsNullOrEmpty(workFlowProcessEntity.EnterConstraint))
                    {
                        if (!Evaluate(workFlowAuditInfo.CallBackTable, objectId, workFlowProcessEntity.EnterConstraint))
                        {
                            // 没有满足入口条件
                            dr.Delete();
                        }
                    }
                }
                dt.AcceptChanges();
                if (dt.Rows.Count == 0)
                {
                    return(currentId);
                }
                workFlowProcessEntity = BaseEntity.Create <BaseWorkFlowProcessEntity>(dt);
                // 这里是获取用户的走的流程
                dtWorkFlowActivity = new BaseWorkFlowActivityManager(this.UserInfo).GetActivityDTById(workFlowProcessEntity.Id.ToString());
                // dtWorkFlowActivity = new BaseWorkFlowActivityManager(this.UserInfo).GetActivityDTByCode(workFlowCode);
                if (dtWorkFlowActivity.Rows.Count == 0)
                {
                    return(currentId);
                }
            }
            lock (WorkFlowCurrentLock)
            {
                BaseWorkFlowStepEntity workFlowStepEntity = null;
                // 这里需要读取一下
                if (dtWorkFlowActivity == null)
                {
                }
                workFlowStepEntity = BaseEntity.Create <BaseWorkFlowStepEntity>(dtWorkFlowActivity.Rows[0]);
                if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                {
                    // 若是任意人可以审核的,需要进行一次人工选任的工作
                    if (workFlowStepEntity.AuditUserId.Equals("Anyone"))
                    {
                        return(null);
                    }
                }
                // 1. 先把已有的流程设置功能都删除掉
                BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);
                workFlowStepManager.Delete(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, categoryCode)
                                           , new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, objectId));
                // 2. 把当前的流程设置保存好
                BaseWorkFlowActivityEntity activityEntity = null;
                // 是否已经满足了条件了
                bool endConstraint = false;
                foreach (DataRow dr in dtWorkFlowActivity.Rows)
                {
                    // 是否已经结束流程了
                    if (endConstraint)
                    {
                        dr.Delete();
                    }
                    else
                    {
                        activityEntity = BaseEntity.Create <BaseWorkFlowActivityEntity>(dr);
                        // 这里是进入条件,结束条件进行筛选
                        // 进入条件是否满足
                        if (!string.IsNullOrEmpty(activityEntity.EnterConstraint))
                        {
                            if (!Evaluate(workFlowAuditInfo.CallBackTable, objectId, activityEntity.EnterConstraint))
                            {
                                // 没有满足入口条件
                                dr.Delete();
                            }
                        }
                        // 结束条件是否满足
                        if (!string.IsNullOrEmpty(activityEntity.EndConstraint))
                        {
                            if (Evaluate(workFlowAuditInfo.CallBackTable, objectId, activityEntity.EndConstraint))
                            {
                                // 已经满足了结束条件了
                                dr.Delete();
                                endConstraint = true;
                            }
                        }
                    }
                }
                dtWorkFlowActivity.AcceptChanges();
                // 没有任何审核流程步骤了
                if (dtWorkFlowActivity.Rows.Count == 0)
                {
                    return(null);
                }

                // 建立审核步骤表,需要走哪些审核步骤的具体步骤表
                foreach (DataRow dr in dtWorkFlowActivity.Rows)
                {
                    workFlowStepEntity = BaseEntity.Create <BaseWorkFlowStepEntity>(dr);
                    // workFlowStepEntity.ActivityId = workFlowActivityEntity.Id;
                    // workFlowStepEntity.ActivityType = workFlowActivityEntity.ActivityType;
                    workFlowStepEntity.CategoryCode = categoryCode;
                    workFlowStepEntity.ObjectId     = objectId;
                    workFlowStepEntity.Id           = null;
                    workFlowStepManager.Add(workFlowStepEntity);
                }
                workFlowStepEntity = BaseEntity.Create <BaseWorkFlowStepEntity>(dtWorkFlowActivity.Rows[0]);

                // 3. 启动审核流程
                currentId = this.GetCurrentId(categoryCode, objectId);
                BaseWorkFlowCurrentEntity workFlowCurrentEntity = null;
                if (currentId.Length > 0)
                {
                    // 获取当前处于什么状态
                    string auditstatus = this.GetProperty(currentId, BaseWorkFlowCurrentEntity.FieldAuditStatus);
                    // 如果还是开始审批状态的话,允许他再次提交把原来的覆盖掉
                    if (auditstatus == AuditStatus.StartAudit.ToString() ||
                        auditstatus == AuditStatus.AuditReject.ToString())
                    {
                        this.UpdataAuditStatr(currentId, categoryCode, categoryFullName, objectId, objectFullName, auditIdea, workFlowStepEntity);
                        if (workFlowManager != null)
                        {
                            workFlowManager.AfterAutoStatr(workFlowAuditInfo);
                        }
                    }
                    // 不是的话则返回
                    else
                    {
                        // 该单据已进入审核状态不能在次提交
                        this.StatusCode = Status.ErrorChanged.ToString();
                        // 返回为空可以判断
                        currentId = null;
                    }
                }
                else
                {
                    if (workFlowManager != null)
                    {
                        workFlowManager.BeforeAutoStatr(workFlowAuditInfo);
                    }
                    currentId             = this.StepAuditStatr(categoryCode, categoryFullName, objectId, objectFullName, auditIdea, workFlowStepEntity);
                    workFlowCurrentEntity = this.GetObject(currentId);
                    // 发送提醒信息,若发给指定的某个人了,就不发给部门的提示信息了
                    if (workFlowManager != null)
                    {
                        if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                        {
                            workFlowStepEntity.AuditDepartmentId = null;
                            workFlowStepEntity.AuditRoleId       = null;
                        }
                        workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.StartAudit, new string[] { workFlowCurrentEntity.CreateUserId, workFlowStepEntity.AuditUserId }, workFlowStepEntity.AuditDepartmentId, workFlowStepEntity.AuditRoleId);
                    }
                    // 成功工作流后的处理
                    if (!string.IsNullOrEmpty(objectId) && workFlowManager != null)
                    {
                        workFlowManager.AfterAutoStatr(workFlowAuditInfo);
                    }
                    // 运行成功
                    this.StatusCode    = Status.OK.ToString();
                    this.StatusMessage = this.GetStateMessage(this.StatusCode);
                }
            }
            return(currentId);
        }