Exemple #1
0
        private void InitAndAddProstprocessorHandler(
            Dictionary <ViewControlId, IViewControlHandler> handlers,
            ViewControlId postprocessorViewId,
            IManager postprocessorsManager,
            IPostprocessorOutputFormFactory outputFormsFactory,
            PostprocessorKind postprocessorKind
            )
        {
            IViewControlHandler handler;

            if (postprocessorViewId == ViewControlId.Correlate)
            {
                handler = new CorrelatorPostprocessorControlHandler(
                    postprocessorsManager,
                    tempFiles,
                    shellOpen
                    );
            }
            else
            {
                handler = new LogSourcePostprocessorControlHandler(
                    postprocessorsManager,
                    postprocessorKind,
                    () => outputFormsFactory.GetPostprocessorOutputForm(postprocessorViewId),
                    shellOpen,
                    tempFiles
                    );
            }
            handlers.Add(postprocessorViewId, handler);
        }
        private void InitAndAddProstprocessorHandler(
            ViewControlId postprocessorViewId,
            PostprocessorKind postprocessorKind
            )
        {
            IViewControlHandler handler;

            if (postprocessorViewId == ViewControlId.Correlate)
            {
                handler = new CorrelatorPostprocessorControlHandler(
                    correlationManager,
                    tempFiles,
                    shellOpen
                    );
            }
            else
            {
                handler = new LogSourcePostprocessorControlHandler(
                    postprocessorsManager,
                    postprocessorKind,
                    () =>
                    postprocessorKind == PostprocessorKind.StateInspector ? presentersFactory.GetStateInspectorVisualizer(true) :
                    postprocessorKind == PostprocessorKind.Timeline ? presentersFactory.GetTimelineVisualizer(true) :
                    postprocessorKind == PostprocessorKind.SequenceDiagram ? presentersFactory.GetSequenceDiagramVisualizer(true) :
                    postprocessorKind == PostprocessorKind.TimeSeries ? presentersFactory.GetTimeSeriesVisualizer(true) :
                    (IPostprocessorVisualizerPresenter)null,
                    shellOpen,
                    tempFiles
                    );
            }
            viewControlHandlers.Add(postprocessorViewId, handler);
        }
Exemple #3
0
 public LogSourcePostprocessor(
     PostprocessorKind kind,
     Func <LogSourcePostprocessorInput[], Task <IPostprocessorRunSummary> > run
     )
 {
     this.kind = kind;
     this.run  = run;
 }
Exemple #4
0
        public static string ToDisplayString(this PostprocessorKind kind)
        {
            switch (kind)
            {
            case PostprocessorKind.Correlator: return("Logs correlation");

            case PostprocessorKind.TimeSeries: return("Time Series");

            default: return(kind.ToString());
            }
        }
 public UnprocessedLogsToastNotification(
     IManager ppm,
     ILogSourcesManager lsm,
     PostprocessorKind postprocessorKind
     )
 {
     this.ppm = ppm;
     this.postprocessorKind = postprocessorKind;
     ppm.Changed           += (s, e) => Update();
     Update();
 }
 public CorrelatorPostprocessorControlHandler(
     IManager postprocessorsManager,
     ITempFilesManager tempFilesManager,
     IShellOpen shellOpen
     )
 {
     this.postprocessorsManager = postprocessorsManager;
     this.tempFilesManager      = tempFilesManager;
     this.postprocessorKind     = PostprocessorKind.Correlator;
     this.shellOpen             = shellOpen;
 }
 public LogSourcePostprocessorControlHandler(
     IManager postprocessorsManager,
     PostprocessorKind postprocessorKind,
     Func <IPostprocessorOutputForm> lazyOutputForm,
     LogJoint.UI.Presenters.IShellOpen shellOpen,
     ITempFilesManager tempFiles
     )
 {
     this.postprocessorsManager = postprocessorsManager;
     this.postprocessorKind     = postprocessorKind;
     this.lazyOutputForm        = lazyOutputForm;
     this.shellOpen             = shellOpen;
     this.tempFiles             = tempFiles;
 }
        public object Deserialize(PostprocessorKind kind, LogSourcePostprocessorDeserializationParams p)
        {
            switch (kind)
            {
            case PostprocessorKind.StateInspector:
                return(new StateInspector.StateInspectorOutput(p, logPartTokenFactories));

            case PostprocessorKind.Timeline:
                return(new Timeline.TimelinePostprocessorOutput(p, logPartTokenFactories));

            case PostprocessorKind.SequenceDiagram:
                return(new SequenceDiagram.SequenceDiagramPostprocessorOutput(p, null));

            case PostprocessorKind.TimeSeries:
                return(new TimeSeries.TimeSeriesPostprocessorOutput(p, null, timeSeriesTypesAccess));

            case PostprocessorKind.Correlator:
                return(new Correlation.PostprocessorOutput(p, logPartTokenFactories, nodeDetectionTokenFactories));

            default:
                return(null);
            }
        }
Exemple #9
0
        public object Deserialize(PostprocessorKind kind, LogSourcePostprocessorDeserializationParams p)
        {
            switch (kind)
            {
            case PostprocessorKind.StateInspector:
                return(new StateInspector.StateInspectorOutput(p));

            case PostprocessorKind.Timeline:
                return(new Timeline.TimelinePostprocessorOutput(p, null));

            case PostprocessorKind.SequenceDiagram:
                return(new SequenceDiagram.SequenceDiagramPostprocessorOutput(p, null));

            case PostprocessorKind.TimeSeries:
                return(new TimeSeries.TimeSeriesPostprocessorOutput(p, null, timeSeriesTypesAccess));

            case PostprocessorKind.Correlator:
                return(Correlation.CorrelatorPostprocessorOutput.Parse(p.Reader));

            default:
                return(null);
            }
        }
Exemple #10
0
 public LogSourcePostprocessorControlHandler(
     IManagerInternal postprocessorsManager,
     PostprocessorKind postprocessorKind,
     Func <IPostprocessorVisualizerPresenter> visualizerPresenter,
     IShellOpen shellOpen,
     ITempFilesManager tempFiles
     )
 {
     this.postprocessorsManager = postprocessorsManager;
     this.postprocessorKind     = postprocessorKind;
     this.visualizerPresenter   = visualizerPresenter;
     this.shellOpen             = shellOpen;
     this.tempFiles             = tempFiles;
     this.getOutputs            = Selectors.Create(
         () => postprocessorsManager.LogSourcePostprocessors,
         outputs => ImmutableList.CreateRange(
             outputs.Where(output => output.Postprocessor.Kind == postprocessorKind)
             )
         );
     this.getControlData = Selectors.Create(
         getOutputs,
         outputs => GetCurrentData(outputs, postprocessorKind)
         );
 }
Exemple #11
0
 TN.IToastNotificationItem IPresentationObjectsFactory.CreateUnprocessedLogsToastNotification(PostprocessorKind postprocessorKind)
 {
     return(new UnprocessedLogsToastNotification(ppm, lsm, postprocessorKind));
 }
Exemple #12
0
 public static LogSourcePostprocessorState[] GetPostprocessorOutputsByPostprocessorId(this IReadOnlyList <LogSourcePostprocessorState> outputs, PostprocessorKind postprocessorKind)
 {
     return(outputs
            .Where(output => output.Postprocessor.Kind == postprocessorKind)
            .ToArray());
 }
Exemple #13
0
 public static LogSourcePostprocessorOutput[] GetPostprocessorOutputsByPostprocessorId(this IManager postprocessorsManager, PostprocessorKind postprocessorKind)
 {
     return(postprocessorsManager
            .LogSourcePostprocessorsOutputs
            .Where(output => output.PostprocessorMetadata.Kind == postprocessorKind)
            .ToArray());
 }
Exemple #14
0
 public LogSourcePostprocessor(
     PostprocessorKind kind,
     Func <LogSourcePostprocessorInput, Task <IPostprocessorRunSummary> > run
     ) : this(kind, MakeRunAdapter(run))
 {
 }
Exemple #15
0
        static ControlData GetCurrentData(ImmutableList <LogSourcePostprocessorState> outputs, PostprocessorKind postprocessorKind)
        {
            if (outputs.Count == 0)
            {
                return(new ControlData(true, postprocessorKind.ToDisplayString() + ": N/A"));
            }

            int    nrOfRunning               = 0;
            int    nrOfLoading               = 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 LogSourcePostprocessorState.Status.Finished:
                case LogSourcePostprocessorState.Status.Failed:
                    if (output.LastRunSummary != null)
                    {
                        if (output.LastRunSummary.HasWarnings)
                        {
                            ++nrOfProcessedWithWarnings;
                        }
                        if (output.LastRunSummary.HasErrors)
                        {
                            ++nrOfProcessedWithErrors;
                        }
                    }
                    ++nrOfProcessed;
                    break;

                case LogSourcePostprocessorState.Status.Outdated:
                    ++nrOfOutdated;
                    ++nrOfProcessed;
                    break;

                case LogSourcePostprocessorState.Status.InProgress:
                    ++nrOfRunning;
                    progress = output.Progress;
                    break;

                case LogSourcePostprocessorState.Status.Loading:
                    ++nrOfLoading;
                    progress = output.Progress;
                    break;

                case LogSourcePostprocessorState.Status.NeverRun:
                    ++nrOfUnprocessed;
                    break;
                }
            }

            var    isClickableCaption = false;
            string action             = null;
            string statusText         = null;

            string controlContent = "";

            ControlData.StatusColor controlColor = ControlData.StatusColor.Neutral;
            double?controlProgress = null;

            Action appendReportLinkIfRequired = () =>
            {
                if (nrOfProcessedWithErrors > 0)
                {
                    statusText += " *report with errors*";
                }
                else if (nrOfProcessedWithWarnings > 0)
                {
                    statusText += " *report with warnings*";
                }
            };

            if (nrOfLoading > 0 && nrOfRunning == 0)
            {
                statusText      = string.Format("loading... ({0} of {1} logs completed)", nrOfLoading, nrOfLoading + nrOfProcessed);
                controlProgress = progress;
            }
            else if (nrOfRunning > 0)
            {
                statusText      = string.Format("running... ({0} of {1} logs completed)", nrOfProcessed, nrOfRunning + nrOfProcessed + nrOfLoading);
                controlProgress = 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 (nrOfProcessed > 0)
                {
                    isClickableCaption = true;
                }
                action       = "run postprocessor";
                controlColor = ControlData.StatusColor.Warning;
            }
            else
            {
                statusText = string.Format("all logs processed");
                if (nrOfProcessed > 0)
                {
                    isClickableCaption = true;
                }
                appendReportLinkIfRequired();
                action = "re-process";
                if (nrOfProcessedWithErrors > 0)
                {
                    controlColor = ControlData.StatusColor.Error;
                }
                else
                {
                    controlColor = ControlData.StatusColor.Success;
                }
            }

            var contentBuilder = new StringBuilder();

            if (isClickableCaption)
            {
                contentBuilder.AppendFormat("*{1} {0}:*", outputs[0].Postprocessor.Kind.ToDisplayString(), Constants.ShowVisualizerActionId);
            }
            else
            {
                contentBuilder.AppendFormat("{0}:", outputs[0].Postprocessor.Kind.ToDisplayString());
            }
            if (statusText != null)
            {
                contentBuilder.AppendFormat("  {0}", statusText);
            }
            if (action != null)
            {
                contentBuilder.AppendFormat("  *{1} {0}*", action, Constants.RunActionId);
            }
            controlContent += contentBuilder.ToString();

            return(new ControlData(false, controlContent, controlColor, controlProgress));
        }