/// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseWorkFlowProcessEntity entity, out string statusCode)
        {
            int result = 0;

            // 检查编号是否重复
            //if (this.Exists(new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldCode, entity.Code), entity.Id))
            //{
            //    // 文件夹名已重复
            //    statusCode = Status.ErrorCodeExist.ToString();
            //}
            //else
            //{
            // 进行更新操作
            result = this.UpdateObject(entity);
            if (result == 1)
            {
                statusCode = Status.OKUpdate.ToString();
            }
            else
            {
                // 数据可能被删除
                statusCode = Status.ErrorDeleted.ToString();
            }
            //}
            return(result);
        }
예제 #2
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="workFlowProcessEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查编号是否重复
            if (this.Exists(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowProcessEntity.Code), workFlowProcessEntity.Id))
            {
                // 文件夹名已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                // 进行更新操作
                returnValue = this.UpdateEntity(workFlowProcessEntity);
                if (returnValue == 1)
                {
                    statusCode = StatusCode.OKUpdate.ToString();
                }
                else
                {
                    // 数据可能被删除
                    statusCode = StatusCode.ErrorDeleted.ToString();
                }
            }
            return(returnValue);
        }
예제 #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);
        }
예제 #5
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);
        }
        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);
        }
예제 #7
0
        /// <summary>
        /// 通过编号获取选项的显示内容
        /// 这里是进行了内存缓存处理,减少数据库的I/O处理,提高程序的运行性能,
        /// 若有数据修改过,重新启动一下程序就可以了,这些基础数据也不是天天修改来修改去的,
        /// 所以没必要过度担忧,当然有需要时也可以写个刷新缓存的程序
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>显示值</returns>
        public static string GetFullName(string id)
        {
            string result = id;

            if (!string.IsNullOrEmpty(id))
            {
                List <BaseWorkFlowProcessEntity> entityList            = GetObjectList();
                BaseWorkFlowProcessEntity        workFlowProcessEntity = entityList.FirstOrDefault(entity => entity.Id.HasValue && entity.Id.ToString().Equals(id));
                if (workFlowProcessEntity != null)
                {
                    result = workFlowProcessEntity.FullName;
                }
            }
            return(result);
        }
예제 #8
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        public int UpdateObject(BaseWorkFlowProcessEntity entity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseWorkFlowProcessEntity.FieldId, entity.Id);
            return(sqlBuilder.EndUpdate());
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldUserId, baseWorkFlowProcessEntity.UserId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldOrganizeId, baseWorkFlowProcessEntity.OrganizeId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldBillTemplateId, baseWorkFlowProcessEntity.BillTemplateId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldAuditCategoryCode, baseWorkFlowProcessEntity.AuditCategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackClass, baseWorkFlowProcessEntity.CallBackClass);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackTable, baseWorkFlowProcessEntity.CallBackTable);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCategoryCode, baseWorkFlowProcessEntity.CategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCode, baseWorkFlowProcessEntity.Code);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldFullName, baseWorkFlowProcessEntity.FullName);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldContents, baseWorkFlowProcessEntity.Contents);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldSortCode, baseWorkFlowProcessEntity.SortCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldEnabled, baseWorkFlowProcessEntity.Enabled);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDeletionStateCode, baseWorkFlowProcessEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDescription, baseWorkFlowProcessEntity.Description);
 }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="workFlowEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>主键</returns>
        public string Add(BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode)
        {
            string returnValue = string.Empty;

            // 检查编号是否重复
            if (this.Exists(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowProcessEntity.Code)))
            {
                // 编号已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(workFlowProcessEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return(returnValue);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>主键</returns>
        public string Add(BaseWorkFlowProcessEntity entity, out string statusCode)
        {
            string result = string.Empty;

            // 检查编号是否重复
            //if (this.Exists(new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair<string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowProcessEntity.Code)))
            //{
            //    // 编号已重复
            //    statusCode = Status.ErrorCodeExist.ToString();
            //}
            //else
            //{
            result = this.AddObject(entity);
            // 运行成功
            statusCode = Status.OKAdd.ToString();
            //}
            return(result);
        }
        /// <summary>
        /// 批量进行保存
        /// </summary>
        /// <param name="dataSet">数据权限</param>
        /// <returns>影响行数</returns>
        public new int BatchSave(DataTable dataTable)
        {
            int returnValue = 0;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                BaseWorkFlowProcessEntity workFlowProcessEntity = new BaseWorkFlowProcessEntity(dataRow);
                // 删除状态
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    string id = dataRow[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        returnValue += this.Delete(id);
                    }
                }
                // 被修改过
                if (dataRow.RowState == DataRowState.Modified)
                {
                    string id = dataRow[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        workFlowProcessEntity.GetFrom(dataRow);
                        // 判断是否允许编辑
                        returnValue += this.Update(workFlowProcessEntity);
                    }
                }
                // 添加状态
                if (dataRow.RowState == DataRowState.Added)
                {
                    workFlowProcessEntity.GetFrom(dataRow);
                    returnValue += this.Add(workFlowProcessEntity).Length > 0 ? 1 : 0;
                }
                if (dataRow.RowState == DataRowState.Unchanged)
                {
                    continue;
                }
                if (dataRow.RowState == DataRowState.Detached)
                {
                    continue;
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// 批量进行保存
        /// </summary>
        /// <param name="dataSet">数据权限</param>
        /// <returns>影响行数</returns>
        public new int BatchSave(DataTable dt)
        {
            int result = 0;

            foreach (DataRow dr in dt.Rows)
            {
                BaseWorkFlowProcessEntity workFlowProcessEntity = BaseEntity.Create <BaseWorkFlowProcessEntity>(dr);
                // 删除状态
                if (dr.RowState == DataRowState.Deleted)
                {
                    string id = dr[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        result += this.Delete(id);
                    }
                }
                // 被修改过
                if (dr.RowState == DataRowState.Modified)
                {
                    string id = dr[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        workFlowProcessEntity.GetFrom(dr);
                        // 判断是否允许编辑
                        result += this.Update(workFlowProcessEntity);
                    }
                }
                // 添加状态
                if (dr.RowState == DataRowState.Added)
                {
                    workFlowProcessEntity.GetFrom(dr);
                    result += this.Add(workFlowProcessEntity).Length > 0 ? 1 : 0;
                }
                if (dr.RowState == DataRowState.Unchanged)
                {
                    continue;
                }
                if (dr.RowState == DataRowState.Detached)
                {
                    continue;
                }
            }
            return(result);
        }
        public IWorkFlowManager GetWorkFlowManager(string id)
        {
            IWorkFlowManager          workFlowManager       = null;
            BaseWorkFlowProcessEntity workFlowProcessEntity = this.GetEntity(id);

            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))
                {
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
        /// <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);
        }
예제 #16
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">实体</param>
 private void SetObject(SQLBuilder sqlBuilder, BaseWorkFlowProcessEntity entity)
 {
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldUserId, entity.UserId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldOrganizeId, entity.OrganizeId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldBillTemplateId, entity.BillTemplateId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldAuditCategoryCode, entity.AuditCategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackClass, entity.CallBackClass);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackTable, entity.CallBackTable);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCategoryCode, entity.CategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCode, entity.Code);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldFullName, entity.FullName);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldContents, entity.Contents);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCommitmentDays, entity.CommitmentDays);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldEnterConstraint, entity.EnterConstraint);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldSortCode, entity.SortCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldEnabled, entity.Enabled);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDeletionStateCode, entity.DeletionStateCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDescription, entity.Description);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackAssembly, entity.CallBackAssembly);
 }
예제 #17
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);
        }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 public int Update(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     return(this.UpdateEntity(baseWorkFlowProcessEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     return(this.AddEntity(baseWorkFlowProcessEntity));
 }
        //-----------------------------------------------------
        //                  启动工作流 步骤流
        //-----------------------------------------------------

        /// <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);
        }
예제 #21
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowProcessEntity entity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddObject(entity));
 }
예제 #22
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BaseWorkFlowProcessEntity entity)
 {
     return(this.UpdateObject(entity));
 }
예제 #23
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(BaseWorkFlowProcessEntity entity)
        {
            string sequence = string.Empty;

            if (entity.SortCode == null || entity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence        = sequenceManager.Increment(this.CurrentTableName);
                entity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseWorkFlowProcessEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldId, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowProcessEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowProcessEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (entity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.Increment(this.CurrentTableName);
                            }
                            entity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldId, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
        public BaseWorkFlowProcessEntity GetEntity(int id)
        {
            BaseWorkFlowProcessEntity baseWorkFlowProcessEntity = new BaseWorkFlowProcessEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldId, id)));

            return(baseWorkFlowProcessEntity);
        }
예제 #25
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowProcessEntity entity)
 {
     return(this.AddObject(entity));
 }