示例#1
0
        public EnergyViewModel GetEnergyView(string buildid, string energyCode, DateTime date)
        {
            EnergyViewModel model = new EnergyViewModel();

            model.ItemValue = GetEnergyItemValueOfElec(buildid, date);

            model.DayChart = new ChartValue();

            model.DayChart.Now    = GetHourTrend(buildid, energyCode, date);
            model.DayChart.Before = GetHourTrend(buildid, energyCode, date.AddDays(-1));

            model.MonthChart = new ChartValue();

            model.MonthChart.Now    = GetDayValueOfMonth(buildid, energyCode, date);
            model.MonthChart.Before = GetDayValueOfMonth(buildid, energyCode, date.AddMonths(-1));

            model.YearChart = new ChartValue();

            model.YearChart.Now    = GetMonthValueOfYear(buildid, energyCode, date);
            model.YearChart.Before = GetMonthValueOfYear(buildid, energyCode, date.AddYears(-1));

            List <CompareValue> compares = new List <CompareValue>();

            compares.Add(GetCompareValue(buildid, energyCode, "day", date));
            compares.Add(GetCompareValue(buildid, energyCode, "month", date));
            compares.Add(GetCompareValue(buildid, energyCode, "year", date));

            model.Compares = compares;

            return(model);
        }
示例#2
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     DataContext = new EnergyViewModel()
     {
         CloseAction = this.Close
     };
 }