コード例 #1
0
        private StrcutureSystem SetHeatPump(LayoutColumn valueSplitted, StrcutureSystem structure)
        {
            var heatPumpFund = structure.HeatPumpList.Find(c => c.ModelName == valueSplitted.ModelName);

            if (heatPumpFund == null)
            {
                var item = new HeatPump()
                {
                    InstallationArea = valueSplitted.Area,
                    ModelName        = valueSplitted.ModelName
                };
                if (!string.IsNullOrEmpty(valueSplitted.Value))
                {
                    if (item.HeatPumpValue == null)
                    {
                        item.HeatPumpValue = new List <HeatPumpValue>();
                    }
                    if (item.HeatPumpValue.Count == 0)
                    {
                        HeatPumpValue heatPumpValue = new HeatPumpValue();
                        heatPumpValue.LabelValues = new List <string>()
                        {
                            valueSplitted.Value
                        };
                        item.HeatPumpValue.Add(heatPumpValue);
                    }
                }
                structure.HeatPumpList.Add(item);
            }
            else
            {
                if (!string.IsNullOrEmpty(valueSplitted.Value))
                {
                    var valueBag = heatPumpFund.HeatPumpValue.LastOrDefault();
                    if (valueBag != null && !valueBag.LabelValues.Contains(valueSplitted.Value))
                    {
                        valueBag.LabelValues.Add(valueSplitted.Value);
                    }
                }
            }
            return(structure);
        }
コード例 #2
0
        private StrcutureSystem SetDateInAllStructure(StrcutureSystem structure, string value)
        {
            if (structure.CogeneratorList.Count > 0)
            {
                foreach (var cogenerator in structure.CogeneratorList)
                {
                    if (cogenerator.CogeneratorValue.Count > 0)
                    {
                        if (cogenerator.CogeneratorValue.FirstOrDefault().DetectionDate == DateTime.MinValue)
                        {
                            cogenerator.CogeneratorValue.FirstOrDefault().DetectionDate = DateTime.Parse(value);
                        }
                        else
                        {
                            var backup = cogenerator.CogeneratorValue.FirstOrDefault();
                            CogeneratoreValue newBag = new CogeneratoreValue();
                            newBag.LabelValues   = new List <string>();
                            newBag.LabelValues   = backup.LabelValues;
                            newBag.DetectionDate = DateTime.Parse(value);
                            cogenerator.CogeneratorValue.Add(newBag);
                        }
                    }
                }
            }

            if (structure.SensorList.Count > 0)
            {
                foreach (var sensor in structure.SensorList)
                {
                    if (sensor.PumpSensorList != null && sensor.PumpSensorList.Count > 0)
                    {
                        if (sensor.PumpSensorList.FirstOrDefault().DetectionDate == DateTime.MinValue)
                        {
                            sensor.PumpSensorList.FirstOrDefault().DetectionDate = DateTime.Parse(value);
                        }
                        else
                        {
                            var        backup = sensor.PumpSensorList.FirstOrDefault();
                            PumpSensor newBag = new PumpSensor();
                            newBag.LabelValues   = new List <string>();
                            newBag.LabelValues   = backup.LabelValues;
                            newBag.DetectionDate = DateTime.Parse(value);
                            sensor.PumpSensorList.Add(newBag);
                        }
                    }
                    if (sensor.EnergyMeterList != null && sensor.EnergyMeterList.Count > 0)
                    {
                        if (sensor.EnergyMeterList.FirstOrDefault().DetectionDate == DateTime.MinValue)
                        {
                            sensor.EnergyMeterList.FirstOrDefault().DetectionDate = DateTime.Parse(value);
                        }
                        else
                        {
                            var         backup = sensor.EnergyMeterList.FirstOrDefault();
                            EnergyMeter newBag = new EnergyMeter();
                            newBag.LabelValues   = new List <string>();
                            newBag.LabelValues   = backup.LabelValues;
                            newBag.DetectionDate = DateTime.Parse(value);
                            sensor.EnergyMeterList.Add(newBag);
                        }
                    }
                }
            }

            if (structure.BoilerList.Count > 0)
            {
                foreach (var boiler in structure.BoilerList)
                {
                    if (boiler.BoilerValue.Count > 0)
                    {
                        if (boiler.BoilerValue.FirstOrDefault().DetectionDate == DateTime.MinValue)
                        {
                            boiler.BoilerValue.FirstOrDefault().DetectionDate = DateTime.Parse(value);
                        }
                        else
                        {
                            var         backup = boiler.BoilerValue.FirstOrDefault();
                            BoilerValue newBag = new BoilerValue();
                            newBag.LabelValues   = new List <string>();
                            newBag.LabelValues   = backup.LabelValues;
                            newBag.DetectionDate = DateTime.Parse(value);
                            boiler.BoilerValue.Add(newBag);
                        }
                    }
                }
            }

            if (structure.HeatPumpList.Count > 0)
            {
                foreach (var heatPump in structure.HeatPumpList)
                {
                    if (heatPump.HeatPumpValue.Count > 0)
                    {
                        if (heatPump.HeatPumpValue.FirstOrDefault().DetectionDate == DateTime.MinValue)
                        {
                            heatPump.HeatPumpValue.FirstOrDefault().DetectionDate = DateTime.Parse(value);
                        }
                        else
                        {
                            var           backup = heatPump.HeatPumpValue.FirstOrDefault();
                            HeatPumpValue newBag = new HeatPumpValue();
                            newBag.LabelValues   = new List <string>();
                            newBag.LabelValues   = backup.LabelValues;
                            newBag.DetectionDate = DateTime.Parse(value);
                            heatPump.HeatPumpValue.Add(newBag);
                        }
                    }
                }
            }

            //TODO ABSORBER

            return(structure);
        }