Esempio n. 1
0
        public static string Collect(IActionLog log)
        {
            string zipPath = string.Empty;

            _logFiles.Clear();

            try {
                zipPath = Path.Combine(Path.GetTempPath(), RtvsLogZipFile);
                var workflowProvider = VsAppShell.Current.GlobalServices.GetService <IRInteractiveWorkflowProvider>();
                var rSessionProvider = workflowProvider.GetOrCreate().RSessions;
                var sessions         = rSessionProvider.GetSessions();
                foreach (var s in sessions)
                {
                    s.FlushLog();
                }

                if (File.Exists(zipPath))
                {
                    File.Delete(zipPath);
                }
            } catch (IOException) {
            } catch (UnauthorizedAccessException) {
            } catch (ArgumentException) {
            }

            LongOperationNotification.ShowWaitingPopup(Resources.GatheringDiagnosticData, _actions, log);
            return(zipPath);
        }
        public void LaunchRClientSetup(ICoreShell coreShell)
        {
            _errorMessage = null;
            var rClientExe = Path.Combine(Path.GetTempPath(), "RClientSetup.exe");

            LongOperationNotification.ShowWaitingPopup(Resources.DownloadingRClientInstaller, new LongAction[] {
                new LongAction()
                {
                    Name = Resources.DownloadingRClientInstaller, Action = DownloadInstaller, Data = rClientExe
                }
            });

            if (!string.IsNullOrEmpty(_errorMessage))
            {
                coreShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_UnableToDownloadRClient, _errorMessage));
            }
            else
            {
                // Suppress 'Operation canceled by the user' if user clicks 'No' to elevation dialog.
                try {
                    coreShell.ShowMessage(Resources.PleaseRestartVisualStudioAfterRClientSetup, MessageButtons.OK);
                    Process.Start(rClientExe);
                } catch (Win32Exception) { }
            }
        }
Esempio n. 3
0
        public static ExcelData GenerateExcelData(string expression, int rows, int cols)
        {
            if (rows <= 0 || cols <= 0)
            {
                return(null);
            }

            try {
                ExcelData xlData = new ExcelData();
                xlData.CellData = new object[rows, cols];
                int chunkSize = 1000;

                int steps = (rows + chunkSize - 1) / chunkSize;
                List <LongAction> actions = new List <LongAction>();

                for (int i = 0; i < steps; i++)
                {
                    actions.Add(
                        new LongAction()
                    {
                        Data   = i,
                        Name   = Resources.Progress_PreparingExcelData,
                        Action = (o) => FetchChunk(expression, ((int)o) * chunkSize, chunkSize, xlData, rows, cols)
                    }
                        );
                }

                if (LongOperationNotification.ShowWaitingPopup(Resources.Progress_PreparingExcelData, actions))
                {
                    if (xlData.CellData[0, 0] == null)
                    {
                        return(null);
                    }
                    return(xlData);
                }
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                VsAppShell.Current.ShowErrorMessage(Resources.Error_ExcelCannotEvaluateExpression);
                GeneralLog.Write(ex);
            }
            return(null);
        }
Esempio n. 4
0
        public void LaunchRClientSetup(ICoreShell coreShell, IFileDownloader downloader = null)
        {
            coreShell.TelemetryService.ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientInstallYes);
            downloader = downloader ?? new FileDownloader();

            string downloadError = null;
            var    rClientExe    = Path.Combine(Path.GetTempPath(), "RClientSetup.exe");

            LongOperationNotification.ShowWaitingPopup(Resources.DownloadingRClientInstaller, new LongAction[] {
                new LongAction()
                {
                    Name   = Resources.DownloadingRClientInstaller,
                    Action = (o, ct) => {
                        downloadError = downloader.Download("http://go.microsoft.com/fwlink/?LinkId=800048", rClientExe, ct);
                    },
                }
            });

            if (!string.IsNullOrEmpty(downloadError))
            {
                var errorMessage = string.Format(CultureInfo.InvariantCulture, Resources.Error_UnableToDownloadRClient, downloadError);
                coreShell.ShowErrorMessage(errorMessage);
                coreShell.TelemetryService.ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientDownloadFailed, errorMessage);
                GeneralLog.Write(errorMessage);
            }
            else
            {
                // Suppress 'Operation canceled by the user' if user clicks 'No' to elevation dialog.
                try {
                    coreShell.ShowMessage(Resources.PleaseRestartVisualStudioAfterRClientSetup, MessageButtons.OK);
                    ProcessServices.Current.Start(rClientExe);
                } catch (Win32Exception ex) {
                    if ((uint)ex.NativeErrorCode == 0x800704C7)
                    {
                        coreShell.TelemetryService.ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientInstallCancel);
                    }
                }
            }
        }
        public void LaunchRClientSetup(IServiceContainer services, IFileDownloader downloader = null)
        {
            services.Telemetry().ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientInstallYes);
            downloader = downloader ?? new FileDownloader();

            string downloadError = null;
            var    rClientExe    = Path.Combine(Path.GetTempPath(), "RClientSetup.exe");

            LongOperationNotification.ShowWaitingPopup(Resources.DownloadingRClientInstaller, new LongAction[] {
                new LongAction()
                {
                    Name   = Resources.DownloadingRClientInstaller,
                    Action = (o, ct) => {
                        downloadError = downloader.Download("https://aka.ms/rclient/download", rClientExe, ct);
                    },
                },
            }, services.Log());

            if (!string.IsNullOrEmpty(downloadError))
            {
                var errorMessage = string.Format(CultureInfo.InvariantCulture, Resources.Error_UnableToDownloadRClient, downloadError);
                services.UI().ShowErrorMessage(errorMessage);
                services.Telemetry().ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientDownloadFailed, errorMessage);
                services.Log().Write(LogVerbosity.Minimal, MessageCategory.Error, "Microsoft R Client download error: " + errorMessage);
            }
            else
            {
                // Suppress 'Operation canceled by the user' if user clicks 'No' to elevation dialog.
                try {
                    services.UI().ShowMessage(Resources.PleaseRestartVisualStudioAfterRClientSetup, MessageButtons.OK);
                    services.Process().Start(rClientExe);
                } catch (Win32Exception ex) {
                    if ((uint)ex.NativeErrorCode == 0x800704C7)
                    {
                        services.Telemetry().ReportEvent(TelemetryArea.Configuration, RtvsTelemetry.ConfigurationEvents.RClientInstallCancel);
                    }
                }
            }
        }