internal void AppendSuppressedExecution(ExecutionInfo exec) { if (!suppressedExecutions.ContainsKey(exec.ExecutionID)) { suppressedExecutions.Add(exec.ExecutionID, exec); } }
internal void RemoveSuppressedExecution(ExecutionInfo exec) { if (suppressedExecutions.ContainsKey(exec.ExecutionID)) { suppressedExecutions.Remove(exec.ExecutionID); } }
internal static void DetectPossibleParentActivities(Activity activity, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> parentActivities, int depth, ExecutionInfo execution) { if (activity != null && allActivities != null && parentActivities != null && depth < MAX_ACTIVITY_TREE_DEPTH && (resultCache == null || !resultCache.DetectPossibleParentActivitiesProxy(activity, allActivities, parentActivities, depth, execution))) { List <TraceRecord> traces = InternalLoadTraceRecordWarpper(activity, execution, containsActivityBoundary: true); Dictionary <int, ExecutionInfo> dictionary = null; if (execution == null) { dictionary = GetActivityExecutions(activity, traces); } else { dictionary = new Dictionary <int, ExecutionInfo>(); dictionary.Add(execution.ExecutionID, execution); } foreach (ExecutionInfo value in dictionary.Values) { ExecutionInfo executionInfo = value; TraceRecord directParentActivityTransferInTrace = GetDirectParentActivityTransferInTrace(activity.Id, traces, allActivities, execution); if (directParentActivityTransferInTrace != null && allActivities.ContainsKey(directParentActivityTransferInTrace.ActivityID)) { if (!parentActivities.ContainsKey(directParentActivityTransferInTrace.ActivityID)) { parentActivities.Add(directParentActivityTransferInTrace.ActivityID, allActivities[directParentActivityTransferInTrace.ActivityID]); } DetectPossibleParentActivities(allActivities[directParentActivityTransferInTrace.ActivityID], allActivities, parentActivities, depth + 1, execution); } } if (resultCache != null) { resultCache.DetectPossibleParentActivitiesResultCache(activity, allActivities, parentActivities, depth, execution); } } }
public List <TraceRecord> LoadTraceRecords(bool isLoadActivityBoundary, ExecutionInfo executionInfo) { List <TraceRecord> result = null; if (dataSource != null) { result = dataSource.LoadTraceRecordsFromActivity(this, isLoadActivityBoundary, executionInfo); } return(result); }
public ExecutionColumnItem(ExecutionInfo executionInfo, Activity activeActivity, Dictionary <string, Activity> allActivities, int index, List <string> suppressedActivityIds, ActivityTraceModeAnalyzer analyzer) { currentExecutionInfo = executionInfo; this.activeActivity = activeActivity; this.allActivities = allActivities; itemIndex = index; this.analyzer = analyzer; if (suppressedActivityIds != null && suppressedActivityIds.Count != 0) { this.suppressedActivityIds = suppressedActivityIds; } }
private void AnalysisHostActivityChild(Activity activity, ExecutionInfo executionInfo, List <string> relatedHostActivityIdentifiers) { if (activity != null && executionInfo != null && ActivityAnalyzerHelper.IsHostRelatedActivity(activity) && !suppressedActivityIds.Contains(activity.Id)) { List <TraceRecord> list = activity.LoadTraceRecords(true, executionInfo); List <TraceRecord> list2 = new List <TraceRecord>(); foreach (TraceRecord item in list) { if (item.IsTransfer && item.ActivityID == activity.Id && ActivityAnalyzerHelper.IsHostRelatedActivity(AllActivities[item.RelatedActivityID]) && !suppressedActivityIds.Contains(item.RelatedActivityID)) { string hostActivityNameIdentifier = ActivityAnalyzerHelper.GetHostActivityNameIdentifier(AllActivities[item.RelatedActivityID]); if (relatedHostActivityIdentifiers.Contains(hostActivityNameIdentifier) && item.Execution.ExecutionID == executionInfo.ExecutionID) { list2.Add(item); if (ActiveActivity.Id != item.RelatedActivityID) { suppressedActivityIds.Add(item.RelatedActivityID); } } } } SaveTargetTraceRecords(activity, list2); } }
private void InternalAnalysisActivityParents(Activity activity, int depth, ExecutionInfo execution) { if (activity != null && depth < ActivityAnalyzerHelper.MAX_ACTIVITY_TREE_DEPTH) { List <TraceRecord> list = null; list = activity.LoadTraceRecords(isLoadActivityBoundary: true); Dictionary <int, ExecutionInfo> activityExecutions = ActivityAnalyzerHelper.GetActivityExecutions(activity, list); foreach (int key in activityExecutions.Keys) { if (execution == null || execution.ExecutionID == key) { TraceRecord directParentActivityTransferInTrace = ActivityAnalyzerHelper.GetDirectParentActivityTransferInTrace(activity.Id, list, AllActivities, activityExecutions[key]); if (directParentActivityTransferInTrace != null && AllActivities.ContainsKey(directParentActivityTransferInTrace.ActivityID)) { List <TraceRecord> list2 = new List <TraceRecord>(); list2.Add(directParentActivityTransferInTrace); if (suppressedActivityIds.Contains(directParentActivityTransferInTrace.ActivityID)) { suppressedActivityIds.Remove(directParentActivityTransferInTrace.ActivityID); } TraceRecord backwardTransferInTrace = ActivityAnalyzerHelper.GetBackwardTransferInTrace(directParentActivityTransferInTrace.ActivityID, directParentActivityTransferInTrace.RelatedActivityID, list, AllActivities, activityExecutions[key]); if (backwardTransferInTrace != null) { list2.Add(backwardTransferInTrace); if (suppressedActivityIds.Contains(backwardTransferInTrace.ActivityID)) { suppressedActivityIds.Remove(backwardTransferInTrace.ActivityID); } } InternalAnalysisActivityParents(AllActivities[directParentActivityTransferInTrace.ActivityID], depth + 1, activityExecutions[key]); SaveTargetTraceRecords(AllActivities[directParentActivityTransferInTrace.ActivityID], list2); } } } } }
internal static Activity FindRootHostActivity(Activity activity, Dictionary <string, Activity> allActivities, ExecutionInfo hostExecution, out List <string> relatedHostActivityIdentifiers) { relatedHostActivityIdentifiers = new List <string>(); if (activity != null && allActivities != null && hostExecution != null && allActivities.ContainsKey("{00000000-0000-0000-0000-000000000000}")) { Activity activity2 = InternalFindParentActivityInType(activity, allActivities, ActivityType.ServiceHostActivity, false, hostExecution); if (activity2 != null) { string hostActivityNameIdentifier = GetHostActivityNameIdentifier(activity2); if (!string.IsNullOrEmpty(hostActivityNameIdentifier) && !relatedHostActivityIdentifiers.Contains(hostActivityNameIdentifier)) { relatedHostActivityIdentifiers.Add(hostActivityNameIdentifier); } TraceRecord directParentActivityTransferInTrace = GetDirectParentActivityTransferInTrace(activity2.Id, null, allActivities, null); while (directParentActivityTransferInTrace != null && allActivities.ContainsKey(directParentActivityTransferInTrace.ActivityID) && allActivities[directParentActivityTransferInTrace.ActivityID].ActivityType == ActivityType.ServiceHostActivity) { hostActivityNameIdentifier = GetHostActivityNameIdentifier(allActivities[directParentActivityTransferInTrace.ActivityID]); if (!string.IsNullOrEmpty(hostActivityNameIdentifier) && !relatedHostActivityIdentifiers.Contains(hostActivityNameIdentifier)) { relatedHostActivityIdentifiers.Add(hostActivityNameIdentifier); } directParentActivityTransferInTrace = GetDirectParentActivityTransferInTrace(allActivities[directParentActivityTransferInTrace.ActivityID].Id, null, allActivities, null); } InternalEnlistAllChildHostActivityIdentifier(activity2, allActivities, relatedHostActivityIdentifiers, INIT_ACTIVITY_TREE_DEPTH2); } Activity activity3 = activity2; if (activity3 != null) { Activity result = activity3; activity3 = InternalFindParentActivityInType(activity3, allActivities, ActivityType.RootActivity, false, hostExecution); if (activity3 != null) { return(activity3); } return(result); } } return(null); }
internal static Activity InternalFindParentActivityInType(Activity activity, Dictionary <string, Activity> allActivities, ActivityType expectedParentType, bool isFirstForwardOccur, ExecutionInfo execution) { if (activity != null && allActivities != null) { if (isFirstForwardOccur && activity.ActivityType == expectedParentType) { return(activity); } int i = INIT_ACTIVITY_TREE_DEPTH; Activity activity2 = activity; TraceRecord directParentActivityTransferInTrace = GetDirectParentActivityTransferInTrace(activity.Id, null, allActivities, execution); for (; i < MAX_ACTIVITY_TREE_DEPTH; i++) { if (directParentActivityTransferInTrace == null) { break; } if (!allActivities.ContainsKey(directParentActivityTransferInTrace.ActivityID)) { break; } if (allActivities[directParentActivityTransferInTrace.ActivityID].ActivityType == expectedParentType) { if (isFirstForwardOccur) { return(allActivities[directParentActivityTransferInTrace.ActivityID]); } activity2 = allActivities[directParentActivityTransferInTrace.ActivityID]; } directParentActivityTransferInTrace = GetDirectParentActivityTransferInTrace(allActivities[directParentActivityTransferInTrace.ActivityID].Id, null, allActivities, execution); } if (!isFirstForwardOccur && activity2 != null && activity2.ActivityType == expectedParentType) { return(activity2); } } return(null); }
internal static void DetectErrorOrWarningOnActivity(Activity activity, Dictionary <string, Activity> allActivities, List <TraceRecord> traces, ExecutionInfo execution, bool isChild, bool isDetectSeverityLevel, ref TraceRecordSetSeverityLevel severityLevel, ref TraceRecord firstErrorTrace, int depth) { if (activity != null && depth < MAX_ACTIVITY_TREE_DEPTH) { traces = ((traces == null) ? InternalLoadTraceRecordWarpper(activity, execution, containsActivityBoundary: true) : traces); foreach (TraceRecord trace in traces) { if (execution == null || execution.ExecutionID == trace.Execution.ExecutionID) { if (trace.Level == TraceEventType.Critical || trace.Level == TraceEventType.Error) { if (firstErrorTrace == null) { firstErrorTrace = trace; } if (severityLevel < TraceRecordSetSeverityLevel.Error) { severityLevel = TraceRecordSetSeverityLevel.Error; } return; } if (trace.Level == TraceEventType.Warning) { if (firstErrorTrace == null) { firstErrorTrace = trace; } if (isDetectSeverityLevel) { break; } if (severityLevel < TraceRecordSetSeverityLevel.Warning) { severityLevel = TraceRecordSetSeverityLevel.Warning; } } } } if (isChild) { foreach (Activity childActivity in GetChildActivities(activity.Id, traces, allActivities, execution)) { DetectErrorOrWarningOnActivity(childActivity, allActivities, null, null, isChild, isDetectSeverityLevel, ref severityLevel, ref firstErrorTrace, depth + 1); if (firstErrorTrace != null) { switch (isDetectSeverityLevel) { case false: return; } if (severityLevel == TraceRecordSetSeverityLevel.Error) { break; } } } } } }
public void DetectAllChildActivitiesResultCache(string currentActivityID, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> resultActivities, ExecutionInfo execution, int depth) { if (depth == INIT_ACTIVITY_TREE_DEPTH && resultActivities != null) { int key = currentActivityID.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (detectAllChildActivitiesCache.ContainsKey(key)) { detectAllChildActivitiesCache[key] = resultActivities; } else { detectAllChildActivitiesCache.Add(key, resultActivities); } } }
internal static List <Activity> GetChildActivities(string currentActivityID, List <TraceRecord> traces, Dictionary <string, Activity> allActivities, ExecutionInfo execution) { List <Activity> list = new List <Activity>(); if (allActivities != null && !string.IsNullOrEmpty(currentActivityID) && allActivities.ContainsKey(currentActivityID)) { if (resultCache != null) { List <Activity> childActivitiesProxy = resultCache.GetChildActivitiesProxy(currentActivityID, allActivities, execution); if (childActivitiesProxy != null) { return(childActivitiesProxy); } } Dictionary <string, Activity> dictionary = new Dictionary <string, Activity>(); DetectPossibleParentActivities(allActivities[currentActivityID], allActivities, dictionary, INIT_ACTIVITY_TREE_DEPTH2, execution); List <string> list2 = new List <string>(); List <string> list3 = new List <string>(); traces = ((traces == null) ? InternalLoadTraceRecordWarpper(allActivities[currentActivityID], execution, containsActivityBoundary: false) : traces); foreach (TraceRecord trace in traces) { if ((execution == null || execution.ExecutionID == trace.Execution.ExecutionID) && trace.IsTransfer) { if (trace.ActivityID == currentActivityID && allActivities.ContainsKey(trace.RelatedActivityID) && !list3.Contains(trace.RelatedActivityID) && !list2.Contains(trace.RelatedActivityID) && !dictionary.ContainsKey(trace.RelatedActivityID)) { list.Add(allActivities[trace.RelatedActivityID]); list2.Add(trace.RelatedActivityID); } if (trace.RelatedActivityID == currentActivityID && allActivities.ContainsKey(trace.ActivityID) && !list3.Contains(trace.ActivityID) && !list2.Contains(trace.ActivityID)) { list3.Add(trace.ActivityID); } } } if (resultCache != null) { resultCache.GetChildActivitiesResultCache(currentActivityID, allActivities, execution, list); } } return(list); }
internal static TraceRecord GetDirectParentActivityTransferInTrace(string currentActivityID, List <TraceRecord> traces, Dictionary <string, Activity> allActivities, ExecutionInfo execution) { if (!string.IsNullOrEmpty(currentActivityID) && allActivities != null && allActivities.ContainsKey(currentActivityID) && allActivities[currentActivityID].ActivityType != 0) { bool flag = false; traces = ((traces == null) ? InternalLoadTraceRecordWarpper(allActivities[currentActivityID], execution, containsActivityBoundary: false) : traces); foreach (TraceRecord trace in traces) { if (execution == null || execution.ExecutionID == trace.Execution.ExecutionID) { if (!flag && trace.IsTransfer) { if (trace.ActivityID == currentActivityID) { return(null); } flag = true; } if (trace.IsTransfer && trace.RelatedActivityID == currentActivityID && allActivities.ContainsKey(trace.ActivityID)) { return(trace); } } } } return(null); }
public void GetChildActivitiesResultCache(string currentActivityID, Dictionary <string, Activity> allActivities, ExecutionInfo execution, List <Activity> result) { if (result != null) { int key = currentActivityID.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (getChildActivitiesCache.ContainsKey(key)) { getChildActivitiesCache[key] = result; } else { getChildActivitiesCache.Add(key, result); } } }
public void DetectPossibleParentActivitiesResultCache(Activity activity, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> parentActivities, int depth, ExecutionInfo execution) { if (depth == INIT_ACTIVITY_TREE_DEPTH && parentActivities != null) { int key = activity.Id.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (detectPossibleParentActivitiesCache.ContainsKey(key)) { detectPossibleParentActivitiesCache[key] = parentActivities; } else { detectPossibleParentActivitiesCache.Add(key, parentActivities); } } }
internal static TraceRecord GetBackwardTransferInTrace(string parentActivityID, string childActivityID, List <TraceRecord> traces, Dictionary <string, Activity> allActivities, ExecutionInfo execution) { if (!string.IsNullOrEmpty(parentActivityID) && !string.IsNullOrEmpty(childActivityID) && allActivities != null && allActivities.ContainsKey(parentActivityID) && allActivities.ContainsKey(childActivityID)) { traces = ((traces == null) ? InternalLoadTraceRecordWarpper(allActivities[childActivityID], execution, containsActivityBoundary: false) : traces); foreach (TraceRecord trace in traces) { if ((execution == null || execution.ExecutionID == trace.Execution.ExecutionID) && trace.IsTransfer && trace.ActivityID == childActivityID && trace.RelatedActivityID == parentActivityID) { return(trace); } } } return(null); }
private static List <TraceRecord> InternalLoadTraceRecordWarpper(Activity activity, ExecutionInfo execution, bool containsActivityBoundary) { List <TraceRecord> list = null; if (activity != null) { try { list = ((execution != null) ? activity.LoadTraceRecords(containsActivityBoundary, execution) : activity.LoadTraceRecords(containsActivityBoundary)); } catch (LogFileException e) { throw new TraceViewerException(SR.GetString("SL_ERROR_LOAD_TRACE"), e); } } if (list == null) { list = new List <TraceRecord>(); } return(list); }
internal static void DetectAllChildActivities(string currentActivityID, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> resultActivities, ExecutionInfo execution, int depth) { if (!string.IsNullOrEmpty(currentActivityID) && allActivities != null && resultActivities != null && allActivities.ContainsKey(currentActivityID) && depth < MAX_ACTIVITY_TREE_DEPTH && (resultCache == null || !resultCache.DetectAllChildActivitiesProxy(currentActivityID, allActivities, resultActivities, execution, depth))) { foreach (Activity childActivity in GetChildActivities(currentActivityID, null, allActivities, execution)) { if (!resultActivities.ContainsKey(childActivity.Id)) { resultActivities.Add(childActivity.Id, childActivity); DetectAllChildActivities(childActivity.Id, allActivities, resultActivities, execution, depth + 1); } } if (resultCache != null) { resultCache.DetectAllChildActivitiesResultCache(currentActivityID, allActivities, resultActivities, execution, depth); } } }
public static DirectActivityRelationship DetectDirectRelationshipBetweenActivities(Activity activity1, Activity activity2, ExecutionInfo execution) { if (activity1 != null && activity2 != null) { foreach (TraceRecord item in InternalLoadTraceRecordWarpper(activity1, execution, containsActivityBoundary: false)) { if (item.IsTransfer && item.ActivityID == activity1.Id && item.RelatedActivityID == activity2.Id) { return(DirectActivityRelationship.Parent); } if (item.IsTransfer && item.ActivityID == activity2.Id && item.RelatedActivityID == activity1.Id) { return(DirectActivityRelationship.Child); } } } return(DirectActivityRelationship.NoRelationship); }
public bool DetectAllChildActivitiesProxy(string currentActivityID, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> resultActivities, ExecutionInfo execution, int depth) { if (depth == INIT_ACTIVITY_TREE_DEPTH) { int key = currentActivityID.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (detectAllChildActivitiesCache.ContainsKey(key)) { foreach (string key2 in detectAllChildActivitiesCache[key].Keys) { if (!resultActivities.ContainsKey(key2)) { resultActivities.Add(key2, detectAllChildActivitiesCache[key][key2]); } } return(true); } } return(false); }
public bool DetectPossibleParentActivitiesProxy(Activity activity, Dictionary <string, Activity> allActivities, Dictionary <string, Activity> parentActivities, int depth, ExecutionInfo execution) { if (depth == INIT_ACTIVITY_TREE_DEPTH) { int key = activity.Id.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (detectPossibleParentActivitiesCache.ContainsKey(key)) { foreach (string key2 in detectPossibleParentActivitiesCache[key].Keys) { if (!parentActivities.ContainsKey(key2)) { parentActivities.Add(key2, detectPossibleParentActivitiesCache[key][key2]); } } return(true); } } return(false); }
public List <Activity> GetChildActivitiesProxy(string currentActivityID, Dictionary <string, Activity> allActivities, ExecutionInfo execution) { int key = currentActivityID.GetHashCode() * allActivities.GetHashCode() * (execution?.ExecutionID ?? 1); if (getChildActivitiesCache.ContainsKey(key)) { return(getChildActivitiesCache[key]); } return(null); }
private void SortResults() { Dictionary <int, List <TraceRecord> > dictionary = new Dictionary <int, List <TraceRecord> >(); Dictionary <int, List <TraceRecord> > dictionary2 = new Dictionary <int, List <TraceRecord> >(); long num = 0L; ExecutionInfo executionInfo = null; DateTime t = DateTime.MaxValue; foreach (TraceRecord value in results.Values) { if (Parameters == null || !Parameters.SuppressedExecutions.ContainsKey(value.Execution.ExecutionID)) { num += value.TraceID; } if (value.Time < t) { executionInfo = value.Execution; t = value.Time; } if (!dictionary.ContainsKey(value.Execution.ExecutionID)) { dictionary.Add(value.Execution.ExecutionID, new List <TraceRecord>()); } dictionary[value.Execution.ExecutionID].Add(value); } renderingHashCode = (int)num; SortedList <TraceRecord, int> sortedList = new SortedList <TraceRecord, int>(new TraceRecordComparer()); foreach (int key in dictionary.Keys) { sortedList.Add(dictionary[key][0], key); } for (int i = 0; i < sortedList.Count; i++) { dictionary2.Add(sortedList.Values[i], dictionary[sortedList.Values[i]]); } int num2 = (executionInfo != null) ? 1 : 0; Queue <ExecutionColumnItem> queue = new Queue <ExecutionColumnItem>(); ExecutionColumnItem executionColumnItem = null; foreach (int key2 in dictionary2.Keys) { dictionary2[key2].Sort(new TraceRecordComparer()); ExecutionColumnItem executionColumnItem2 = null; if (executionInfo == null) { executionColumnItem2 = new ExecutionColumnItem(dictionary2[key2][0].Execution, ActiveActivity, AllActivities, num2++, suppressedActivityIds, this); queue.Enqueue(executionColumnItem2); } else { executionColumnItem2 = new ExecutionColumnItem(dictionary2[key2][0].Execution, ActiveActivity, AllActivities, (executionInfo.ExecutionID != dictionary2[key2][0].Execution.ExecutionID) ? num2++ : 0, suppressedActivityIds, this); if (executionInfo.ExecutionID == dictionary2[key2][0].Execution.ExecutionID) { executionColumnItem = executionColumnItem2; } else { queue.Enqueue(executionColumnItem2); } } foreach (TraceRecord item in dictionary2[key2]) { TraceRecordCellItem traceRecordCellItem = executionColumnItem2.AppendTraceRecord(item); if (traceRecordCellItem != null && (traceRecordCellItem.CurrentTraceRecord.IsMessageSentRecord || traceRecordCellItem.CurrentTraceRecord.IsMessageReceivedRecord || traceRecordCellItem.CurrentTraceRecord.IsMessageLogged)) { messageRelatedItems.Add(traceRecordCellItem); } } } if (parameters == null) { parameters = new ActivityTraceModeAnalyzerParameters(); } if (executionColumnItem != null && executionColumnItem.ActivityColumnCount != 0) { if (!Parameters.SuppressedExecutions.ContainsKey(executionColumnItem.CurrentExecutionInfo.ExecutionID)) { executionItems.Add(executionColumnItem); } allInvolvedExecutionItems.Add(executionColumnItem); Parameters.PushExecutionColumnItem(executionColumnItem); } while (queue.Count != 0) { ExecutionColumnItem executionColumnItem3 = queue.Dequeue(); if (executionColumnItem3.ActivityColumnCount != 0) { if (!Parameters.SuppressedExecutions.ContainsKey(executionColumnItem3.CurrentExecutionInfo.ExecutionID)) { executionItems.Add(executionColumnItem3); } allInvolvedExecutionItems.Add(executionColumnItem3); parameters.PushExecutionColumnItem(executionColumnItem3); } } Parameters.ReorderExecutionColumnItems(executionItems); AnalyzeCrossExecutionMessageExchange(); AnalyzePairedActivities(); }