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