//命令部分

        #region # 创建信息系统 —— void CreateInfoSystem(string infoSystemNo, string infoSystemName...
        /// <summary>
        /// 创建信息系统
        /// </summary>
        /// <param name="infoSystemNo">信息系统编号</param>
        /// <param name="infoSystemName">信息系统名称</param>
        /// <param name="adminLoginId">系统管理员账号</param>
        /// <param name="applicationType">应用程序类型</param>
        public void CreateInfoSystem(string infoSystemNo, string infoSystemName, string adminLoginId, ApplicationType applicationType)
        {
            #region # 验证

            if (this._repMediator.InfoSystemRep.ExistsNo(infoSystemNo))
            {
                throw new ArgumentOutOfRangeException(nameof(infoSystemNo), $"信息系统编号\"{infoSystemNo}\"已存在!");
            }
            if (this._repMediator.UserRep.ExistsNo(adminLoginId))
            {
                throw new ArgumentOutOfRangeException(nameof(adminLoginId), $"用户名:\"{adminLoginId}\"已存在!");
            }

            #endregion

            InfoSystem infoSystem      = new InfoSystem(infoSystemNo, infoSystemName, adminLoginId, applicationType);
            User       superAdmin      = this._unitOfWork.Resolve <User>(CommonConstants.AdminLoginId);
            User       systemAdmin     = new User(infoSystem.AdminLoginId, $"{infoSystem.Name}管理员", CommonConstants.InitialPassword);
            Role       systemAdminRole = new Role($"{infoSystem.Name}管理员", infoSystem.Number, null, infoSystem.Number);
            superAdmin.AppendRoles(new[] { systemAdminRole });
            systemAdmin.AppendRoles(new[] { systemAdminRole });
            Menu systemMenu = new Menu(infoSystem.Number, infoSystem.ApplicationType, infoSystem.Name, 0, null, null, null, null);

            this._unitOfWork.RegisterAdd(infoSystem);
            this._unitOfWork.RegisterAdd(systemAdmin);
            this._unitOfWork.RegisterAdd(systemAdminRole);
            this._unitOfWork.RegisterAdd(systemMenu);
            this._unitOfWork.RegisterSave(superAdmin);
            this._unitOfWork.Commit();
        }
        //查询部分

        #region # 获取信息系统 —— InfoSystemInfo GetInfoSystem(string infoSystemNo)
        /// <summary>
        /// 获取信息系统
        /// </summary>
        /// <param name="infoSystemNo">信息系统编号</param>
        /// <returns>信息系统</returns>
        public InfoSystemInfo GetInfoSystem(string infoSystemNo)
        {
            InfoSystem     infoSystem     = this._repMediator.InfoSystemRep.Single(infoSystemNo);
            InfoSystemInfo infoSystemInfo = infoSystem.ToDTO();

            return(infoSystemInfo);
        }
        /// <summary>
        /// 信息系统模型映射
        /// </summary>
        public static InfoSystem ToModel(this InfoSystemInfo infoSystemInfo)
        {
            InfoSystem infoSystem = infoSystemInfo.Map <InfoSystemInfo, InfoSystem>();

            infoSystem.ApplicationTypeName = infoSystemInfo.ApplicationType.GetEnumMember();

            return(infoSystem);
        }
        /// <summary>
        /// 初始化信息系统
        /// </summary>
        /// <param name="infoSystemNo">信息系统编号</param>
        /// <param name="host">主机名称</param>
        /// <param name="port">端口</param>
        /// <param name="index">首页</param>
        public void InitInfoSystem(string infoSystemNo, string host, int port, string index)
        {
            InfoSystem infoSystem = this._unitOfWork.Resolve <InfoSystem>(infoSystemNo);

            infoSystem.Init(host, port, index);

            this._unitOfWork.RegisterSave(infoSystem);
            this._unitOfWork.Commit();
        }
        /// <summary>
        /// 批量初始化信息系统
        /// </summary>
        /// <param name="initParams">初始化信息系统参数模型集</param>
        public void InitInfoSystems(IEnumerable <InfoSystemParam> initParams)
        {
            foreach (InfoSystemParam param in initParams)
            {
                InfoSystem currentSystem = this._unitOfWork.Resolve <InfoSystem>(param.SystemNo);
                currentSystem.Init(param.Host, param.Port, param.Index);

                this._unitOfWork.RegisterSave(currentSystem);
            }

            this._unitOfWork.Commit();
        }
        /// <summary>
        /// 初始化信息系统
        /// </summary>
        /// <param name="systemNo">信息系统编号</param>
        /// <param name="host">主机名称</param>
        /// <param name="port">端口</param>
        /// <param name="index">首页</param>
        public void InitInfoSystem(string systemNo, string host, int port, string index)
        {
            InfoSystem currentSystem = this._unitOfWork.Resolve <InfoSystem>(systemNo);

            currentSystem.Init(host, port, index);

            this._unitOfWork.RegisterSave(currentSystem);
            this._unitOfWork.Commit();

            //清除缓存
            CacheMediator.Remove(typeof(IInfoSystemRepository).FullName);
        }
        //命令部分

        #region # 创建信息系统 —— void CreateInfoSystem(string systemNo, string systemName...

        /// <summary>
        /// 创建信息系统
        /// </summary>
        /// <param name="systemNo">组织编号</param>
        /// <param name="systemName">信息系统名称</param>
        /// <param name="adminLoginId">系统管理员登录名</param>
        /// <param name="applicationType">应用程序类型</param>
        public void CreateInfoSystem(string systemNo, string systemName, string adminLoginId, ApplicationType applicationType)
        {
            //验证
            Assert.IsFalse(this._repMediator.UserRep.Exists(adminLoginId), $"登录名:\"{adminLoginId}\"已存在,请重试!");

            InfoSystem infoSystem = new InfoSystem(systemNo, systemName, adminLoginId, applicationType);

            this._unitOfWork.RegisterAdd(infoSystem);
            this._unitOfWork.UnitedCommit();

            //清除缓存
            CacheMediator.Remove(typeof(IInfoSystemRepository).FullName);
        }
        /// <summary>
        /// 获取角色
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <returns>角色</returns>
        public RoleInfo GetRole(Guid roleId)
        {
            Role role = this._repMediator.RoleRep.Single(roleId);

            InfoSystem infoSystem = this._repMediator.InfoSystemRep.Single(role.InfoSystemNo);
            IDictionary <string, InfoSystemInfo> infoSystemInfos = new Dictionary <string, InfoSystemInfo>
            {
                { infoSystem.Number, infoSystem.ToDTO() }
            };

            RoleInfo roleInfo = role.ToDTO(infoSystemInfos);

            return(roleInfo);
        }
        /// <summary>
        /// 获取菜单
        /// </summary>
        /// <param name="menuId">菜单Id</param>
        /// <returns>菜单</returns>
        public MenuInfo GetMenu(Guid menuId)
        {
            Menu menu = this._repMediator.MenuRep.Single(menuId);

            InfoSystem infoSystem = this._repMediator.InfoSystemRep.Single(menu.InfoSystemNo);
            IDictionary <string, InfoSystemInfo> infoSystemInfos = new Dictionary <string, InfoSystemInfo>
            {
                { infoSystem.Number, infoSystem.ToDTO() }
            };

            MenuInfo menuInfo = menu.ToDTO(infoSystemInfos);

            return(menuInfo);
        }
        /// <summary>
        /// 获取权限
        /// </summary>
        /// <param name="authorityId">权限Id</param>
        /// <returns>权限视图模型</returns>
        public AuthorityInfo GetAuthority(Guid authorityId)
        {
            Authority authority = this._repMediator.AuthorityRep.Single(authorityId);

            InfoSystem infoSystem = this._repMediator.InfoSystemRep.Single(authority.InfoSystemNo);
            IDictionary <string, InfoSystemInfo> infoSystemInfos = new Dictionary <string, InfoSystemInfo>
            {
                { infoSystem.Number, infoSystem.ToDTO() }
            };

            AuthorityInfo authorityInfo = authority.ToDTO(infoSystemInfos);

            return(authorityInfo);
        }
        /// <summary>
        /// 修改信息系统
        /// </summary>
        /// <param name="infoSystemNo">信息系统编号</param>
        /// <param name="infoSystemName">信息系统名称</param>
        public void UpdateInfoSystem(string infoSystemNo, string infoSystemName)
        {
            #region # 验证

            if (this._repMediator.InfoSystemRep.ExistsNo(infoSystemNo))
            {
                throw new ArgumentOutOfRangeException(nameof(infoSystemNo), $"信息系统编号\"{infoSystemNo}\"已存在!");
            }

            #endregion

            InfoSystem infoSystem = this._unitOfWork.Resolve <InfoSystem>(infoSystemNo);
            infoSystem.UpdateInfo(infoSystemName);

            this._unitOfWork.RegisterSave(infoSystem);
            this._unitOfWork.Commit();
        }
        /// <summary>
        /// 信息系统/角色EasyUI树节点映射
        /// </summary>
        public static Node ToNode(this InfoSystem infoSystem, IEnumerable <Role> roles)
        {
            var attributes = new
            {
                type = "infoSystem"
            };

            Node infoSystemNode = new Node(infoSystem.Id, infoSystem.Name, "open", false, attributes);

            foreach (Role role in roles)
            {
                if (role.InfoSystemNo == infoSystem.Number)
                {
                    infoSystemNode.children.Add(role.ToNode());
                }
            }

            return(infoSystemNode);
        }
示例#13
0
        /// <summary>
        /// 初始化用户角色
        /// </summary>
        private void InitUserRoles()
        {
            if (this._systems.Any())
            {
                //获取超级管理员
                User superAdmin = this._users.Single(x => x.Number == CommonConstants.AdminLoginId);

                foreach (Role role in this._roles)
                {
                    //获取信息系统
                    InfoSystem currentSystem = this._systems.Single(x => x.Number == role.SystemNo);

                    //追加系统管理员权限
                    User systemAdmin = this._users.Single(x => x.Number == currentSystem.AdminLoginId);
                    systemAdmin.AppendRoles(new[] { role });

                    //追加超级管理员权限
                    superAdmin.AppendRoles(new[] { role });
                }
            }
        }
        /// <summary>
        /// 信息系统/权限EasyUI树节点映射
        /// </summary>
        public static Node ToNode(this InfoSystem infoSystem, IEnumerable <Authority> authorities)
        {
            var attributes = new
            {
                type = "infoSystem"
            };

            Node infoSystemNode = new Node(infoSystem.Id, infoSystem.Name, "open", false, attributes);
            IEnumerable <IGrouping <string, Authority> > authoritiesGroups = authorities.GroupBy(x => x.ApplicationTypeName);

            foreach (IGrouping <string, Authority> authoritiesGroup in authoritiesGroups)
            {
                Node applicationTypeNode = new Node(Guid.Empty, authoritiesGroup.Key, "open", false, attributes);
                infoSystemNode.children.Add(applicationTypeNode);
                foreach (Authority authority in authoritiesGroup)
                {
                    applicationTypeNode.children.Add(authority.ToNode());
                }
            }

            return(infoSystemNode);
        }
        /// <summary>
        /// 信息系统映射
        /// </summary>
        public static InfoSystemInfo ToDTO(this InfoSystem infoSystem)
        {
            InfoSystemInfo infoSystemInfo = infoSystem.Map <InfoSystem, InfoSystemInfo>();

            return(infoSystemInfo);
        }
        //查询部分

        #region # 获取信息系统 —— InfoSystemInfo GetInfoSystem(string systemNo)
        /// <summary>
        /// 获取信息系统
        /// </summary>
        /// <param name="systemNo">信息系统编号</param>
        /// <returns>信息系统</returns>
        public InfoSystemInfo GetInfoSystem(string systemNo)
        {
            InfoSystem currentSystem = this._repMediator.InfoSystemRep.Single(systemNo);

            return(currentSystem.ToDTO());
        }
 /// <summary>
 /// 信息系统登录信息映射
 /// </summary>
 public static LoginSystemInfo ToLoginSystemInfo(this InfoSystem infoSystem)
 {
     return(new LoginSystemInfo(infoSystem.Number, infoSystem.Name, infoSystem.ApplicationType, infoSystem.Index));
 }
        /// <summary>
        /// 信息系统映射
        /// </summary>
        /// <param name="infoSystem">信息系统领域模型</param>
        /// <returns>信息系统数据传输对象</returns>
        public static InfoSystemInfo ToDTO(this InfoSystem infoSystem)
        {
            InfoSystemInfo systemInfo = Transform <InfoSystem, InfoSystemInfo> .Map(infoSystem);

            return(systemInfo);
        }
        public ViewResult Init(string id)
        {
            InfoSystem currentSystem = this._infoSystemPresenter.GetInfoSystem(id);

            return(base.View(currentSystem));
        }