private List <object> ExecuteCommand(bool stringOutput, bool marshallResults = true) { var jobManager = TypeResolver.ResolveFromCache <IJobManager>(); var job = jobManager.GetContextJob(); JobName = job?.Name; if (stringOutput) { powerShell.Commands.AddCommand(OutDefaultCommand); } if (Runspace.DefaultRunspace == null) { Runspace.DefaultRunspace = host.Runspace; } if (Debugging) { host.Runspace.Debugger.DebuggerStop += DebuggerOnDebuggerStop; host.Runspace.Debugger.BreakpointUpdated += DebuggerOnBreakpointUpdated; SetVariable("SpeDebug", true); if (Interactive) { var message = Message.Parse(this, "ise:debugstart"); SendUiMessage(message); } } else { Engine.SessionState.PSVariable.Remove("SpeDebug"); } abortRequested = false; LastErrors?.Clear(); // execute the commands in the pipeline now var execResults = powerShell.Invoke(); if (powerShell.HadErrors) { LastErrors = powerShell.Streams.Error.ToList(); } LogErrors(powerShell, execResults); if (Interactive && Debugging) { host.Runspace.Debugger.DebuggerStop -= DebuggerOnDebuggerStop; host.Runspace.Debugger.BreakpointUpdated -= DebuggerOnBreakpointUpdated; var message = Message.Parse(this, "ise:debugend"); SendUiMessage(message); Debugging = false; } JobName = string.Empty; return(marshallResults ? execResults?.Select(p => p?.BaseObject).ToList() : execResults?.Cast <object>().ToList()); }
public static void ShowLast() { if (LastErrors?.Any() != true) { return; } var errVM = new ErrorsVM(LastErrors) { IsDialog = false }; var errView = new ErrorsView(errVM); Application.ShowModelessWindow(errView); }
public Task <bool> Populate() { Dictionary <string, string> userAliasMap = null; try { userAliasMap = CalendarManager.ResolveUserAccounts(UserDataResolver, CalendarProviderConfig.TeamList); if ((userAliasMap == null) || !userAliasMap.Any()) { throw new InvalidOperationException("no user account data found."); } } catch (Exception ex) { TraceTool.Instance.Value.TraceException(ex); LastErrors.Add(HtmlTools.GetHtmlError(ex.Message)); return(Task.FromResult(false)); } try { var userAccounts = userAliasMap.Select(kvp => kvp.Key).ToList(); var cInfoList = CalendarManager.ResolveCalendarData(CalendarDataProvider, CalendarGridConfig.StartDate, userAccounts).ToList(); CalendarGrid.Populate(cInfoList, userAliasMap.Keys.Select(strUser => new CalendarResource { Name = userAliasMap[strUser], Email = strUser }).ToList()); } catch (Exception ex) { TraceTool.Instance.Value.TraceException(ex); LastErrors.Add(HtmlTools.GetHtmlError(ex.Message)); return(Task.FromResult(false)); } return(Task.FromResult(true)); }
public Exception(ParseRule rule) : base(rule.Descriptor + " could not be executed on input") { AllErrors.AddRange(rule.errorInfo); LastErrors.AddRange(rule.LastErrors); Rule = rule; }
private List <object> ExecuteCommand(bool stringOutput, bool marshallResults = true) { JobName = Context.Job?.Name; if (stringOutput) { powerShell.Commands.AddCommand(OutDefaultCommand); } if (Runspace.DefaultRunspace == null) { Runspace.DefaultRunspace = host.Runspace; } if (Debugging) { host.Runspace.Debugger.DebuggerStop += DebuggerOnDebuggerStop; host.Runspace.Debugger.BreakpointUpdated += DebuggerOnBreakpointUpdated; SetVariable("SpeDebug", true); if (Interactive) { var message = Message.Parse(this, "ise:debugstart"); SendUiMessage(message); } } else { Engine.SessionState.PSVariable.Remove("SpeDebug"); } abortRequested = false; LastErrors?.Clear(); // execute the commands in the pipeline now var execResults = powerShell.Invoke(); if (powerShell.HadErrors) { LastErrors = powerShell.Streams.Error.ToList(); } if (execResults != null && execResults.Any()) { foreach (var record in execResults.Where(r => r != null).Select(p => p.BaseObject).OfType <ErrorRecord>()) { LogUtils.Debug(record + record.InvocationInfo.PositionMessage, this); } } if (Interactive && Debugging) { host.Runspace.Debugger.DebuggerStop -= DebuggerOnDebuggerStop; host.Runspace.Debugger.BreakpointUpdated -= DebuggerOnBreakpointUpdated; var message = Message.Parse(this, "ise:debugend"); SendUiMessage(message); Debugging = false; } JobName = string.Empty; return(marshallResults ? execResults?.Select(p => p?.BaseObject).ToList() : execResults?.Cast <object>().ToList()); }