public PrintableFuelReportViewModel()
 {
     _result = new ReportFuelModel(); _selectedDate = DateTime.Now;
     if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         return;
     }
     Report.Add(new KVPBase {
         Name = DateTime.Now.ToShortTimeString(), id = 0
     });
 }
示例#2
0
 private void FillFuelReport(string row)
 {
     try
     {
         ReportFuelModel model = JsonConvert.DeserializeObject <ReportFuelModel>(row);
         if (Application.Current != null)
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 _fuel = model;
             }));
         }
     }
     catch { }
     if (Application.Current != null && FuelReportLoaded != null)
     {
         Application.Current.Dispatcher.BeginInvoke(new Action(() =>
         {
             FuelReportLoaded(this, new EventArgs());
         }));
     }
 }
        public PrintableFuelReportViewModel(FuelReportViewModel model, DateTime dt)
        {
            CarNumber = model.CarNumber;
            var res = new ReportFuelModel();

            if (model.Result != null)
            {
                res.DID    = model.Result.DID;
                res.Report = model.Result.Report.Where(o => dt.Equals(o.DT.ToDate())).OrderBy(r => r.DT.ToDateTime()).ToList();
                _report    = res.Report.GroupBy(x =>
                {
                    var stamp = x.DT.ToDateTime();
                    stamp     = stamp.AddMinutes(-(stamp.Minute % 15));
                    stamp     = stamp.AddMilliseconds(-stamp.Millisecond - 1000 * stamp.Second);
                    return(stamp);
                })
                             .Select(g => new KVPBase {
                    Name = string.Format("{0:00}:{1:00}", g.Key.Hour, g.Key.Minute), id = g.Min(f => f.Vol)
                }).ToList();
            }
            Result        = res;
            _selectedDate = dt;
        }