void IToastNotificationItem.PerformAction(string actionId) { ppm.RunPostprocessor( ppm.GetPostprocessorOutputsByPostprocessorId(postprocessorId) .Select(output => new KeyValuePair <ILogSourcePostprocessor, ILogSource>(output.PostprocessorMetadata, output.LogSource)) .ToArray(), forceSourcesSelection: false ); }
async void IViewControlHandler.ExecuteAction(string actionId, ClickFlags flags) { var state = postprocessorsManager.GetCorrelatorStateSummary(); switch (actionId) { case "1": switch (state.Status) { case CorrelatorStateSummary.StatusCode.Processed: case CorrelatorStateSummary.StatusCode.ProcessingFailed: if (state.Report != null) { ShowTextInTextViewer(state.Report); } break; } break; case "2": switch (state.Status) { case CorrelatorStateSummary.StatusCode.NeedsProcessing: case CorrelatorStateSummary.StatusCode.Processed: case CorrelatorStateSummary.StatusCode.ProcessingFailed: await this.postprocessorsManager.RunPostprocessors( postprocessorsManager.GetPostprocessorOutputsByPostprocessorId(postprocessorId), ClickFlags.None); break; } break; } }
async void IToastNotificationItem.PerformAction(string actionId) { switch (lastSummary.Status) { case CorrelatorStateSummary.StatusCode.NeedsProcessing: case CorrelatorStateSummary.StatusCode.Processed: case CorrelatorStateSummary.StatusCode.ProcessingFailed: await this.ppm.RunPostprocessor( ppm.GetPostprocessorOutputsByPostprocessorId(PostprocessorIds.Correlator) .Select(output => new KeyValuePair <ILogSourcePostprocessor, ILogSource>(output.PostprocessorMetadata, output.LogSource)) .ToArray(), forceSourcesSelection : false ); break; } }
ControlData IViewControlHandler.GetCurrentData() { var outputs = postprocessorsManager.GetPostprocessorOutputsByPostprocessorId(postprocessorId); if (outputs.Length == 0) { return(new ControlData() { Disabled = true, Content = postprocessorsManager.KnownLogTypes .SelectMany(x => x.SupportedPostprocessors) .Where(p => p.TypeID == postprocessorId) .Select(p => p.Caption) .FirstOrDefault(postprocessorId) + ": N/A" }); } int nrOfRunning = 0; int nrOfProcessed = 0; int nrOfUnprocessed = 0; int nrOfOutdated = 0; int nrOfProcessedWithWarnings = 0; int nrOfProcessedWithErrors = 0; double?progress = null; foreach (var output in outputs) { switch (output.OutputStatus) { case LogSourcePostprocessorOutput.Status.Finished: case LogSourcePostprocessorOutput.Status.Failed: if (output.LastRunSummary != null) { if (output.LastRunSummary.HasWarnings) { ++nrOfProcessedWithWarnings; } if (output.LastRunSummary.HasErrors) { ++nrOfProcessedWithErrors; } } ++nrOfProcessed; break; case LogSourcePostprocessorOutput.Status.Outdated: ++nrOfOutdated; ++nrOfProcessed; break; case LogSourcePostprocessorOutput.Status.InProgress: ++nrOfRunning; progress = output.Progress; break; case LogSourcePostprocessorOutput.Status.NeverRun: ++nrOfUnprocessed; break; } } var ret = new ControlData(); var isClickableCaption = false; string action = null; string statusText = null; ret.Disabled = false; Action appendReportLinkIfRequired = () => { if (nrOfProcessedWithErrors > 0) { statusText += " *report with errors*"; } else if (nrOfProcessedWithWarnings > 0) { statusText += " *report with warnings*"; } }; if (nrOfRunning > 0) { statusText = string.Format("running... ({0} of {1} logs completed)", nrOfProcessed, nrOfRunning + nrOfProcessed); ret.Progress = progress; } else if (nrOfUnprocessed > 0 || nrOfOutdated > 0) { statusText = string.Format("{0} of {1} logs processed", nrOfProcessed, nrOfProcessed + nrOfUnprocessed); appendReportLinkIfRequired(); if (nrOfOutdated > 0) { statusText += string.Format(", {0} outdated", nrOfOutdated); } if (lazyOutputForm != null && nrOfProcessed > 0) { isClickableCaption = true; } action = "run postprocessor"; ret.Color = ControlData.StatusColor.Warning; } else { statusText = string.Format("all logs processed"); if (lazyOutputForm != null && nrOfProcessed > 0) { isClickableCaption = true; } appendReportLinkIfRequired(); action = "re-process"; if (nrOfProcessedWithErrors > 0) { ret.Color = ControlData.StatusColor.Error; } else { ret.Color = ControlData.StatusColor.Success; } } var contentBuilder = new StringBuilder(); if (isClickableCaption) { contentBuilder.AppendFormat("*show {0}:*", outputs[0].PostprocessorMetadata.Caption); } else { contentBuilder.AppendFormat("{0}:", outputs[0].PostprocessorMetadata.Caption); } if (statusText != null) { contentBuilder.AppendFormat(" {0}", statusText); } if (action != null) { contentBuilder.AppendFormat(" *action {0}*", action); } ret.Content += contentBuilder.ToString(); return(ret); }