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);
     }
 }
예제 #3
0
        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));
        }
예제 #4
0
 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;
 }
예제 #7
0
 /// <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;
 }
 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);
     }
 }
예제 #9
0
파일: PSCommand.cs 프로젝트: nickchal/pash
		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);
 }
 internal PSInvocationStateChangedEventArgs(PSInvocationStateInfo psStateInfo)
 {
     this.executionStateInfo = psStateInfo;
 }
예제 #13
0
        /// <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();
 }
예제 #15
0
 internal void SetStateInfo(PSInvocationStateInfo stateInfo)
 {
     this.shell.SetStateChanged(stateInfo);
 }