Пример #1
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);
        }