Пример #1
0
        internal void SetState(RequestState value)
        {
            if (this.curState == value)
            {
                return;
            }
            DateTime utcNow   = TimeProvider.UtcNow;
            TimeSpan duration = utcNow.Subtract(this.stateChangeTimestamp);

            this.RefreshDurations();
            if (RequestJobTimeTracker.SupportDurationTracking(this.curState))
            {
                RequestJobDurationData requestJobDurationData;
                if (!this.durations.TryGetValue(this.curState, out requestJobDurationData))
                {
                    requestJobDurationData = new RequestJobDurationData(this.curState);
                }
                requestJobDurationData.AddTime(duration);
                this.durations[this.curState] = requestJobDurationData;
            }
            this.stateChangeTimestamp = utcNow;
            this.curState             = value;
            if (RequestJobTimeTracker.SupportDurationTracking(this.curState))
            {
                this.UpdateActiveCounts(this.curState, 1L);
                this.IncRateCounts(this.curState);
            }
        }
Пример #2
0
                object IObjectLogPropertyDefinition <RequestJobLogData> .GetValue(RequestJobLogData rj)
                {
                    RequestJobDurationData duration = rj.Request.TimeTracker.GetDuration(this.rs);

                    if (duration != null)
                    {
                        return((long)duration.Duration.TotalMilliseconds);
                    }
                    return(null);
                }
Пример #3
0
        private TimeSpan GetNonEmptyDuration(RequestState state)
        {
            RequestJobDurationData duration = this.GetDuration(state);

            if (duration != null)
            {
                return(duration.Duration);
            }
            return(TimeSpan.Zero);
        }
Пример #4
0
        public RequestJobDurationData GetDisplayDuration(RequestState state)
        {
            RequestJobDurationData duration = this.GetDuration(state);

            if (duration == null)
            {
                return(new RequestJobDurationData(state));
            }
            return(duration);
        }
Пример #5
0
        public void AddDurationToState(TimeSpan duration, RequestState requestState)
        {
            RequestJobDurationData requestJobDurationData;

            if (!this.durations.TryGetValue(requestState, out requestJobDurationData))
            {
                requestJobDurationData = new RequestJobDurationData(requestState);
            }
            requestJobDurationData.AddTime(duration);
            this.durations[requestState] = requestJobDurationData;
        }
Пример #6
0
        public EnhancedTimeSpan?GetDisplayDuration(RequestState[] states)
        {
            EnhancedTimeSpan?result = null;

            foreach (RequestState state in states)
            {
                RequestJobDurationData displayDuration = this.GetDisplayDuration(state);
                if (displayDuration != null)
                {
                    result = new EnhancedTimeSpan?(displayDuration.Duration + ((result != null) ? result.Value : EnhancedTimeSpan.Zero));
                }
            }
            return(result);
        }
Пример #7
0
        public static RequestJobDurationData operator +(RequestJobDurationData data1, RequestJobDurationData data2)
        {
            if (data1 != null && data2 == null)
            {
                return(data1);
            }
            if (data2 != null && data1 == null)
            {
                return(data2);
            }
            RequestJobDurationData requestJobDurationData = new RequestJobDurationData();

            requestJobDurationData.Duration = data1.Duration + data2.Duration;
            requestJobDurationData.minutes.PopulateFrom(data1.minutes, data2.minutes);
            requestJobDurationData.hours.PopulateFrom(data1.hours, data2.hours);
            requestJobDurationData.days.PopulateFrom(data1.days, data2.days);
            requestJobDurationData.months.PopulateFrom(data1.months, data2.months);
            return(requestJobDurationData);
        }
Пример #8
0
        public RequestJobDurationData GetDuration(RequestState state)
        {
            RequestJobDurationData requestJobDurationData = null;
            RequestJobDurationData requestJobDurationData2;

            if (this.durations.TryGetValue(state, out requestJobDurationData2))
            {
                requestJobDurationData = requestJobDurationData2;
            }
            if (state == this.curState)
            {
                DateTime utcNow   = TimeProvider.UtcNow;
                TimeSpan duration = utcNow.Subtract(this.stateChangeTimestamp);
                if (requestJobDurationData == null)
                {
                    requestJobDurationData = new RequestJobDurationData(state);
                    requestJobDurationData.AddTime(duration);
                    this.durations[this.curState] = requestJobDurationData;
                }
                else
                {
                    requestJobDurationData.AddTime(duration);
                }
                this.stateChangeTimestamp = utcNow;
            }
            RequestJobStateNode state2 = RequestJobStateNode.GetState(state);

            if (state2 != null)
            {
                foreach (RequestJobStateNode requestJobStateNode in state2.Children)
                {
                    RequestJobDurationData duration2 = this.GetDuration(requestJobStateNode.MRState);
                    if (duration2 != null)
                    {
                        requestJobDurationData += duration2;
                    }
                }
            }
            return(requestJobDurationData);
        }
Пример #9
0
        private RequestJobTimeTrackerXML.DurationRec DumpDurationTreeForDiagnostics(RequestJobStateNode treeRoot, bool showTimeSlots = false)
        {
            RequestJobDurationData displayDuration = this.GetDisplayDuration(treeRoot.MRState);

            if (displayDuration == null)
            {
                return(null);
            }
            RequestJobTimeTrackerXML.DurationRec durationRec = displayDuration.GetDurationRec(treeRoot.MRState, showTimeSlots);
            foreach (RequestJobStateNode treeRoot2 in treeRoot.Children)
            {
                RequestJobTimeTrackerXML.DurationRec durationRec2 = this.DumpDurationTreeForDiagnostics(treeRoot2, showTimeSlots);
                if (durationRec2 != null && durationRec2.Duration != TimeSpan.Zero.ToString())
                {
                    if (durationRec.ChildNodes == null)
                    {
                        durationRec.ChildNodes = new List <RequestJobTimeTrackerXML.DurationRec>();
                    }
                    durationRec.ChildNodes.Add(durationRec2);
                }
            }
            return(durationRec);
        }