Ejemplo n.º 1
0
        // Stamping:

        public static void SetBegin(Stamp stamp, TimeSpan value)
        {
            if (value < stamp.Begin)
            {
                // also move first activity to the correct earlier begin time
                var activity = stamp.GetFirstActivity();
                if (activity != null)
                {
                    activity.Begin = value;
                }
            }
            else if (value > stamp.Begin)
            {
                // cut off earlier activities and/or set the earliest activity to the correct later begin time
                var activities = stamp.ActivityRecords.OrderBy(r => r.Begin.Value).ToArray();
                foreach (var act in activities)
                {
                    // starts before 'new check-in' and ends before 'new check-in': remove activity completely:
                    if (act.Begin.Value < value && act.End.HasValue && act.End.Value < value)
                    {
                        stamp.ActivityRecords.Remove(act);
                    }
                    // either starts after, ends after 'new check-in', or has open end: set new begin time for activity and stop iteration:
                    else
                    {
                        act.Begin = value;
                        break;
                    }
                }
            }
            stamp.Begin = value;
        }
Ejemplo n.º 2
0
 public void DeleteActivity(Stamp stamp, ActivityRecord activity)
 {
     if (activity == TodayCurrentActivity)
     {
         // todays end auf neuen letzten zeitpunkt setzen, current activity clearen:
         stamp.ActivityRecords.Remove(activity);
         TodayCurrentActivity = null;
         var newLastActivity = stamp.GetLastActivity();
         stamp.End = newLastActivity.End.Value;
         // TODO: need to recalculate pause?
         TimeManager.CalculatePauseFromActivities(stamp);
     }
     else if (activity == stamp.GetFirstActivity())
     {
         // update todays start time:
         stamp.ActivityRecords.Remove(activity);
         var newFirstActivity = stamp.GetFirstActivity();
         stamp.Begin = newFirstActivity.Begin.Value;
         // TODO: need to recalculate pause?
         TimeManager.CalculatePauseFromActivities(stamp);
     }
     else if (activity == stamp.GetLastActivity())
     {
         // update todays end time:
         stamp.ActivityRecords.Remove(activity);
         var newLastActivity = stamp.GetLastActivity();
         stamp.End = newLastActivity.End.Value;
         // TODO: need to recalculate pause?
         TimeManager.CalculatePauseFromActivities(stamp);
     }
     else
     {
         // in between activity; update todays pause time:
         stamp.ActivityRecords.Remove(activity);
         TimeManager.CalculatePauseFromActivities(stamp);
     }
 }