internal void SendStateChangedInformationToClient(PSInvocationStateInfo stateInfo) { this.SendDataAsync(RemotingEncoder.GeneratePowerShellStateInfo(stateInfo, this.clientPowerShellId, this.clientRunspacePoolId)); if (this.clientPowerShellId != Guid.Empty) { this.transportManager.Closing -= new EventHandler(this.HandleTransportClosing); this.transportManager.Close(null); } }
internal void SendStateChangedInformationToClient(PSInvocationStateInfo stateInfo) { using (ServerPowerShellDataStructureHandler.tracer.TraceMethod()) { this.SendDataAsync(RemotingEncoder.GeneratePowerShellStateInfo(stateInfo, this.clientPowerShellId, this.clientRunspacePoolId)); if (!(this.clientPowerShellId != Guid.Empty)) { return; } this.transportManager.Closing -= new EventHandler(this.HandleTransportClosing); this.transportManager.Close((Exception)null); } }
internal static RemoteDataObject GeneratePowerShellStateInfo(PSInvocationStateInfo stateInfo, Guid clientPowerShellId, Guid clientRunspacePoolId) { PSObject data = CreateEmptyPSObject(); PSNoteProperty member = new PSNoteProperty("PipelineState", (int)stateInfo.State); data.Properties.Add(member); if (stateInfo.Reason != null) { string errorId = "RemotePSInvocationStateInfoReason"; PSNoteProperty property2 = GetExceptionProperty(stateInfo.Reason, errorId, ErrorCategory.NotSpecified); data.Properties.Add(property2); } return(RemoteDataObject.CreateFrom(RemotingDestination.InvalidDestination | RemotingDestination.Client, RemotingDataType.PowerShellStateInfo, clientRunspacePoolId, clientPowerShellId, data)); }
internal static RemoteDataObject GeneratePowerShellStateInfo( PSInvocationStateInfo stateInfo, Guid clientPowerShellId, Guid clientRunspacePoolId) { using (RemotingEncoder._trace.TraceMethod()) { PSObject emptyPsObject = RemotingEncoder.CreateEmptyPSObject(); PSNoteProperty psNoteProperty = new PSNoteProperty("PipelineState", (object)(int)stateInfo.State); emptyPsObject.Properties.Add((PSPropertyInfo)psNoteProperty); if (stateInfo.Reason != null) { string errorId = "RemotePSInvocationStateInfoReason"; PSNoteProperty exceptionProperty = RemotingEncoder.GetExceptionProperty(stateInfo.Reason, errorId, ErrorCategory.NotSpecified); emptyPsObject.Properties.Add((PSPropertyInfo)exceptionProperty); } return(RemoteDataObject.CreateFrom(RemotingDestination.Client, RemotingDataType.PowerShellStateInfo, clientRunspacePoolId, clientPowerShellId, (object)emptyPsObject)); } }
/// <summary> /// Send the state information to the client. /// </summary> /// <param name="stateInfo">state information to be /// sent to the client</param> internal void SendStateChangedInformationToClient(PSInvocationStateInfo stateInfo) { Dbg.Assert((stateInfo.State == PSInvocationState.Completed) || (stateInfo.State == PSInvocationState.Failed) || (stateInfo.State == PSInvocationState.Stopped), "SendStateChangedInformationToClient should be called to notify a termination state"); SendDataAsync(RemotingEncoder.GeneratePowerShellStateInfo( stateInfo, _clientPowerShellId, _clientRunspacePoolId)); // Close the transport manager only if the PowerShell Guid != Guid.Empty. // When Guid.Empty is used, PowerShell must be using pool's transport manager // to send data to client. if (_clientPowerShellId != Guid.Empty) { // no need to listen for closing events as we are initiating the close _transportManager.Closing -= HandleTransportClosing; // if terminal state is reached close the transport manager instead of letting // the client initiate the close. _transportManager.Close(null); } }
internal PSInvocationStateChangedEventArgs(PSInvocationStateInfo psStateInfo) { this.executionStateInfo = psStateInfo; }
/// <summary> /// Initializes a new instance of the PooledJobInvocationStateChangedEventArgs class based on the state provided. /// </summary> /// <param name="stateInfo">The state information to provide with the event.</param> internal PooledJobInvocationStateChangedEventArgs(PSInvocationStateInfo stateInfo) { _stateInfo = stateInfo; }
private static Exception CheckInvocationStateInfoForException(PSInvocationStateInfo invokeStateInfo) { if (invokeStateInfo.State != PSInvocationState.Failed) { return null; } else { return invokeStateInfo.Reason; } }
internal void HandleTransportError(object sender, TransportErrorOccuredEventArgs e) { PSInvocationStateInfo data = new PSInvocationStateInfo(PSInvocationState.Failed, e.Exception); this.InvocationStateInfoReceived.SafeInvoke<RemoteDataEventArgs<PSInvocationStateInfo>>(this, new RemoteDataEventArgs<PSInvocationStateInfo>(data)); }
internal void ProcessDisconnect(RunspacePoolStateInfo rsStateInfo) { PSInvocationStateInfo data = new PSInvocationStateInfo(PSInvocationState.Disconnected, (rsStateInfo != null) ? rsStateInfo.Reason : null); this.InvocationStateInfoReceived.SafeInvoke<RemoteDataEventArgs<PSInvocationStateInfo>>(this, new RemoteDataEventArgs<PSInvocationStateInfo>(data)); Interlocked.CompareExchange(ref this.connectionState, 3, 1); }
/// <summary> /// Send the state information to the client /// </summary> /// <param name="stateInfo">state information to be /// sent to the client</param> internal void SendStateChangedInformationToClient(PSInvocationStateInfo stateInfo) { Dbg.Assert((stateInfo.State == PSInvocationState.Completed) || (stateInfo.State == PSInvocationState.Failed) || (stateInfo.State == PSInvocationState.Stopped), "SendStateChangedInformationToClient should be called to notify a termination state"); SendDataAsync(RemotingEncoder.GeneratePowerShellStateInfo( stateInfo, _clientPowerShellId, _clientRunspacePoolId)); // Close the transport manager only if the PowerShell Guid != Guid.Empty. // When Guid.Empty is used, PowerShell must be using pool's transport manager // to send data to client. if (_clientPowerShellId != Guid.Empty) { // no need to listen for closing events as we are initiating the close _transportManager.Closing -= HandleTransportClosing; // if terminal state is reached close the transport manager instead of letting // the client initiate the close. _transportManager.Close(null); } }
internal PSInvocationStateChangedEventArgs(PSInvocationStateInfo psStateInfo) { throw new NotImplementedException(); }
internal void SetStateInfo(PSInvocationStateInfo stateInfo) { this.shell.SetStateChanged(stateInfo); }