/// <summary> /// 获取一个番茄的效率 /// </summary> /// <param name="tomato"></param> /// <returns></returns> private double GetTomatoEfficiency(Tomato tomato) { tomato = GetFullTomato(tomato.TomatoID); if (tomato == null) { return(0); } TimeStatisticService tss = TimeStatisticService.GetTimeStatisticService(); List <UserActivity> userActivities = tss.GetUserActivitiesWithin(tomato.BeginTime, tomato.EndTime); TimeSpan focusTime = new TimeSpan(); TimeSpan totalTime = tomato.EndTime - tomato.BeginTime; if (totalTime.TotalSeconds <= 0) { return(0); } List <string> focusAppNames = new List <string>(); foreach (var focusApp in tomato.FocusApps) { focusAppNames.Add(focusApp.AppName); } foreach (UserActivity userActivity in userActivities) { if (focusAppNames.Contains(userActivity.Name)) { focusTime += userActivity.SpanTime; } } return(focusTime.TotalSeconds / totalTime.TotalSeconds); }
public void UpdateWhiteListValue(string selectedWhiteListKey = null) { WhiteListValueList.Clear(); TimeStatisticService tss = TimeStatisticService.GetTimeStatisticService(); List <string> softwareNames = tss.GetSoftwareNames(); foreach (string softwareName in softwareNames) { Software software = new Software(); software.Name = softwareName; if (selectedWhiteListKey != null && configService.TTConfig.WhiteLists[selectedWhiteListKey].Contains(softwareName)) { software.IsChecked = true; } else { software.IsChecked = false; } WhiteListValueList.Add(software); } }
public MainWindowViewModel() { tss = TimeStatisticService.GetTimeStatisticService(); tts = TaskTomatoService.GetTaskTomatoService(); LineSeriesCollection = new SeriesCollection(); LineXLabels = new List <string>(); TodayColumnSeriesCollection = new SeriesCollection(); WeekColumnSeriesCollection = new SeriesCollection(); TodayPieSeriesCollection = new SeriesCollection(); WeekPieSeriesCollection = new SeriesCollection(); TodayColumnXLabels = new List <string>(); WeekColumnXLabels = new List <string>(); RelativeFileItems = new List <RelativeFileItem>(); WhiteListKeys = new List <string>(); Update(); }