public LocalViewResponse GetLocalView(LocalViewRequest request) { LocalViewResponse response = null; this.ServiceRequest(delegate { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ExTraceGlobals.DiagnosticsAggregationTracer.TraceFunction <string, string, string>(0L, "GetLocalView 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()); this.log.LogOperationFromClient(DiagnosticsAggregationEvent.LocalViewRequestReceived, 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"); } ServerQueuesSnapshot localServerQueues = this.localQueuesDataProvider.GetLocalServerQueues(); if (localServerQueues.IsEmpty()) { throw DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataNotAvailable, localServerQueues.LastError); } string message; if (this.LocalQueueDataTooOld(localServerQueues.TimeStampOfQueues, out message)) { throw DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.LocalQueueDataTooOld, message); } response = new LocalViewResponse(localServerQueues.GetServerSnapshotStatus()); response.QueueLocalViewResponse = new QueueLocalViewResponse(new List <LocalQueueInfo>(localServerQueues.Queues), localServerQueues.TimeStampOfQueues); stopwatch.Stop(); this.log.LogOperationFromClient(DiagnosticsAggregationEvent.LocalViewResponseSent, request.ClientInformation, new TimeSpan?(stopwatch.Elapsed), ""); }, "GetLocalView", request.ClientInformation); return(response); }
protected virtual void CheckClientAuthorization() { ServiceSecurityContext serviceSecurityContext = ServiceSecurityContext.Current; bool flag = false; if (serviceSecurityContext == null) { ExTraceGlobals.DiagnosticsAggregationTracer.TraceError((long)this.GetHashCode(), "ServiceSecurityContext is null"); } else if (serviceSecurityContext.WindowsIdentity == null) { ExTraceGlobals.DiagnosticsAggregationTracer.TraceError((long)this.GetHashCode(), "ServiceSecurityContext WindowsIdentity is null"); } else if (!this.HasReadAccessInAd(serviceSecurityContext)) { ExTraceGlobals.DiagnosticsAggregationTracer.TraceError <string>((long)this.GetHashCode(), "User {0} does not have Read access in AD", ServiceSecurityContext.Current.WindowsIdentity.Name); } else { flag = true; } if (!flag) { string empty = string.Empty; if (serviceSecurityContext != null && serviceSecurityContext.WindowsIdentity != null) { string name = serviceSecurityContext.WindowsIdentity.Name; } throw DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.AccessDenied, "Access is Denied"); } }
private static FaultException <DiagnosticsAggregationFault> NewUnsupportedParameterFault(object parameterValue, string parameterName) { string message = string.Format(CultureInfo.InvariantCulture, "parameter [{0}] has an unsupported value [{1}]", new object[] { parameterName, parameterValue }); return(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.UnsupportedParameter, message)); }
private static FaultException <DiagnosticsAggregationFault> NewInvalidParameterFault(object parameterValue, string parameterName) { if (parameterValue == null) { parameterValue = "<null>"; } else if (object.Equals(parameterValue, string.Empty)) { parameterValue = "<empty_string>"; } string message = string.Format(CultureInfo.InvariantCulture, "parameter [{0}] has an invalid value [{1}]", new object[] { parameterName, parameterValue }); return(DiagnosticsAggregationServiceImpl.NewFault(ErrorCode.InvalidParameter, message)); }
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); }