Example #1
0
        private static void MaybeCommitSummary(DateTime currTimePoint)
        {
            if (currTimePoint > activeTimePoint)
            {
                // Separate snapshots belonging to the current and the next interval
                List <ActivitySnapshot> currSnapshots = new List <ActivitySnapshot>();
                List <ActivitySnapshot> nextSnapshots = new List <ActivitySnapshot>();
                SplitSnapshots(activeSnapshots, activeTimePoint, currSnapshots, nextSnapshots);

                // Summarize the previous interval
                ActivitySummary summary = GetActivitySummary(currSnapshots, activeTimePoint);

                if (summary.Entries.Count >= 1)
                {
                    Persistence.Store(summary);
                    currentLog.Add(summary);
                    if (currentLog == selectedLog)
                    {
                        OnCurrentLogExtended(summary);
                    }
                }

                // Consider the end of the day
                bool dateChanged = (currTimePoint.Date > activeTimePoint.Date);
                if (dateChanged)
                {
                    Persistence.Close();

                    currentLog.Clear();
                    if (currentLog == selectedLog)
                    {
                        OnCurrentLogChanged(currTimePoint.Date);
                    }
                }

                // Start a new interval
                activeSnapshots = nextSnapshots;
                activeTimePoint = currTimePoint;
            }
        }
Example #2
0
 public void AddSummary(ActivitySummary summary)
 {
     Persistence.Store(summary);
     Activities.Add(summary);
 }