Example #1
0
 private void HandleErrorReady(object sender, EventArgs eventArgs)
 {
     PSDataCollectionPipelineReader<ErrorRecord, object> reader = sender as PSDataCollectionPipelineReader<ErrorRecord, object>;
     foreach (object obj2 in reader.NonBlockingRead())
     {
         ErrorRecord errorRecord = obj2 as ErrorRecord;
         if (errorRecord != null)
         {
             OriginInfo originInfo = new OriginInfo(reader.ComputerName, reader.RunspaceId);
             RemotingErrorRecord record2 = new RemotingErrorRecord(errorRecord, originInfo) {
                 PreserveInvocationInfoOnce = true
             };
             this.WriteError(record2);
         }
     }
 }
Example #2
0
		internal static ErrorRecord InitializeErrorRecordCore(InvocationContext context, Exception exception, string errorId, ErrorCategory errorCategory, CimResultContext cimResultContext)
		{
			object errorSource = null;
			if (cimResultContext != null)
			{
				errorSource = cimResultContext.ErrorSource;
			}
			if (errorSource == null && context != null && context.TargetCimInstance != null)
			{
				errorSource = context.TargetCimInstance;
			}
			ErrorRecord errorRecord = new ErrorRecord(exception, errorId, errorCategory, errorSource);
			if (context != null)
			{
				OriginInfo originInfo = new OriginInfo(context.ComputerName, Guid.Empty);
				ErrorRecord remotingErrorRecord = new RemotingErrorRecord(errorRecord, originInfo);
				DebugHelper.WriteLogEx("Created RemotingErrorRecord.", 0);
				return remotingErrorRecord;
			}
			else
			{
				return errorRecord;
			}
		}
Example #3
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);
            }
        }