예제 #1
0
        public static bool Update(BaseVillage model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (string.IsNullOrWhiteSpace(model.VNo))
            {
                throw new ArgumentNullException("小区编号不能为空");
            }

            IVillage factory = VillageFactory.GetFactory();

            BaseVillage dbModel = factory.QueryVillageByVillageNo(model.VNo, model.CPID);

            if (dbModel != null && dbModel.VID != model.VID)
            {
                throw new MyException("小区编号已经存在");
            }

            dbModel = factory.QueryVillageByProxyNo(model.ProxyNo);
            if (dbModel != null && dbModel.VID != model.VID)
            {
                throw new MyException("代理编号已存在");
            }

            bool result = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Update);
            }
            return(result);
        }
예제 #2
0
        public void ExecuteGameLoop()
        {
            Day     = 0;
            Village = VillageFactory.CreateVillage(Options);

            do
            {
                Day++;
                Village.Day = Day; //refactor

                ExecuteTurn();

                WriteRoundResult();
            } while(!IsGameOver());

            //Logging
            if (IsEvilVictory())
            {
                Log.EvilVictory();
            }
            else
            {
                Log.GoodVictory();
            }

            WriteGameResult();
        }
예제 #3
0
        public static List <BaseVillage> QueryVillageByCompanyIds(List <string> companyIds)
        {
            if (companyIds == null || companyIds.Count == 0)
            {
                throw new ArgumentNullException("companyIds");
            }

            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByCompanyIds(companyIds));
        }
예제 #4
0
        public static List <BaseVillage> QueryVillageByEmployeeMobilePhone(string mobilePhone)
        {
            if (string.IsNullOrWhiteSpace(mobilePhone))
            {
                throw new ArgumentNullException("mobilePhone");
            }

            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByEmployeeMobilePhone(mobilePhone));
        }
예제 #5
0
        public static BaseVillage QueryVillageByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByRecordId(recordId));
        }
예제 #6
0
        public static List <BaseVillage> QueryVillageByUserId(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByUserId(userId));
        }
예제 #7
0
        public static BaseVillage QueryVillageByProxyNo(string proxyNo)
        {
            if (string.IsNullOrWhiteSpace(proxyNo))
            {
                throw new ArgumentNullException("proxyNo");
            }

            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByProxyNo(proxyNo));
        }
예제 #8
0
        /// <summary>
        /// 创建默认小区
        /// </summary>
        /// <param name="model"></param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static bool AddVillageDefaultUser(BaseVillage model, DbOperator dbOperator)
        {
            model.DataStatus     = DataStatus.Normal;
            model.LastUpdateTime = DateTime.Now;
            model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;
            IVillage factory = VillageFactory.GetFactory();
            bool     result  = factory.Add(model, dbOperator);

            if (result)
            {
                OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Add);
            }
            return(result);
        }
예제 #9
0
        public static List <CarParkingResult> GetParkGrantByPlateNo(string plateNo)
        {
            if (plateNo.IsEmpty())
            {
                throw new ArgumentNullException("plateNo");
            }

            List <CarParkingResult> models = new List <CarParkingResult>();
            IParkGrant       factory       = ParkGrantFactory.GetFactory();
            List <ParkGrant> grants        = factory.GetParkGrantByPlateNo(plateNo);

            if (grants.Count > 0)
            {
                List <ParkCarType>  carTypes = ParkCarTypeServices.QueryParkCarTypeByRecordIds(grants.Select(p => p.CarTypeID).ToList());
                List <BaseParkinfo> parkings = ParkingServices.QueryParkingByRecordIds(grants.Select(p => p.PKID).ToList());
                List <BaseVillage>  villages = new List <BaseVillage>();
                if (parkings.Count > 0)
                {
                    IVillage factoryVillage = VillageFactory.GetFactory();
                    villages = factoryVillage.QueryVillageByRecordIds(parkings.Select(p => p.VID).ToList());
                }
                foreach (var item in grants)
                {
                    CarParkingResult model = new CarParkingResult();
                    model.PlateNo = plateNo;
                    BaseParkinfo parking = parkings.FirstOrDefault(p => p.PKID == item.PKID);

                    if (parking != null)
                    {
                        model.ParkingName = parkings != null ? parking.PKName : string.Empty;
                        BaseVillage village = villages.FirstOrDefault(p => p.VID == parking.VID);
                        model.VillageName = village != null ? village.VName : string.Empty;
                    }
                    ParkCarType carType = carTypes.FirstOrDefault(p => p.CarTypeID == item.CarTypeID);
                    if (carType != null)
                    {
                        model.CarTypeName = carType.CarTypeName;
                    }
                    model.StartTime = item.BeginDate;
                    model.EndTime   = item.EndDate;
                    models.Add(model);
                }
            }
            return(models);
        }
예제 #10
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);
        }
예제 #11
0
        public static List <BaseVillage> QueryVillageByCompanyId(string companyId)
        {
            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageByCompanyId(companyId));
        }
예제 #12
0
        public static List <BaseVillage> QueryPage(List <string> villageIds, string companyId, int pageIndex, int pageSize, out int totalRecord)
        {
            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryPage(villageIds, companyId, pageIndex, pageSize, out totalRecord));
        }
예제 #13
0
        public static List <BaseVillage> QueryVillageAll()
        {
            IVillage factory = VillageFactory.GetFactory();

            return(factory.QueryVillageAll());
        }