internal PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus notification, string computerName, int maxRetryConnectionTime, object infoRecord)
 {
     this._notification           = notification;
     this._computerName           = computerName;
     this._maxRetryConnectionTime = maxRetryConnectionTime;
     this._infoRecord             = infoRecord;
 }
 internal PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus notification, string computerName, int maxRetryConnectionTime, object infoRecord)
 {
     this._notification = notification;
     this._computerName = computerName;
     this._maxRetryConnectionTime = maxRetryConnectionTime;
     this._infoRecord = infoRecord;
 }
Пример #3
0
 internal PSConnectionRetryStatusEventArgs(
     PSConnectionRetryStatus notification,
     string computerName,
     int maxRetryConnectionTime,
     object infoRecord)
 {
     Notification           = notification;
     ComputerName           = computerName;
     MaxRetryConnectionTime = maxRetryConnectionTime;
     InformationRecord      = infoRecord;
 }
Пример #4
0
        internal void StopAsync()
        {
            PSConnectionRetryStatus connectionRetryStatus = this.connectionRetryStatus;

            if (((connectionRetryStatus == PSConnectionRetryStatus.NetworkFailureDetected) || (connectionRetryStatus == PSConnectionRetryStatus.ConnectionRetryAttempt)) && (this.runspacePool.RunspacePoolStateInfo.State == RunspacePoolState.Opened))
            {
                this.runspacePool.BeginDisconnect(null, null);
            }
            else
            {
                this.stopCalled = true;
                this.dataStructureHandler.SendStopPowerShellMessage();
            }
        }
Пример #5
0
        /// <summary>
        /// Stop the remote powershell asynchronously
        /// </summary>
        /// <remarks>This method will be called from
        /// within the lock on PowerShell. Hence no need
        /// to lock</remarks>
        internal void StopAsync()
        {
            // If we are in robust connection retry mode then auto-disconnect this command
            // rather than try to stop it.
            PSConnectionRetryStatus retryStatus = _connectionRetryStatus;

            if ((retryStatus == PSConnectionRetryStatus.NetworkFailureDetected ||
                 retryStatus == PSConnectionRetryStatus.ConnectionRetryAttempt) &&
                this.runspacePool.RunspacePoolStateInfo.State == RunspacePoolState.Opened)
            {
                // While in robust connection retry mode, this call forces robust connections
                // to abort retries and go directly to auto-disconnect.
                this.runspacePool.BeginDisconnect(null, null);
                return;
            }

            // powershell CoreStop would have handled cases
            // for NotStarted, Stopping and already Stopped
            // so at this point, there is no need to make any
            // check. The message simply needs to be sent
            // across to the server
            stopCalled = true;
            dataStructureHandler.SendStopPowerShellMessage();
        }
Пример #6
0
 internal PSConnectionRetryStatusEventArgs(
     PSConnectionRetryStatus notification,
     string computerName,
     int maxRetryConnectionTime,
     object infoRecord)
 {
     Notification = notification;
     ComputerName = computerName;
     MaxRetryConnectionTime = maxRetryConnectionTime;
     InformationRecord = infoRecord;
 }
Пример #7
0
        private void HandleRobustConnectionNotification(object sender, ConnectionStatusEventArgs e)
        {
            PSConnectionRetryStatusEventArgs eventArgs = null;
            WarningRecord infoRecord             = null;
            ErrorRecord   record2                = null;
            int           maxRetryConnectionTime = this.runspacePool.MaxRetryConnectionTime;
            int           num2 = maxRetryConnectionTime / 0xea60;

            switch (e.Notification)
            {
            case ConnectionStatus.NetworkFailureDetected:
                infoRecord = new WarningRecord("PowerShellNetworkFailureDetected", StringUtil.Format(RemotingErrorIdStrings.RCNetworkFailureDetected, this.computerName, num2));
                eventArgs  = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.NetworkFailureDetected, this.computerName, maxRetryConnectionTime, infoRecord);
                break;

            case ConnectionStatus.ConnectionRetryAttempt:
                infoRecord = new WarningRecord("PowerShellConnectionRetryAttempt", StringUtil.Format(RemotingErrorIdStrings.RCConnectionRetryAttempt, this.computerName));
                eventArgs  = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.ConnectionRetryAttempt, this.computerName, maxRetryConnectionTime, infoRecord);
                break;

            case ConnectionStatus.ConnectionRetrySucceeded:
                infoRecord = new WarningRecord("PowerShellConnectionRetrySucceeded", StringUtil.Format(RemotingErrorIdStrings.RCReconnectSucceeded, this.computerName));
                eventArgs  = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.ConnectionRetrySucceeded, this.computerName, num2, infoRecord);
                break;

            case ConnectionStatus.AutoDisconnectStarting:
                infoRecord = new WarningRecord("PowerShellNetworkFailedStartDisconnect", StringUtil.Format(RemotingErrorIdStrings.RCAutoDisconnectingWarning, this.computerName));
                eventArgs  = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.AutoDisconnectStarting, this.computerName, num2, infoRecord);
                break;

            case ConnectionStatus.AutoDisconnectSucceeded:
                infoRecord = new WarningRecord("PowerShellAutoDisconnectSucceeded", StringUtil.Format(RemotingErrorIdStrings.RCAutoDisconnected, this.computerName));
                eventArgs  = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.AutoDisconnectSucceeded, this.computerName, num2, infoRecord);
                break;

            case ConnectionStatus.InternalErrorAbort:
            {
                RuntimeException exception = new RuntimeException(StringUtil.Format(RemotingErrorIdStrings.RCInternalError, this.computerName));
                record2   = new ErrorRecord(exception, "PowerShellNetworkOrDisconnectFailed", ErrorCategory.InvalidOperation, this);
                eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.InternalErrorAbort, this.computerName, num2, record2);
                break;
            }
            }
            if (eventArgs != null)
            {
                this.connectionRetryStatus = eventArgs.Notification;
                if (infoRecord != null)
                {
                    RemotingWarningRecord message = new RemotingWarningRecord(infoRecord, new OriginInfo(this.computerName, this.InstanceId));
                    this.HandleInformationalMessageReceived(this, new RemoteDataEventArgs <InformationalMessage>(new InformationalMessage(message, RemotingDataType.PowerShellWarning)));
                    RemoteHostCall data = new RemoteHostCall(-100L, RemoteHostMethodId.WriteWarningLine, new object[] { infoRecord.Message });
                    try
                    {
                        this.HandleHostCallReceived(this, new RemoteDataEventArgs <RemoteHostCall>(data));
                    }
                    catch (PSNotImplementedException)
                    {
                    }
                }
                if (record2 != null)
                {
                    RemotingErrorRecord record4 = new RemotingErrorRecord(record2, new OriginInfo(this.computerName, this.InstanceId));
                    this.HandleErrorReceived(this, new RemoteDataEventArgs <ErrorRecord>(record4));
                }
                this.RCConnectionNotification.SafeInvoke <PSConnectionRetryStatusEventArgs>(this, eventArgs);
            }
        }
Пример #8
0
        private void HandleRobustConnectionNotification(object sender, ConnectionStatusEventArgs e)
        {
            PSConnectionRetryStatusEventArgs eventArgs = null;
            WarningRecord infoRecord = null;
            ErrorRecord record2 = null;
            int maxRetryConnectionTime = this.runspacePool.MaxRetryConnectionTime;
            int num2 = maxRetryConnectionTime / 0xea60;
            switch (e.Notification)
            {
                case ConnectionStatus.NetworkFailureDetected:
                    infoRecord = new WarningRecord("PowerShellNetworkFailureDetected", StringUtil.Format(RemotingErrorIdStrings.RCNetworkFailureDetected, this.computerName, num2));
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.NetworkFailureDetected, this.computerName, maxRetryConnectionTime, infoRecord);
                    break;

                case ConnectionStatus.ConnectionRetryAttempt:
                    infoRecord = new WarningRecord("PowerShellConnectionRetryAttempt", StringUtil.Format(RemotingErrorIdStrings.RCConnectionRetryAttempt, this.computerName));
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.ConnectionRetryAttempt, this.computerName, maxRetryConnectionTime, infoRecord);
                    break;

                case ConnectionStatus.ConnectionRetrySucceeded:
                    infoRecord = new WarningRecord("PowerShellConnectionRetrySucceeded", StringUtil.Format(RemotingErrorIdStrings.RCReconnectSucceeded, this.computerName));
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.ConnectionRetrySucceeded, this.computerName, num2, infoRecord);
                    break;

                case ConnectionStatus.AutoDisconnectStarting:
                    infoRecord = new WarningRecord("PowerShellNetworkFailedStartDisconnect", StringUtil.Format(RemotingErrorIdStrings.RCAutoDisconnectingWarning, this.computerName));
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.AutoDisconnectStarting, this.computerName, num2, infoRecord);
                    break;

                case ConnectionStatus.AutoDisconnectSucceeded:
                    infoRecord = new WarningRecord("PowerShellAutoDisconnectSucceeded", StringUtil.Format(RemotingErrorIdStrings.RCAutoDisconnected, this.computerName));
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.AutoDisconnectSucceeded, this.computerName, num2, infoRecord);
                    break;

                case ConnectionStatus.InternalErrorAbort:
                {
                    RuntimeException exception = new RuntimeException(StringUtil.Format(RemotingErrorIdStrings.RCInternalError, this.computerName));
                    record2 = new ErrorRecord(exception, "PowerShellNetworkOrDisconnectFailed", ErrorCategory.InvalidOperation, this);
                    eventArgs = new PSConnectionRetryStatusEventArgs(PSConnectionRetryStatus.InternalErrorAbort, this.computerName, num2, record2);
                    break;
                }
            }
            if (eventArgs != null)
            {
                this.connectionRetryStatus = eventArgs.Notification;
                if (infoRecord != null)
                {
                    RemotingWarningRecord message = new RemotingWarningRecord(infoRecord, new OriginInfo(this.computerName, this.InstanceId));
                    this.HandleInformationalMessageReceived(this, new RemoteDataEventArgs<InformationalMessage>(new InformationalMessage(message, RemotingDataType.PowerShellWarning)));
                    RemoteHostCall data = new RemoteHostCall(-100L, RemoteHostMethodId.WriteWarningLine, new object[] { infoRecord.Message });
                    try
                    {
                        this.HandleHostCallReceived(this, new RemoteDataEventArgs<RemoteHostCall>(data));
                    }
                    catch (PSNotImplementedException)
                    {
                    }
                }
                if (record2 != null)
                {
                    RemotingErrorRecord record4 = new RemotingErrorRecord(record2, new OriginInfo(this.computerName, this.InstanceId));
                    this.HandleErrorReceived(this, new RemoteDataEventArgs<ErrorRecord>(record4));
                }
                this.RCConnectionNotification.SafeInvoke<PSConnectionRetryStatusEventArgs>(this, eventArgs);
            }
        }