Example #1
0
 /// <summary>
 /// 判断登录名是否被占用
 /// </summary>
 /// <param name="LoginName"></param>
 /// <returns></returns>
 public bool IsExists(string LoginName)
 {
     using (var factory = new BaseAccess(base._DBConfigPath))
     {
         return(factory.IsExists <UserEntity>(Specification <UserEntity> .Create(c => c.UserLoginName == LoginName)));
     }
 }
Example #2
0
        /// <summary>
        /// 设置用户角色
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="RoleID"></param>
        /// <param name="IsHas">ture设置 false移除</param>
        public void SetUserRole(string UserID, string RoleID)
        {
            using (var factory = new BaseAccess())
            {
                //如果传入的roleid为空的话移除改用户对对应的所有角色
                if (string.IsNullOrWhiteSpace(RoleID))
                {
                    var entity = factory.GetAll <UserRoleEntity>(Specification <UserRoleEntity> .Create(c => c.UserID == UserID));
                    factory.Delete <UserRoleEntity>(entity);
                }
                else
                {
                    var entity = factory.GetAll <UserRoleEntity>(Specification <UserRoleEntity> .Create(c => c.UserID == UserID));
                    factory.Delete <UserRoleEntity>(entity);
                    var Rids = RoleID.Split(',');
                    foreach (var item in Rids)
                    {
                        var spec = Specification <UserRoleEntity> .Create(c => c.UserID == UserID && c.RoleID == item);

                        bool bl = factory.IsExists <UserRoleEntity>(spec);
                        if (!bl)
                        {
                            var userRole = new UserRoleEntity()
                            {
                                RoleID = item, UserID = UserID
                            };
                            factory.Insert <UserRoleEntity>(userRole);
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// 根据当前登陆用户获取用户配置信息
        /// 如果没有配置信息则 创建一天空的配置信息
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public Configuration_S GetConfigurationByUserId(string UserId)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <SYS_ConfigurationEntity> .Create(c => c.USERID == UserId);

                try
                {
                    if (factory.IsExists <SYS_ConfigurationEntity>(spec))
                    {
                        var entity = factory.GetSingle <SYS_ConfigurationEntity>(spec);
                        return(entity.Adapter <Configuration_S>(new Configuration_S()));
                    }
                    else
                    {
                        var entity = new SYS_ConfigurationEntity();
                        entity.ID     = Guid.NewGuid().ToString();
                        entity.USERID = UserId;
                        factory.Insert <SYS_ConfigurationEntity>(entity, false);
                        factory.Commit();
                        return(null);
                    }
                }
                catch (Exception ex)
                {
                    factory.Rollback();
                    return(null);
                }
            }
        }
Example #4
0
        /// <summary>
        /// 判断字典编号是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="DictType"></param>
        /// <param name="DictCode"></param>
        /// <returns></returns>
        public bool IsExists(string ID, string DictType, string DictCode)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <Sys_DictionaryEntity> .Create(c => c.DictType == DictType && c.DictCode == DictCode);

                if (!string.IsNullOrEmpty(ID))
                {
                    spec &= Specification <Sys_DictionaryEntity> .Create(c => c.ID != ID);
                }
                return(factory.IsExists <Sys_DictionaryEntity>(spec));
            }
        }
Example #5
0
        /// <summary>
        /// 判断分组编号是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="OrganNO"></param>
        /// <returns></returns>
        public bool IsExists(string ID, string OrganNO)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <OrganizationEntity> .Create(c => c.OrganNO == OrganNO);

                if (!string.IsNullOrEmpty(ID))
                {
                    spec &= Specification <OrganizationEntity> .Create(c => c.ID != ID);
                }
                return(factory.IsExists <OrganizationEntity>(spec));
            }
        }
Example #6
0
        /// <summary>
        /// 判断数据权限编号是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="MenuCode"></param>
        /// <returns></returns>
        public bool IsDataExists(string ID, string MenuCode)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <MenuEntity> .Create(c => c.MenuType == (int)MenuType.Data && c.MenuCode == MenuCode);

                if (!string.IsNullOrEmpty(ID))
                {
                    spec &= Specification <MenuEntity> .Create(c => c.ID != ID);
                }
                return(factory.IsExists <MenuEntity>(spec));
            }
        }
Example #7
0
        /// <summary>
        /// 系统是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        public bool _IsExists(string ID, string AppRegisterID)
        {
            using (var factory = new BaseAccess(base._DBConfigPath))
            {
                var spec = Specification <SYS_AppRegisterEntity> .Create(c => c.AppRegisterID == AppRegisterID);

                if (!string.IsNullOrEmpty(ID))
                {
                    spec &= Specification <SYS_AppRegisterEntity> .Create(c => c.ID != ID);
                }
                return(factory.IsExists <SYS_AppRegisterEntity>(spec));
            }
        }
Example #8
0
        /// <summary>
        /// 角色是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        public bool _IsExists(string ID, string RoleName)
        {
            using (var factory = new BaseAccess())
            {
                var spec = Specification <RoleEntity> .Create(c => c.RoleName == RoleName);

                if (!string.IsNullOrEmpty(ID))
                {
                    spec &= Specification <RoleEntity> .Create(c => c.ID != ID);
                }
                return(factory.IsExists <RoleEntity>(spec));
            }
        }