Ejemplo n.º 1
0
 public void WarningDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is WarningRecord record)
     {
         PublishStreamRecord(record, _context, _command);
     }
 }
Ejemplo n.º 2
0
 private void HandlePowerShellErrorBufferDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded != null)
     {
         HandlePowerShellPStreamItem(new PSStreamObject(PSStreamObjectType.Error, e.ItemAdded));
     }
 }
Ejemplo n.º 3
0
 public void InformationDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is InformationRecord record)
     {
         PublishStreamRecord(record, _context, _command);
     }
 }
Ejemplo n.º 4
0
 public void InformationDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is InformationRecord record)
     {
         _logger.Log(LogLevel.Information, $"INFORMATION: {record.MessageData}", isUserLog: true);
     }
 }
Ejemplo n.º 5
0
 public void DebugDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is DebugRecord record)
     {
         _logger.Log(LogLevel.Debug, $"DEBUG: {record.Message}", isUserLog: true);
     }
 }
Ejemplo n.º 6
0
 public void ProgressDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is ProgressRecord record)
     {
         _logger.Log(LogLevel.Trace, $"PROGRESS: {record.StatusDescription}", isUserLog: true);
     }
 }
Ejemplo n.º 7
0
 private void Psdata_DataAdding(object sender, DataAddingEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         MyOutput.AddColoredText(e.ItemAdded.ToString(), Brushes.White);
     });
 }
Ejemplo n.º 8
0
 public void VerboseDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is VerboseRecord record)
     {
         _logger.Log(LogLevel.Trace, $"VERBOSE: {record.Message}", isUserLog: true);
     }
 }
Ejemplo n.º 9
0
        private static void PowerShellInvocation_ErrorAdding(object sender, DataAddingEventArgs e, HostSettingCommandMetadata commandMetadata)
        {
            ErrorRecord errorRecord = e.ItemAdded as ErrorRecord;

            if (errorRecord != null)
            {
                if (commandMetadata != null)
                {
                    ScriptPosition scriptStart = new ScriptPosition(
                        commandMetadata.CommandName,
                        commandMetadata.StartLineNumber,
                        commandMetadata.StartColumnNumber,
                        null);
                    ScriptPosition scriptEnd = new ScriptPosition(
                        commandMetadata.CommandName,
                        commandMetadata.EndLineNumber,
                        commandMetadata.EndColumnNumber,
                        null);
                    ScriptExtent extent = new ScriptExtent(scriptStart, scriptEnd);

                    if (errorRecord.InvocationInfo != null)
                    {
                        errorRecord.InvocationInfo.DisplayScriptPosition = extent;
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public void WarningDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is WarningRecord record)
     {
         _logger.Log(LogLevel.Warning, $"WARNING: {record.Message}", isUserLog: true);
     }
 }
Ejemplo n.º 11
0
 public void ErrorDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is ErrorRecord record)
     {
         _logger.Log(LogLevel.Error, $"ERROR: {record.Exception.Message}", record.Exception, isUserLog: true);
     }
 }
 public void InformationDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is InformationRecord record)
     {
         string prefix = (record.Tags.Count == 1 && record.Tags[0] == "__PipelineObject__") ? "OUTPUT:" : "INFORMATION:";
         _logger.Log(isUserOnlyLog: true, LogLevel.Information, $"{prefix} {record.MessageData}");
     }
 }
 public void ErrorDataAdding(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded is ErrorRecord record)
     {
         ErrorAnalysisLogger.Log(_logger, record, isException: false);
         _logger.Log(isUserOnlyLog: true, LogLevel.Error, $"ERROR: {_errorRecordFormatter.Format(record)}", record.Exception);
     }
 }
Ejemplo n.º 14
0
 private void ConsoleOutput(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded != null)
     {
         sScriptResult = e.ItemAdded.ToString();
         Trace.WriteLine(e.ItemAdded.ToString());
     }
 }
Ejemplo n.º 15
0
 private void ConsoleError(object sender, DataAddingEventArgs e)
 {
     if (e.ItemAdded != null)
     {
         sScriptResult = "ERROR: " + e.ItemAdded.ToString();
         Trace.WriteLine("ERROR: " + e.ItemAdded.ToString());
     }
 }
Ejemplo n.º 16
0
        private static void HandleErrorDataAdding(object sender, DataAddingEventArgs e)
        {
            HostSettingCommandMetadata commandMetadata;

            CommandMetadataTable.TryGetValue(e.PowerShellInstanceId, out commandMetadata);

            if (commandMetadata != null)
            {
                PowerShellInvocation_ErrorAdding(sender, e, commandMetadata);
            }
        }
Ejemplo n.º 17
0
        public void ErrorDataAdding(object sender, DataAddingEventArgs e)
        {
            if (e.ItemAdded is ErrorRecord record)
            {
                if (record.FullyQualifiedErrorId == "CommandNotFoundException")
                {
                    _logger.Log(isUserOnlyLog: false, LogLevel.Warning, PowerShellWorkerStrings.CommandNotFoundException_Error);
                }

                _logger.Log(isUserOnlyLog: true, LogLevel.Error, $"ERROR: {_errorRecordFormatter.Format(record)}", record.Exception);
            }
        }
Ejemplo n.º 18
0
 private void HandleResultsDataAdding(object sender, DataAddingEventArgs dataAddingArgs)
 {
     if (_debugCollection.IsOpen)
     {
         PSStreamObject streamObject = dataAddingArgs.ItemAdded as PSStreamObject;
         if (streamObject != null)
         {
             try
             {
                 _debugCollection.Add(streamObject);
             }
             catch (PSInvalidOperationException) { }
         }
     }
 }
Ejemplo n.º 19
0
        public async void ProgressDataAdding(object sender, DataAddingEventArgs e)
        {
            if (e.ItemAdded is ProgressRecord record)
            {
                if (_progresses.TryGetValue(record.ActivityId, out DisplayedValue displayedValue))
                {
                    displayedValue.Update(record);

                    if (record.RecordType == ProgressRecordType.Completed)
                    {
                        _progresses.TryRemove(record.ActivityId, out DisplayedValue _);
                    }
                }
                else
                {
                    DisplayedValue dv = await _context.DisplayAsync(record);

                    _progresses[record.ActivityId] = dv;
                }
            }
        }
Ejemplo n.º 20
0
 private void OutputCollection_DataAdding(object sender, DataAddingEventArgs e)
 {
     sScriptResult = e.ItemAdded.ToString();
 }