示例#1
0
        public static List <SysUser> QuerySysUserByParkingId(string parkingId)
        {
            if (string.IsNullOrWhiteSpace(parkingId))
            {
                throw new ArgumentNullException("parkingId");
            }

            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserByParkingId(parkingId));
        }
示例#2
0
        public static SysUser QuerySysUserByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserByRecordId(recordId));
        }
示例#3
0
        public static bool LoginSuccess(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.LoginSuccess(recordId));
        }
示例#4
0
        public static bool LoginErrorByUserId(string userAccount)
        {
            if (string.IsNullOrWhiteSpace(userAccount))
            {
                throw new ArgumentNullException("userAccount");
            }

            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.LoginErrorByUserId(userAccount));
        }
示例#5
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ISysUser factory = SysUserFactory.GetFactory();

            SysUser model = factory.QuerySysUserByRecordId(recordId);

            if (model == null)
            {
                throw new MyException("待删除的用户不存在");
            }

            if (model.IsDefaultUser == YesOrNo.Yes)
            {
                throw new MyException("该用户为系统默认用户不能删除");
            }

            ISysUserRolesMapping roleFactory  = SysUserRolesMappingFactory.GetFactory();
            ISysUserScopeMapping scopeFactory = SysUserScopeMappingFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = factory.Delete(recordId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加用户信息失败");
                    }

                    roleFactory.DeleteByUserId(recordId, dbOperator);
                    scopeFactory.DeleteByUserID(recordId, dbOperator);

                    dbOperator.CommitTransaction();
                    if (result)
                    {
                        OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("RecordId:{0}", recordId));
                    }
                    return(true);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
示例#6
0
        public static SysUser QuerySysUserByUserAccount(string userAccount)
        {
            if (string.IsNullOrWhiteSpace(userAccount))
            {
                throw new ArgumentNullException("userAccount");
            }

            //if (DateTime.Now > DateTime.Parse("2017-09-30"))
            //{
            //    return null;
            //}
            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserByUserAccount(userAccount));
        }
示例#7
0
        public static bool Update(SysUser model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            ISysUser factory = SysUserFactory.GetFactory();
            bool     result  = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <SysUser>(model, OperateType.Update);
            }
            return(result);
        }
示例#8
0
        public static bool ResetPassword(string userAccount, string newPassword)
        {
            if (string.IsNullOrWhiteSpace(userAccount))
            {
                throw new ArgumentNullException("userAccount");
            }
            if (string.IsNullOrWhiteSpace(newPassword))
            {
                throw new ArgumentNullException("newPassword");
            }

            ISysUser factory = SysUserFactory.GetFactory();
            bool     result  = factory.ResetPassword(userAccount, newPassword);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Update, string.Format("userAccount:{0},修改密码为:{1}", userAccount, newPassword));
            }
            return(result);
        }
示例#9
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            ICompany    factory = CompanyFactory.GetFactory();
            BaseCompany model   = factory.QueryCompanyByRecordId(recordId);

            if (model == null)
            {
                throw new MyException("待删除的单位不存在");
            }

            List <BaseCompany> models = factory.QueryCompanysByMasterID(model.CPID);

            if (models.Count > 0)
            {
                throw new MyException("请先删除该公司下的所有下级公司");
            }

            List <BaseVillage> villages = VillageServices.QueryVillageByCompanyId(recordId);

            if (villages.Count != 0)
            {
                throw new MyException("请先删除该单位下的所有的小区");
            }

            ISysUser factoryUser = SysUserFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = factory.Delete(recordId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("移除单位信息失败");
                    }

                    result = factoryUser.DeleteByCompanyId(recordId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("移除用户信息失败");
                    }

                    dbOperator.CommitTransaction();
                    if (result)
                    {
                        OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
                    }
                    return(result);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
示例#10
0
        public static bool Update(SysUser model, List <SysUserRolesMapping> useRoleMappings, List <SysUserScopeMapping> useScopeMappings)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (useRoleMappings == null || useRoleMappings.Count == 0)
            {
                throw new ArgumentNullException("useRoleMappings");
            }
            if (useScopeMappings == null || useScopeMappings.Count == 0)
            {
                throw new ArgumentNullException("useScopeMappings");
            }

            ISysUser             factory      = SysUserFactory.GetFactory();
            ISysUserRolesMapping roleFactory  = SysUserRolesMappingFactory.GetFactory();
            ISysUserScopeMapping scopeFactory = SysUserScopeMappingFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = factory.Update(model, dbOperator);
                    if (!result)
                    {
                        throw new MyException("修改用户信息失败");
                    }

                    roleFactory.DeleteByUserId(model.RecordID, dbOperator);
                    result = roleFactory.Add(useRoleMappings, dbOperator);
                    if (!result)
                    {
                        throw new MyException("修改模块授权信息失败");
                    }

                    scopeFactory.DeleteByUserID(model.RecordID, dbOperator);
                    result = scopeFactory.Add(useScopeMappings, dbOperator);
                    if (!result)
                    {
                        throw new MyException("修改作用域授权信息失败");
                    }

                    dbOperator.CommitTransaction();
                    if (result)
                    {
                        OperateLogServices.AddOperateLog <SysUser>(model, OperateType.Update);
                        OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("UserRolesMapping,UserId:{0}", model.RecordID));
                        OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("UserScopeMapping,UserId:{0}", model.RecordID));

                        foreach (var item in useRoleMappings)
                        {
                            OperateLogServices.AddOperateLog <SysUserRolesMapping>(item, OperateType.Add);
                        }
                        foreach (var item in useScopeMappings)
                        {
                            OperateLogServices.AddOperateLog <SysUserScopeMapping>(item, OperateType.Add);
                        }
                    }
                    return(result);
                }
                catch {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
0
        public static List <SysUser> QuerySysUserPage(string companyId, string userAccount, int pagesize, int pageindex, out int total)
        {
            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserPage(companyId, userAccount, pagesize, pageindex, out total));
        }
示例#14
0
        public static List <SysUser> QuerySysUserByCompanys(List <string> companys)
        {
            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserByCompanys(companys));
        }
示例#15
0
        public static List <SysUser> QuerySysUserAll()
        {
            ISysUser factory = SysUserFactory.GetFactory();

            return(factory.QuerySysUserAll());
        }
示例#16
0
        public static bool Add(SysUser model, List <SysUserRolesMapping> useRoleMappings, List <SysUserScopeMapping> useScopeMappings)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (useRoleMappings == null || useRoleMappings.Count == 0)
            {
                throw new ArgumentNullException("useRoleMappings");
            }
            if (useScopeMappings == null || useScopeMappings.Count == 0)
            {
                throw new ArgumentNullException("useScopeMappings");
            }

            ISysUser             factory      = SysUserFactory.GetFactory();
            ISysUserRolesMapping roleFactory  = SysUserRolesMappingFactory.GetFactory();
            ISysUserScopeMapping scopeFactory = SysUserScopeMappingFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = factory.Add(model, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加用户信息失败");
                    }

                    result = roleFactory.Add(useRoleMappings, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加模块授权信息失败");
                    }

                    result = scopeFactory.Add(useScopeMappings, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加作用域授权信息失败");
                    }

                    dbOperator.CommitTransaction();
                    if (result)
                    {
                        OperateLogServices.AddOperateLog <SysUser>(model, OperateType.Add);
                        foreach (var item in useRoleMappings)
                        {
                            OperateLogServices.AddOperateLog <SysUserRolesMapping>(item, OperateType.Add);
                        }
                        foreach (var item in useScopeMappings)
                        {
                            OperateLogServices.AddOperateLog <SysUserScopeMapping>(item, OperateType.Add);
                        }
                    }
                    return(result);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }