示例#1
0
        private void HandleWarningAdded(object sender, DataAddedEventArgs eventArgs)
        {
            int        index = eventArgs.Index;
            PowerShell pipelinePowerShell = this.GetPipelinePowerShell(this.remotePipeline, eventArgs.PowerShellInstanceId);

            if (pipelinePowerShell != null)
            {
                WarningRecord item = pipelinePowerShell.Streams.Warning[index];
                base.Warning.Add(item);
                base.Results.Add(new PSStreamObject(PSStreamObjectType.WarningRecord, item));
            }
        }
示例#2
0
 private void HandleDebugAdded(object sender, DataAddedEventArgs eventArgs)
 {
     int index = eventArgs.Index;
     lock (this.syncObject)
     {
         int num2 = !this.extraPowerShellAlreadyScheduled ? 0 : 1;
         if ((num2 == 0) && !this.datasent[num2])
         {
             DebugRecord record = this.localPowerShell.Streams.Debug[index];
             this.localPowerShell.Streams.Debug.RemoveAt(index);
             this.dsHandler.SendDebugRecordToClient(record);
         }
     }
 }
        private void HandleDebugAdded(object sender, DataAddedEventArgs eventArgs)
        {
            int index = eventArgs.Index;

            lock (this.syncObject)
            {
                int num2 = !this.extraPowerShellAlreadyScheduled ? 0 : 1;
                if ((num2 == 0) && !this.datasent[num2])
                {
                    DebugRecord record = this.localPowerShell.Streams.Debug[index];
                    this.localPowerShell.Streams.Debug.RemoveAt(index);
                    this.dsHandler.SendDebugRecordToClient(record);
                }
            }
        }
        private void HandleErrorDataAdded(object sender, DataAddedEventArgs e)
        {
            int index = e.Index;

            lock (this.syncObject)
            {
                int num2 = !this.extraPowerShellAlreadyScheduled ? 0 : 1;
                if ((num2 == 0) && !this.datasent[num2])
                {
                    ErrorRecord errorRecord = this.localPowerShell.Streams.Error[index];
                    this.localPowerShell.Streams.Error.RemoveAt(index);
                    this.dsHandler.SendErrorRecordToClient(errorRecord);
                }
            }
        }
示例#5
0
 private void childJob_ResultsAdded(object sender, DataAddedEventArgs e)
 {
     try
     {
         long currentCount = Interlocked.Increment(ref this._jobResultsCurrentCount);
         this.WriteWarningAboutHighUsageOfFlowControlBuffers(currentCount);
         this._jobResultsThrottlingSemaphore.Wait(this._cancellationTokenSource.Token);
     }
     catch (ObjectDisposedException)
     {
     }
     catch (OperationCanceledException)
     {
     }
 }
        private void HandleOutputDataAdded(object sender, DataAddedEventArgs e)
        {
            int index = e.Index;

            lock (this.syncObject)
            {
                int num2 = !this.extraPowerShellAlreadyScheduled ? 0 : 1;
                if (!this.datasent[num2])
                {
                    PSObject data = this.localPowerShellOutput[index];
                    this.localPowerShellOutput.RemoveAt(index);
                    this.dsHandler.SendOutputDataToClient(data);
                }
            }
        }
示例#7
0
 private void HandleDebugAdded(object sender, DataAddedEventArgs eventArgs)
 {
     using (ServerPowerShellDriver.tracer.TraceEventHandlers())
     {
         int index = eventArgs.Index;
         lock (this.syncObject)
         {
             if (this.datasent)
             {
                 return;
             }
             DebugRecord record = this.localPowerShell.Streams.Debug[index];
             this.localPowerShell.Streams.Debug.RemoveAt(index);
             this.dsHandler.SendDebugRecordToClient(record);
         }
     }
 }
示例#8
0
 private void HandleOutputDataAdded(object sender, DataAddedEventArgs e)
 {
     using (ServerPowerShellDriver.tracer.TraceMethod())
     {
         int index = e.Index;
         lock (this.syncObject)
         {
             if (this.datasent)
             {
                 return;
             }
             PSObject data = this.localPowerShellOutput[index];
             this.localPowerShellOutput.RemoveAt(index);
             this.dsHandler.SendOutputDataToClient(data);
         }
     }
 }
示例#9
0
 private void HandleErrorDataAdded(object sender, DataAddedEventArgs e)
 {
     using (ServerPowerShellDriver.tracer.TraceMethod())
     {
         int index = e.Index;
         lock (this.syncObject)
         {
             if (this.datasent)
             {
                 return;
             }
             ErrorRecord errorRecord = this.localPowerShell.Streams.Error[index];
             this.localPowerShell.Streams.Error.RemoveAt(index);
             this.dsHandler.SendErrorRecordToClient(errorRecord);
         }
     }
 }
        private void childJob_ResultsAdded(object sender, DataAddedEventArgs e)
        {
            Dbg.Assert(_jobResultsThrottlingSemaphore != null, "JobResultsThrottlingSemaphore should be non-null if childJob_ResultsAdded handled is registered");
            try
            {
                long jobResultsUpdatedCount = Interlocked.Increment(ref _jobResultsCurrentCount);
                this.WriteWarningAboutHighUsageOfFlowControlBuffers(jobResultsUpdatedCount);

                _jobResultsThrottlingSemaphore.Wait(_cancellationTokenSource.Token);
            }
            catch (ObjectDisposedException)
            {
            }
            catch (OperationCanceledException)
            {
            }
        }
示例#11
0
        /// <summary>
        /// Handles DataAdded from Information of PowerShell
        /// </summary>
        /// <param name="sender">sender of this information, unused</param>
        /// <param name="eventArgs">sender of this information</param>
        private void HandleInformationAdded(object sender, DataAddedEventArgs eventArgs)
        {
            int index = eventArgs.Index;

            lock (_syncObject)
            {
                int indexIntoDataSent = (!_extraPowerShellAlreadyScheduled) ? 0 : 1;
                if ((indexIntoDataSent == 0) && (!_datasent[indexIntoDataSent]))
                {
                    InformationRecord data = LocalPowerShell.Streams.Information[index];
                    // once the Information message is sent, it is removed so that
                    // the same is not sent again by SendRemainingData() method
                    LocalPowerShell.Streams.Information.RemoveAt(index);

                    // send the output data to the client
                    DataStructureHandler.SendInformationRecordToClient(data);
                }
            } // lock ..
        }
示例#12
0
        /// <summary>
        /// Handles DataAdded event from Error of the PowerShell
        /// </summary>
        /// <param name="sender">sender of this event</param>
        /// <param name="e">arguments describing this event</param>
        private void HandleErrorDataAdded(object sender, DataAddedEventArgs e)
        {
            int index = e.Index;

            lock (_syncObject)
            {
                int indexIntoDataSent = (!_extraPowerShellAlreadyScheduled) ? 0 : 1;
                if ((indexIntoDataSent == 0) && (!_datasent[indexIntoDataSent]))
                {
                    ErrorRecord errorRecord = LocalPowerShell.Streams.Error[index];
                    // once send the error record is removed so that the same
                    // is not sent again by SendRemainingData() method
                    LocalPowerShell.Streams.Error.RemoveAt(index);

                    // send the error record to the client
                    DataStructureHandler.SendErrorRecordToClient(errorRecord);
                }
            } // lock ...
        }
示例#13
0
        /// <summary>
        /// Handles DataAdded event from the Output of the powershell
        /// </summary>
        /// <param name="sender">sender of this information</param>
        /// <param name="e">arguments describing this event</param>
        private void HandleOutputDataAdded(object sender, DataAddedEventArgs e)
        {
            int index = e.Index;

            lock (_syncObject)
            {
                int indexIntoDataSent = (!_extraPowerShellAlreadyScheduled) ? 0 : 1;
                if (!_datasent[indexIntoDataSent])
                {
                    PSObject data = _localPowerShellOutput[index];
                    // once send the output is removed so that the same
                    // is not sent again by SendRemainingData() method
                    _localPowerShellOutput.RemoveAt(index);

                    // send the output data to the client
                    DataStructureHandler.SendOutputDataToClient(data);
                }
            } // lock ..
        }
示例#14
0
 void outputCollection_DataAdded(object sender, DataAddedEventArgs e)
 {
     using (StreamWriter w = File.AppendText("log.txt"))
     {
         w.WriteLine(((PSDataCollection<PSObject>)sender)[e.Index].ToString());
     }
 }
 void SendVerbose(object sender, DataAddedEventArgs e)
 {
     if (sender == null) return;
     var rec = sender as PSDataCollection<VerboseRecord>;
     Trace.TraceInformation("POWERSHELL: {0}", rec[e.Index]);
 }
示例#16
0
 private void ProgressAdded(object sender, DataAddedEventArgs e)
 {
     this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Progress, e.Index));
 }
示例#17
0
        private void VerboseRecordAdded(object sender, DataAddedEventArgs e)
        {
            var record = _powerShell.Streams.Verbose[e.Index];

            AllRecords.Add(record);
        }
示例#18
0
 private void WarningAdded(object sender, DataAddedEventArgs e)
 {
     this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Warning, e.Index));
 }
示例#19
0
        private void WriteOutput(string prefix, object sender, DataAddedEventArgs e)
        {
            if (_powerShellConfiguration.OnOutput == null)
              {
            return;
              }

              var psDataCollection = sender as PSDataCollection<PSObject>;
              if (psDataCollection != null)
              {
            PSObject psObject = psDataCollection[e.Index];

            _powerShellConfiguration.OnOutput(string.Format("{0}: {1}", prefix, psObject));
              }
        }
示例#20
0
        private void WriteError(string prefix, object sender, DataAddedEventArgs e)
        {
            if (_powerShellConfiguration.OnError == null)
              {
            return;
              }

              var psErrorCollection = sender as PSDataCollection<ErrorRecord>;
              if (psErrorCollection != null)
              {
            ErrorRecord error = psErrorCollection[e.Index];
            _powerShellConfiguration.OnError(string.Format("{0}: {1}", prefix, error.Exception));
              }
        }
示例#21
0
 private void OnWarning(object sender, DataAddedEventArgs e)
 {
     WriteOutput("PS WARNING", sender, e);
 }
示例#22
0
 private void OnVerbose(object sender, DataAddedEventArgs e)
 {
     WriteOutput("PS VERBOSE: ", sender, e);
 }
示例#23
0
 private void OnProgress(object sender, DataAddedEventArgs e)
 {
     WriteOutput("PS PROGRESS", sender, e);
 }
示例#24
0
 void Error_DataAdded(object sender, DataAddedEventArgs e)
 {
     using (StreamWriter w = File.AppendText("log.txt"))
     {
         w.WriteLine(((PSDataCollection<ErrorRecord>)sender)[e.Index].ToString());
     }
 }
示例#25
0
        private void OnError(object sender, DataAddedEventArgs e)
        {
            var data = (PSDataCollection<ErrorRecord>) sender;
            ErrorRecord record = data[e.Index];

            WriteError(record.ToString());
        }
示例#26
0
        private void OnVerbose(object sender, DataAddedEventArgs e)
        {
            var data = (PSDataCollection<VerboseRecord>) sender;
            VerboseRecord record = data[e.Index];

            Write(record.ToString());
        }
示例#27
0
 private void OnDebug(object sender, DataAddedEventArgs e)
 {
     WriteOutput("PS DEBUG", sender, e);
 }
示例#28
0
 private void ProgressRecordAdded(object sender, DataAddedEventArgs e)
 {
     var record = _powerShell.Streams.Progress[e.Index];
     ProgressRecords.Add(record);
 }
示例#29
0
 private void OnError(object sender, DataAddedEventArgs e)
 {
     _errorCount++;
       WriteError("PS ERROR", sender ,e);
 }
示例#30
0
        private void WarningRecordAdded(object sender, DataAddedEventArgs e)
        {
            var record = _powerShell.Streams.Warning[e.Index];

            AllRecords.Add(record);
        }
示例#31
0
 private void OnOutput(object sender, DataAddedEventArgs e)
 {
     WriteOutput("PS", sender, e);
 }
示例#32
0
            private void MonitoredJobResults_DataAdded(object sender, DataAddedEventArgs e)
            {
                PSDataCollection <PSStreamObject> resultsCollection = (PSDataCollection <PSStreamObject>)sender;

                this.AggregateJobResults(resultsCollection);
            }
示例#33
0
 private void childJob_ResultsAdded(object sender, DataAddedEventArgs e)
 {
     try
     {
         long currentCount = Interlocked.Increment(ref this._jobResultsCurrentCount);
         this.WriteWarningAboutHighUsageOfFlowControlBuffers(currentCount);
         this._jobResultsThrottlingSemaphore.Wait(this._cancellationTokenSource.Token);
     }
     catch (ObjectDisposedException)
     {
     }
     catch (OperationCanceledException)
     {
     }
 }
 void SendWarning( object sender, DataAddedEventArgs e)
 {
     if (sender == null) return;
     var rec = sender as PSDataCollection<WarningRecord>;
     Trace.TraceWarning("POWERSHELL: {0}", rec[e.Index]);
 }
示例#35
0
 private void MonitoredJobResults_DataAdded(object sender, DataAddedEventArgs e)
 {
     PSDataCollection<PSStreamObject> resultsCollection = (PSDataCollection<PSStreamObject>) sender;
     this.AggregateJobResults(resultsCollection);
 }
 /// <summary>
 /// Event handler for the error stream.
 /// </summary>
 private void ErrorDataAdded(object sender, DataAddedEventArgs e, TraceWriter traceWriter)
 {
     var source = (PSDataCollection<ErrorRecord>)sender;
     var msg = GetErrorMessage(_functionName, _scriptFilePath, source[e.Index]);
     traceWriter.Error(msg);
 }
示例#37
0
        private void error_DataAdded(object sender, DataAddedEventArgs e, PsRequest request, ConcurrentBag<ErrorRecord> errors)
        {
            PSDataCollection<ErrorRecord> errorStream = sender as PSDataCollection<ErrorRecord>;

            if (errorStream == null)
            {
                return;
            }

            var error = errorStream[e.Index];

            if (error != null)
            {
                // add the error so we can report them later
                errors.Add(error);
            }
        
        }
 /// <summary>
 /// Event handler for the output stream.
 /// </summary>
 private static void OutputCollectionDataAdded(object sender, DataAddedEventArgs e, TraceWriter traceWriter)
 {
     // trace objects written to the output stream
     var source = (PSDataCollection<PSObject>)sender;
     var data = source[e.Index];
     if (data != null)
     {
         var msg = data.ToString();
         traceWriter.Info(msg);
     }
 }
示例#39
0
 private void VerboseAdded(object sender, DataAddedEventArgs e)
 {
     this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Verbose, e.Index));
 }
示例#40
0
        private void WarningDataAdded(object sender, DataAddedEventArgs args)
        {
            var outputCollection = sender as PSDataCollection<PSObject>;

            var output = outputCollection[args.Index].ToString();

            this.RaiseOutputReceiced(output);
        }
示例#41
0
 private void Error_DataAdded(object sender, DataAddedEventArgs e)
 {
     base.WriteError(((PSDataCollection<ErrorRecord>) sender)[e.Index]);
 }
示例#42
0
        private void output_DataAdded(object sender, DataAddedEventArgs e, PsRequest request, ref object finalValue)
        {
            PSDataCollection<PSObject> outputstream = sender as PSDataCollection<PSObject>;

            if (outputstream == null)
            {
                return;
            }

            PSObject psObject = outputstream[e.Index];
            if (psObject != null)
            {
                var value = psObject.ImmediateBaseObject;
                var y = value as Yieldable;
                if (y != null)
                {
                    // yield it to stream the result gradually
                    y.YieldResult(request);
                }
                else
                {
                    finalValue = value;
                    return;
                }
            }
        }
示例#43
0
 private void Output_DataAdded(object sender, DataAddedEventArgs e)
 {
     base.WriteObject(((PSDataCollection<object>) sender)[e.Index]);
 }
示例#44
0
        private void OnProgress(object sender, DataAddedEventArgs e)
        {
            var data = (PSDataCollection<ProgressRecord>) sender;
            ProgressRecord record = data[e.Index];

            Write(record.ToString());
        }
示例#45
0
        /// <summary>
        /// Output data added event handler. This event is called when
        /// there is data added to the output pipe. It reads the
        /// data available and displays it on the console.
        /// </summary>
        /// <param name="sender">The output pipe this event is associated with.</param>
        /// <param name="e">Unused</param>
        static void Output_DataAdded(object sender, DataAddedEventArgs e)
        {
            PSDataCollection<PSObject> myp = (PSDataCollection<PSObject>)sender;

            Collection<PSObject> results = myp.ReadAll();
            foreach (PSObject result in results)
            {
                Console.WriteLine(result.ToString());
            }
        }
示例#46
0
        private void OnWarning(object sender, DataAddedEventArgs e)
        {
            var data = (PSDataCollection<WarningRecord>) sender;
            WarningRecord record = data[e.Index];

            WriteLine(record.ToString());
        }
示例#47
0
 private void ErrorAdded(object sender, DataAddedEventArgs e)
 {
     this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Error, e.Index));
 }