예제 #1
0
        public WeeklyPeaksModel GetpeakDemandSummary(string customerGuid, int ptID)
        {
            var weeklyData = new WeeklyPeaksModel();

            // TEMPORARY
            // MOCK DATA
            if (customerGuid == "123mock123")
            {
                weeklyData = _mockPeakDemandSummaryData();
            }
            else
            {
                var startTime        = DateTime.Today.Subtract(TimeSpan.FromDays(7));
                var lastPeaksSamples = from s in _dataRep.Samples
                                       where s.PointId == ptID &&
                                       s.SampleType == SampleType.DailyPeakDemand &&
                                       s.TimeStamp > startTime
                                       select s;
                var weeklyPeaks = new List <SampleModel>();

                foreach (var item in lastPeaksSamples)
                {
                    weeklyPeaks.Add(_mapSampleToSampleModel(item));
                }

                weeklyData.WeeklyPeaks         = weeklyPeaks;
                weeklyData.AverageWeeklyDemand = (int)weeklyPeaks.Average(r => r.val);
                weeklyData.YearToDatePeak      = (int)weeklyPeaks.Max(r => r.val);
            }

            return(weeklyData);
        }
예제 #2
0
        private WeeklyPeaksModel _mockPeakDemandSummaryData()
        {
            var data       = new WeeklyPeaksModel();
            var weeklyData = new List <SampleModel>();
            var today      = DateTime.Today;

            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(6)), val = 550
            });
            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(5)), val = 590
            });
            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(4)), val = 400
            });
            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(3)), val = 430
            });
            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(2)), val = 600
            });
            weeklyData.Add(new SampleModel()
            {
                t = today.Subtract(TimeSpan.FromDays(1)), val = 520
            });
            weeklyData.Add(new SampleModel()
            {
                t = today, val = 480
            });
            data.WeeklyPeaks         = weeklyData;
            data.YearToDatePeak      = 890;
            data.AverageWeeklyDemand = 470;
            return(data);
        }