Beispiel #1
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseRoleEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseRoleEntity roleEntity = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    string tableName = BaseRoleEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "Role";
                    }
                    BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo, tableName);
                    roleEntity = roleManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.RoleService_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 roleEntity;
        }
Beispiel #2
0
        public bool IsAdministrator(string userId)
        {
            // 用户是超级管理员
            if (userId.Equals("Administrator"))
            {
                return true;
            }
            BaseUserEntity userEntity = this.GetEntity(userId);
            if (userEntity.Code != null && userEntity.Code.Equals("Administrator"))
            {
                return true;
            }
            if (userEntity.UserName != null && userEntity.UserName.Equals("Administrator"))
            {
                return true;
            }

            string tableName = BaseUserRoleEntity.TableName;
            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "Role";
            }
            // 用户的默认角色是超级管理员
            BaseRoleManager roleManager = new BaseRoleManager(this.DbHelper, this.UserInfo, tableName);
            // 用户默认角色是否为超级管理员
            BaseRoleEntity roleEntity = null;
            if (userEntity.RoleId != null)
            {
                roleEntity = roleManager.GetEntity(userEntity.RoleId);
                if (roleEntity.Code != null && roleEntity.Code.Equals(DefaultRole.Administrators.ToString()))
                {
                    return true;
                }
            }

            // 用户在超级管理员群里
            string[] roleIds = this.GetAllRoleIds(userId);
            for (int i = 0; i < roleIds.Length; i++)
            {
                if (roleIds[i].Equals(DefaultRole.Administrators.ToString()))
                {
                    return true;
                }
                roleEntity = roleManager.GetEntity(roleIds[i]);
                if (roleEntity.Code != null && roleEntity.Code.Equals(DefaultRole.Administrators.ToString()))
                {
                    return true;
                }
            }
            return false;
        }
        /// <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);
        }
Beispiel #4
0
 public BaseUserInfo ConvertToUserInfo(BaseUserEntity userEntity, BaseUserInfo userInfo)
 {
     userInfo.OpenId = userEntity.OpenId;
     userInfo.Id = userEntity.Id.ToString();
     userInfo.Code = userEntity.Code;
     userInfo.UserName = userEntity.UserName;
     userInfo.RealName = userEntity.RealName;
     userInfo.RoleId = userEntity.RoleId;
     userInfo.CompanyId = userEntity.CompanyId;
     userInfo.CompanyName = userEntity.CompanyName;
     userInfo.SubCompanyId = userEntity.SubCompanyId;
     userInfo.SubCompanyName = userEntity.SubCompanyName;
     userInfo.DepartmentId = userEntity.DepartmentId;
     userInfo.DepartmentName = userEntity.DepartmentName;
     userInfo.WorkgroupId = userEntity.WorkgroupId;
     userInfo.WorkgroupName = userEntity.WorkgroupName;
     if (userEntity.SecurityLevel == null)
     {
         userEntity.SecurityLevel = 0;
     }
     userInfo.SecurityLevel = (int)userEntity.SecurityLevel;
     if (userEntity.RoleId != null)
     {
         // 获取角色名称
         BaseRoleManager roleManager = new BaseRoleManager(DbHelper, UserInfo);
         BaseRoleEntity roleEntity = roleManager.GetEntity(userEntity.RoleId);
         if (roleEntity.Id > 0)
         {
             userInfo.RoleName = roleEntity.RealName;
         }
     }
     return userInfo;
 }