public TimeFormModel GetTimeLogs(DateTime start, DateTime end) { var startId = _baseContext.Events.First(e => e.TriggeredAt.Value >= start).EventId; var endId = _baseContext.Events.OrderByDescending(e => e.TriggeredAt).First(e => e.TriggeredAt.Value <= end).EventId; var total = TotalActivity(startId, endId); var code = CodeActivity(startId, endId); var debug = DebugActivity(startId, endId); var test = TestActivity(startId, endId); var doc = DocumentActivity(startId, endId); TimeFormModel m = new TimeFormModel(Guid.NewGuid()) { CreatedAt = DateTime.Now, From = start, To = end, Documents = new ObservableList <DocumentActivityModel>( doc.Select(d => new DocumentActivityModel(d.DocumentName, (int)Math.Round(d.Duration.TotalMinutes))).ToArray()), Interruption = (int)(end.Subtract(start).TotalMinutes - (int)total.Sum(a => a.ActivityMinutes)), CodingTime = (int)getIntersect(total, code), DebuggingTime = (int)getIntersect(total, debug), TestingTime = (int)getIntersect(total, test) }; return(m); }
private void OnNewFormsRequested(DateTime start, DateTime end) { // Size Forms: foreach (var hook in fileHooks) { hook.MeasureCodeFiles <PSPSizeMeasure>(); var forms = hook.Files.ToPSPForm(); if (forms.Length > 0) { wpf.App.VMLocator <PSPFormsVMLocator>().PopulateSizeForms(forms); } } // Time Forms: try { TimeFormModel form = DBQueryAgent.Instance.GetTimeLogs(start, end); wpf.App.VMLocator <PSPFormsVMLocator>().PopulateTimeForms(new [] { form }); } catch (Exception e) { Logger.Instance.Log(e.ToString()); } }
public TimeFormViewModel(TimeFormModel model, TimeFormModel clone) { _model = model; _clone = clone; }