public static async Task<SqlPublshOptionsDialog> CreateAsync(
            IApplicationShell appShell, IProjectSystemServices pss, IProjectConfigurationSettingsProvider pcsp, ISettingsStorage settings) {
            var dialog = await CreateAsync(appShell, pss, new FileSystem(), pcsp, settings);

            await appShell.SwitchToMainThreadAsync();
            dialog.InitializeComponent();
            dialog.InitializeUI();
            return dialog;
        }
示例#2
0
        public static async Task <SqlPublshOptionsDialog> CreateAsync(
            IApplicationShell appShell, IProjectSystemServices pss, IProjectConfigurationSettingsProvider pcsp)
        {
            var dialog = await CreateAsync(appShell, pss, new FileSystem(), pcsp);

            await appShell.SwitchToMainThreadAsync();

            dialog.InitializeComponent();
            dialog.InitializeUI();
            return(dialog);
        }
示例#3
0
        public async Task <bool> TryHandleCommandAsync(IImmutableSet <IProjectTree> nodes, long commandId, bool focused, long commandExecuteOptions, IntPtr variantArgIn, IntPtr variantArgOut)
        {
            if (commandId == RPackageCommandId.icmdPublishSProcOptions)
            {
                if (_dacServicesProvider.GetDacPackageServices(showMessage: true) != null)
                {
                    var dlg = await SqlPublshOptionsDialog.CreateAsync(_appShell, _pss, _pcsp);

                    await _appShell.SwitchToMainThreadAsync();

                    dlg.ShowModal();
                }
                return(true);
            }
            return(false);
        }
示例#4
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices)
        {
            await appShell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0)
            {
                return;
            }

            var workflow = appShell.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate();
            var session  = workflow.RSession;

            var folder = GetTempCsvFilesFolder();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var pss          = appShell.ExportProvider.GetExportedValue <IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName  = MakeCsvFileName(appShell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var    statusBar = appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar));

            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                appShell.ProgressDialog.Show(async(p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file))
                {
                    processServices.Start(file);
                }
            } catch (Win32Exception ex) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } catch (IOException ex) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
示例#5
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices) {
            await appShell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0) {
                return;
            }

            var workflow = appShell.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate();
            var session = workflow.RSession;

            var folder = GetTempCsvFilesFolder();
            if (!Directory.Exists(folder)) {
                Directory.CreateDirectory(folder);
            }

            var pss = appShell.ExportProvider.GetExportedValue<IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName = MakeCsvFileName(appShell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar));
            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                appShell.ProgressDialog.Show(async (p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p, ct), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file)) {
                    processServices.Start(file);
                }
            } catch (Exception ex) when (ex is Win32Exception || ex is IOException || ex is UnauthorizedAccessException) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }