예제 #1
0
        public static async void ExecuteBatchAnalysisAsync()
        {
            if (_dte.ActiveDocument.ActiveWindow == null)
            {
                return;
            }

            var scriptEditorControl = GetCurrentAnalysisWindowEditorControl();

            if (scriptEditorControl == null)
            {
                return;
            }

            var dialogSelected = ShowDialogForSelectConnection();

            if (dialogSelected == null)
            {
                return;
            }

            var analysisServerResultsControl = RestoreAnalysisServerResultsControl(scriptEditorControl, showOriginalControls: false);

            try
            {
                var document  = (TextDocument)_dte.ActiveDocument.Object("TextDocument");
                var statement = (document.Selection.Text.Length > 0 ? document.Selection.Text : document.StartPoint.CreateEditPoint().GetText(document.EndPoint)).Trim();
                if (statement.Length == 0)
                {
                    return;
                }

                LogoPanel.SetMode(scriptEditorControl, LogoPanel.PanelMode.Batch);

                var server   = scriptEditorControl.Connection.ServerName;
                var database = scriptEditorControl.Connection.AdvancedOptions.Get("DATABASE");

                using (var client = new SSASQueryAnalyzerClient(server, database))
                {
                    client.ExecutionProgressControlEnabled       = true;
                    client.ExecutionProgressControl.TitleMessage = "Batch";

                    analysisServerResultsControl.ResizeFor(client.ExecutionProgressControl);
                    analysisServerResultsControl.Controls.Add(client.ExecutionProgressControl);

                    var analyzerStatistics = await client.AnalyzeBatchAsync(dialogSelected.Item1, statement, batchName : dialogSelected.Item2);

                    var control = client.BuildBatchResultControl(analyzerStatistics);
                    analysisServerResultsControl.ResizeFor(control);
                    analysisServerResultsControl.Controls.Add(control);
                }
            }
            catch (Exception ex)
            {
                analysisServerResultsControl.Controls.Add(CustomErrorControl.CreateFromException(ex));
            }
        }
예제 #2
0
        public static async void ExecuteLoadFromBatchAnalysisAsync(string connectionStringBatch, string batchID, string statement, Action onExecuted = null)
        {
            NewAnalysisWindow();

            var scriptEditorControl = GetCurrentAnalysisWindowEditorControl();

            if (scriptEditorControl == null || scriptEditorControl.Connection == null)
            {
                return;
            }

            var analysisServerResultsControl = RestoreAnalysisServerResultsControl(scriptEditorControl, showOriginalControls: false);

            try
            {
                var document = (TextDocument)_dte.ActiveDocument.Object("TextDocument");

                var selection = document.Selection;
                selection.StartOfDocument(false);
                selection.EndOfDocument(true);
                selection.Delete();

                var point = document.EndPoint.CreateEditPoint();
                point.Insert(statement);

                LogoPanel.SetMode(scriptEditorControl, LogoPanel.PanelMode.LoadFomDB);

                var server   = scriptEditorControl.Connection.ServerName;
                var database = scriptEditorControl.Connection.AdvancedOptions.Get("DATABASE");

                using (var client = new SSASQueryAnalyzerClient(server, database))
                {
                    client.ExecutionProgressControlEnabled       = true;
                    client.ExecutionProgressControl.TitleMessage = "FromBatch";

                    analysisServerResultsControl.ResizeFor(client.ExecutionProgressControl);
                    analysisServerResultsControl.Controls.Add(client.ExecutionProgressControl);

                    var analyzerStatistics = await client.AnalyzeFromBatchAsync(connectionStringBatch, batchID);

                    ValidateFromBatchAnalysisSettings(analyzerStatistics.ColdCacheExecutionResult.ASQAServerConfig);

                    var control = client.BuildLoadBatchResultControl(analyzerStatistics);
                    analysisServerResultsControl.ResizeFor(control);
                    analysisServerResultsControl.Controls.Add(control);
                }

                onExecuted?.Invoke();
            }
            catch (Exception ex)
            {
                analysisServerResultsControl.Controls.Add(CustomErrorControl.CreateFromException(ex));
            }
        }
예제 #3
0
        public static void NewAnalysisWindow(bool debug = false)
        {
            var scriptFactory = ServiceCache.ScriptFactory;

            if (scriptFactory == null)
            {
                return;
            }

            var scriptEditorControl = (ScriptAndResultsEditorControl)scriptFactory.CreateNewBlankScript(ScriptType.Mdx);

            LogoPanel.Create(scriptEditorControl);

            AnalysisWindows.Add(_dte.ActiveDocument.ActiveWindow, scriptEditorControl);
#if DEBUG
            var debugDocument = (TextDocument)_dte.ActiveDocument.Object("TextDocument");

            var debugPoint = debugDocument.EndPoint.CreateEditPoint();
            debugPoint.Insert(DefaultHeader());
            debugPoint = debugDocument.EndPoint.CreateEditPoint();
            debugPoint.Insert(CommandNewAnalysisDefaultStatement);
#endif
        }
예제 #4
0
        public static async void ExecuteAnalysisAsync(Action onExecuted = null)
        {
            if (_dte.ActiveDocument.ActiveWindow == null)
            {
                return;
            }

            var scriptEditorControl = GetCurrentAnalysisWindowEditorControl();

            if (scriptEditorControl == null)
            {
                return;
            }

            var analysisServerResultsControl = RestoreAnalysisServerResultsControl(scriptEditorControl, showOriginalControls: false);

            try
            {
                var document  = (TextDocument)_dte.ActiveDocument.Object("TextDocument");
                var statement = (document.Selection.Text.Length > 0 ? document.Selection.Text : document.StartPoint.CreateEditPoint().GetText(document.EndPoint)).Trim();
                if (statement.Length == 0)
                {
                    return;
                }

                var server   = scriptEditorControl.Connection.ServerName;
                var database = scriptEditorControl.Connection.AdvancedOptions.Get("DATABASE");

                LogoPanel.SetMode(scriptEditorControl, LogoPanel.PanelMode.Live);

                using (var client = new SSASQueryAnalyzerClient(server, database))
                {
                    using (var config = await client.GetConfigurationForTraceEventsAsync())
                        ValidateLiveAnalysisSettings(config);

                    client.DebugToXml = Settings.Default.DebugEnabled;
                    client.ExecutionProgressControlEnabled            = true;
                    client.ExecutionProgressControl.ActivitiesEnabled = Settings.Default.ExecutionProgressActivitiesEnabled;
                    client.ExecutionProgressControl.TitleMessage      = "Live";

                    analysisServerResultsControl.ResizeFor(client.ExecutionProgressControl);
                    analysisServerResultsControl.Controls.Add(client.ExecutionProgressControl);

                    var analyzerStatistics = await client.AnalyzeAsync(statement, queryResultRowLimit : Settings.Default.MaxRowsReturned);

                    {
                        LogoPanel.SetValues(scriptEditorControl,
                                            columns: analyzerStatistics.ColdCacheExecutionResult.QueryResults.Columns.Count,
                                            rows: analyzerStatistics.ColdCacheExecutionResult.QueryResults.Rows.Count
                                            );

                        var control = client.BuildResultControl(analyzerStatistics);

                        analysisServerResultsControl.ResizeFor(control);
                        analysisServerResultsControl.Controls.Add(control);
                    }
                }

                onExecuted?.Invoke();
            }
            catch (Exception ex)
            {
                analysisServerResultsControl.Controls.Add(CustomErrorControl.CreateFromException(ex));
            }
        }