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