Beispiel #1
0
 private void LocalPipeline_StateChanged(object sender, PipelineStateEventArgs e)
 {
     if ((e.PipelineStateInfo.State == PipelineState.Stopping) && (this.powerShell.InvocationStateInfo.State == PSInvocationState.Running))
     {
         this.powerShell.Stop();
     }
 }
 private void HandlePipelineStateChanged(object sender, PipelineStateEventArgs stateEventArgs)
 {
     switch (stateEventArgs.PipelineStateInfo.State)
     {
         case PipelineState.NotStarted:
         case PipelineState.Running:
         case PipelineState.Stopping:
         case PipelineState.Disconnected:
             return;
     }
     this.SendStopComplete(stateEventArgs);
 }
 private void HandlePipelineStateChanged(object sender, PipelineStateEventArgs stateEventArgs)
 {
     switch (stateEventArgs.PipelineStateInfo.State)
     {
         case PipelineState.Stopped:
         case PipelineState.Completed:
         case PipelineState.Failed:
             if (this.remoteRunspace != null)
             {
                 this.remoteRunspace.CloseAsync();
             }
             return;
     }
 }
Beispiel #4
0
        //private psguifo
        
//        public UiaPSHost()
//        {
//        }

        private void pipeline_StateChanged(object sender, PipelineStateEventArgs e)
        {
            Pipeline source = sender as Pipeline;
            // if the command completed update GUI.
            bool updateGUI = false;
            StringBuilder output = new StringBuilder();
            if (e.PipelineStateInfo.State == PipelineState.Completed)
            {
                updateGUI = true;
                Collection<PSObject> results = source.Output.ReadToEnd();
                foreach (PSObject result in results)
                {
                    string resultString = (string)LanguagePrimitives.ConvertTo(result, typeof(string));
                    output.Append(resultString);
                }
            }
            else if ((e.PipelineStateInfo.State == PipelineState.Stopped) ||
                     (e.PipelineStateInfo.State == PipelineState.Failed))
            {
                updateGUI = true;
                string message = string.Format("Command did not complete successfully. Reason: {0}",
                    e.PipelineStateInfo.Reason.Message);
                MessageBox.Show(message);
            }

            if (updateGUI)
            {
//                PSGUIForm.SetOutputTextBoxContentDelegate optDelegate =
//                    new PSGUIForm.SetOutputTextBoxContentDelegate(gui.SetOutputTextBoxContent);
//                gui.OutputTextBox.Invoke(optDelegate, new object[] { output.ToString() });
//
//                PSGUIForm.SetInvokeButtonStateDelegate invkBtnDelegate =
//                    new PSGUIForm.SetInvokeButtonStateDelegate(gui.SetInvokeButtonState);
//                gui.InvokeButton.Invoke(invkBtnDelegate, new object[] { true });
            }
        }
Beispiel #5
0
        } // HandleRunspaceStateChanged

        /// <summary>
        /// Handles the state changed event for the pipeline.
        /// </summary>
        /// <param name="sender">sender of this information</param>
        /// <param name="stateEventArgs">object describing this event</param>
        private void HandlePipelineStateChanged(object sender,
                        PipelineStateEventArgs stateEventArgs)
        {
            PipelineState state = stateEventArgs.PipelineStateInfo.State;

            switch (state)
            {
                case PipelineState.Running:
                case PipelineState.NotStarted:
                case PipelineState.Stopping:
                    return;

                case PipelineState.Completed:
                case PipelineState.Stopped:
                case PipelineState.Failed:
                    if (RemoteRunspace != null)
                    {
                        RemoteRunspace.CloseAsync();
                    }
                    break;
            } // switch(state...
        } // HandlePipelineStateChanged
Beispiel #6
0
        /// <summary>
        /// Handles the state changed events for the pipeline. This is registered in both
        /// StartOperation and StopOperation. Here nothing more is done excepting raising
        /// the OperationComplete event appropriately which will be handled by the cmdlet
        /// </summary>
        /// <param name="sender">source of this event</param>
        /// <param name="stateEventArgs">object describing state information about the
        /// pipeline</param>
        private void HandlePipelineStateChanged(object sender, PipelineStateEventArgs stateEventArgs)
        {
            PipelineStateInfo stateInfo = stateEventArgs.PipelineStateInfo;

            switch (stateInfo.State)
            {
                case PipelineState.Running:
                case PipelineState.NotStarted:
                case PipelineState.Stopping:
                case PipelineState.Disconnected:
                    return;
            }

            RaiseOperationCompleteEvent(stateEventArgs);
        } // HandlePipelineStateChanged
 void onPipelineStateChanged(object sender, PipelineStateEventArgs e)
 {
     switch (e.PipelineStateInfo.State)
     {
         case PipelineState.Completed:
         case PipelineState.Failed:
         case PipelineState.Stopped:
             // Fire event indicating execution of the pipeline is 
             // finished.
             executionDone.Signal(e.PipelineStateInfo.Reason?.Message);
             break;
     }
 }
Beispiel #8
0
//        static void PipelineStateChanged() //PipelineStateEventArgs e)
//        {
//            System.Console.WriteLine("===================sdf================");
//            //System.Console.WriteLine(e.ToString());
//        }
        
        static void pipeline_StateChanged(object sender, PipelineStateEventArgs e)
        {
            /*
            if (e.PipelineStateInfo.State == PipelineState.Failed)
//                Console.WriteLine(e.PipelineStateInfo.Reason);
//                //Console.WriteLine("The pipeline has {0} error!", PsPipeline.Error.Count);
//                Console.WriteLine("The pipeline has {0} error!", pipeline.Error.Count);
                
                PSErrorThrown(e.PipelineStateInfo.Reason.Message);
            else if (e.PipelineStateInfo.State == PipelineState.Completed)
                OnPSCodeCompleted("");
//            } else if (e.PipelineStateInfo.State == PipelineState.Disconnected) {
//                OnPSDisconnected(e.PipelineStateInfo.Reason.Message);
            else if (e.PipelineStateInfo.State == PipelineState.NotStarted)
                OnPSCodeNotStarted(e.PipelineStateInfo.Reason.Message);
            else if (e.PipelineStateInfo.State == PipelineState.Running)
                OnPSCodeRunning("");
            else if (e.PipelineStateInfo.State == PipelineState.Stopped)
                OnPSCodeStopped(e.PipelineStateInfo.Reason.Message);
            else if (e.PipelineStateInfo.State == PipelineState.Stopping)
                OnPSCodeStopping("");
            */
            switch (e.PipelineStateInfo.State) {
                case PipelineState.Failed:
                    PSErrorThrown(e.PipelineStateInfo.Reason.Message);
                    break;
                case PipelineState.Completed:
                    OnPSCodeCompleted("");
                    break;
                case PipelineState.NotStarted:
                    OnPSCodeNotStarted(e.PipelineStateInfo.Reason.Message);
                    break;
                case PipelineState.Running:
                    OnPSCodeRunning("");
                    break;
                case PipelineState.Stopped:
                    OnPSCodeStopped(e.PipelineStateInfo.Reason.Message);
                    break;
                case PipelineState.Stopping:
                    OnPSCodeStopping("");
                    break;
            }
//            else {
//                Console.WriteLine("All OK");
//                Console.WriteLine("e.PipelineStateInfo.State = " + e.PipelineStateInfo.State.ToString());
//                Console.WriteLine("e.PipelineStateInfo.Reason.Message = " + e.PipelineStateInfo.Reason.Message);
//                Console.WriteLine(e.PipelineStateInfo.Reason);
//                Console.WriteLine("The pipeline has {0} error!", pipeline.Error.Count);
//            }
        }
Beispiel #9
0
        private void OnPipelineStateChange(object sender, PipelineStateEventArgs e)
        {
            switch( e.PipelineStateInfo.State )
            {
                case( PipelineState.Completed ):
                case( PipelineState.Failed) :
                case( PipelineState.Stopped ):
                    {
                        ((Pipeline)sender).StateChanged -= OnPipelineStateChange;

                        RunspaceReady.Set();
                        break;
                    }
                case( PipelineState.Running):
                    {
                        RunspaceReady.Reset();
                        break;

                    }
                default:
                    break;
            }
        }
 private void PipelineStateChanged(object sender, PipelineStateEventArgs e)
 {
     // report to parent
     if(OnStateChanged != null) {
         OnStateChanged(this, e.PipelineStateInfo);
     }
 }
Beispiel #11
0
			private void PipelineStateChangedHandler(object sender, PipelineStateEventArgs e)
			{
				if (e.PipelineStateInfo.State == PipelineState.Completed || e.PipelineStateInfo.State == PipelineState.Failed || e.PipelineStateInfo.State == PipelineState.Stopped)
				{
					this.eventHandle.Set();
				}
			}
Beispiel #12
0
		void HandleStateChanged (object sender, PipelineStateEventArgs e)		
		{
			if (e.PipelineStateInfo.State == PipelineState.Running) {
				//is running
			}
			else if (OutputHandler != null) {
				OutputHandler(sender, e);
			}
		}
Beispiel #13
0
 protected virtual void HandlePipelineStateChanged(object sender, PipelineStateEventArgs e)
 {
     if ((this.remoteRunspace != null) && (e.PipelineStateInfo.State != PipelineState.Running))
     {
         ((RemoteRunspace) this.remoteRunspace).URIRedirectionReported -= new EventHandler<RemoteDataEventArgs<Uri>>(this.HandleURIDirectionReported);
     }
     PipelineState state = e.PipelineStateInfo.State;
     if (state != PipelineState.Running)
     {
         if (state != PipelineState.Disconnected)
         {
             return;
         }
     }
     else
     {
         if (this.disconnectedBlocked)
         {
             this.disconnectedBlocked = false;
             base.SetJobState(JobState.Blocked);
             return;
         }
         base.SetJobState(JobState.Running);
         return;
     }
     this.disconnectedBlocked = base.JobStateInfo.State == JobState.Blocked;
     base.SetJobState(JobState.Disconnected);
 }
        protected override void HandlePipelineStateChanged(object sender, PipelineStateEventArgs e)
        {
            PipelineState pipelineState = e.PipelineStateInfo.State;
            switch (pipelineState)
            {
                case PipelineState.Running:
                    base.SetJobState(JobState.Running);
                    return;

                case PipelineState.Stopping:
                    break;

                case PipelineState.Stopped:
                case PipelineState.Completed:
                case PipelineState.Failed:
                case PipelineState.Disconnected:
                    this.CheckForAndSetDisconnectedState(pipelineState);
                    break;

                default:
                    return;
            }
        }
Beispiel #15
0
 private void PipelineStateChanged(object sender, PipelineStateEventArgs e)
 {
 }
Beispiel #16
0
        private void Handle_StateChanged(object sender, PipelineStateEventArgs e)
        {
            Pipeline pipeline = sender as Pipeline;
            lock (lockState)
            {
                stateInfo = pipeline.PipelineStateInfo;
            }
            executeAction(stateChangedAction);
            if (pipeline.PipelineStateInfo.State > PipelineState.Stopping)
            {

                 pipeline.Dispose();
            }
        }