Example #1
0
        public static bool ModifyChargingPile(ChargingPileEntity entity)
        {
            int result = 0;

            if (entity != null)
            {
                ChargeRepository mr = new ChargeRepository();

                ChargingPileInfo info = TranslateChargingPileEntity(entity);


                if (entity.ID > 0)
                {
                    result = mr.ModifyChargingPile(info);
                }
                else
                {
                    info.CreateDate = DateTime.Now;
                    result          = mr.CreateNewChargingPile(info);
                    if (result > 0)
                    {
                        ChargingBaseInfo cb = mr.GetChargingBaseById(info.ChargingBaseID);
                        if (cb != null)
                        {
                            int num = cb.ChargeNum + 1;
                            mr.ModifyPileNum(num, info.ChargingBaseID);
                        }
                    }
                }

                List <ChargingPileInfo> miList = mr.GetAllChargingPileInfo();//刷新缓存
                Cache.Add("ChargingPileALL", miList);
            }
            return(result > 0);
        }
Example #2
0
        public static ChargingPileEntity GetChargingPileEntityById(long id)
        {
            ChargingPileEntity entity = new ChargingPileEntity();
            ChargingPileInfo   info   = new ChargeRepository().GetChargingPileById(id);

            if (info != null)
            {
                entity = TranslateChargingPileInfo(info);
            }

            return(entity);
        }
Example #3
0
        private static OrderEntity TranslateOrderEntity(OrderInfo info)
        {
            OrderEntity orderEntity = new OrderEntity();

            if (info != null)
            {
                orderEntity.OrderInnerID  = info.OrderInnerID;
                orderEntity.OrderID       = info.OrderID;
                orderEntity.PreID         = info.PreID;
                orderEntity.CustomerID    = info.CustomerID;
                orderEntity.CustomerName  = info.CustomerName;
                orderEntity.Mobile        = info.Mobile;
                orderEntity.EID           = info.EID;
                orderEntity.UseType       = info.UseType;
                orderEntity.PayType       = info.PayType;
                orderEntity.SupplierID    = info.SupplierID;
                orderEntity.SupplierCode  = info.SupplierCode;
                orderEntity.LeaseTime     = info.LeaseTime;
                orderEntity.Price         = info.Price;
                orderEntity.Amount        = info.Amount;
                orderEntity.Remark        = info.Remark;
                orderEntity.AttachmentIDs = info.AttachmentIDs;
                orderEntity.Status        = info.Status;
                orderEntity.ModifyDate    = info.ModifyDate;
                orderEntity.Operator      = info.Operator;

                CustomerEntity customer = CustomerService.GetCustomerByID(info.CustomerID);
                orderEntity.Customer = customer;

                if ((info.UseType ?? "").ToLower() == "car")//汽车预约
                {
                    CarEntity car = CarService.GetCarEntityById(info.EID);
                    orderEntity.Car = car;
                }
                else if ((info.UseType ?? "").ToLower() == "chargepile")//充电桩预约
                {
                    ChargingPileEntity chargingPile = ChargeService.GetChargingPileEntityById(info.EID);
                    orderEntity.ChargePile = chargingPile;
                }

                BaseDataEntity pay = BaseDataService.GetBaseDataByPCode("P00").FirstOrDefault(t => t.TypeCode == info.PayType) ?? new BaseDataEntity();
                orderEntity.PayTypeInfo = pay;//支付信息

                StoreEntity store = StoreService.GetStoreById(info.SupplierID);
                orderEntity.Store = store;

                BaseDataEntity use = BaseDataService.GetBaseDataByPCode("U00").FirstOrDefault(t => t.TypeCode == info.UseType) ?? new BaseDataEntity();
                orderEntity.UseTypeDesc = use;//使用方式信息
            }

            return(orderEntity);
        }
Example #4
0
        public static ChargingBaseEntity TransChargeBase(ChargingBaseInfo info, bool isShowPile = false)
        {
            ChargingBaseEntity entity = new ChargingBaseEntity();

            entity.ChargeBaseID = info.ChargeBaseID;
            entity.Name         = info.Name;
            entity.Code         = info.Code;
            entity.ChargeFee    = info.ChargeFee;
            entity.ParkFee      = info.ParkFee;
            entity.ChargeNum    = info.ChargeNum;
            entity.PayType      = info.PayType;
            entity.StartTime    = info.StartTime;
            entity.EndTime      = info.EndTime;
            entity.IsUse        = info.IsUse;
            Random rd = new Random();
            int    R  = rd.Next(1, 8);

            entity.imageUrl = FileUrl + "/Images/Charging/" + R + ".jpg";;
            if (isShowPile)
            {
                entity.chargingPile = new List <ChargingPileEntity>();
                List <ChargingPileInfo> lstCharging = Cache.Get <List <ChargingPileInfo> >("GetChargingPileInfo" + info.ChargeBaseID);
                if (lstCharging.IsEmpty())
                {
                    lstCharging = ChargeRepository.GetChargingPileInfo(info.ChargeBaseID.ToString());;
                    Cache.Add("GetChargingPileInfo" + info.ChargeBaseID, lstCharging);
                }

                if (lstCharging != null && lstCharging.Count > 0)
                {
                    foreach (ChargingPileInfo info1 in lstCharging)
                    {
                        ChargingPileEntity entityP = new ChargingPileEntity();
                        entityP.ID             = info1.ID;
                        entityP.Code           = info1.Code;
                        entityP.ChargingBaseID = info1.ChargingBaseID;
                        entityP.Standard       = info1.Standard;
                        entityP.SOC            = info1.SOC;
                        entityP.Power          = info1.Power + "KW";
                        entityP.Electric       = info1.Electric;
                        entityP.CElectric      = info1.CElectric;
                        entityP.Voltage        = info1.Voltage + "V";
                        entityP.CVoltage       = info1.CVoltage + "V";
                        R = rd.Next(1, 6);
                        entityP.imageUrl = FileUrl + "/Images/Charging/p" + R + ".jpg";;
                        entity.chargingPile.Add(entityP);
                    }
                }
            }
            return(entity);
        }
Example #5
0
        public static List <ChargingPileEntity> GetChargingPileListByBaseID(int baseID)
        {
            List <ChargingPileEntity> all    = new List <ChargingPileEntity>();
            ChargeRepository          mr     = new ChargeRepository();
            List <ChargingPileInfo>   miList = mr.GetChargingPileListByBaseID(baseID);

            if (!miList.IsEmpty())
            {
                foreach (ChargingPileInfo mInfo in miList)
                {
                    ChargingPileEntity chargingPileEntity = TranslateChargingPileInfo(mInfo);
                    all.Add(chargingPileEntity);
                }
            }

            return(all);
        }
Example #6
0
        private static ChargingPileInfo TranslateChargingPileEntity(ChargingPileEntity chargingPileEntity)
        {
            ChargingPileInfo chargingPileInfo = new ChargingPileInfo();

            if (chargingPileEntity != null)
            {
                chargingPileInfo.ID             = chargingPileEntity.ID;
                chargingPileInfo.Code           = chargingPileEntity.Code;
                chargingPileInfo.Standard       = chargingPileEntity.Standard;
                chargingPileInfo.SOC            = chargingPileEntity.SOC;
                chargingPileInfo.Power          = chargingPileEntity.Power;
                chargingPileInfo.Electric       = chargingPileEntity.Electric;
                chargingPileInfo.CElectric      = chargingPileEntity.CElectric;
                chargingPileInfo.Voltage        = chargingPileEntity.Voltage;
                chargingPileInfo.CVoltage       = chargingPileEntity.CVoltage;
                chargingPileInfo.ChargingBaseID = chargingPileEntity.ChargingBaseID;
                chargingPileInfo.IsUse          = chargingPileEntity.IsUse;
            }
            return(chargingPileInfo);
        }
Example #7
0
        public static List <ChargingPileEntity> GetAllChargingPileEntity()
        {
            List <ChargingPileEntity> all    = new List <ChargingPileEntity>();
            ChargeRepository          mr     = new ChargeRepository();
            List <ChargingPileInfo>   miList = Cache.Get <List <ChargingPileInfo> >("ChargingPileALL");

            if (miList.IsEmpty())
            {
                miList = mr.GetAllChargingPileInfo();
                Cache.Add("ChargingPileALL", miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (ChargingPileInfo mInfo in miList)
                {
                    ChargingPileEntity chargingPileEntity = TranslateChargingPileInfo(mInfo);
                    all.Add(chargingPileEntity);
                }
            }

            return(all);
        }
Example #8
0
        private static ReservationsEntity TranslateReservationsEntity(ReservationsInfo info)
        {
            ReservationsEntity reservationsEntity = new ReservationsEntity();

            if (info != null)
            {
                reservationsEntity.ID           = info.ID;
                reservationsEntity.CustomerID   = info.CustomerID;
                reservationsEntity.CustomerName = info.CustomerName;
                reservationsEntity.RType        = info.RType;
                reservationsEntity.PayType      = info.PayType;
                reservationsEntity.CarID        = info.CarID;
                reservationsEntity.LeaseTime    = info.LeaseTime;
                reservationsEntity.Price        = info.Price;
                reservationsEntity.Remark       = info.Remark;
                reservationsEntity.RDate        = info.RDate;
                reservationsEntity.Status       = info.Status;

                CustomerEntity customer = null;//CustomerService.GetCustomerByID(info.CustomerID);
                reservationsEntity.Customer = customer;

                if (info.RType == "SJ" || info.RType == "ZL")//汽车预约
                {
                    CarEntity car = CarService.GetCarEntityById(info.CarID);
                    reservationsEntity.Car = car;
                }
                else if (info.RType == "DZ")//充电桩预约
                {
                    ChargingPileEntity chargingPile = ChargeService.GetChargingPileEntityById(info.CarID);
                    reservationsEntity.ChargingPile = chargingPile;
                }

                BaseDataEntity pay = BaseDataService.GetBaseDataByPCode("P00").FirstOrDefault(t => t.TypeCode == info.PayType) ?? new BaseDataEntity();
                reservationsEntity.PayTypeInfo = pay;//支付信息
            }

            return(reservationsEntity);
        }
Example #9
0
        private static ChargingPileEntity TranslateChargingPileInfo(ChargingPileInfo chargingPileInfo)
        {
            ChargingPileEntity chargingPileEntity = new ChargingPileEntity();

            if (chargingPileInfo != null)
            {
                chargingPileEntity.ID             = chargingPileInfo.ID;
                chargingPileEntity.Code           = chargingPileInfo.Code;
                chargingPileEntity.Standard       = chargingPileInfo.Standard;
                chargingPileEntity.SOC            = chargingPileInfo.SOC;
                chargingPileEntity.Power          = chargingPileInfo.Power;
                chargingPileEntity.Electric       = chargingPileInfo.Electric;
                chargingPileEntity.CElectric      = chargingPileInfo.CElectric;
                chargingPileEntity.Voltage        = chargingPileInfo.Voltage;
                chargingPileEntity.CVoltage       = chargingPileInfo.CVoltage;
                chargingPileEntity.ChargingBaseID = chargingPileInfo.ChargingBaseID;
                chargingPileEntity.IsUse          = chargingPileInfo.IsUse;

                ChargingBaseEntity chargeBase = GetAllChargingBaseEntity().FirstOrDefault(t => t.IsUse == 1 && t.ChargeBaseID == chargingPileEntity.ChargingBaseID) ?? new ChargingBaseEntity();
                chargingPileEntity.ChargingBase = chargeBase;
            }
            return(chargingPileEntity);
        }
Example #10
0
 public void ModifyChargePile(ChargingPileEntity entity)
 {
     ChargeService.ModifyChargingPile(entity);
     Response.Redirect("/Charge/ChargePile");
 }