// Token: 0x06001082 RID: 4226 RVA: 0x00032783 File Offset: 0x00030983
 internal void PipelineStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     if (e.InvocationStateInfo.State == PSInvocationState.Failed || e.InvocationStateInfo.State == PSInvocationState.Stopped || e.InvocationStateInfo.State == PSInvocationState.Completed)
     {
         this.UnblockWaitOne();
     }
 }
Exemple #2
0
 private void StateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     if (e.InvocationStateInfo.State == PSInvocationState.Completed)
     {
         StoppableInvoke(synchComplete, new object[] { this });
     }
 }
Exemple #3
0
 protected virtual void OnInvocationStateChanged(PSInvocationStateChangedEventArgs e)
 {
     if (InvocationStateChanged != null)
     {
         InvocationStateChanged(this, e);
     }
 }
Exemple #4
0
 /// <summary>
 /// This event handler is called when the pipeline state is changed.
 /// If the state change is to Completed, it issues a message
 /// asking the user to exit the program.
 /// </summary>
 /// <param name="sender">Unused</param>
 /// <param name="e">The PowerShell state information.</param>
 static void Powershell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     Console.WriteLine("PowerShell state changed: state: {0}\n", e.InvocationStateInfo.State);
     if (e.InvocationStateInfo.State == PSInvocationState.Completed)
     {
         Console.WriteLine("Processing completed, press a key to exit!");
     }
 }
Exemple #5
0
 private void InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     if (e.InvocationStateInfo.State != this.InvocationState.State ||
         e.InvocationStateInfo.Reason != this.InvocationState.Reason)
     {
         NotifyOfPropertyChange(() => InvocationState);
     }
 }
Exemple #6
0
        private void Ps_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            log.WriteInfo(e.InvocationStateInfo.State.ToString());
            string comments = string.Empty;

            if (e.InvocationStateInfo.State == PSInvocationState.Completed)
            {
                comments = GetMetalogixJobLogResults(currentPs, "Failed");
            }
            log.WriteToCVS(Environment.MachineName, currentPs, e.InvocationStateInfo.State.ToString(), DateTime.Now.ToLongTimeString(), DateTime.Today.ToShortDateString(), comments);
        }
 /**
  * <summary>
  * Executa o método após a execução do comando, powershell, ter sido concluído.
  * <para><paramref name="sender"/> - Instância do método que chamou esse método.</para>
  * <para><paramref name="e"/> - Parâmetro que representa a invocação do método.</para>
  * <para>Método Assíncrono</para>
  * </summary>
  */
 public void BeginInvoke_Concluido(object sender, PSInvocationStateChangedEventArgs e)
 {
     try
     {
         //string Result = "";
     }
     catch (Exception ex)
     {
         TratadorErros(ex, this.GetType().Name);
     }
 }
 // Token: 0x06000F27 RID: 3879 RVA: 0x0002BB98 File Offset: 0x00029D98
 internal void PipelineStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "-->MonadAsyncResult.PipelineStateChanged()");
     this.SetIsCompleted(e.InvocationStateInfo.State);
     if (this.IsCompleted && this.callback != null)
     {
         ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "\tInvoking callback.");
         this.callback(this);
     }
     ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "<--MonadAsyncResult.PipelineStateChanged()");
 }
Exemple #9
0
        private void Powershell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            switch (e.InvocationStateInfo.State)
            {
            case PSInvocationState.Failed:
                AddError("Errored out: " + e.InvocationStateInfo.Reason.Message);
                break;

            default:
                AddInfo(e.InvocationStateInfo.State.ToString());
                break;
            }
        }
            static void handler(object self, PSInvocationStateChangedEventArgs e)
            {
                if (e.InvocationStateInfo.State is
                    not PSInvocationState.Completed
                    and not PSInvocationState.Failed
                    and not PSInvocationState.Stopped)
                {
                    return;
                }

                PowerShell pwsh = (PowerShell)self;

                pwsh.InvocationStateChanged -= handler;
                pwsh.Dispose();
            }
        private void PowerShellOnInvocationStateChanged(object sender, PSInvocationStateChangedEventArgs psInvocationStateChangedEventArgs)
        {
            switch (psInvocationStateChangedEventArgs.InvocationStateInfo.State)
            {
            case PSInvocationState.Stopped:
                ReleasePowerShell();
                _pool.ReportStopped(this);
                break;

            case PSInvocationState.Completed:
            case PSInvocationState.Failed:
                ResetPowerShell();
                _pool.ReportAvailable(this);
                break;
            }
        }
Exemple #12
0
 /// <summary>
 /// Synchronizes Job State with Background Runspace
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void powerShellCommand_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     try {
         if (e.InvocationStateInfo.State == PSInvocationState.Completed)
         {
             runspace.Close();
         }
         if (e.InvocationStateInfo.State == PSInvocationState.Failed)
         {
             ErrorRecord err = new ErrorRecord(e.InvocationStateInfo.Reason, "JobFailed", ErrorCategory.OperationStopped, this);
             Error.Add(err);
             runspace.Close();
         }
         JobState js = (JobState)Enum.Parse(typeof(JobState), e.InvocationStateInfo.State.ToString(), true);
         this.SetJobState(js);
     } catch {}
 }
Exemple #13
0
        private void Powershell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            switch (e.InvocationStateInfo.State)
            {
            case PSInvocationState.Failed:
                AddError(null, new MessageEventArgs {
                    Message = $"Errored out: {e.InvocationStateInfo.Reason.Message}"
                });
                break;

            default:
                AddInfo(null, new MessageEventArgs {
                    Message = e.InvocationStateInfo.State.ToString()
                });
                break;
            }
        }
        private void PowerShellInstance_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            switch (e.InvocationStateInfo.State)
            {
            case PSInvocationState.Completed:
            case PSInvocationState.Disconnected:
            case PSInvocationState.Failed:
            case PSInvocationState.NotStarted:
            case PSInvocationState.Stopped:
                base.StatusHandler.TaskCompleted(e.InvocationStateInfo.Reason != null ? e.InvocationStateInfo.Reason.HResult : 0);
                break;

            //case PSInvocationState.Running:
            //case PSInvocationState.Stopping:
            default:
                break;
            }
        }
Exemple #15
0
        private void HandleStateChanged(PSInvocationStateChangedEventArgs stateChangeInfo)
        {
            if (_dataStreamWriter != null)
            {
                // Treat any terminating exception as a non-terminating error record
                var newStateInfo = stateChangeInfo.InvocationStateInfo;
                if (newStateInfo.Reason != null)
                {
                    var errorRecord = new ErrorRecord(
                        newStateInfo.Reason,
                        "PSTaskException",
                        ErrorCategory.InvalidOperation,
                        this);

                    _dataStreamWriter.Add(
                        new PSStreamObject(PSStreamObjectType.Error, errorRecord));
                }
            }

            RaiseStateChangedEvent(stateChangeInfo);
        }
Exemple #16
0
        private void OnExecutingCommandInvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            bool flag = false;

            lock (this.sessionStateLock)
            {
                if (this.State != PowwaSession.SessionState.Closed)
                {
                    PSInvocationState state = e.InvocationStateInfo.State;
                    if (state == PSInvocationState.Completed || state == PSInvocationState.Failed || state == PSInvocationState.Stopped)
                    {
                        if (state == PSInvocationState.Failed)
                        {
                            this.WriteException(e.InvocationStateInfo.Reason);
                        }
                        flag = true;
                        if (state == PSInvocationState.Completed)
                        {
                            //Ouput Stuff...
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            if (flag)
            {
                string powerShellPrompt = this.GetPowerShellPrompt();
                lock (this.sessionStateLock)
                {
                    if (this.State != PowwaSession.SessionState.Closed)
                    {
                        this.PostClientMessage(new CommandCompletedMessage(powerShellPrompt), false);
                        this.State = PowwaSession.SessionState.Available;
                    }
                }
            }
        }
Exemple #17
0
 void powerShellCommand_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     if (e.InvocationStateInfo.State == PSInvocationState.Failed)
     {
         ErrorRecord err = new ErrorRecord(e.InvocationStateInfo.Reason, "PowerShellDataSource.TerminatingError", ErrorCategory.InvalidOperation, powerShellCommand);
         powerShellCommand.Streams.Error.Add(err);
     }
     if (Dispatcher != null)
     {
         RunOnUIThread(
             new DispatcherOperationCallback(
                 delegate
         {
             NotifyInvocationStateChanged();
             return(null);
         }),
             true);
     }
     else
     {
         NotifyInvocationStateChanged();
     }
 }
Exemple #18
0
 internal void RaiseStateChangedEvent(PSInvocationStateChangedEventArgs args)
 {
     StateChanged.SafeInvoke(this, args);
 }
Exemple #19
0
 private void HandleStateChanged(PSInvocationStateChangedEventArgs stateChangeInfo)
 {
     RaiseStateChangedEvent(stateChangeInfo);
 }
Exemple #20
0
 private void PowerShellPipeLine_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     _pipeLineState = e.InvocationStateInfo.State.ToString();
 }
Exemple #21
0
 private void Powershell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     OnInvocationStateChanged(e);
 }
        void powerShell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
        {
            SessionStateChangedEventArgs eventArgs = TranslateInvocationStateInfo(e.InvocationStateInfo);

            this.OnSessionStateChanged(this, eventArgs);
        }
        private void OnStateChanged(object sender, PSInvocationStateChangedEventArgs args)
        {
            lock (_sync)
            {
                switch (args.InvocationStateInfo.State)
                {
                case PSInvocationState.Completed:
                {
                    foreach (var observer in _observers)
                    {
                        _isCompleted = true;
                        observer.OnCompleted();
                    }
                    foreach (var observer in _psObservers)
                    {
                        observer.OnCompleted();
                    }
                }
                break;

                case PSInvocationState.Disconnected:
                {
                    _isCompleted = true;
                    var ex = new PSTerminalStateException(PSInvocationState.Disconnected, "The PowerShell invocation state indicated disconnection.", args.InvocationStateInfo.Reason);
                    var er = new ErrorRecord(ex, "PSTerminalState", ErrorCategory.NotSpecified, _powerShell);
                    foreach (var observer in _observers)
                    {
                        observer.OnError(ex);
                    }
                    foreach (var observer in _psObservers)
                    {
                        observer.OnFailed(er);
                    }
                }
                break;

                case PSInvocationState.Failed:
                {
                    _isCompleted = true;
                    var ex = new PSTerminalStateException(PSInvocationState.Failed, "The PowerShell invocation state indicated failure.", args.InvocationStateInfo.Reason);
                    var er = new ErrorRecord(ex, "PSTerminalState", ErrorCategory.NotSpecified, _powerShell);
                    _exception = ex;
                    foreach (var observer in _observers)
                    {
                        observer.OnError(ex);
                    }
                    foreach (var observer in _psObservers)
                    {
                        observer.OnFailed(er);
                    }
                }
                break;

                case PSInvocationState.Stopped:
                {
                    _isCompleted = true;
                    var ex = new PSTerminalStateException(PSInvocationState.Stopped, "The PowerShell invocation state indicated cancellation.", args.InvocationStateInfo.Reason);
                    var er = new ErrorRecord(ex, "PSTerminalState", ErrorCategory.NotSpecified, _powerShell);
                    _exception = ex;
                    foreach (var observer in _observers)
                    {
                        observer.OnError(ex);
                    }
                    foreach (var observer in _psObservers)
                    {
                        observer.OnFailed(er);
                    }
                }
                break;

                default: return;
                }
                _observers.Clear();
                _psObservers.Clear();
                Output.DataAdded -= OnOutputAdded;
                _powerShell.Streams.Error.DataAdded       -= OnErrorAdded;
                _powerShell.Streams.Warning.DataAdded     -= OnWarningAdded;
                _powerShell.Streams.Verbose.DataAdded     -= OnVerboseAdded;
                _powerShell.Streams.Debug.DataAdded       -= OnDebugAdded;
                _powerShell.Streams.Progress.DataAdded    -= OnProgressAdded;
                _powerShell.Streams.Information.DataAdded -= OnInformationAdded;
                Dispose();
            }
        }
Exemple #24
0
 private void Ps_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
 }
Exemple #25
0
 private static void Powershell_InvocationStateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     Console.WriteLine("PowerShell object state changed: state: {0}\n", e.InvocationStateInfo.State);
 }
Exemple #26
0
 void StateChanged(object sender, PSInvocationStateChangedEventArgs e)
 {
     var x = e.InvocationStateInfo.State;
 }