private static void VerifyParameterIsNotNullOrEmpty(string parameterValue, string parameterName)
 {
     if (string.IsNullOrEmpty(parameterValue))
     {
         throw DiagnosticsAggregationServiceImpl.NewInvalidParameterFault(parameterValue, parameterName);
     }
 }
 private static void VerifyParameterIsNotNull(object parameterValue, string parameterName)
 {
     if (parameterValue == null)
     {
         throw DiagnosticsAggregationServiceImpl.NewInvalidParameterFault(parameterValue, parameterName);
     }
 }
        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);
        }