/// <summary> /// Generates SQL files for stored procedures as well as publishing scripts /// and then adds them to the target database project. /// </summary> private void PublishToProject(SqlSProcPublishSettings settings, IEnumerable <string> sprocFiles) { Check.ArgumentNull(nameof(settings), settings.TargetProject); var targetProject = _pss.GetProject(settings.TargetProject); var generator = new SProcProjectFilesGenerator(_pss, _services.FileSystem()); targetProject = targetProject ?? _pss.GetActiveProject(); generator.Generate(settings, sprocFiles, targetProject); RtvsTelemetry.Current?.TelemetryService.ReportEvent(TelemetryArea.SQL, SqlTelemetryEvents.SqlProjectPublish); }
private static string MakeCsvFileName(ICoreShell shell, IProjectSystemServices pss, string variableName) { var project = pss.GetActiveProject(); var projectName = project?.FileName; var contentTypeService = shell.GetService <IContentTypeRegistryService>(); var viewTracker = shell.GetService <IActiveWpfTextViewTracker>(); var activeView = viewTracker.GetLastActiveTextView(contentTypeService.GetContentType(RContentTypeDefinition.ContentType)); var filePath = activeView.GetFilePath(); var csvFileName = string.Empty; if (!string.IsNullOrEmpty(projectName)) { csvFileName += Path.GetFileNameWithoutExtension(projectName); csvFileName += "_"; } if (!string.IsNullOrEmpty(filePath)) { csvFileName += Path.GetFileNameWithoutExtension(filePath); csvFileName += "_"; } if (variableName.StartsWith("$", StringComparison.Ordinal)) { variableName = variableName.Substring(1); } int invalidCharIndex = variableName.IndexOfAny(Path.GetInvalidFileNameChars()); variableName = MakeFileSystemCompatible(variableName); if (variableName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { variableName = _variableNameReplacement; } csvFileName += variableName; return(csvFileName); }
public override async Task LaunchAsync(DebugLaunchOptions launchOptions) { // Reset first, before attaching debugger via LaunchAsync (since it'll detach on reset). if (await _properties.GetResetReplOnRunAsync()) { await _interactiveWorkflow.Operations.ResetAsync(); } // Base implementation will try to launch or attach via the debugger, but there's nothing to launch // in case of Ctrl+F5 - we only want to source the file. So only invoke base if we intend to debug. if (!launchOptions.HasFlag(DebugLaunchOptions.NoDebug)) { await base.LaunchAsync(launchOptions); } _interactiveWorkflow.ActiveWindow?.Container.Show(focus: false, immediate: false); bool transferFiles = await _properties.GetTransferProjectOnRunAsync(); string remotePath = await _properties.GetRemoteProjectPathAsync(); string filterString = await _properties.GetFileFilterAsync(); var activeProject = _pss.GetActiveProject(); if (transferFiles && Session.IsRemote && activeProject != null) { await SendProjectAsync(activeProject, remotePath, filterString, CancellationToken.None); } // user must set the path for local or remote cases var startupFile = await GetStartupFileAsync(transferFiles, activeProject); if (string.IsNullOrWhiteSpace(startupFile)) { Console.WriteErrorLine(Resources.Launch_NoStartupFile); return; } await SourceFileAsync(transferFiles, startupFile, $"{Resources.Launch_StartupFileDoesNotExist} {startupFile}"); var settingsFile = await _properties.GetSettingsFileAsync(); if (!string.IsNullOrWhiteSpace(settingsFile)) { if (activeProject != null) { var dirPath = Path.GetDirectoryName(activeProject.FullName); settingsFile = settingsFile.MakeAbsolutePathFromRRelative(dirPath); if (FileSystem.FileExists(settingsFile)) { if (Session.IsRemote) { var remoteSettingsPath = GetRemoteSettingsFile(settingsFile, dirPath, remotePath); await SourceFileAsync(transferFiles, remoteSettingsPath, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}"); } else { await SourceFileAsync(transferFiles, settingsFile, $"{Resources.Launch_SettingsFileDoesNotExist} {settingsFile}"); } } } } }
protected override void SetStatus() { Supported = true; Enabled = _pss.GetActiveProject() != null && _interactiveWorkflow.RSession.IsHostRunning && !_interactiveWorkflow.RSession.IsRemote; }
private static string MakeCsvFileName(IApplicationShell appShell, IProjectSystemServices pss, string variableName) { var project = pss.GetActiveProject(); var projectName = project?.FileName; var contentTypeService = appShell.ExportProvider.GetExportedValue<IContentTypeRegistryService>(); var viewTracker = appShell.ExportProvider.GetExportedValue<IActiveWpfTextViewTracker>(); var activeView = viewTracker.GetLastActiveTextView(contentTypeService.GetContentType(RContentTypeDefinition.ContentType)); var filePath = activeView.GetFilePath(); var csvFileName = string.Empty; if (!string.IsNullOrEmpty(projectName)) { csvFileName += Path.GetFileNameWithoutExtension(projectName); csvFileName += "_"; } if (!string.IsNullOrEmpty(filePath)) { csvFileName += Path.GetFileNameWithoutExtension(filePath); csvFileName += "_"; } if (variableName.StartsWith("$", StringComparison.Ordinal)) { variableName = variableName.Substring(1); } int invalidCharIndex = variableName.IndexOfAny(Path.GetInvalidFileNameChars()); variableName = MakeFileSystemCompatible(variableName); if (variableName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { variableName = _variableNameReplacement; } csvFileName += variableName; return csvFileName; }
protected override void SetStatus() { Supported = true; Enabled = _pss.GetActiveProject() != null; }