public AggregatedViewResponse GetAggregatedView(AggregatedViewRequest request) { ExTraceGlobals.DiagnosticsAggregationTracer.TraceFunction <string, string, string>(0L, "GetAggregatedView called. ClientMachineName={0}; ClientProcessName={1}; ClientProcessId={2}", (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientMachineName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessName, (request.ClientInformation == null) ? string.Empty : request.ClientInformation.ClientProcessId.ToString()); AggregatedViewResponse response = null; this.ServiceRequest(delegate { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.log.LogOperationFromClient(DiagnosticsAggregationEvent.AggregatedViewRequestReceived, request.ClientInformation, null, ""); DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNull(request, "request"); DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.RequestType, "request.RequestType"); RequestType requestType; bool flag = Enum.TryParse <RequestType>(request.RequestType, out requestType); if (!flag || requestType != RequestType.Queues) { throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.RequestType, "request.RequestType"); } DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNull(request.QueueAggregatedViewRequest, "request.QueueAggregatedViewRequest"); IQueueFilter filter; if (!QueueFilter.TryParse(request.QueueAggregatedViewRequest.QueueFilter, out filter)) { throw DiagnosticsAggregationServiceImpl.NewInvalidParameterFault(request.QueueAggregatedViewRequest.QueueFilter, "request.QueueAggregatedViewRequest.QueueFilter"); } DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.QueueAggregatedViewRequest.GroupByKey, "request.QueueAggregatedViewRequest.GroupByKey"); QueueDigestGroupBy groupByKey; if (!Enum.TryParse <QueueDigestGroupBy>(request.QueueAggregatedViewRequest.GroupByKey, out groupByKey)) { throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.QueueAggregatedViewRequest.GroupByKey, "request.QueueAggregatedViewRequest.GroupByKey"); } DiagnosticsAggregationServiceImpl.VerifyParameterIsNotNullOrEmpty(request.QueueAggregatedViewRequest.DetailsLevel, "request.QueueAggregatedViewRequest.DetailsLevel"); DetailsLevel detailsLevel; if (!Enum.TryParse <DetailsLevel>(request.QueueAggregatedViewRequest.DetailsLevel, out detailsLevel)) { throw DiagnosticsAggregationServiceImpl.NewUnsupportedParameterFault(request.QueueAggregatedViewRequest.DetailsLevel, "request.QueueAggregatedViewRequest.DetailsLevel"); } QueueAggregator queueAggregator = new QueueAggregator(groupByKey, detailsLevel, filter, new TimeSpan?(this.GetTimeSpanForQueueDataBeingCurrent())); bool flag2 = request.ServersToInclude != null && request.ServersToInclude.Count > 0; HashSet <string> hashSet = flag2 ? new HashSet <string>(request.ServersToInclude, StringComparer.InvariantCultureIgnoreCase) : new HashSet <string>(); IDictionary <ADObjectId, ServerQueuesSnapshot> currentGroupServerToQueuesMap = this.groupQueuesDataProvider.GetCurrentGroupServerToQueuesMap(); currentGroupServerToQueuesMap.Add(this.localQueuesDataProvider.GetLocalServerId(), this.localQueuesDataProvider.GetLocalServerQueues()); List <ServerSnapshotStatus> list = new List <ServerSnapshotStatus>(); foreach (KeyValuePair <ADObjectId, ServerQueuesSnapshot> keyValuePair in currentGroupServerToQueuesMap) { ADObjectId key = keyValuePair.Key; ServerQueuesSnapshot value = keyValuePair.Value; if (!flag2 || hashSet.Contains(key.ToString())) { string message; if (value.IsEmpty()) { value.SetAsFailed(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataNotAvailable, value.LastError).Detail.ToString()); } else if (this.LocalQueueDataTooOld(value.TimeStampOfQueues, out message)) { value.SetAsFailed(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataTooOld, message).Detail.ToString()); } else { queueAggregator.AddLocalQueues(value.Queues, value.TimeStampOfQueues); } list.Add(value.GetServerSnapshotStatus()); } } response = new AggregatedViewResponse(list); response.QueueAggregatedViewResponse = new QueueAggregatedViewResponse(queueAggregator.GetResultSortedByMessageCount(request.ResultSize)); stopwatch.Stop(); this.log.LogOperationFromClient(DiagnosticsAggregationEvent.AggregatedViewResponseSent, request.ClientInformation, new TimeSpan?(stopwatch.Elapsed), ""); }, "GetAggregatedView", request.ClientInformation); return(response); }
private void OnInvokeWebServiceCompleted(IAsyncResult ar) { GetQueueDigestWebServiceImpl.WebServiceRequestAsyncState webServiceRequestAsyncState = (GetQueueDigestWebServiceImpl.WebServiceRequestAsyncState)ar.AsyncState; IDiagnosticsAggregationService client = webServiceRequestAsyncState.Client; ADObjectId serverToConnectTo = webServiceRequestAsyncState.ServerToConnectTo; int dagIndex = webServiceRequestAsyncState.DagIndex; string text = null; LocalizedString? localizedString = null; AggregatedViewResponse aggregatedViewResponse = null; try { if (webServiceRequestAsyncState.FailedOnBegin) { text = webServiceRequestAsyncState.FailedOnBeginException.ToString(); } else { aggregatedViewResponse = client.EndGetAggregatedView(ar); } } catch (FaultException <DiagnosticsAggregationFault> faultException) { text = string.Format("{0}: {1}", faultException.Detail.ErrorCode, faultException.Detail.Message); } catch (CommunicationException ex) { if (GetQueueDigestWebServiceImpl.IsQuotaExceeded(ex)) { localizedString = new LocalizedString?(Strings.GetQueueDigestQuotaExceeded(serverToConnectTo.Name)); } text = ex.ToString(); } catch (TimeoutException ex2) { text = ex2.ToString(); } finally { this.cmdlet.DisposeWebServiceClient(client); } bool flag = false; lock (this) { if (!webServiceRequestAsyncState.IsConnectingToDag || this.pendingRequestsToDag[dagIndex] != 0) { if (aggregatedViewResponse != null) { this.aggregator.AddAggregatedQueues(aggregatedViewResponse.QueueAggregatedViewResponse.AggregatedQueues); if (this.cmdlet.IsVerbose) { foreach (ServerSnapshotStatus serverSnapshotStatus in aggregatedViewResponse.SnapshotStatusOfServers) { this.verboseMessages.Add(new LocalizedString(string.Format("{0}: {1}", serverToConnectTo.Name, serverSnapshotStatus.ToString()))); } } if (webServiceRequestAsyncState.IsConnectingToDag) { this.pendingRequestsToDag[dagIndex] = 0; } } else if (webServiceRequestAsyncState.IsConnectingToDag) { this.pendingRequestsToDag[dagIndex]--; if (this.pendingRequestsToDag[dagIndex] > 0) { flag = true; } else { this.failedToConnectDags.Add(serverToConnectTo.Name); } } else { this.failedToConnectServers.Add(serverToConnectTo.Name); } if (text != null) { this.debugMessages.Add(new LocalizedString(string.Format("{0}: {1}", serverToConnectTo.Name, text))); } if (localizedString != null) { this.warningMessages.Add(localizedString.Value); } if (!flag) { this.webServiceRequestsPending--; } if (this.webServiceRequestsPending == 0) { this.webServiceRequestsDone.Set(); } } } }