Beispiel #1
0
        public void EdgeUndo(TaskTimeMetric wronglyStarted, TaskTimeMetric wronglyFinished)
        {
            WhenStarted.Remove(wronglyStarted);
            WhenFinished.Remove(wronglyFinished);

            if (wronglyFinished == TaskTimeMetric.Queued || wronglyStarted == TaskTimeMetric.Queued)
            {
                RecalcWaitInQueueOverhead();
            }
        }
Beispiel #2
0
        /*
         * [DataMember]
         * public DateTime? EstimatedStart { get; set; }
         *
         * [DataMember]
         * public DateTime? EstimatedFinish { get; set; }
         *
         * [DataMember]
         * public TimeSpan? Left
         * {
         *  get
         *  {
         *      if (EstimatedFinish == null || EstimatedStart == null)
         *          return null;
         *
         *      if (!WhenStarted.ContainsKey(TaskTimeMetric.Calculation))
         *          return EstimatedFinish - DateTime.Now;
         *
         *      if (WhenFinished.ContainsKey(TaskTimeMetric.Calculation))
         *          return TimeSpan.FromSeconds(0);
         *
         *      TimeSpan duration = EstimatedFinish.Value - EstimatedStart.Value;
         *      TimeSpan passed = DateTime.Now - WhenStarted[TaskTimeMetric.Calculation];
         *      TimeSpan left = duration - passed;
         *      return (left.TotalMilliseconds < 0) ? TimeSpan.FromSeconds(0) : left;
         *  }
         *
         *  private set { }  // Property is evaluated, not set. Setter needed for deserialization.
         * }
         */

        private void RecalcWaitInQueueOverhead()
        {
            if (!WhenStarted.ContainsKey(TaskTimeMetric.Queued) || WhenStarted[TaskTimeMetric.Queued] == null)
            {
                _overheads[TaskTimeOverheads.WaitInQueue] = TimeSpan.Zero;
            }
            else
            {
                //TimeSpan queuedDuration = DateTime.Now - WhenStarted[TaskTimeMetric.Queued];
                //if (WhenFinished.ContainsKey(TaskTimeMetric.Queued) && WhenFinished[TaskTimeMetric.Queued] != null)
                //    queuedDuration = WhenFinished[TaskTimeMetric.Queued] - WhenStarted[TaskTimeMetric.Queued];

                TimeSpan oversWhileInQueue = _overheads
                                             .Where(o => !(new[] { TaskTimeOverheads.All, TaskTimeOverheads.Other, TaskTimeOverheads.WaitInQueue }).Contains(o.Key))
                                             .Select(pair => pair.Value).Aggregate(TimeSpan.Zero, (acc, cur) => acc + cur);
                _overheads[TaskTimeOverheads.WaitInQueue] = Duration[TaskTimeMetric.Queued] - oversWhileInQueue;
            }
        }