Example #1
0
 public TimeManager(ITimeSystem timeSystem, ITimeLogsManager timeLogsManager)
 {
     currentActivity = new RunningActivity(FIRST_ACTIVITY, timeSystem);
     midnightCorrector = new MidnightSwitcher();
     if (timeLogsManager != null)
     {
         TimeLogsManager = timeLogsManager;
         timeLogsManager.ActivateTimeLog(currentActivity.Start.Date);
     }
 }
Example #2
0
 public TimeManager(ITimeLogsManager timeLogsManager)
 {
     currentActivity   = new RunningActivity(FIRST_ACTIVITY);
     midnightCorrector = new MidnightSwitcher();
     if (timeLogsManager != null)
     {
         TimeLogsManager = timeLogsManager;
         timeLogsManager.ActivateTimeLog(currentActivity.Start.Date);
     }
 }
Example #3
0
        public bool LoadTimeLog(DateTime date)
        {
            ITimeLog timeLog = null;

            if (timeLogsManager != null)
            {
                timeLog = timeLogsManager.ActivateTimeLog(date);
            }
            return(timeLog != null);
        }
 public void PerformMidnightCorrection(IActivity currentActivity, ITimeLogsManager timeLogsManager)
 {
     DateTime endTime = currentActivity.End;
     DateTime midnightTime = endTime.Date;
     DateTime startTime = currentActivity.Start;
     if (startTime < midnightTime)
     {
         TimeSpan oldDayActivityDuration = midnightTime - startTime;
         TimeSpan newDayActivityDuration = endTime - midnightTime;
         currentActivity.Duration = oldDayActivityDuration;
         if (timeLogsManager != null)
         {
             ITimeLog timeLog = timeLogsManager.ActiveTimeLog;
             if (timeLog != null)
                 timeLog.AddActivity(currentActivity);
             timeLogsManager.ActivateTimeLog(midnightTime);
         }
         currentActivity.Start = midnightTime;
         currentActivity.Duration = newDayActivityDuration;
     }
 }
Example #5
0
        public void PerformMidnightCorrection(IActivity currentActivity, ITimeLogsManager timeLogsManager)
        {
            DateTime endTime      = currentActivity.End;
            DateTime midnightTime = endTime.Date;
            DateTime startTime    = currentActivity.Start;

            if (startTime < midnightTime)
            {
                TimeSpan oldDayActivityDuration = midnightTime - startTime;
                TimeSpan newDayActivityDuration = endTime - midnightTime;
                currentActivity.Duration = oldDayActivityDuration;
                if (timeLogsManager != null)
                {
                    ITimeLog timeLog = timeLogsManager.ActiveTimeLog;
                    if (timeLog != null)
                    {
                        timeLog.AddActivity(currentActivity);
                    }
                    timeLogsManager.ActivateTimeLog(midnightTime);
                }
                currentActivity.Start    = midnightTime;
                currentActivity.Duration = newDayActivityDuration;
            }
        }