Beispiel #1
0
 private RemotingErrorRecord(ErrorRecord errorRecord, System.Management.Automation.Remoting.OriginInfo originInfo, Exception replaceParentContainsErrorRecordException) : base(errorRecord, replaceParentContainsErrorRecordException)
 {
     if (errorRecord != null)
     {
         base.SetInvocationInfo(errorRecord.InvocationInfo);
     }
     this._originInfo = originInfo;
 }
 private RemotingErrorRecord(ErrorRecord errorRecord, System.Management.Automation.Remoting.OriginInfo originInfo, Exception replaceParentContainsErrorRecordException) : base(errorRecord, replaceParentContainsErrorRecordException)
 {
     if (errorRecord != null)
     {
         base.SetInvocationInfo(errorRecord.InvocationInfo);
     }
     this._originInfo = originInfo;
 }
Beispiel #3
0
        /// <summary>
        /// constructor that is used to wrap an error record
        /// </summary>
        /// <param name="errorRecord"></param>
        /// <param name="originInfo"></param>
        /// <param name="replaceParentContainsErrorRecordException"></param>
        private RemotingErrorRecord(ErrorRecord errorRecord, OriginInfo originInfo, Exception replaceParentContainsErrorRecordException) :
            base(errorRecord, replaceParentContainsErrorRecordException)
        {
            if (null != errorRecord)
            {
                base.SetInvocationInfo(errorRecord.InvocationInfo);
            }

            _originInfo = originInfo;
        }
Beispiel #4
0
 public RemotingProgressRecord(ProgressRecord progressRecord, System.Management.Automation.Remoting.OriginInfo originInfo) : base(Validate(progressRecord).ActivityId, Validate(progressRecord).Activity, Validate(progressRecord).StatusDescription)
 {
     this._originInfo = originInfo;
     if (progressRecord != null)
     {
         base.PercentComplete  = progressRecord.PercentComplete;
         base.ParentActivityId = progressRecord.ParentActivityId;
         base.RecordType       = progressRecord.RecordType;
         base.SecondsRemaining = progressRecord.SecondsRemaining;
         if (!string.IsNullOrEmpty(progressRecord.CurrentOperation))
         {
             base.CurrentOperation = progressRecord.CurrentOperation;
         }
     }
 }
 public RemotingProgressRecord(ProgressRecord progressRecord, System.Management.Automation.Remoting.OriginInfo originInfo) : base(Validate(progressRecord).ActivityId, Validate(progressRecord).Activity, Validate(progressRecord).StatusDescription)
 {
     this._originInfo = originInfo;
     if (progressRecord != null)
     {
         base.PercentComplete = progressRecord.PercentComplete;
         base.ParentActivityId = progressRecord.ParentActivityId;
         base.RecordType = progressRecord.RecordType;
         base.SecondsRemaining = progressRecord.SecondsRemaining;
         if (!string.IsNullOrEmpty(progressRecord.CurrentOperation))
         {
             base.CurrentOperation = progressRecord.CurrentOperation;
         }
     }
 }
Beispiel #6
0
		private void InitializeErrorRecordCore(CimJobContext jobContext, Exception exception, string errorId, ErrorCategory errorCategory)
		{
			object targetObject;
			Exception exception1 = exception;
			string str = errorId;
			ErrorCategory errorCategory1 = errorCategory;
			if (jobContext != null)
			{
				targetObject = jobContext.TargetObject;
			}
			else
			{
				targetObject = null;
			}
			ErrorRecord errorRecord = new ErrorRecord(exception1, str, errorCategory1, targetObject);
			if (jobContext == null)
			{
				this.errorRecord = errorRecord;
				return;
			}
			else
			{
				OriginInfo originInfo = new OriginInfo(jobContext.Session.ComputerName, Guid.Empty);
				this.errorRecord = new RemotingErrorRecord(errorRecord, originInfo);
				this.errorRecord.SetInvocationInfo(jobContext.CmdletInvocationInfo);
				this.errorRecord.PreserveInvocationInfoOnce = true;
				return;
			}
		}
Beispiel #7
0
 /// <summary>
 /// Deserializer constructor.
 /// </summary>
 /// <param name="info">Serializer information</param>
 /// <param name="context">Streaming context</param>
 protected RemotingErrorRecord(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _originInfo = (OriginInfo)info.GetValue("RemoteErrorRecord_OriginInfo", typeof(OriginInfo));
 }
Beispiel #8
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="errorRecord">the error record that is wrapped</param>
 /// <param name="originInfo">origin information</param>
 public RemotingErrorRecord(ErrorRecord errorRecord, OriginInfo originInfo) : this(errorRecord, originInfo, null) { }
 public RemotingWarningRecord(string message, System.Management.Automation.Remoting.OriginInfo originInfo) : base(message)
 {
     this._originInfo = originInfo;
 }
Beispiel #10
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;
			}
		}
Beispiel #11
0
 /// <summary>
 /// Constructor taking WarningRecord to wrap and OriginInfo.
 /// </summary>
 /// <param name="warningRecord">WarningRecord to wrap</param>
 /// <param name="originInfo">OriginInfo</param>
 internal RemotingWarningRecord(
     WarningRecord warningRecord,
     OriginInfo originInfo)
     : base(warningRecord.FullyQualifiedWarningId, warningRecord.Message)
 {
     _originInfo = originInfo;
 }
Beispiel #12
0
 protected RemotingErrorRecord(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this._originInfo = (System.Management.Automation.Remoting.OriginInfo) info.GetValue("RemoteErrorRecord_OriginInfo", typeof(System.Management.Automation.Remoting.OriginInfo));
 }
Beispiel #13
0
 protected void ProcessJobFailure(ExecutionCmdletHelper helper, out Exception failureException, out ErrorRecord failureErrorRecord)
 {
     RemotePipeline pipeline = helper.Pipeline as RemotePipeline;
     RemoteRunspace runspace = pipeline.GetRunspace() as RemoteRunspace;
     failureException = null;
     failureErrorRecord = null;
     if (helper.InternalException != null)
     {
         string errorId = "RemotePipelineExecutionFailed";
         failureException = helper.InternalException;
         if ((failureException is InvalidRunspaceStateException) || (failureException is InvalidRunspacePoolStateException))
         {
             errorId = "InvalidSessionState";
             if (!string.IsNullOrEmpty(failureException.Source))
             {
                 errorId = string.Format(CultureInfo.InvariantCulture, "{0},{1}", new object[] { errorId, failureException.Source });
             }
         }
         failureErrorRecord = new ErrorRecord(helper.InternalException, errorId, ErrorCategory.OperationStopped, helper);
     }
     else if (runspace.RunspaceStateInfo.State == RunspaceState.Broken)
     {
         failureException = runspace.RunspaceStateInfo.Reason;
         object computerName = runspace.ConnectionInfo.ComputerName;
         string str2 = null;
         PSRemotingTransportException exception = failureException as PSRemotingTransportException;
         string fQEIDFromTransportError = WSManTransportManagerUtils.GetFQEIDFromTransportError((exception != null) ? exception.ErrorCode : 0, "PSSessionStateBroken");
         if (exception != null)
         {
             str2 = "[" + runspace.ConnectionInfo.ComputerName + "] ";
             if (exception.ErrorCode == -2144108135)
             {
                 string str4 = PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.URIRedirectionReported, new object[] { exception.Message, "MaximumConnectionRedirectionCount", "PSSessionOption", "AllowRedirection" });
                 str2 = str2 + str4;
             }
             else if (!string.IsNullOrEmpty(exception.Message))
             {
                 str2 = str2 + exception.Message;
             }
             else if (!string.IsNullOrEmpty(exception.TransportMessage))
             {
                 str2 = str2 + exception.TransportMessage;
             }
         }
         if (failureException == null)
         {
             failureException = new RuntimeException(PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.RemoteRunspaceOpenUnknownState, new object[] { runspace.RunspaceStateInfo.State }));
         }
         failureErrorRecord = new ErrorRecord(failureException, computerName, fQEIDFromTransportError, ErrorCategory.OpenError, null, null, null, null, null, str2, null);
     }
     else if (pipeline.PipelineStateInfo.State == PipelineState.Failed)
     {
         object targetObject = runspace.ConnectionInfo.ComputerName;
         failureException = pipeline.PipelineStateInfo.Reason;
         if (failureException != null)
         {
             RemoteException exception2 = failureException as RemoteException;
             ErrorRecord errorRecord = null;
             if (exception2 != null)
             {
                 errorRecord = exception2.ErrorRecord;
             }
             else
             {
                 errorRecord = new ErrorRecord(pipeline.PipelineStateInfo.Reason, "JobFailure", ErrorCategory.OperationStopped, targetObject);
             }
             string str5 = ((RemoteRunspace) pipeline.GetRunspace()).ConnectionInfo.ComputerName;
             Guid instanceId = pipeline.GetRunspace().InstanceId;
             OriginInfo originInfo = new OriginInfo(str5, instanceId);
             failureErrorRecord = new RemotingErrorRecord(errorRecord, originInfo);
         }
     }
 }
Beispiel #14
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);
         }
     }
 }
 public RemotingErrorRecord(ErrorRecord errorRecord, System.Management.Automation.Remoting.OriginInfo originInfo) : this(errorRecord, originInfo, null)
 {
 }
 protected RemotingErrorRecord(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this._originInfo = (System.Management.Automation.Remoting.OriginInfo)info.GetValue("RemoteErrorRecord_OriginInfo", typeof(System.Management.Automation.Remoting.OriginInfo));
 }
Beispiel #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="message">The debug message that is wrapped</param>
 /// <param name="originInfo">The origin information</param>
 public RemotingDebugRecord(string message, OriginInfo originInfo) : base(message)
 {
     _originInfo = originInfo;
 }
Beispiel #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="message">The verbose message that is wrapped</param>
 /// <param name="originInfo">The origin information</param>
 public RemotingVerboseRecord(string message, OriginInfo originInfo) : base(message)
 {
     _originInfo = originInfo;
 }
Beispiel #19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="record">The Information message that is wrapped</param>
 /// <param name="originInfo">The origin information</param>
 public RemotingInformationRecord(InformationRecord record, OriginInfo originInfo)
     : base(record)
 {
     _originInfo = originInfo;
 }
Beispiel #20
0
        internal void WriteStreamObject(Cmdlet cmdlet, Guid instanceId, bool overrideInquire = false)
        {
            switch (this.ObjectType)
            {
            case PSStreamObjectType.Output:
                if (instanceId != Guid.Empty)
                {
                    PSObject psObj = this.Value as PSObject;
                    if (psObj != null)
                    {
                        AddSourceJobNoteProperty(psObj, instanceId);
                    }
                }
                cmdlet.WriteObject(this.Value);
                return;

            case PSStreamObjectType.Error:
            {
                ErrorRecord errorRecord = (ErrorRecord)this.Value;
                if ((!(errorRecord is RemotingErrorRecord) && (errorRecord.ErrorDetails != null)) && !string.IsNullOrEmpty(errorRecord.ErrorDetails.RecommendedAction))
                {
                    string str;
                    Guid   guid;
                    GetIdentifierInfo(errorRecord.ErrorDetails.RecommendedAction, out guid, out str);
                    errorRecord = new RemotingErrorRecord(errorRecord, new OriginInfo(str, Guid.Empty, guid));
                }
                errorRecord.PreserveInvocationInfoOnce = true;
                MshCommandRuntime commandRuntime = cmdlet.CommandRuntime as MshCommandRuntime;
                if (commandRuntime == null)
                {
                    break;
                }
                commandRuntime.WriteError(errorRecord, overrideInquire);
                return;
            }

            case PSStreamObjectType.MethodExecutor:
            case PSStreamObjectType.BlockingError:
            case PSStreamObjectType.ShouldMethod:
            case PSStreamObjectType.WarningRecord:
                this.WriteStreamObject(cmdlet, overrideInquire);
                break;

            case PSStreamObjectType.Warning:
            {
                string            message  = (string)this.Value;
                WarningRecord     record   = new WarningRecord(message);
                MshCommandRuntime runtime2 = cmdlet.CommandRuntime as MshCommandRuntime;
                if (runtime2 == null)
                {
                    break;
                }
                runtime2.WriteWarning(record, overrideInquire);
                return;
            }

            case PSStreamObjectType.Debug:
            {
                string            str5     = (string)this.Value;
                DebugRecord       record7  = new DebugRecord(str5);
                MshCommandRuntime runtime5 = cmdlet.CommandRuntime as MshCommandRuntime;
                if (runtime5 == null)
                {
                    break;
                }
                runtime5.WriteDebug(record7, overrideInquire);
                return;
            }

            case PSStreamObjectType.Progress:
            {
                ProgressRecord progressRecord = (ProgressRecord)this.Value;
                if (!(progressRecord is RemotingProgressRecord))
                {
                    Guid   guid2;
                    string str4;
                    GetIdentifierInfo(progressRecord.CurrentOperation, out guid2, out str4);
                    OriginInfo originInfo = new OriginInfo(str4, Guid.Empty, guid2);
                    progressRecord = new RemotingProgressRecord(progressRecord, originInfo);
                }
                MshCommandRuntime runtime4 = cmdlet.CommandRuntime as MshCommandRuntime;
                if (runtime4 == null)
                {
                    break;
                }
                runtime4.WriteProgress(progressRecord, overrideInquire);
                return;
            }

            case PSStreamObjectType.Verbose:
            {
                string            str3     = (string)this.Value;
                VerboseRecord     record4  = new VerboseRecord(str3);
                MshCommandRuntime runtime3 = cmdlet.CommandRuntime as MshCommandRuntime;
                if (runtime3 == null)
                {
                    break;
                }
                runtime3.WriteVerbose(record4, overrideInquire);
                return;
            }

            default:
                return;
            }
        }
 internal RemotingWarningRecord(WarningRecord warningRecord, System.Management.Automation.Remoting.OriginInfo originInfo) : base(warningRecord.FullyQualifiedWarningId, warningRecord.Message)
 {
     this._originInfo = originInfo;
 }