private NamedPipeClientStream PrepareClientStream()
        {
            NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", CacheApplicationManager.GetAppPipeName(this.Application), PipeDirection.InOut);

            try
            {
                namedPipeClientStream.Connect(2000);
            }
            catch (TimeoutException)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorConnectToApplicationTimeout(this.Application, this.Server)), (ErrorCategory)1002, null);
            }
            return(namedPipeClientStream);
        }
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            base.CheckExclusiveParameters(new object[]
            {
                "Organizations",
                "CurrentOrganization"
            });
            if (!CacheApplicationManager.IsApplicationDefined(this.Application))
            {
                base.WriteError(new ArgumentException(Strings.ErrorApplicationNotDefined(this.Application)), (ErrorCategory)1000, null);
            }
            ICollection <Guid> collection     = this.ResolveOrganizations();
            DiagnosticType     diagnosticType = this.GetDiagnosticType();
            DiagnosticType     command        = diagnosticType;
            ICollection <Guid> orgIds         = collection;
            ICollection <Guid> entries;

            if (this.CacheKeys != null)
            {
                ICollection <Guid> cacheKeys = this.CacheKeys;
                entries = cacheKeys;
            }
            else
            {
                entries = new List <Guid>();
            }
            DiagnosticCommand diagnosticCommand = new DiagnosticCommand(command, orgIds, entries);

            using (NamedPipeClientStream namedPipeClientStream = this.PrepareClientStream())
            {
                byte[] array  = diagnosticCommand.ToSendMessage();
                byte[] array2 = new byte[5000];
                try
                {
                    namedPipeClientStream.Write(array, 0, array.Length);
                    namedPipeClientStream.Flush();
                    int num;
                    do
                    {
                        Array.Clear(array2, 0, array2.Length);
                        num = namedPipeClientStream.Read(array2, 0, array2.Length);
                        if (num > 0)
                        {
                            this.ProcessReceivedData(array2, num);
                        }
                    }while (num > 0 && namedPipeClientStream.IsConnected);
                }
                catch (IOException exception)
                {
                    base.WriteError(exception, (ErrorCategory)1001, null);
                }
                catch (ObjectDisposedException exception2)
                {
                    base.WriteError(exception2, (ErrorCategory)1001, null);
                }
                catch (NotSupportedException exception3)
                {
                    base.WriteError(exception3, (ErrorCategory)1001, null);
                }
                catch (InvalidOperationException exception4)
                {
                    base.WriteError(exception4, (ErrorCategory)1001, null);
                }
            }
        }