Beispiel #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);
        }
Beispiel #2
0
        public ChargingPileInfo GetChargingPileById(long id)
        {
            ChargingPileInfo chpile  = new ChargingPileInfo();
            DataCommand      command = new DataCommand(ConnectionString, GetDbCommand(ChargeStatement.GetChargingPileByKey, "Text"));

            command.AddInputParameter("@ID", DbType.Int64, id);
            chpile = command.ExecuteEntity <ChargingPileInfo>();
            return(chpile);
        }
Beispiel #3
0
        public int ModifyChargingPile(ChargingPileInfo piple)
        {
            DataCommand command = new DataCommand(ConnectionString, GetDbCommand(ChargeStatement.ModifyChargingPile, "Text"));

            command.AddInputParameter("@ID", DbType.Int64, piple.ID);
            command.AddInputParameter("@Code", DbType.String, piple.Code);
            command.AddInputParameter("@Standard", DbType.String, piple.Standard);
            command.AddInputParameter("@SOC", DbType.String, piple.SOC);
            command.AddInputParameter("@Power", DbType.String, piple.Power);
            command.AddInputParameter("@Electric", DbType.String, piple.Electric);
            command.AddInputParameter("@CElectric", DbType.String, piple.CElectric);
            command.AddInputParameter("@Voltage", DbType.String, piple.Voltage);
            command.AddInputParameter("@CVoltage", DbType.String, piple.CVoltage);
            command.AddInputParameter("@ChargingBaseID", DbType.Int32, piple.ChargingBaseID);
            command.AddInputParameter("@IsUse", DbType.Int32, piple.IsUse);

            return(command.ExecuteNonQuery());
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }