Example #1
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <ParkGate> gates = ParkGateServices.QueryByParkBoxRecordId(recordId);

            if (gates.Count != 0)
            {
                throw new MyException("请先删除该岗亭下面的所有通道");
            }

            IParkBox factory = ParkBoxFactory.GetFactory();
            bool     result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Example #2
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <ParkBox> boxs = ParkBoxServices.QueryByParkAreaId(recordId);

            if (boxs.Count != 0)
            {
                throw new MyException("请先删除改区域下所有岗亭");
            }

            IParkArea factory = ParkAreaFactory.GetFactory();
            bool      result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Example #3
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <BaseParkinfo> parks = ParkingServices.QueryParkingByVillageId(recordId);

            if (parks.Count != 0)
            {
                throw new MyException("请先删除小区下面所有的车场");
            }

            IVillage factory = VillageFactory.GetFactory();
            bool     result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Example #4
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <ParkArea> areas = ParkAreaServices.GetParkAreaByParkingId(recordId);

            if (areas.Count != 0)
            {
                throw new MyException("请先删除改车场下的所有区域");
            }

            IParking factory = ParkingFactory.GetFactory();
            bool     result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Example #5
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <ParkDevice> devices = ParkDeviceServices.QueryParkDeviceByGateRecordId(recordId);

            if (devices.Count != 0)
            {
                throw new MyException("请先删除该通道下所有设备信息");
            }

            IParkGate factory = ParkGateFactory.GetFactory();
            bool      result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Example #6
0
        public static bool Update(BaseCompany model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            ICompany    factory = CompanyFactory.GetFactory();
            BaseCompany dbModel = factory.QueryCompanyByCompanyName(model.CPName);

            if (dbModel != null && dbModel.CPID != model.CPID)
            {
                throw new MyException("系统已存在相同单位名称的单位");
            }

            bool result = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <BaseCompany>(model, OperateType.Update);
            }
            return(result);
        }
Example #7
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);
        }
Example #8
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);
        }
Example #9
0
        /// <summary>
        /// 创建默认车场
        /// </summary>
        /// <param name="model"></param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static bool AddParkinfoDefault(BaseParkinfo model, DbOperator dbOperator)
        {
            IParking factory = ParkingFactory.GetFactory();

            try
            {
                dbOperator.BeginTransaction();
                bool result = factory.Add(model, dbOperator);
                if (!result)
                {
                    throw new MyException("添加车场信息失败");
                }

                result = ParkCarModelServices.AddDefault(model.PKID, dbOperator);
                if (!result)
                {
                    throw new MyException("添加车型失败");
                }

                result = ParkCarTypeServices.AddDefault(model.PKID, dbOperator);
                if (!result)
                {
                    throw new MyException("添加车类型失败");
                }
                dbOperator.CommitTransaction();
                if (result)
                {
                    OperateLogServices.AddOperateLog <BaseParkinfo>(model, OperateType.Add);
                }
                return(true);
            }
            catch
            {
                dbOperator.RollbackTransaction();
                throw;
            }
        }
Example #10
0
        public static bool Add(ParkCarModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.CarModelName = model.CarModelName.Trim();
            model.CarModelID   = GuidGenerator.GetGuidString();
            IParkCarModel       factory   = ParkCarModelFactory.GetFactory();
            List <ParkCarModel> carModels = factory.QueryByParkingId(model.PKID);

            if (carModels.Count(p => p.CarModelName == model.CarModelName) != 0)
            {
                throw new MyException("车型名称已存在,请更改名称");
            }
            bool result = factory.Add(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkCarModel>(model, OperateType.Add);
            }
            return(result);
        }
Example #11
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;
                }
            }
        }
Example #12
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;
                }
            }
        }
Example #13
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;
                }
            }
        }