Exemple #1
0
        private int UpdataAuditStatr(string id, string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(id);

            workFlowCurrentEntity.CategoryCode     = categoryCode;
            workFlowCurrentEntity.CategoryFullName = categoryFullName;
            workFlowCurrentEntity.ObjectId         = objectId;
            workFlowCurrentEntity.ObjectFullName   = objectFullName;
            workFlowCurrentEntity.WorkFlowId       = workFlowStepEntity.WorkFlowId;
            workFlowCurrentEntity.ActivityId       = workFlowStepEntity.Id;
            workFlowCurrentEntity.SendDate         = DateTime.Now;
            workFlowCurrentEntity.AuditDate        = DateTime.Now;
            workFlowCurrentEntity.AuditStatus      = AuditStatus.StartAudit.ToString();
            workFlowCurrentEntity.AuditStatusName  = AuditStatus.StartAudit.ToDescription();

            // 是否提交给组织机构审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditDepartmentId))
            {
                workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditDepartmentId;
                workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
            }
            // 是否提交给角色审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditRoleId))
            {
                workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditRoleId;
                workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditRoleRealName;
            }
            // 是否提交给用户审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
            {
                BaseUserManager userManager = new BaseUserManager(UserInfo);
                BaseUserEntity  userEntity  = userManager.GetEntity(workFlowStepEntity.AuditUserId);
                workFlowCurrentEntity.ToUserId       = workFlowStepEntity.AuditUserId;
                workFlowCurrentEntity.ToUserRealName = userEntity.RealName;
                // TODO 用户的部门信息需要处理
                if (!string.IsNullOrEmpty(userEntity.DepartmentId))
                {
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                    BaseOrganizeEntity  organizeEntity  = organizeManager.GetEntity(userEntity.DepartmentId);
                    workFlowCurrentEntity.ToDepartmentId   = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
                }
            }
            // 当前审核人的信息写入当前工作流
            // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditIdea = auditIdea;
            workFlowCurrentEntity.AuditDate = DateTime.Now;
            return(this.UpdateEntity(workFlowCurrentEntity));
        }
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseOrganizeEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseOrganizeEntity organizeEntity = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo);
                    organizeEntity = organizeManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_GetEntity, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(organizeEntity);
        }
        /// <summary>
        /// 下个流程发送给谁
        /// </summary>
        /// <param name="id">当前主键</param>
        /// <returns>影响行数</returns>
        private int StepAuditTransmit(string currentId, string workFlowCategory, string sendToId, string auditIdea)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录当前的审核时间、审核人信息
            workFlowCurrentEntity.ToDepartmentId   = this.UserInfo.DepartmentId;
            workFlowCurrentEntity.ToDepartmentName = this.UserInfo.DepartmentName;
            workFlowCurrentEntity.ToUserId         = this.UserInfo.Id;
            workFlowCurrentEntity.ToUserRealName   = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus      = AuditStatus.Transmit.ToString();
            workFlowCurrentEntity.AuditStatusName  = AuditStatus.Transmit.ToDescription();

            // 2.记录审核日志
            this.AddHistory(workFlowCurrentEntity);

            // 3.上一个审核结束了,新的审核又开始了,更新待审核情况
            workFlowCurrentEntity.AuditUserId       = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditDate         = DateTime.Now;
            workFlowCurrentEntity.AuditIdea         = auditIdea;

            // 是否提交给部门审批
            if (workFlowCategory.Equals("ByOrganize"))
            {
                BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                BaseOrganizeEntity  organizeEntity  = organizeManager.GetEntity(sendToId);
                // 设置审批部门主键
                workFlowCurrentEntity.ToDepartmentId = sendToId;
                // 设置审批部门名称
                workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
            }
            // 是否提交给角色审批
            if (workFlowCategory.Equals("ByRole"))
            {
                BaseRoleManager roleManger = new BaseRoleManager(this.UserInfo);
                BaseRoleEntity  roleEntity = roleManger.GetEntity(sendToId);
                // 设置审批角色主键
                workFlowCurrentEntity.ToRoleId = sendToId;
                // 设置审批角色名称
                workFlowCurrentEntity.ToRoleRealName = roleEntity.RealName;
            }
            // 是否提交给用户审批
            if (workFlowCategory.Equals("ByUser"))
            {
                BaseUserManager userManager = new BaseUserManager(UserInfo);
                BaseUserEntity  userEntity  = userManager.GetEntity(sendToId);
                // 设置审批用户主键
                workFlowCurrentEntity.ToUserId = sendToId;
                // 设置审批用户名称
                workFlowCurrentEntity.ToUserRealName = userEntity.RealName;
                // TODO 用户的部门信息需要处理
                if (!string.IsNullOrEmpty(userEntity.DepartmentId))
                {
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                    BaseOrganizeEntity  organizeEntity  = organizeManager.GetEntity(userEntity.DepartmentId);
                    workFlowCurrentEntity.ToDepartmentId   = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
                }
            }
            workFlowCurrentEntity.AuditStatus     = AuditStatus.WaitForAudit.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.WaitForAudit.ToDescription();
            // 当前审核人的信息写入当前工作流
            workFlowCurrentEntity.Enabled           = 0;
            workFlowCurrentEntity.DeletionStateCode = 0;
            return(this.UpdateEntity(workFlowCurrentEntity));
        }