Ejemplo n.º 1
0
        public AllPostprocessorsControlHandler(
            IManagerInternal postprocessorsManager,
            ICorrelationManager correlationManager
            )
        {
            this.postprocessorsManager = postprocessorsManager;
            this.getOutputs            = Selectors.Create(
                () => postprocessorsManager.LogSourcePostprocessors,
                () => correlationManager.StateSummary,
                (outputs, correlatorSummary) =>
                outputs.GetAutoPostprocessingCapableOutputs()
                .Union(GetCorrelationOutputs(outputs, correlatorSummary))
                .ToArray()
                );
            this.getControlData = Selectors.Create(
                getOutputs,
                outputs => {
                var relevantPostprocessorExists = outputs.Any();

                return(new ControlData(
                           !relevantPostprocessorExists,
                           "*action Run all postprocessors*",
                           ControlData.StatusColor.Neutral
                           ));
            }
                );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the <paramref name="correlatedFunc"/> with its own <see cref="CorrelationContext"/>.
        /// </summary>
        /// <typeparam name="T">The return type.</typeparam>
        /// <param name="correlationManager">The correlation manager.</param>
        /// <param name="correlatedFunc">The func to execute.</param>
        /// <param name="onException">A delegate to handle the exception inside the correlation scope, before it is disposed. Returns <see langword="true" /> to consider the exception handled, or <see langword="false" /> to throw.</param>
        /// <returns>Returns the result of the <paramref name="correlatedFunc"/>.</returns>
        /// <remarks>
        /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
        /// </remarks>
        public static T Correlate <T>(this ICorrelationManager correlationManager, Func <T> correlatedFunc, OnException <T>?onException)
        {
            if (correlationManager is null)
            {
                throw new ArgumentNullException(nameof(correlationManager));
            }

            return(correlationManager.Correlate(null, correlatedFunc, onException));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the <paramref name="correlatedAction"/> with its own <see cref="CorrelationContext"/>.
        /// </summary>
        /// <param name="correlationManager">The correlation manager.</param>
        /// <param name="correlationId">The correlation id to use, or null to generate a new one.</param>
        /// <param name="correlatedAction">The action to execute.</param>
        /// <remarks>
        /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
        /// </remarks>
        public static void Correlate(this ICorrelationManager correlationManager, string?correlationId, Action correlatedAction)
        {
            if (correlationManager is null)
            {
                throw new ArgumentNullException(nameof(correlationManager));
            }

            correlationManager.Correlate(correlationId, correlatedAction, null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes the <paramref name="correlatedAction"/> with its own <see cref="CorrelationContext"/>.
        /// </summary>
        /// <param name="correlationManager">The correlation manager.</param>
        /// <param name="correlatedAction">The action to execute.</param>
        /// <param name="onException">A delegate to handle the exception inside the correlation scope, before it is disposed. Returns <see langword="true" /> to consider the exception handled, or <see langword="false" /> to throw.</param>
        /// <remarks>
        /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
        /// </remarks>
        public static void Correlate(this ICorrelationManager correlationManager, Action correlatedAction, OnException?onException)
        {
            if (correlationManager is null)
            {
                throw new ArgumentNullException(nameof(correlationManager));
            }

            correlationManager.Correlate(null, correlatedAction, onException);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Executes the <paramref name="correlatedFunc"/> with its own <see cref="CorrelationContext"/>.
        /// </summary>
        /// <typeparam name="T">The return type.</typeparam>
        /// <param name="correlationManager">The correlation manager.</param>
        /// <param name="correlationId">The correlation id to use, or null to generate a new one.</param>
        /// <param name="correlatedFunc">The func to execute.</param>
        /// <returns>Returns the result of the <paramref name="correlatedFunc"/>.</returns>
        /// <remarks>
        /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
        /// </remarks>
        public static T Correlate <T>(this ICorrelationManager correlationManager, string?correlationId, Func <T> correlatedFunc)
        {
            if (correlationManager is null)
            {
                throw new ArgumentNullException(nameof(correlationManager));
            }

            return(correlationManager.Correlate(correlationId, correlatedFunc, null));
        }
Ejemplo n.º 6
0
 public PresentationObjectsFactory(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     IChangeNotification changeNotification,
     IAlertPopup alerts,
     ICorrelationManager correlationManager
     )
 {
     this.ppm                = ppm;
     this.lsm                = lsm;
     this.alerts             = alerts;
     this.correlationManager = correlationManager;
 }
 public CorrelatorToastNotification(
     IManagerInternal ppm,
     ILogSourcesManager lsm,
     ICorrelationManager correlationManager
     )
 {
     this.ppm = ppm;
     this.correlationManager = correlationManager;
     // todo: redesign IToastNotificationItem to be reactive
     ppm.Changed += (s, e) => Update();
     lsm.OnLogSourceTimeOffsetChanged += (s, e) => Update();
     Update();
 }
Ejemplo n.º 8
0
 public CorrelatorPostprocessorControlHandler(
     ICorrelationManager correlationManager,
     ITempFilesManager tempFilesManager,
     IShellOpen shellOpen
     )
 {
     this.correlationManager = correlationManager;
     this.tempFilesManager   = tempFilesManager;
     this.shellOpen          = shellOpen;
     this.getControlData     = Selectors.Create(
         () => correlationManager.StateSummary,
         GetCurrentData
         );
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Executes the <paramref name="correlatedFunc"/> with its own <see cref="CorrelationContext"/>.
 /// </summary>
 /// <typeparam name="T">The return type.</typeparam>
 /// <param name="correlationManager">The correlation manager.</param>
 /// <param name="correlatedFunc">The func to execute.</param>
 /// <returns>Returns the result of the <paramref name="correlatedFunc"/>.</returns>
 /// <remarks>
 /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
 /// </remarks>
 public static T Correlate <T>(this ICorrelationManager correlationManager, Func <T> correlatedFunc)
 {
     return(correlationManager.Correlate(null, correlatedFunc));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Executes the <paramref name="correlatedAction"/> with its own <see cref="CorrelationContext"/>.
 /// </summary>
 /// <param name="correlationManager">The correlation manager.</param>
 /// <param name="correlatedAction">The action to execute.</param>
 /// <remarks>
 /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
 /// </remarks>
 public static void Correlate(this ICorrelationManager correlationManager, Action correlatedAction)
 {
     correlationManager.Correlate(null, correlatedAction);
 }
Ejemplo n.º 11
0
        public Factory(
            IViewsFactory postprocessingViewsFactory,
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext synchronizationContext,
            IChangeNotification changeNotification,
            IBookmarks bookmarks,
            IModelThreads threads,
            Persistence.IStorageManager storageManager,
            ILogSourceNamesProvider logSourceNamesProvider,
            IUserNamesProvider shortNames,
            SourcesManager.IPresenter sourcesManagerPresenter,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IPresentersFacade presentersFacade,
            IAlertPopup alerts,
            IColorTheme colorTheme,
            Drawing.IMatrixFactory matrixFactory,
            ICorrelationManager correlationManager
            )
        {
            stateInspectorVisualizer = new Lazy <StateInspectorVisualizer.IPresenterInternal>(() =>
            {
                var view  = postprocessingViewsFactory.CreateStateInspectorView();
                var model = new LogJoint.Postprocessing.StateInspector.StateInspectorVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    synchronizationContext,
                    shortNames
                    );
                return(new StateInspectorVisualizer.StateInspectorPresenter(
                           view,
                           model,
                           shortNames,
                           logSourcesManager,
                           loadedMessagesPresenter,
                           bookmarks,
                           threads,
                           presentersFacade,
                           clipboardAccess,
                           sourcesManagerPresenter,
                           colorTheme
                           ));
            });

            timelineVisualizer = new Lazy <TimelineVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimelineView();
                var model = new LogJoint.Postprocessing.Timeline.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimelineVisualizer.TimelineVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme
                           ));
            });

            sequenceDiagramVisualizer = new Lazy <SequenceDiagramVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateSequenceDiagramView();
                var model = new LogJoint.Postprocessing.SequenceDiagram.SequenceDiagramVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider,
                    changeNotification
                    );
                return(new SequenceDiagramVisualizer.SequenceDiagramVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme,
                           matrixFactory
                           ));
            });

            timeSeriesVisualizer = new Lazy <TimeSeriesVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimeSeriesView();
                var model = new LogJoint.Postprocessing.TimeSeries.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimeSeriesVisualizer.TimeSeriesVisualizerPresenter(
                           model,
                           view,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter.LogViewerPresenter,
                           bookmarks,
                           presentersFacade,
                           changeNotification
                           ));
            });
        }
Ejemplo n.º 12
0
        public Presenter(
            IView view,
            IManagerInternal postprocessorsManager,
            ICorrelationManager correlationManager,
            IFactory presentersFactory,
            ITempFilesManager tempFiles,
            IShellOpen shellOpen,
            NewLogSourceDialog.IPresenter newLogSourceDialog,
            IChangeNotification changeNotification,
            MainForm.IPresenter mainFormPresenter
            )
        {
            this.view = view;
            this.postprocessorsManager = postprocessorsManager;
            this.correlationManager    = correlationManager;
            this.presentersFactory     = presentersFactory;
            this.tempFiles             = tempFiles;
            this.shellOpen             = shellOpen;
            this.changeNotification    = changeNotification.CreateChainedChangeNotification(false);


            InitAndAddProstprocessorHandler(ViewControlId.StateInspector, PostprocessorKind.StateInspector);
            InitAndAddProstprocessorHandler(ViewControlId.Timeline, PostprocessorKind.Timeline);
            InitAndAddProstprocessorHandler(ViewControlId.Sequence, PostprocessorKind.SequenceDiagram);
            InitAndAddProstprocessorHandler(ViewControlId.Correlate, PostprocessorKind.Correlator);
            InitAndAddProstprocessorHandler(ViewControlId.TimeSeries, PostprocessorKind.TimeSeries);
            viewControlHandlers.Add(ViewControlId.LogsCollectionControl1, new GenericLogsOpenerControlHandler(newLogSourceDialog));
            viewControlHandlers.Add(ViewControlId.AllPostprocessors, new AllPostprocessorsControlHandler(postprocessorsManager, correlationManager));

            this.getControlsData = Selectors.Create(
                () => (
                    viewControlHandlers[ViewControlId.StateInspector].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Timeline].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Sequence].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Correlate].GetCurrentData(),
                    viewControlHandlers[ViewControlId.TimeSeries].GetCurrentData(),
                    viewControlHandlers[ViewControlId.LogsCollectionControl1].GetCurrentData(),
                    viewControlHandlers[ViewControlId.AllPostprocessors].GetCurrentData()
                    ), _ => {
                return(ImmutableDictionary.CreateRange(
                           viewControlHandlers.Select(h => new KeyValuePair <ViewControlId, ControlData>(h.Key, h.Value.GetCurrentData()))
                           ));
            }
                );

            this.getActionStates = Selectors.Create(
                getControlsData,
                ctrlData => ImmutableDictionary.CreateRange(
                    ctrlData.Select(h => {
                Action makeAction(string id) =>
                h.Value.Content.Contains($"*{id}")
                                                        ? () => viewControlHandlers[h.Key].ExecuteAction(id, ClickFlags.None)
                                                        : (Action)null;
                return(new KeyValuePair <ViewControlId, ActionState>(
                           h.Key,
                           new ActionState
                {
                    Enabled = !h.Value.Disabled,
                    Run = makeAction(Constants.RunActionId),
                    Show = makeAction(Constants.ShowVisualizerActionId)
                }
                           ));
            })
                    )
                );

            this.view.SetViewModel(this);

            if (IsBrowser.Value)
            {
                this.changeNotification.Active = true;
            }
            else
            {
                mainFormPresenter.TabChanging += (sender, e) =>
                {
                    this.changeNotification.Active = e.TabID == MainForm.TabIDs.Postprocessing;
                };
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Executes the <paramref name="correlatedFunc"/> with its own <see cref="CorrelationContext"/>.
 /// </summary>
 /// <typeparam name="T">The return type.</typeparam>
 /// <param name="correlationManager">The correlation manager.</param>
 /// <param name="correlationId">The correlation id to use, or null to generate a new one.</param>
 /// <param name="correlatedFunc">The func to execute.</param>
 /// <returns>Returns the result of the <paramref name="correlatedFunc"/>.</returns>
 /// <remarks>
 /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
 /// </remarks>
 public static T Correlate <T>(this ICorrelationManager correlationManager, string correlationId, Func <T> correlatedFunc)
 {
     return(correlationManager.Correlate(correlationId, correlatedFunc, null));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Executes the <paramref name="correlatedFunc"/> with its own <see cref="CorrelationContext"/>.
 /// </summary>
 /// <typeparam name="T">The return type.</typeparam>
 /// <param name="correlationManager">The correlation manager.</param>
 /// <param name="correlatedFunc">The func to execute.</param>
 /// <param name="onException">A delegate to handle the exception inside the correlation scope, before it is disposed. Returns <see langword="true" /> to consider the exception handled, or <see langword="false" /> to throw.</param>
 /// <returns>Returns the result of the <paramref name="correlatedFunc"/>.</returns>
 /// <remarks>
 /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
 /// </remarks>
 public static T Correlate <T>(this ICorrelationManager correlationManager, Func <T> correlatedFunc, OnException <T> onException)
 {
     return(correlationManager.Correlate(null, correlatedFunc, onException));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Executes the <paramref name="correlatedAction"/> with its own <see cref="CorrelationContext"/>.
 /// </summary>
 /// <param name="correlationManager">The correlation manager.</param>
 /// <param name="correlationId">The correlation id to use, or null to generate a new one.</param>
 /// <param name="correlatedAction">The action to execute.</param>
 /// <remarks>
 /// When logging and tracing are both disabled, no correlation context is created and the action simply executed as it normally would.
 /// </remarks>
 public static void Correlate(this ICorrelationManager correlationManager, string correlationId, Action correlatedAction)
 {
     correlationManager.Correlate(correlationId, correlatedAction, null);
 }