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)); } }
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); } } }
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); } } }
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); } } }
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); } } }
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) { } }
/// <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 .. }
/// <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 ... }
/// <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 .. }
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]); }
private void ProgressAdded(object sender, DataAddedEventArgs e) { this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Progress, e.Index)); }
private void VerboseRecordAdded(object sender, DataAddedEventArgs e) { var record = _powerShell.Streams.Verbose[e.Index]; AllRecords.Add(record); }
private void WarningAdded(object sender, DataAddedEventArgs e) { this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Warning, e.Index)); }
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)); } }
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)); } }
private void OnWarning(object sender, DataAddedEventArgs e) { WriteOutput("PS WARNING", sender, e); }
private void OnVerbose(object sender, DataAddedEventArgs e) { WriteOutput("PS VERBOSE: ", sender, e); }
private void OnProgress(object sender, DataAddedEventArgs e) { WriteOutput("PS PROGRESS", sender, e); }
void Error_DataAdded(object sender, DataAddedEventArgs e) { using (StreamWriter w = File.AppendText("log.txt")) { w.WriteLine(((PSDataCollection<ErrorRecord>)sender)[e.Index].ToString()); } }
private void OnError(object sender, DataAddedEventArgs e) { var data = (PSDataCollection<ErrorRecord>) sender; ErrorRecord record = data[e.Index]; WriteError(record.ToString()); }
private void OnVerbose(object sender, DataAddedEventArgs e) { var data = (PSDataCollection<VerboseRecord>) sender; VerboseRecord record = data[e.Index]; Write(record.ToString()); }
private void OnDebug(object sender, DataAddedEventArgs e) { WriteOutput("PS DEBUG", sender, e); }
private void ProgressRecordAdded(object sender, DataAddedEventArgs e) { var record = _powerShell.Streams.Progress[e.Index]; ProgressRecords.Add(record); }
private void OnError(object sender, DataAddedEventArgs e) { _errorCount++; WriteError("PS ERROR", sender ,e); }
private void WarningRecordAdded(object sender, DataAddedEventArgs e) { var record = _powerShell.Streams.Warning[e.Index]; AllRecords.Add(record); }
private void OnOutput(object sender, DataAddedEventArgs e) { WriteOutput("PS", sender, e); }
private void MonitoredJobResults_DataAdded(object sender, DataAddedEventArgs e) { PSDataCollection <PSStreamObject> resultsCollection = (PSDataCollection <PSStreamObject>)sender; this.AggregateJobResults(resultsCollection); }
void SendWarning( object sender, DataAddedEventArgs e) { if (sender == null) return; var rec = sender as PSDataCollection<WarningRecord>; Trace.TraceWarning("POWERSHELL: {0}", rec[e.Index]); }
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); }
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); } }
private void VerboseAdded(object sender, DataAddedEventArgs e) { this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Verbose, e.Index)); }
private void WarningDataAdded(object sender, DataAddedEventArgs args) { var outputCollection = sender as PSDataCollection<PSObject>; var output = outputCollection[args.Index].ToString(); this.RaiseOutputReceiced(output); }
private void Error_DataAdded(object sender, DataAddedEventArgs e) { base.WriteError(((PSDataCollection<ErrorRecord>) sender)[e.Index]); }
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; } } }
private void Output_DataAdded(object sender, DataAddedEventArgs e) { base.WriteObject(((PSDataCollection<object>) sender)[e.Index]); }
private void OnProgress(object sender, DataAddedEventArgs e) { var data = (PSDataCollection<ProgressRecord>) sender; ProgressRecord record = data[e.Index]; Write(record.ToString()); }
/// <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()); } }
private void OnWarning(object sender, DataAddedEventArgs e) { var data = (PSDataCollection<WarningRecord>) sender; WarningRecord record = data[e.Index]; WriteLine(record.ToString()); }
private void ErrorAdded(object sender, DataAddedEventArgs e) { this.OnJobDataAdded(new JobDataAddedEventArgs(this, PowerShellStreamType.Error, e.Index)); }