public static SI.MenuData.Item CreateStateInspectorMenuItem(
            SI.IVisualizerNode selectedNode,
            LogJoint.UI.Presenters.IPromptDialog prompt,
            Preprocessing.IManager preprocessingManager,
            SpringServiceLog.IPreprocessingStepsFactory preprocessingStepsFactory
            )
        {
            if (preprocessingStepsFactory == null)
            {
                return(null);
            }

            SI.IVisualizerNode GetParent(SI.IVisualizerNode n) => n.Parent == null ? n : GetParent(n.Parent);

            var(id, referenceTime, env) = Rtc.MeetingsStateInspector.GetMeetingRelatedId(
                selectedNode.CreationEvent, selectedNode.ChangeHistory,
                GetParent(selectedNode).CreationEvent, GetParent(selectedNode).ChangeHistory
                );
            if (id == null)
            {
                return(null);
            }

            return(new SI.MenuData.Item(
                       "Download backend logs",
                       () =>
            {
                var input = prompt.ExecuteDialog(
                    "Download RTC backend logs",
                    "Specify query parameters",
                    $"ID={id}{Environment.NewLine}Environment={env ?? "(undetected)"}{Environment.NewLine}Reference time={referenceTime.ToString("o")}");
                if (input != null)
                {
                    var ids = new[] { id };
                    foreach (var line in input.Split('\r', '\n'))
                    {
                        var m = Regex.Match(line, @"^(?<k>[^\=]+)\=(?<v>.+)$", RegexOptions.ExplicitCapture);
                        if (!m.Success)
                        {
                            continue;
                        }
                        var k = m.Groups["k"].Value;
                        var v = m.Groups["v"].Value;
                        if (k == "ID")
                        {
                            ids = v.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        }
                        else if (k == "Environment")
                        {
                            env = v;
                        }
                        else if (k == "Reference time")
                        {
                            if (DateTime.TryParseExact(v, "o", null, System.Globalization.DateTimeStyles.None, out var tmpRefTime))
                            {
                                referenceTime = tmpRefTime;
                            }
                        }
                    }
                    preprocessingManager.Preprocess(
                        new[] { preprocessingStepsFactory.CreateDownloadBackendLogsStep(ids, referenceTime, env) },
                        "Downloading backend logs",
                        Preprocessing.PreprocessingOptions.HighlightNewPreprocessing
                        );
                }
            }
                       ));
        }
Exemplo n.º 2
0
        public static ModelObjects Create(LogJoint.IModel appModel)
        {
            var logger = appModel.TraceSourceFactory.CreateTraceSource("App", "sym-plugin");

            logger.Info("Symphony plugin loaded!");

            appModel.Postprocessing.TimeSeries.RegisterTimeSeriesTypesAssembly(typeof(TimeSeries.PostprocessorsFactory).Assembly);

            StateInspector.IPostprocessorsFactory statePostprocessors = new StateInspector.PostprocessorsFactory(
                appModel.TempFilesManager,
                appModel.Postprocessing
                );

            TimeSeries.IPostprocessorsFactory timeSeriesPostprocessors = new TimeSeries.PostprocessorsFactory(
                appModel.Postprocessing
                );

            Timeline.IPostprocessorsFactory timelinePostprocessors = new Timeline.PostprocessorsFactory(
                appModel.TempFilesManager,
                appModel.Postprocessing
                );

            SequenceDiagram.IPostprocessorsFactory sequenceDiagramPostprocessors = new SequenceDiagram.PostprocessorsFactory(
                appModel.Postprocessing
                );

            IPostprocessorsRegistry postprocessorsRegistry = new PostprocessorsInitializer(
                appModel.Postprocessing.Manager,
                appModel.UserDefinedFormatsManager,
                statePostprocessors,
                timeSeriesPostprocessors,
                new Correlator.PostprocessorsFactory(appModel),
                timelinePostprocessors,
                sequenceDiagramPostprocessors
                );

            var chromiumPlugin = appModel.PluginsManager.Get <Chromium.IPluginModel>();

            if (chromiumPlugin != null)
            {
                chromiumPlugin.RegisterSource(statePostprocessors.CreateChromeDebugSourceFactory());
                chromiumPlugin.RegisterSource(timeSeriesPostprocessors.CreateChromeDebugSourceFactory());
                chromiumPlugin.RegisterSource(timelinePostprocessors.CreateChromeDebugLogEventsSourceFactory());
                chromiumPlugin.RegisterSource(timelinePostprocessors.CreateChromeDriverEventsSourceFactory());
                chromiumPlugin.RegisterSource(sequenceDiagramPostprocessors.CreateChromeDebugLogEventsSourceFactory());
            }

            appModel.Preprocessing.ExtensionsRegistry.AddLogDownloaderRule(
                new Uri("https://perzoinc.atlassian.net/secure/attachment/"),
                Preprocessing.LogDownloaderRule.CreateBrowserDownloaderRule(new[] { "https://id.atlassian.com/login" })
                );

            SpringServiceLog.IPreprocessingStepsFactory backendLogsPreprocessingStepsFactory = null;
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                backendLogsPreprocessingStepsFactory = new SpringServiceLog.PreprocessingStepsFactory(
                    appModel.Preprocessing.StepsFactory,
                    appModel.WebViewTools,
                    appModel.ContentCache
                    );
                appModel.Preprocessing.ExtensionsRegistry.Register(new SpringServiceLog.PreprocessingManagerExtension(
                                                                       backendLogsPreprocessingStepsFactory));
            }

            return(new ModelObjects
            {
                PostprocessorsRegistry = postprocessorsRegistry,
                BackendLogsPreprocessingStepsFactory = backendLogsPreprocessingStepsFactory,
                Logger = logger
            });
        }