コード例 #1
0
 public static ISysScope GetFactory()
 {
     if (factory == null)
     {
         Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.SysScopeDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true);
         factory = (ISysScope)Activator.CreateInstance(type);
     }
     return(factory);
 }
コード例 #2
0
        public static SysScope QuerySysScopeByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysScope factory = SysScopeFactory.GetFactory();

            return(factory.QuerySysScopeByRecordId(recordId));
        }
コード例 #3
0
        public static List <SysScope> QuerySysScopeByUserId(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            ISysScope factory = SysScopeFactory.GetFactory();

            return(factory.QuerySysScopeByUserId(userId));
        }
コード例 #4
0
        public static bool Update(SysScope model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            ISysScope factory = SysScopeFactory.GetFactory();
            bool      result  = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <SysScope>(model, OperateType.Update);
            }
            return(result);
        }
コード例 #5
0
        public static bool Add(SysScope model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.ASID = GuidGenerator.GetGuid().ToString();
            ISysScope factory = SysScopeFactory.GetFactory();
            bool      result  = factory.Add(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <SysScope>(model, OperateType.Add);
            }
            return(result);
        }
コード例 #6
0
        public static bool DeleteByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysScope factory = SysScopeFactory.GetFactory();
            SysScope  scope   = factory.QuerySysScopeByRecordId(recordId);

            if (scope != null && scope.IsDefaultScope == YesOrNo.Yes)
            {
                throw new MyException("默认作用域不能删除");
            }

            bool result = factory.DeleteByRecordId(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("RecordId:{0}", recordId));
            }
            return(result);
        }
コード例 #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);
        }
コード例 #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);
        }