Generate() публичный Метод

Generates SQL scripts for the deployment of R code into SQL database. Writes scripts to files and pushes files into the target database project.
public Generate ( SqlSProcPublishSettings settings, IEnumerable sprocFiles, EnvDTE targetProject ) : void
settings SqlSProcPublishSettings
sprocFiles IEnumerable
targetProject EnvDTE
Результат void
Пример #1
0
        /// <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, _fs);

            generator.Generate(settings, targetProject);
            RtvsTelemetry.Current?.TelemetryService.ReportEvent(TelemetryArea.SQL, SqlTelemetryEvents.SqlProjectPublish);
        }
Пример #2
0
        public void Generate(string rFile, RCodePlacement codePlacement, SqlQuoteType quoteType, string sprocName) {
            var fs = new FileSystem();
            var settings = new SqlSProcPublishSettings();
            var g = new SProcProjectFilesGenerator(_pss, fs);

            var targetProjItem = Substitute.For<EnvDTE.ProjectItem>();
            var targetProjItems = Substitute.For<EnvDTE.ProjectItems>();
            targetProjItem.ProjectItems.Returns(targetProjItems);

            var rootProjItems = Substitute.For<EnvDTE.ProjectItems>();
            rootProjItems.Item("R").Returns((EnvDTE.ProjectItem)null);
            rootProjItems.AddFolder("R").Returns(targetProjItem);
            _project.ProjectItems.Returns(rootProjItems);

            var templateFile = Path.Combine(_files.DestinationPath, Path.GetFileNameWithoutExtension(rFile) + SProcFileExtensions.SProcFileExtension);

           var sprocFiles = new string[] {
                Path.Combine(_files.DestinationPath, rFile),
                Path.Combine(_files.DestinationPath, Path.GetFileNameWithoutExtension(rFile) + SProcFileExtensions.QueryFileExtension),
                templateFile };

            settings.CodePlacement = codePlacement;
            settings.QuoteType = quoteType;

            g.Generate(settings, sprocFiles, _project);
            rootProjItems.Received().AddFolder("R");

            var targetFolder = Path.Combine(_files.DestinationPath, "R\\");
            var rFilePath = Path.Combine(targetFolder, rFile);
            var sprocFile = Path.ChangeExtension(Path.Combine(targetFolder, sprocName), ".sql");

            targetProjItem.ProjectItems.Received().AddFromFile(sprocFile);
            if (codePlacement == RCodePlacement.Table) {
                targetProjItem.ProjectItems.Received().AddFromFile(Path.Combine(targetFolder, SProcProjectFilesGenerator.PostDeploymentScriptName));
                targetProjItem.ProjectItems.Received().AddFromFile(Path.Combine(targetFolder, SProcProjectFilesGenerator.CreateRCodeTableScriptName));
            }

            var mode = codePlacement == RCodePlacement.Inline ? "inline" : "table";
            var baseline = fs.ReadAllText(Path.Combine(_files.DestinationPath, Invariant($"{Path.GetFileNameWithoutExtension(rFile)}.{mode}.baseline.sql")));
            string actual = fs.ReadAllText(sprocFile);
            BaselineCompare.CompareStringLines(baseline, actual);
        }
Пример #3
0
 /// <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, _fs);
     generator.Generate(settings, sprocFiles, targetProject);
     RtvsTelemetry.Current?.TelemetryService.ReportEvent(TelemetryArea.SQL, SqlTelemetryEvents.SqlProjectPublish);
 }
Пример #4
0
 public void GenerateEmpty() {
     var fs = new FileSystem();
     var g = new SProcProjectFilesGenerator(_pss, fs);
     var settings = new SqlSProcPublishSettings();
     g.Generate(settings, Enumerable.Empty<string>(), _project);
 }