/// <summary> /// Packages stored procedures into a DACPAC. /// </summary> private void PublishToDacPac(SqlSProcPublishSettings settings, IEnumerable <string> sprocFiles) { var project = _pss.GetSelectedProject <IVsHierarchy>()?.GetDTEProject(); var dacpacPath = Path.ChangeExtension(project.FullName, DacPacExtension); CreateDacPac(settings, sprocFiles, dacpacPath); RtvsTelemetry.Current?.TelemetryService.ReportEvent(TelemetryArea.SQL, SqlTelemetryEvents.SqlDacPacPublish); }
private void ConfigureSettingAccessMock(IEnumerable <IConfigurationSetting> settings) { var confProj = Substitute.For <ConfiguredProject>(); var unconf = Substitute.For <UnconfiguredProject>(); unconf.LoadedConfiguredProjects.Returns((IEnumerable <ConfiguredProject>) new ConfiguredProject[] { confProj }); var browseContext = Substitute.For <IVsBrowseObjectContext>(); browseContext.UnconfiguredProject.Returns(unconf); var dteProj = Substitute.For <EnvDTE.Project>(); dteProj.Object.Returns(browseContext); var access = Substitute.For <IProjectConfigurationSettingsAccess>(); var coll = new ConfigurationSettingCollection(); foreach (var s in settings) { coll.Add(s); } access.Settings.Returns(coll); _pcsp.OpenProjectSettingsAccessAsync(confProj).Returns(Task.FromResult(access)); object ext; var hier = Substitute.For <IVsHierarchy>(); hier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ext).Returns((c) => { c[2] = dteProj; return(VSConstants.S_OK); }); _pss.GetSelectedProject <IVsHierarchy>().Returns(hier); }
private void Handle() { var project = _pss.GetSelectedProject <IVsHierarchy>()?.GetDTEProject(); if (project != null) { var sprocFiles = project.GetSProcFiles(_pss); if (sprocFiles.Any()) { try { // Make sure all files are saved and up to date on disk. var dte = _appShell.GetGlobalService <DTE>(typeof(DTE)); dte.ExecuteCommand("File.SaveAll"); var publisher = new SProcPublisher(_appShell, _pss, _fs, _dacServicesProvider.GetDacPackageServices()); var settings = new SqlSProcPublishSettings(_settings); publisher.Publish(settings, sprocFiles); } catch (Exception ex) { _appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.SqlPublish_PublishError, ex.Message)); } } else { _appShell.ShowErrorMessage(Resources.SqlPublishDialog_NoSProcFiles); } } }
protected async Task SaveSetting(string value) { string name = null; var hier = _projectSystemServices.GetSelectedProject <IVsHierarchy>(); var configuredProject = hier?.GetConfiguredProject(); if (configuredProject != null) { using (var access = await _projectConfigurationSettingsProvider.OpenProjectSettingsAccessAsync(configuredProject)) { name = access.Settings.FindNextAvailableSettingName(_settingNameTemplate); var s = new ConfigurationSetting(name, value ?? name, ConfigurationSettingValueType.String) { EditorType = ConnectionStringEditor.ConnectionStringEditorName, Category = ConnectionStringEditor.ConnectionStringEditorCategory, Description = Resources.ConnectionStringDescription }; access.Settings.Add(s); } } if (Workflow.RSession.IsHostRunning) { var expr = Invariant($"if (!exists('settings')) {{ settings <- as.environment(list()); }}; if (is.environment(settings)) {{ settings${name ?? _settingNameTemplate} = {value.ToRStringLiteral()}; }}"); Workflow.Operations.EnqueueExpression(expr, addNewLine: true); } }
public void PublishSProcCommandHandle01() { _pss.GetSelectedProject <IVsHierarchy>().Returns((IVsHierarchy)null); _pss.GetProjectFiles(null).ReturnsForAnyArgs(new string[] { "file.r" }); var hier = Substitute.For <IVsHierarchy>(); object ext; hier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ext).Returns((c) => { c[2] = Substitute.For <EnvDTE.Project>(); return(VSConstants.S_OK); }); _pss.GetSelectedProject <IVsHierarchy>().Returns(hier); var cmd = new PublishSProcCommand(_appShell, _pss); cmd.TryHandleCommand(null, RPackageCommandId.icmdPublishSProc, false, 0, IntPtr.Zero, IntPtr.Zero).Should().BeTrue(); //_appShell.Received().ShowErrorMessage(Resources.SqlPublishDialog_NoDbProject); }
protected override void Handle() { string projectFile = null; var project = _pss.GetSelectedProject <IVsProject>(); if (VSConstants.S_OK == project?.GetMkDocument((uint)VSConstants.VSITEMID.Root, out projectFile)) { if (!string.IsNullOrEmpty(projectFile)) { _interactiveWorkflow.RSession.SetWorkingDirectoryAsync(Path.GetDirectoryName(projectFile)) .SilenceException <RException>() .DoNotWait(); } } }
private void SetupProjectMocks(string fileName) { var dteProj = Substitute.For <EnvDTE.Project>(); dteProj.FullName.Returns(fileName); dteProj.Name.Returns(Path.GetFileNameWithoutExtension(fileName)); object ext; var hier = Substitute.For <IVsHierarchy>(); hier.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out ext).Returns((c) => { c[2] = dteProj; return(VSConstants.S_OK); }); _pss.GetSelectedProject <IVsHierarchy>().Returns(hier); }
private async Task PopulateTargetsAsync() { var project = _pss.GetSelectedProject <IVsHierarchy>().GetConfiguredProject(); switch (Settings.TargetType) { case PublishTargetType.Dacpac: Targets = new List <string>(); break; case PublishTargetType.Project: PopulateProjectList(); break; case PublishTargetType.Database: await PopulateDatabaseConnectionsListAsync(project); break; } }
protected async Task SaveSetting(string value) { string name = null; var hier = _projectSystemServices.GetSelectedProject <IVsHierarchy>(); var configuredProject = hier?.GetConfiguredProject(); if (configuredProject != null) { using (var access = await _projectConfigurationSettingsProvider.OpenProjectSettingsAccessAsync(configuredProject)) { name = access.Settings.FindNextAvailableSettingName(_settingNameTemplate); var s = new ConfigurationSetting(name, value ?? name, ConfigurationSettingValueType.String); s.EditorType = ConnectionStringEditor.ConnectionStringEditorName; s.Category = ConnectionStringEditor.ConnectionStringEditorCategory; s.Description = Resources.ConnectionStringDescription; access.Settings.Add(s); } } if (Workflow.RSession.IsHostRunning) { Workflow.Operations.EnqueueExpression(Invariant($"{name ?? _settingNameTemplate} <- '{value}'"), addNewLine: true); } }