Exemplo n.º 1
0
 public static ISysRoles GetFactory()
 {
     if (factory == null)
     {
         Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.SysRolesDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true);
         factory = (ISysRoles)Activator.CreateInstance(type);
     }
     return factory;
 }
Exemplo n.º 2
0
        public static List <SysRoles> QuerySysRolesByCompanyId(string companyId)
        {
            if (string.IsNullOrWhiteSpace(companyId))
            {
                throw new ArgumentNullException("companyId");
            }

            ISysRoles factory = SysRolesFactory.GetFactory();

            return(factory.QuerySysRolesByCompanyId(companyId));
        }
Exemplo n.º 3
0
        public static SysRoles QuerySysRolesByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysRoles factory = SysRolesFactory.GetFactory();

            return(factory.QuerySysRolesByRecordId(recordId));
        }
Exemplo n.º 4
0
        public static bool AddSysRole(SysRoles model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.RecordID = GuidGenerator.GetGuid().ToString();
            ISysRoles factory = SysRolesFactory.GetFactory();
            bool      result  = factory.AddSysRole(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <SysRoles>(model, OperateType.Add);
            }
            return(result);
        }
Exemplo n.º 5
0
        public static bool UpdateRole(SysRoles model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            ISysRoles factory = SysRolesFactory.GetFactory();
            bool      result  = factory.UpdateRole(model);

            if (result)
            {
                model = factory.QuerySysRolesByRecordId(model.RecordID);
                if (model != null)
                {
                    OperateLogServices.AddOperateLog <SysRoles>(model, OperateType.Update);
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public static bool DeleteRoleByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysRoles factory = SysRolesFactory.GetFactory();
            SysRoles  model   = factory.QuerySysRolesByRecordId(recordId);

            if (model != null && model.IsDefaultRole == YesOrNo.Yes)
            {
                throw new MyException("系统默认角色不能删除");
            }

            bool result = factory.DeleteRoleByRecordId(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("RecordId:{0}", recordId));
            }
            return(result);
        }
Exemplo n.º 7
0
        internal static bool AddCompanyDefaultUserCS(BaseCompany company, BaseVillage village, DbOperator dbOperator, string systemmodelpath)
        {
            ISysUser factory = SysUserFactory.GetFactory();

            if (factory.QuerySysUserByUserAccount(company.UserAccount) != null)
            {
                throw new MyException("用户名已存在");
            }

            SysUser user   = GetDefaultUserModel(company.CPID, company.UserAccount, company.UserPassword);
            bool    result = factory.Add(user, dbOperator);

            if (!result)
            {
                throw new MyException("添加用户失败");
            }

            //添加默认角色
            SysRoles  role        = GetDefaultSysRolesModel(company.CPID);
            ISysRoles roleFactory = SysRolesFactory.GetFactory();

            result = roleFactory.AddSysRole(role, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位默认角色失败");
            }

            //添加收费员角色
            SysRoles  role2        = GetDefaultBaRolesModel(company.CPID);
            ISysRoles roleFactory2 = SysRolesFactory.GetFactory();

            result = roleFactory2.AddSysRole(role2, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位收费角色失败");
            }

            //添加默认角色模块授权失败
            List <SysRoleAuthorize> roleAuthorizes2        = GetCompanyDefaultSFYRoleAuthorizeCS(role2.RecordID, systemmodelpath);
            ISysRoleAuthorize       roleAuthorizesFactory2 = SysRoleAuthorizeFactory.GetFactory();

            result = roleAuthorizesFactory2.Add(roleAuthorizes2, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位收费角色失败");
            }

            //添加默认角色模块授权失败
            List <SysRoleAuthorize> roleAuthorizes        = GetCompanyDefaultSysRoleAuthorizeCS(role.RecordID, systemmodelpath);
            ISysRoleAuthorize       roleAuthorizesFactory = SysRoleAuthorizeFactory.GetFactory();

            result = roleAuthorizesFactory.Add(roleAuthorizes, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位默认角色失败");
            }

            //添加作用域
            SysScope scope = GetSystemDefaultSysScope(company.CPID);

            ISysScope scopeFactory = SysScopeFactory.GetFactory();

            result = scopeFactory.Add(scope, dbOperator);
            if (!result)
            {
                throw new MyException("添加系统默认作用域失败");
            }

            SysScopeAuthorize model = new SysScopeAuthorize();

            model.ASID           = scope.ASID;
            model.ASType         = ASType.Village;
            model.CPID           = company.CPID;
            model.DataStatus     = 0;
            model.HaveUpdate     = 3;
            model.LastUpdateTime = DateTime.Now;
            model.TagID          = village.VID;
            model.ASDID          = GuidGenerator.GetGuidString();
            List <SysScopeAuthorize> list = new List <SysScopeAuthorize>();

            list.Add(model);

            ISysScopeAuthorize scopeauthorize = SysScopeAuthorizeFactory.GetFactory();

            result = scopeauthorize.Add(list, dbOperator);
            if (!result)
            {
                throw new MyException("添加默认用户 用户作用域失败");
            }

            ISysUserRolesMapping       roleMappingFactory = SysUserRolesMappingFactory.GetFactory();
            List <SysUserRolesMapping> roleMapping        = GetSysUserRolesMapping(user.RecordID, role.RecordID);

            result = roleMappingFactory.Add(roleMapping, dbOperator);
            if (!result)
            {
                throw new MyException("添加默认用户 用户授权角色失败");
            }

            ISysUserScopeMapping       userMappingFactory = SysUserScopeMappingFactory.GetFactory();
            List <SysUserScopeMapping> scopeMapping       = GetSysUserScopeMapping(user.RecordID, scope.ASID);

            result = userMappingFactory.Add(scopeMapping, dbOperator);
            if (!result)
            {
                throw new MyException("添加默认用户 用户授权作用域失败");
            }
            return(result);
        }
Exemplo n.º 8
0
        internal static bool AddCompanyDefaultUser(BaseCompany company, DbOperator dbOperator)
        {
            ISysUser factory = SysUserFactory.GetFactory();

            if (factory.QuerySysUserByUserAccount(company.UserAccount) != null)
            {
                throw new MyException("用户名已存在");
            }

            SysUser user   = GetDefaultUserModel(company.CPID, company.UserAccount, company.UserPassword);
            bool    result = factory.Add(user, dbOperator);

            if (!result)
            {
                throw new MyException("添加用户失败");
            }

            //添加默认角色
            SysRoles  role        = GetDefaultSysRolesModel(company.CPID);
            ISysRoles roleFactory = SysRolesFactory.GetFactory();

            result = roleFactory.AddSysRole(role, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位默认角色失败");
            }


            //添加默认角色模块授权失败
            List <SysRoleAuthorize> roleAuthorizes        = GetCompanyDefaultSysRoleAuthorize(role.RecordID);
            ISysRoleAuthorize       roleAuthorizesFactory = SysRoleAuthorizeFactory.GetFactory();

            result = roleAuthorizesFactory.Add(roleAuthorizes, dbOperator);
            if (!result)
            {
                throw new MyException("添加单位默认角色失败");
            }

            //添加作用域
            SysScope  scope        = GetSystemDefaultSysScope(company.CPID);
            ISysScope scopeFactory = SysScopeFactory.GetFactory();

            result = scopeFactory.Add(scope, dbOperator);
            if (!result)
            {
                throw new MyException("添加系统默认作用域失败");
            }


            ISysUserRolesMapping       roleMappingFactory = SysUserRolesMappingFactory.GetFactory();
            List <SysUserRolesMapping> roleMapping        = GetSysUserRolesMapping(user.RecordID, role.RecordID);

            result = roleMappingFactory.Add(roleMapping, dbOperator);
            if (!result)
            {
                throw new MyException("添加默认用户 用户授权角色失败");
            }


            ISysUserScopeMapping       userMappingFactory = SysUserScopeMappingFactory.GetFactory();
            List <SysUserScopeMapping> scopeMapping       = GetSysUserScopeMapping(user.RecordID, scope.ASID);

            result = userMappingFactory.Add(scopeMapping, dbOperator);
            if (!result)
            {
                throw new MyException("添加默认用户 用户授权作用域失败");
            }
            return(result);
        }