Exemplo n.º 1
0
        /// <summary>
        /// 审核退回详细步骤
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="toUserId">发送给</param>
        /// <param name="activityId">退回到指定步骤</param>
        /// <returns>影响行数</returns>
        private BaseWorkFlowCurrentEntity StepAuditReject(string currentId, string auditIdea, string toUserId = null, string activityId = null)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录审核时间、审核人
            workFlowCurrentEntity.AuditUserId       = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserCode     = this.UserInfo.Code;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus       = AuditStatus.AuditReject.ToString();
            workFlowCurrentEntity.AuditStatusName   = AuditStatus.AuditReject.ToDescription();
            workFlowCurrentEntity.AuditDate         = DateTime.Now;
            workFlowCurrentEntity.AuditIdea         = auditIdea;
            // 2.记录日志
            this.AddHistory(workFlowCurrentEntity);

            // 3.更新待审核情况,流程已经结束了
            workFlowCurrentEntity.ActivityId = null;
            if (!string.IsNullOrEmpty(activityId))
            {
                workFlowCurrentEntity.ActivityId = int.Parse(activityId);
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowActivityEntity  workFlowActivityEntity  = workFlowActivityManager.GetEntity(activityId);
                workFlowCurrentEntity.SortCode         = workFlowActivityEntity.SortCode;
                workFlowCurrentEntity.ToUserId         = workFlowActivityEntity.AuditUserId;
                workFlowCurrentEntity.ToUserRealName   = workFlowActivityEntity.AuditUserRealName;
                workFlowCurrentEntity.ToDepartmentId   = workFlowActivityEntity.AuditDepartmentId;
                workFlowCurrentEntity.ToDepartmentName = workFlowActivityEntity.AuditDepartmentName;
                workFlowCurrentEntity.ToRoleId         = workFlowActivityEntity.AuditRoleId;
                workFlowCurrentEntity.ToRoleRealName   = workFlowActivityEntity.AuditRoleRealName;
            }
            else
            {
                if (!string.IsNullOrEmpty(toUserId))
                {
                    BaseUserManager userManager = new BaseUserManager(UserInfo);
                    BaseUserEntity  userEntity  = userManager.GetEntity(toUserId);
                    workFlowCurrentEntity.ToUserId         = userEntity.Id;
                    workFlowCurrentEntity.ToUserRealName   = userEntity.RealName;
                    workFlowCurrentEntity.ToDepartmentId   = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = userEntity.DepartmentName;
                }
                //workFlowCurrentEntity.SortCode = null;
            }
            workFlowCurrentEntity.SendDate = DateTime.Now;
            workFlowCurrentEntity.Enabled  = 0;
            // 4.生成审核结束的记录
            this.UpdateEntity(workFlowCurrentEntity);
            return(workFlowCurrentEntity);
        }
        /// <summary>
        /// 添加工作流
        /// </summary>
        /// <param name="userInfo">当前用户</param>
        /// <param name="workFlowActivityEntity">工作流定义实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseWorkFlowActivityEntity workFlowActivityEntity)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 数据库事务开始
                    // dbHelper.BeginTransaction();
                    BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(dbHelper, userInfo);
                    returnValue = workFlowActivityManager.Add(workFlowActivityEntity);
                    // 写入日志信息
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                    // 数据库事务提交
                    // dbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    // 数据库事务回滚
                    // dbHelper.RollbackTransaction();
                    // 记录异常信息
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return returnValue;
        }
Exemplo n.º 3
0
        private string StepAuditStatr(string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = new BaseWorkFlowCurrentEntity();

            // 1.这个是工作流的第一个发出日期,需要全局保留,其实也是创建日期了,但是有重新审核的这个说法,若有2次重新审核的事项,的确需要保留这个字段
            // workFlowCurrentEntity.CallBack = workFlowManager.GetType().ToString();
            workFlowCurrentEntity.WorkFlowId = workFlowStepEntity.WorkFlowId;
            workFlowCurrentEntity.ActivityId = workFlowStepEntity.Id;
            // 这里是为了优化越级审核用的,按排序嘛进行先后顺序排序
            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

            workFlowCurrentEntity.CategoryCode     = categoryCode;
            workFlowCurrentEntity.CategoryFullName = categoryFullName;
            workFlowCurrentEntity.ObjectId         = objectId;
            workFlowCurrentEntity.ObjectFullName   = objectFullName;
            // 2.当前审核人的信息写入当前工作流
            // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditIdea       = auditIdea;
            workFlowCurrentEntity.AuditStatus     = AuditStatus.StartAudit.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription();
            workFlowCurrentEntity.SendDate        = DateTime.Now;
            // 3.接下来需要待审核的对象的信息
            workFlowCurrentEntity.ToUserId         = workFlowStepEntity.AuditUserId;
            workFlowCurrentEntity.ToUserRealName   = workFlowStepEntity.AuditUserRealName;
            workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditDepartmentId;
            workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
            workFlowCurrentEntity.ToRoleId         = workFlowStepEntity.AuditRoleId;
            workFlowCurrentEntity.ToRoleRealName   = workFlowStepEntity.AuditRoleRealName;
            // 4.这些标志信息需要处理好,这里表示工作流还没完成生效,还在审批中的意思。
            workFlowCurrentEntity.SortCode          = workFlowStepEntity.SortCode;
            workFlowCurrentEntity.Enabled           = 0;
            workFlowCurrentEntity.DeletionStateCode = 0;
            return(this.AddEntity(workFlowCurrentEntity));
        }
        /// <summary>
        /// 获取工作流步骤定义列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="workFlowId">工作流主键</param> 
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo, string workFlowId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseWorkFlowProcessEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(dbHelper, userInfo);

                    List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                    parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
                    parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
                    parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));

                    dataTable = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
                    dataTable.TableName = BaseWorkFlowActivityEntity.TableName;
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return dataTable;
        }
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dataTable)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(dbHelper, userInfo);
                    returnValue = workFlowActivityManager.BatchSave(dataTable);
                    // dataTable = Role.GetDataTableByOrganize(organizeId);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return returnValue;
        }
        /// <summary>
        /// 获取第一步审核的
        /// </summary>
        /// <param name="categoryCode">单据分类</param>
        /// <param name="workFlowCode">审批流程编号</param>
        /// <returns>审核步骤</returns>
        public BaseWorkFlowActivityEntity GetFirstActivityEntity(string workFlowCode, string categoryCode = null)
        {
            BaseWorkFlowActivityEntity workFlowActivityEntity = null;

            string workFlowId = string.Empty;
            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            // 这里是获取用户的工作流, 按用户主键,按模板编号
            if (string.IsNullOrEmpty(workFlowCode))
            {
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowBillTemplateEntity.FieldCategoryCode, categoryCode));
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowBillTemplateEntity.FieldDeletionStateCode, 0));
                BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo);
                DataTable dt = templateManager.GetDataTable(parameters);
                BaseWorkFlowBillTemplateEntity templateEntity = new BaseWorkFlowBillTemplateEntity(dt);
                if (!string.IsNullOrEmpty(templateEntity.Id))
                {
                    workFlowCode = this.UserInfo.Id + "_" + templateEntity.Id;
                }
            }
            if (string.IsNullOrEmpty(workFlowCode))
            {
                return null;
            }
            // 1. 先检查工作流是否存在?
            BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);

            parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowCode));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0));

            string[] names = new string[] { BaseWorkFlowProcessEntity.FieldCode, BaseWorkFlowProcessEntity.FieldEnabled, BaseWorkFlowProcessEntity.FieldDeletionStateCode };  // 2010.01.25 LiangMingMing 将 BaseWorkFlowProcessEntity.FieldCode 改 BaseWorkFlowProcessEntity.FieldId
            object[] values = new object[] { workFlowCode, 1, 0 };
            workFlowId = workFlowProcessManager.GetId(parameters);
            if (string.IsNullOrEmpty(workFlowId))
            {
                return null;
            }
            // 2. 查找第一步是按帐户审核?还是按角色审核?
            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
            // 2010.01.25 LiangMingMing 新加了两个参数new string[] { BaseWorkFlowActivityEntity.FieldWorkFlowId }, new string[] { Convert.ToString(workFlowId) },(具体获取哪个流程的步骤)

            parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId.ToString()));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));

            DataTable dataTable = workFlowActivityManager.GetDataTable(parameters);
            // 3. 取第一个排序的数据
            if (dataTable.Rows.Count == 0)
            {
                return null;
            }
            workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataTable.Rows[0]);
            if ((workFlowActivityEntity.AuditUserId == null) && (workFlowActivityEntity.AuditRoleId == null))
            {
                return null;
            }
            return workFlowActivityEntity;
        }
        public BaseWorkFlowActivityEntity GetNextWorkFlowActivity(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            BaseWorkFlowActivityEntity workFlowActivityEntity = null;
            DataTable dataTable = null;

            // 工作流主键
            string workFlowId = workFlowCurrentEntity.WorkFlowId.ToString();

            // 1. 从工作流审核步骤里选取审核步骤
            BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);

            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));

            dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode);

            if (dataTable.Rows.Count > 0)
            {
                dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId);
                dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId;
            }
            else
            {
                // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

                parameters = new List<KeyValuePair<string, object>>();
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId));
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));

                dataTable = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
            }

            // 审核步骤主键
            string activityId = string.Empty;
            if (workFlowCurrentEntity.ActivityId != null)
            {
                activityId = workFlowCurrentEntity.ActivityId.ToString();
            }
            if (dataTable.Rows.Count == 0)
            {
                return workFlowActivityEntity;
            }
            string nextActivityId = string.Empty;
            if (!string.IsNullOrEmpty(activityId))
            {
                nextActivityId = BaseSortLogic.GetNextId(dataTable, activityId.ToString());
            }
            else
            {
                nextActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString();
            }
            if (!string.IsNullOrEmpty(nextActivityId))
            {
                // workFlowActivityEntity = workFlowActivityManager.GetEntity(nextActivityId);
                DataRow dataRow = BaseBusinessLogic.GetDataRow(dataTable, nextActivityId);
                workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataRow);
            }
            return workFlowActivityEntity;
        }
Exemplo n.º 8
0
        public BaseWorkFlowActivityEntity GetNextWorkFlowActivity(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            BaseWorkFlowActivityEntity workFlowActivityEntity = null;
            DataTable dataTable = null;

            // 工作流主键
            string workFlowId = workFlowCurrentEntity.WorkFlowId.ToString();

            // 1. 从工作流审核步骤里选取审核步骤
            BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);

            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));

            dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode);

            if (dataTable.Rows.Count > 0)
            {
                dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId);
                dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId;
            }
            else
            {
                // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

                parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId));
                parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));

                dataTable = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
            }

            // 审核步骤主键
            string activityId = string.Empty;

            if (workFlowCurrentEntity.ActivityId != null)
            {
                activityId = workFlowCurrentEntity.ActivityId.ToString();
            }
            if (dataTable.Rows.Count == 0)
            {
                return(workFlowActivityEntity);
            }
            string nextActivityId = string.Empty;

            if (!string.IsNullOrEmpty(activityId))
            {
                nextActivityId = BaseSortLogic.GetNextId(dataTable, activityId.ToString());
            }
            else
            {
                nextActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString();
            }
            if (!string.IsNullOrEmpty(nextActivityId))
            {
                // workFlowActivityEntity = workFlowActivityManager.GetEntity(nextActivityId);
                DataRow dataRow = BaseBusinessLogic.GetDataRow(dataTable, nextActivityId);
                workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataRow);
            }
            return(workFlowActivityEntity);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取第一步审核的
        /// </summary>
        /// <param name="categoryCode">单据分类</param>
        /// <param name="workFlowCode">审批流程编号</param>
        /// <returns>审核步骤</returns>
        public BaseWorkFlowActivityEntity GetFirstActivityEntity(string workFlowCode, string categoryCode = null)
        {
            BaseWorkFlowActivityEntity workFlowActivityEntity = null;

            string workFlowId = string.Empty;
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            // 这里是获取用户的工作流, 按用户主键,按模板编号
            if (string.IsNullOrEmpty(workFlowCode))
            {
                parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowBillTemplateEntity.FieldCategoryCode, categoryCode));
                parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowBillTemplateEntity.FieldDeletionStateCode, 0));
                BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo);
                DataTable dt = templateManager.GetDataTable(parameters);
                BaseWorkFlowBillTemplateEntity templateEntity = new BaseWorkFlowBillTemplateEntity(dt);
                if (!string.IsNullOrEmpty(templateEntity.Id))
                {
                    workFlowCode = this.UserInfo.Id + "_" + templateEntity.Id;
                }
            }
            if (string.IsNullOrEmpty(workFlowCode))
            {
                return(null);
            }
            // 1. 先检查工作流是否存在?
            BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);

            parameters = new List <KeyValuePair <string, object> >();
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowCode));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0));

            string[] names  = new string[] { BaseWorkFlowProcessEntity.FieldCode, BaseWorkFlowProcessEntity.FieldEnabled, BaseWorkFlowProcessEntity.FieldDeletionStateCode }; // 2010.01.25 LiangMingMing 将 BaseWorkFlowProcessEntity.FieldCode 改 BaseWorkFlowProcessEntity.FieldId
            object[] values = new object[] { workFlowCode, 1, 0 };
            workFlowId = workFlowProcessManager.GetId(parameters);
            if (string.IsNullOrEmpty(workFlowId))
            {
                return(null);
            }
            // 2. 查找第一步是按帐户审核?还是按角色审核?
            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

            // 2010.01.25 LiangMingMing 新加了两个参数new string[] { BaseWorkFlowActivityEntity.FieldWorkFlowId }, new string[] { Convert.ToString(workFlowId) },(具体获取哪个流程的步骤)

            parameters = new List <KeyValuePair <string, object> >();
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId.ToString()));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));

            DataTable dataTable = workFlowActivityManager.GetDataTable(parameters);

            // 3. 取第一个排序的数据
            if (dataTable.Rows.Count == 0)
            {
                return(null);
            }
            workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataTable.Rows[0]);
            if ((workFlowActivityEntity.AuditUserId == null) && (workFlowActivityEntity.AuditRoleId == null))
            {
                return(null);
            }
            return(workFlowActivityEntity);
        }
        /// <summary>
        /// 审核退回
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="historyId">退回到第几步</param>
        /// <returns>影响行数</returns>
        public int AuditReject(IWorkFlowManager workFlowManager, string currentId, string auditIdea, string historyId = null)
        {
            int returnValue = 0;

            lock (WorkFlowCurrentLock)
            {
                // using (TransactionScope transactionScope = new TransactionScope())
                //{
                try
                {
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);
                    // 判断是是否是自由流(自由流这个为空)
                    if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                    {
                        // 若都已经被退回到彻底了,不能再被退回了,意思是已经退回到创建人了
                        if (workFlowCurrentEntity.ActivityId == null)
                        {
                            return returnValue;
                        }
                    }

                    // 只有待审核状态的,才可以退回,还需要能持续退回
                    if ( //workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditComplete.ToString()) ||
                        workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditQuash.ToString()))
                    {
                        return returnValue;
                    }

                    /* 彻底退回的处理
                    if (activityId == null)
                    {
                        // 发送给当初发起这个工作流的创建者
                        sendToUserId = workFlowCurrentEntity.CreateUserId;
                    }
                    else
                    {
                        BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                        BaseWorkFlowActivityEntity workFlowActivityEntity = workFlowActivityManager.GetEntity(activityId.ToString());
                        sendToUserId = workFlowActivityEntity.AuditUserId.ToString();
                    }
                    */

                    if (!string.IsNullOrEmpty(workFlowCurrentEntity.ToUserId))
                    {
                        // 若不是自己应该审核的,不应该能退回,在审核历史里需要控制一下
                        if (!this.UserInfo.IsAdministrator
                            &&(!workFlowCurrentEntity.AuditUserId.ToString().Equals(this.UserInfo.Id)
                             || workFlowCurrentEntity.ToUserId.ToString().Equals(this.UserInfo.Id)))
                        {
                            return returnValue;
                        }

                        // 一个审核者不能持续退回,但是发给自己的,还可以持续退回
                        if (workFlowCurrentEntity.AuditUserId.ToString().Equals(this.UserInfo.Id)
                            && workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditReject.ToString())
                            && (!workFlowCurrentEntity.ToUserId.ToString().Equals(this.UserInfo.Id)))
                        {
                            return returnValue;
                        }
                    }

                    // 默认是自由工作流
                    string workFlowId = "0";
                    List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                    DataTable dataTable = null;
                    BaseWorkFlowHistoryManager workFlowHistoryManager = new BaseWorkFlowHistoryManager(this.DbHelper, this.UserInfo);
                    string rejectToActivityId = string.Empty;
                    // 工作流主键
                    if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                    {
                        workFlowId = workFlowCurrentEntity.WorkFlowId.ToString();
                        BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);
                        parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode));
                        parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId));
                        parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
                        parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
                        parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));
                        dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode);
                        if (dataTable.Rows.Count > 0)
                        {
                            dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId);
                            dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId;
                        }
                        else
                        {
                            // 判断是是否是自由流(自由流这个为空)
                            if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                            {
                                return returnValue;
                            }
                        }

                        if (!string.IsNullOrEmpty(historyId))
                        {
                            BaseWorkFlowHistoryEntity workFlowHistoryEntity = workFlowHistoryManager.GetEntity(historyId);
                            rejectToActivityId = workFlowHistoryEntity.ActivityId.ToString();
                        }
                        else
                        {
                            // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤
                            // 3. 下一步是多少?按工作流进行查找审核步骤
                            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                            parameters = new List<KeyValuePair<string, object>>();
                            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId));
                            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
                            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));
                            DataTable dataTableActivity = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
                            if (dataTableActivity.Rows.Count > 0)
                            {
                                dataTable = dataTableActivity;
                            }
                            string activityId = string.Empty;
                            if (workFlowCurrentEntity.ActivityId != null)
                            {
                                activityId = workFlowCurrentEntity.ActivityId.ToString();
                            }

                            if (!string.IsNullOrEmpty(activityId))
                            {
                                rejectToActivityId = BaseSortLogic.GetPreviousId(dataTable, activityId.ToString());
                            }
                            else
                            {
                                if (dataTable.Rows.Count > 0)
                                {
                                    rejectToActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString();
                                }
                            }
                            if (string.IsNullOrEmpty(rejectToActivityId))
                            {
                                // 这里已经是最后一步,发出者这里了
                                // 已经到自己手里的,没必要再继续退回了
                                if (this.UserInfo.Id.Equals(workFlowCurrentEntity.CreateUserId))
                                {
                                    return returnValue;
                                }
                            }
                        }
                    }

                    // 这里不应该是发给所有的人,审核过的人,才可以看到才对。
                    string[] userIds = workFlowHistoryManager.GetProperties(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldWorkFlowId, workFlowCurrentEntity.Id), BaseWorkFlowCurrentEntity.FieldAuditUserId);
                    userIds = StringUtil.Concat(userIds, workFlowCurrentEntity.CreateUserId);

                    // 进行更新操作
                    workFlowCurrentEntity = this.StepAuditReject(currentId, auditIdea, workFlowCurrentEntity.CreateUserId, rejectToActivityId);
                    if (workFlowCurrentEntity.Id != null)
                    {
                        // 5.发送提示信息
                        if (workFlowManager != null)
                        {
                            workFlowManager.OnAuditReject(workFlowCurrentEntity);
                            /*
                            // 这个是表明已经彻底退回了,不是退回给指定的一个人了
                            if (activityId == null)
                            {
                                // 已经审核过的人,都需要得到退回的信息
                                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.UserInfo);
                                DataTable dt = workFlowActivityManager.GetBackToDT(workFlowCurrentEntity);
                                userIds = BaseBusinessLogic.FieldToArray(dt, BaseWorkFlowActivityEntity.FieldAuditUserId);
                            }
                            */
                            // 都给谁发送退回的消息
                            workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditReject, userIds, workFlowCurrentEntity.ToDepartmentId, workFlowCurrentEntity.ToRoleId);

                        }
                        returnValue = 1;
                    }
                    else
                    {
                        // 数据可能被删除
                        this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
                    }
                    // 应该给创建者一个提醒消息
                    this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
                }
                catch (System.Exception ex)
                {
                    // 在本地记录异常
                    FileUtil.WriteException(UserInfo, ex);
                }
                finally
                {
                }
                // transactionScope.Complete();
                // }
            }
            return returnValue;
        }
        /// <summary>
        /// 审核退回详细步骤
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="toUserId">发送给</param>
        /// <param name="activityId">退回到指定步骤</param>
        /// <returns>影响行数</returns>
        private BaseWorkFlowCurrentEntity StepAuditReject(string currentId, string auditIdea, string toUserId = null, string activityId = null)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);
            // 1.记录审核时间、审核人
            workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus = AuditStatus.AuditReject.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.AuditReject.ToDescription();
            workFlowCurrentEntity.AuditDate = DateTime.Now;
            workFlowCurrentEntity.AuditIdea = auditIdea;
            // 2.记录日志
            this.AddHistory(workFlowCurrentEntity);

            // 3.更新待审核情况,流程已经结束了
            workFlowCurrentEntity.ActivityId = null;
            if (!string.IsNullOrEmpty(activityId))
            {
                workFlowCurrentEntity.ActivityId = int.Parse(activityId);
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowActivityEntity workFlowActivityEntity = workFlowActivityManager.GetEntity(activityId);
                workFlowCurrentEntity.SortCode = workFlowActivityEntity.SortCode;
                workFlowCurrentEntity.ToUserId = workFlowActivityEntity.AuditUserId;
                workFlowCurrentEntity.ToUserRealName = workFlowActivityEntity.AuditUserRealName;
                workFlowCurrentEntity.ToDepartmentId = workFlowActivityEntity.AuditDepartmentId;
                workFlowCurrentEntity.ToDepartmentName = workFlowActivityEntity.AuditDepartmentName;
                workFlowCurrentEntity.ToRoleId = workFlowActivityEntity.AuditRoleId;
                workFlowCurrentEntity.ToRoleRealName = workFlowActivityEntity.AuditRoleRealName;
            }
            else
            {
                if (!string.IsNullOrEmpty(toUserId))
                {
                    BaseUserManager userManager = new BaseUserManager(UserInfo);
                    BaseUserEntity userEntity = userManager.GetEntity(toUserId);
                    workFlowCurrentEntity.ToUserId = userEntity.Id;
                    workFlowCurrentEntity.ToUserRealName = userEntity.RealName;
                    workFlowCurrentEntity.ToDepartmentId = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = userEntity.DepartmentName;
                }
                //workFlowCurrentEntity.SortCode = null;
            }
            workFlowCurrentEntity.SendDate = DateTime.Now;
            workFlowCurrentEntity.Enabled = 0;
            // 4.生成审核结束的记录
            this.UpdateEntity(workFlowCurrentEntity);
            return workFlowCurrentEntity;
        }
 private string StepAuditStatr(string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
 {
     BaseWorkFlowCurrentEntity workFlowCurrentEntity = new BaseWorkFlowCurrentEntity();
     // 1.这个是工作流的第一个发出日期,需要全局保留,其实也是创建日期了,但是有重新审核的这个说法,若有2次重新审核的事项,的确需要保留这个字段
     // workFlowCurrentEntity.CallBack = workFlowManager.GetType().ToString();
     workFlowCurrentEntity.WorkFlowId = workFlowStepEntity.WorkFlowId;
     workFlowCurrentEntity.ActivityId = workFlowStepEntity.Id;
     // 这里是为了优化越级审核用的,按排序嘛进行先后顺序排序
     BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
     workFlowCurrentEntity.CategoryCode = categoryCode;
     workFlowCurrentEntity.CategoryFullName = categoryFullName;
     workFlowCurrentEntity.ObjectId = objectId;
     workFlowCurrentEntity.ObjectFullName = objectFullName;
     // 2.当前审核人的信息写入当前工作流
     // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
     // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
     // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
     workFlowCurrentEntity.AuditIdea = auditIdea;
     workFlowCurrentEntity.AuditStatus = AuditStatus.StartAudit.ToString();
     workFlowCurrentEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription();
     workFlowCurrentEntity.SendDate = DateTime.Now;
     // 3.接下来需要待审核的对象的信息
     workFlowCurrentEntity.ToUserId = workFlowStepEntity.AuditUserId;
     workFlowCurrentEntity.ToUserRealName = workFlowStepEntity.AuditUserRealName;
     workFlowCurrentEntity.ToDepartmentId = workFlowStepEntity.AuditDepartmentId;
     workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
     workFlowCurrentEntity.ToRoleId = workFlowStepEntity.AuditRoleId;
     workFlowCurrentEntity.ToRoleRealName = workFlowStepEntity.AuditRoleRealName;
     // 4.这些标志信息需要处理好,这里表示工作流还没完成生效,还在审批中的意思。
     workFlowCurrentEntity.SortCode = workFlowStepEntity.SortCode;
     workFlowCurrentEntity.Enabled = 0;
     workFlowCurrentEntity.DeletionStateCode = 0;
     return this.AddEntity(workFlowCurrentEntity);
 }
Exemplo n.º 13
0
        /// <summary>
        /// 审核退回
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="historyId">退回到第几步</param>
        /// <returns>影响行数</returns>
        public int AuditReject(IWorkFlowManager workFlowManager, string currentId, string auditIdea, string historyId = null)
        {
            int returnValue = 0;

            lock (WorkFlowCurrentLock)
            {
                // using (TransactionScope transactionScope = new TransactionScope())
                //{
                try
                {
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);
                    // 判断是是否是自由流(自由流这个为空)
                    if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                    {
                        // 若都已经被退回到彻底了,不能再被退回了,意思是已经退回到创建人了
                        if (workFlowCurrentEntity.ActivityId == null)
                        {
                            return(returnValue);
                        }
                    }

                    // 只有待审核状态的,才可以退回,还需要能持续退回
                    if ( //workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditComplete.ToString()) ||
                        workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditQuash.ToString()))
                    {
                        return(returnValue);
                    }

                    /* 彻底退回的处理
                     * if (activityId == null)
                     * {
                     *  // 发送给当初发起这个工作流的创建者
                     *  sendToUserId = workFlowCurrentEntity.CreateUserId;
                     * }
                     * else
                     * {
                     *  BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                     *  BaseWorkFlowActivityEntity workFlowActivityEntity = workFlowActivityManager.GetEntity(activityId.ToString());
                     *  sendToUserId = workFlowActivityEntity.AuditUserId.ToString();
                     * }
                     */

                    if (!string.IsNullOrEmpty(workFlowCurrentEntity.ToUserId))
                    {
                        // 若不是自己应该审核的,不应该能退回,在审核历史里需要控制一下
                        if (!this.UserInfo.IsAdministrator &&
                            (!workFlowCurrentEntity.AuditUserId.ToString().Equals(this.UserInfo.Id) ||
                             workFlowCurrentEntity.ToUserId.ToString().Equals(this.UserInfo.Id)))
                        {
                            return(returnValue);
                        }

                        // 一个审核者不能持续退回,但是发给自己的,还可以持续退回
                        if (workFlowCurrentEntity.AuditUserId.ToString().Equals(this.UserInfo.Id) &&
                            workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditReject.ToString()) &&
                            (!workFlowCurrentEntity.ToUserId.ToString().Equals(this.UserInfo.Id)))
                        {
                            return(returnValue);
                        }
                    }

                    // 默认是自由工作流
                    string workFlowId = "0";
                    List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                    DataTable dataTable = null;
                    BaseWorkFlowHistoryManager workFlowHistoryManager = new BaseWorkFlowHistoryManager(this.DbHelper, this.UserInfo);
                    string rejectToActivityId = string.Empty;
                    // 工作流主键
                    if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                    {
                        workFlowId = workFlowCurrentEntity.WorkFlowId.ToString();
                        BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);
                        parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode));
                        parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId));
                        parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
                        parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
                        parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));
                        dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode);
                        if (dataTable.Rows.Count > 0)
                        {
                            dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId);
                            dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId;
                        }
                        else
                        {
                            // 判断是是否是自由流(自由流这个为空)
                            if (workFlowCurrentEntity.WorkFlowId != null && workFlowCurrentEntity.WorkFlowId != 0)
                            {
                                return(returnValue);
                            }
                        }

                        if (!string.IsNullOrEmpty(historyId))
                        {
                            BaseWorkFlowHistoryEntity workFlowHistoryEntity = workFlowHistoryManager.GetEntity(historyId);
                            rejectToActivityId = workFlowHistoryEntity.ActivityId.ToString();
                        }
                        else
                        {
                            // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤
                            // 3. 下一步是多少?按工作流进行查找审核步骤
                            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                            parameters = new List <KeyValuePair <string, object> >();
                            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId));
                            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
                            parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));
                            DataTable dataTableActivity = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
                            if (dataTableActivity.Rows.Count > 0)
                            {
                                dataTable = dataTableActivity;
                            }
                            string activityId = string.Empty;
                            if (workFlowCurrentEntity.ActivityId != null)
                            {
                                activityId = workFlowCurrentEntity.ActivityId.ToString();
                            }

                            if (!string.IsNullOrEmpty(activityId))
                            {
                                rejectToActivityId = BaseSortLogic.GetPreviousId(dataTable, activityId.ToString());
                            }
                            else
                            {
                                if (dataTable.Rows.Count > 0)
                                {
                                    rejectToActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString();
                                }
                            }
                            if (string.IsNullOrEmpty(rejectToActivityId))
                            {
                                // 这里已经是最后一步,发出者这里了
                                // 已经到自己手里的,没必要再继续退回了
                                if (this.UserInfo.Id.Equals(workFlowCurrentEntity.CreateUserId))
                                {
                                    return(returnValue);
                                }
                            }
                        }
                    }

                    // 这里不应该是发给所有的人,审核过的人,才可以看到才对。
                    string[] userIds = workFlowHistoryManager.GetProperties(new KeyValuePair <string, object>(BaseWorkFlowCurrentEntity.FieldWorkFlowId, workFlowCurrentEntity.Id), BaseWorkFlowCurrentEntity.FieldAuditUserId);
                    userIds = StringUtil.Concat(userIds, workFlowCurrentEntity.CreateUserId);

                    // 进行更新操作
                    workFlowCurrentEntity = this.StepAuditReject(currentId, auditIdea, workFlowCurrentEntity.CreateUserId, rejectToActivityId);
                    if (workFlowCurrentEntity.Id != null)
                    {
                        // 5.发送提示信息
                        if (workFlowManager != null)
                        {
                            workFlowManager.OnAuditReject(workFlowCurrentEntity);

                            /*
                             * // 这个是表明已经彻底退回了,不是退回给指定的一个人了
                             * if (activityId == null)
                             * {
                             *  // 已经审核过的人,都需要得到退回的信息
                             *  BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.UserInfo);
                             *  DataTable dt = workFlowActivityManager.GetBackToDT(workFlowCurrentEntity);
                             *  userIds = BaseBusinessLogic.FieldToArray(dt, BaseWorkFlowActivityEntity.FieldAuditUserId);
                             * }
                             */
                            // 都给谁发送退回的消息
                            workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditReject, userIds, workFlowCurrentEntity.ToDepartmentId, workFlowCurrentEntity.ToRoleId);
                        }
                        returnValue = 1;
                    }
                    else
                    {
                        // 数据可能被删除
                        this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
                    }
                    // 应该给创建者一个提醒消息
                    this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
                }
                catch (System.Exception ex)
                {
                    // 在本地记录异常
                    FileUtil.WriteException(UserInfo, ex);
                }
                finally
                {
                }
                // transactionScope.Complete();
                // }
            }
            return(returnValue);
        }