Ejemplo n.º 1
0
        /// <summary>
        /// 获取反射调用的类
        /// 回写状态时用
        /// </summary>
        /// <param name="currentId">当前工作流主键</param>
        /// <returns></returns>
        public IWorkFlowManager GetWorkFlowManager(string currentId)
        {
            IWorkFlowManager workFlowManager = new BaseUserBillManager();

            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            workFlowManager.SetUserInfo(this.UserInfo);
            workFlowManager.CurrentTableName = workFlowCurrentEntity.CategoryCode;

            string workFlowId = this.GetEntity(currentId).WorkFlowId.ToString();

            if (!workFlowId.Equals("0"))
            {
                BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowProcessEntity  workFlowProcessEntity  = new BaseWorkFlowProcessEntity();
                if (!string.IsNullOrEmpty(workFlowId))
                {
                    workFlowProcessEntity = workFlowProcessManager.GetEntity(workFlowId);
                }
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackClass))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    Type objType = Type.GetType(workFlowProcessEntity.CallBackClass, true);
                    workFlowManager = (IWorkFlowManager)Activator.CreateInstance(objType);
                    workFlowManager.SetUserInfo(this.UserInfo);
                }
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackTable))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo, string id = null)
        {
            var dt = new DataTable(BaseWorkFlowProcessEntity.TableName);

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                if (string.IsNullOrEmpty(id))
                {
                    dt = workFlowManager.GetDataTable(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), BaseWorkFlowProcessEntity.FieldSortCode);
                }
                else
                {
                    //dt = workFlowManager.GetDataTableById(id);
                    List <KeyValuePair <string, object> > parametersList = new List <KeyValuePair <string, object> >();
                    parametersList.Add(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0));
                    parametersList.Add(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldId, id));
                    dt = workFlowManager.GetDataTable(parametersList, BaseWorkFlowProcessEntity.FieldSortCode);
                }
                //result = workFlowManager.GetDataTable();
                dt.TableName = BaseWorkFlowProcessEntity.TableName;
            });
            return(dt);
        }
Ejemplo n.º 3
0
        public string GetWorkFlowActivityByCode(string workFlowCode)
        {
            BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
            string workFlowId = workFlowProcessManager.GetId(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowCode));

            return(GetWorkFlowActivity(workFlowId));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取反射调用的类
        /// 回写状态时用
        /// </summary>
        /// <param name="currentId">当前工作流主键</param>
        /// <returns></returns>
        public IWorkFlowManager GetWorkFlowManager(string currentId)
        {
            IWorkFlowManager          workFlowManager       = null;
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(currentId);
            string processId = this.GetObject(currentId).ProcessId.ToString();

            if (!string.IsNullOrEmpty(processId))
            {
                BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowProcessEntity  workFlowProcessEntity  = new BaseWorkFlowProcessEntity();
                if (!string.IsNullOrEmpty(processId))
                {
                    workFlowProcessEntity = workFlowProcessManager.GetObject(processId);
                }
                // 这里本来是想动态创建类库 编码外包[100]
                // System.Reflection.Assembly assembly = Assembly.Load("__code");
                // System.Reflection.Assembly assembly = Assembly.Load("app_code");
                string assemblyString = workFlowProcessEntity.CallBackAssembly;
                workFlowManager = (IWorkFlowManager)Assembly.Load(assemblyString).CreateInstance(workFlowProcessEntity.CallBackClass, true);
                // Type objType = assembly.GetType(workFlowProcessEntity.CallBackClass, true);
                // workFlowManager = (IWorkFlowManager)Activator.CreateInstance(objType);
                workFlowManager.SetUserInfo(this.UserInfo);
                workFlowManager.CurrentTableName = workFlowCurrentEntity.CategoryCode;
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackTable))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
Ejemplo n.º 5
0
        public string GetWorkFlowActivityByOrganize(string organizeId, string billTemplateId)
        {
            BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
            string workFlowId = workFlowProcessManager.GetId(
                new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0)
                , new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldOrganizeId, organizeId)
                , new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldBillTemplateId, billTemplateId));

            return(GetWorkFlowActivity(workFlowId));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加工作流
        /// </summary>
        /// <param name="userInfo">当前用户</param>
        /// <param name="workFlowProcessEntity">工作流定义实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            statusCode    = string.Empty;
            statusMessage = string.Empty;
            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 数据库事务开始
                    // dbHelper.BeginTransaction();
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    returnValue = workFlowManager.Add(workFlowProcessEntity, out statusCode);
                    // 获得状态消息
                    statusMessage = workFlowManager.GetStateMessage(statusCode);
                    // 写入日志信息
                    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);
        }
        /// <summary>
        /// 获取具体的审批流程
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="workFlowCode">工作流程编号</param>
        /// <returns>流程</returns>
        public string GetProcessId(BaseUserInfo userInfo, string workFlowCode)
        {
            string result = string.Empty;

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                result = workFlowManager.GetProcessId(userInfo, workFlowCode);
            });
            return(result);
        }
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            int result = 0;

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                result = workFlowManager.SetDeleted(ids);
            });
            return(result);
        }
        public BaseWorkFlowProcessEntity GetObject(BaseUserInfo userInfo, string id)
        {
            BaseWorkFlowProcessEntity entity = new BaseWorkFlowProcessEntity();

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                // 创建实现类
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                entity = workFlowManager.GetObject(id);
            });
            return(entity);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        /// <param name="parameters"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Exists(BaseUserInfo userInfo, List <KeyValuePair <string, object> > parameters, object id = null)
        {
            bool result = false;

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowProcessManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                result = workFlowProcessManager.Exists(parameters, id);
            });

            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo, string id = null)
        {
            // 写入调试信息
            #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);
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    if (string.IsNullOrEmpty(id))
                    {
                        dataTable = workFlowManager.GetDataTable(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), BaseWorkFlowProcessEntity.FieldSortCode);
                    }
                    else
                    {
                        dataTable = workFlowManager.GetDataTable(id);
                    }
                    //dataTable = workFlowManager.GetDataTable();
                    dataTable.TableName = BaseWorkFlowProcessEntity.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="result">数据表</param>
        /// <returns>数据表</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dt)
        {
            int result = 0;

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                result = workFlowManager.BatchSave(dt);
                // this.StatusMessage = workFlowManager.StatusMessage;
                // this.StatusCode = workFlowManager.StatusCode;
                // ReturnDataTable = workFlowManager.GetDataTable();
            });
            return(result);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取具体的审批流程
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="workFlowCode">工作流程编号</param>
        /// <returns>流程</returns>
        public string GetProcessId(BaseUserInfo userInfo, string workFlowCode)
        {
            // 写入调试信息
            #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);
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    returnValue = workFlowManager.GetProcessId(userInfo, workFlowCode);
                    // 写入日志信息
                    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);
        }
Ejemplo n.º 14
0
        /// <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);
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    returnValue = workFlowManager.BatchSave(dataTable);
                    // this.ReturnStatusMessage = workFlowManager.ReturnStatusMessage;
                    // this.ReturnStatusCode = workFlowManager.ReturnStatusCode;
                    // ReturnDataTable = workFlowManager.GetDataTable();
                    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="userInfo">当前用户</param>
        /// <param name="entity">工作流定义实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseWorkFlowProcessEntity entity, out string statusCode, out string statusMessage)
        {
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            string result        = string.Empty;

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

            ServiceUtil.ProcessWorkFlowDb(userInfo, parameter, (dbHelper) =>
            {
                var workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                result = workFlowManager.Add(entity, out returnCode);
                // 获得状态消息
                returnMessage = workFlowManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Ejemplo n.º 16
0
        public BaseWorkFlowProcessEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseWorkFlowProcessEntity workFlowEntity = new BaseWorkFlowProcessEntity();
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 创建实现类
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    workFlowEntity = workFlowManager.GetEntity(id);
                    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(workFlowEntity);
        }
Ejemplo n.º 17
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;
            DataTable dt         = null;
            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);
                dt = templateManager.GetDataTable(parameters);
                BaseWorkFlowBillTemplateEntity templateEntity = BaseEntity.Create <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.FieldProcessId }, new string[] { Convert.ToString(workFlowId) },(具体获取哪个流程的步骤)

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

            dt = workFlowActivityManager.GetDataTable(parameters);
            // 3. 取第一个排序的数据
            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            workFlowActivityEntity = BaseEntity.Create <BaseWorkFlowActivityEntity>(dt.Rows[0]);
            if ((workFlowActivityEntity.AuditUserId == null) && (workFlowActivityEntity.AuditRoleId == null))
            {
                return(null);
            }
            return(workFlowActivityEntity);
        }
        /// <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);
        }
        //-----------------------------------------------------
        //                  启动工作流 步骤流
        //-----------------------------------------------------

        /// <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);
        }