예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        public void PublishDacpac(string rFile)
        {
            var fs       = new FileSystem();
            var settings = new SqlSProcPublishSettings();

            settings.TargetType = PublishTargetType.Dacpac;

            SetupProjectMocks("project.rproj");

            var builder = Substitute.For <IDacPacBuilder>();

            builder.When(x => x.Build(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <IEnumerable <string> >())).Do(c => {
                c.Args()[0].Should().Be("project.dacpac");
                c.Args()[1].Should().Be("project");

                var e = c.Args()[2] as IEnumerable <string>;
                e.Should().HaveCount(1);
                e.First().Should().StartWith("CREATE PROCEDURE ProcName");
            });

            _dacServices.GetBuilder().Returns(builder);

            var files     = new string[] { Path.Combine(_files.DestinationPath, rFile) };
            var publisher = new SProcPublisher(_shell, _pss, fs, _dacServices);

            publisher.Publish(settings, files);

            builder.Received(1).Build(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <IEnumerable <string> >());
        }
예제 #3
0
        public void PublishDatabase(string rFile)
        {
            var fs       = new FileSystem();
            var settings = new SqlSProcPublishSettings();

            settings.TargetType = PublishTargetType.Database;

            var odbc = new OdbcConnectionStringBuilder();

            odbc[ConnectionStringConverter.OdbcDriverKey]   = "SQL Server";
            odbc[ConnectionStringConverter.OdbcServerKey]   = "(local)";
            odbc[ConnectionStringConverter.OdbcDatabaseKey] = "AventureWorks";
            settings.TargetDatabaseConnection = odbc.ConnectionString;

            SetupProjectMocks("project.rproj");

            var builder = Substitute.For <IDacPacBuilder>();

            _dacServices.GetBuilder(null).ReturnsForAnyArgs(builder);
            _dacServices.When(x => x.Deploy(Arg.Any <DacPackage>(), Arg.Any <string>(), Arg.Any <string>())).Do(c => {
                ((string)c.Args()[1]).Should().Be("Data Source=(local);Initial Catalog=AventureWorks;Integrated Security=True");
            });

            var files     = new string[] { Path.Combine(_files.DestinationPath, rFile) };
            var publisher = new SProcPublisher(_appShell, _pss, fs, _dacServices);

            publisher.Publish(settings, files);

            _dacServices.Received(1).Deploy(Arg.Any <DacPackage>(), Arg.Any <string>(), Arg.Any <string>());
        }