Exemplo n.º 1
0
 public Bundler(IFileSystem system, IDeploymentController controller, DeploymentSettings settings, IBottleRepository bottles)
 {
     _system = system;
     _controller = controller;
     _settings = settings;
     _bottles = bottles;
 }
Exemplo n.º 2
0
 // TESTING CTOR ONLY!!!!!!!!
 private DeploymentPlan(DeploymentSettings settings, DeploymentOptions options, IEnumerable<Recipe> recipes, IEnumerable<HostManifest> hosts)
 {
     _recipes = recipes;
     settings.Plan = this;
     _hosts = hosts;
     _options = options;
     _rootData = new SettingsData();
 }
Exemplo n.º 3
0
        public void WriteTo(string recipeName, HostDefinition host, DeploymentSettings settings)
        {
            var fileName = settings.GetHost(recipeName, host.Name);

            host.References.Each(WriteReference);
            host.Values.Each(WritePropertyValue);
            host.Directives.Each(WriteDirective);

            _fileSystem.WriteStringToFile(fileName, ToText());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the default values.
        /// </summary>
        private void SetToDefault()
        {
            fileName = "";

            Name               = DefaultName;
            Version            = ProjectVersion.Default;
            Description        = "";
            ConfigBase         = new ConfigBase();
            Interface          = new Interface();
            Instances          = new List <Instance>();
            DeploymentSettings = new DeploymentSettings();
        }
Exemplo n.º 5
0
        public static void AreEqualDeploymentSettings(ServiceSettings settings, string configPath, string deploymentName, string label, string packagePath, string subscriptionId, DeploymentSettings actual)
        {
            AreEqualServiceSettings(settings, actual.ServiceSettings);
            Assert.AreEqual<string>(configPath, actual.ConfigPath);
            Assert.AreEqual<string>(deploymentName, actual.DeploymentName);
            Assert.AreEqual<string>(label, actual.Label);
            Assert.AreEqual<string>(packagePath, actual.PackagePath);
            Assert.AreEqual<string>(subscriptionId, actual.SubscriptionId);

            Assert.IsTrue(File.Exists(actual.ConfigPath));
            Assert.IsTrue(File.Exists(actual.PackagePath));
        }
Exemplo n.º 6
0
 public Covid19ApiNormalizingBackgroundService(ILogger <Covid19ApiNormalizingBackgroundService> logger,
                                               ICovidHandler covidHandler, IGetStartUpDataService getStartUpDataService, IGetUpdatedDataService getUpdatedDataService)
 {
     _logger                = logger;
     _covidHandler          = covidHandler;
     _getStartUpDataService = getStartUpDataService;
     _getUpdatedDataService = getUpdatedDataService;
     _deploymentSettings    = new DeploymentSettings()
     {
         IsFirstDeploy = false
     };
 }
Exemplo n.º 7
0
        public override bool Execute(AddReferenceCommandInput input)
        {
            var deploymentSettings = DeploymentSettings.ForDirectory(input.DeploymentFlag);

            var settings = new EnvironmentSettings();

            IFileSystem fileSystem = new FileSystem();

            Execute(input, settings, fileSystem, deploymentSettings);

            return(true);
        }
Exemplo n.º 8
0
        public override void Exec()
        {
            UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
            //SolutionClass solution = hierItem.Object as SolutionClass;

            DeploymentSettings ds = new DeploymentSettings( (Project)hierItem.Object);
            EnhancedDeployWindow dlg = new EnhancedDeployWindow();
            dlg.TargetDatabase = ds.TargetDatabase;
            dlg.TargetServer = ds.TargetServer;
            dlg.SourceObject = (Database)((Project)hierItem.Object).Object;
            dlg.ShowDialog();
        }
Exemplo n.º 9
0
        public override bool Execute(AddRecipeInput input)
        {
            var settings = DeploymentSettings.ForDirectory(input.DeploymentFlag);

            var recipe = new RecipeDefinition(input.Name);

            var writer = new RecipeWriter(new TypeDescriptorCache());

            writer.WriteTo(recipe, settings);


            return(true);
        }
 public OwinEnrichedDataNormalizingService(ILogger <OwinEnrichedDataNormalizingService> logger,
                                           IAwsSecurityProvider securityProvider, IAthenaDataService athenaDataService,
                                           IAthenaUpdateService athenaUpdateService)
 {
     _logger              = logger;
     _securityProvider    = securityProvider;
     _athenaDataService   = athenaDataService;
     _athenaUpdateService = athenaUpdateService;
     _deploymentSettings  = new DeploymentSettings()
     {
         IsFirstDeploy = false
     };
 }
 public void TestDeploymentSettingsTestEmptyDeploymentNameFail()
 {
     try
     {
         DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, configPath, service.ServiceName, string.Empty);
         Assert.Fail("No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.IsInstanceOfType(ex, typeof(ArgumentException));
         Assert.IsTrue(string.Compare(string.Format(Resources.InvalidOrEmptyArgumentMessage, "Deployment name"), ex.Message, true) == 0);
     }
 }
Exemplo n.º 12
0
        private DeploymentAdditionalData ConstructDeploymentAdditionalData(DeploymentSettings updateSettingsSettings,
                                                                           Options optionsValue)
        {
            var additionalData = new DeploymentAdditionalData();

            if (!string.IsNullOrEmpty(_options.Value.SSHConnection) && optionsValue.VerifyPassword(updateSettingsSettings.ThisMachinePassword))
            {
                additionalData.AvailableDeploymentTypes.Add(DeploymentType.ThisMachine);
            }

            additionalData.AvailableDeploymentTypes.Add(DeploymentType.RemoteMachine);
            additionalData.AvailableDeploymentTypes.Add(DeploymentType.Manual);
            return(additionalData);
        }
Exemplo n.º 13
0
        public override void Exec()
        {
            UIHierarchy     solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
            UIHierarchyItem hierItem    = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
            //SolutionClass solution = hierItem.Object as SolutionClass;

            DeploymentSettings   ds  = new DeploymentSettings((Project)hierItem.Object);
            EnhancedDeployWindow dlg = new EnhancedDeployWindow();

            dlg.TargetDatabase = ds.TargetDatabase;
            dlg.TargetServer   = ds.TargetServer;
            dlg.SourceObject   = (Database)((Project)hierItem.Object).Object;
            dlg.ShowDialog();
        }
Exemplo n.º 14
0
        public override bool Execute(DeployInput input)
        {
            var settings = new DeploymentSettings(input.DeploymentRoot())
            {
                UserForced = input.ForceFlag
            };

            var container            = DeploymentBootstrapper.Bootstrap(settings);
            var deploymentController = container.GetInstance <IDeploymentController>();

            deploymentController.Deploy();

            return(true);
        }
        public void RunCreateDatabaseScripts(DeploymentSettings settings, string createScriptPath, MigrationResultSet result)
        {
            if (!File.Exists(createScriptPath))
            {
                return;
            }
            using (var conn = this.connectionFactory.GetMasterConnection(settings.Server, settings.CredentialInfo))
            {
                var scriptText = File.ReadAllText(createScriptPath);
                result.Messages.Add(new LogMessage(LogSeverity.Info, $"Creating database started."));
                string[] commandTexts = Regex.Split(scriptText + "\n", @"^\s*GO\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                foreach (var commandText in commandTexts)
                {
                    if (string.IsNullOrWhiteSpace(commandText))
                    {
                        continue;
                    }

                    result.Messages.Add(new LogMessage(LogSeverity.Info, $"Create database script {commandText}"));
                    conn.Execute(commandText);
                }
            }

            // Test to see if we can connect to new database before finishing
            result.Messages.Add(new LogMessage(LogSeverity.Info, $"Testing to see if we can connect to database."));
            var stop    = 0;
            var timeout = DateTime.UtcNow.AddSeconds(120);

            while (stop == 0 && timeout > DateTime.UtcNow)
            {
                System.Threading.Thread.Sleep(1000);
                try
                {
                    using (var conn = this.connectionFactory.GetTargetConnection(settings.DatabaseName, settings.Server, settings.CredentialInfo))
                    {
                        stop = conn.ExecuteScalar <int>("select top(1) 1 FROM [sys].[objects]");
                    }
                }
                catch { /* -- Intentionally eating exception -- */ }
            }

            // Create initial roundhouse databases if they don't exist
            using (var conn = this.connectionFactory.GetTargetConnection(settings.DatabaseName, settings.Server, settings.CredentialInfo))
            {
                result.Messages.Add(new LogMessage(LogSeverity.Info, $"Creating Roundhouse Tables if they don't exist."));
                conn.Execute(Resources.CreateRoundHouseTables);
            }

            result.Messages.Add(new LogMessage(LogSeverity.Info, "Creating database completed."));
        }
Exemplo n.º 16
0
        public DatabaseMigrator(DeploymentSettings deploymentSettings, IConnectionFactory connectionFactory)
        {
            this.deploymentSettings = deploymentSettings;
            this.connectionFactory  = connectionFactory;

            // Instantiate everything else
            this.keepWorkingDirectory = false;
            roundHouseManager         = new RoundhouseManager();
            fileService = new RoundHouseFileService();
            availabilityGroupRepository = new AvailabilityGroupRepository(connectionFactory);
            deploymentRepo               = new DeploymentRepository(connectionFactory);
            sqlScriptTokenService        = new SqlScriptTokenService(new SqlScriptTokenValueProvider(deploymentRepo, this.deploymentSettings.Server));
            this.configurationRepository = new ConfigurationRepository(connectionFactory);
            this.timeService             = new TimeService();
        }
Exemplo n.º 17
0
        public bool Execute(IFileSystem system, CreateAllInput input)
        {
            var settings = DeploymentSettings.ForDirectory(input.DeploymentFlag);

            ConsoleWriter.Write("Creating all packages");
            ConsoleWriter.Write("  Removing all previous package files");
            system.CleanDirectory(settings.BottlesDirectory);

            ConsoleWriter.Write("  Reading bottle manifest file at " + settings.BottleManifestFile);
            var bottleManifestFile = settings.BottleManifestFile;

            system.ReadTextFile(bottleManifestFile, dir => createPackage(dir, settings.BottlesDirectory, input));

            return(true);
        }
Exemplo n.º 18
0
        public override bool Execute(AddPakInput input)
        {
            var settings = DeploymentSettings.ForDirectory(input.DeploymentFlag);

            new FileSystem().AlterFlatFile(settings.BottleManifestFile, list =>
            {
                list.Fill(input.PackageDirectory);
                list.Sort();

                Console.WriteLine("Adding directory {0} to the bottles manifest at {1}", input.PackageDirectory, settings.BottleManifestFile);
                Console.WriteLine("The current bottles are:");
                list.Each(x => Console.WriteLine("  " + x));
            });

            return(true);
        }
        public void TestDeploymentSettingsTestNullSettingsFail()
        {
            string label          = "MyLabel";
            string deploymentName = service.ServiceName;

            try
            {
                DeploymentSettings deploySettings = new DeploymentSettings(null, packagePath, configPath, label, deploymentName);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));
                Assert.AreEqual <string>(Resources.InvalidServiceSettingMessage, ex.Message);
            }
        }
        public void TestDeploymentSettingsTestDoesNotConfigPathFail()
        {
            string label           = "MyLabel";
            string deploymentName  = service.ServiceName;
            string doesNotExistDir = Path.Combine(Directory.GetCurrentDirectory(), "qewindw443298.cscfg");

            try
            {
                DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, doesNotExistDir, label, deploymentName);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(FileNotFoundException));
                Assert.AreEqual <string>(string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, doesNotExistDir), ex.Message);
            }
        }
        public void TestDeploymentSettingsTestDoesNotConfigPathFail()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;
            string doesNotExistDir = Path.Combine(Directory.GetCurrentDirectory(), "qewindw443298.cscfg");

            try
            {
                DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, doesNotExistDir, label, deploymentName);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(FileNotFoundException));
                Assert.AreEqual<string>(string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, doesNotExistDir), ex.Message);
            }
        }
Exemplo n.º 22
0
        public void DeployWebsite()
        {
            var testRoot = Path.GetFullPath(@".\integration");

            var writer = new DeploymentWriter(testRoot, new FileSystem());

            writer.AddEnvironmentSetting("name", "dru");


            var r = writer.RecipeFor("FubuTestApplication");

            var h = r.HostFor("web");

            var d = new FubuWebsite();

            d.WebsiteName         = "test";
            d.WebsitePhysicalPath = @"C:\dev\test-web";
            d.VDir             = "bob";
            d.VDirPhysicalPath = @"C:\dev\test-app";
            d.HostBottle       = "FubuTestApplication";
            d.AppPool          = "fubu-test";

            h.AddDirective(d);

            writer.Flush(FlushOptions.Wipeout);

            //copy over bottles
            var fileName    = "FubuTestApplication.zip";
            var destination = @".\integration\bottles\";

            Directory.CreateDirectory(destination);
            File.Copy(@"C:\Users\dsellers.fcs\Desktop\ProfileScratch\FubuTestApplication.zip", Path.Combine(destination, fileName), true);
            //<stop>


            var settings = new DeploymentSettings(testRoot)
            {
                UserForced = true
            };

            var container            = DeploymentBootstrapper.Bootstrap(settings);
            var deploymentController = container.GetInstance <IDeploymentController>();

            deploymentController.Deploy();
        }
        public void Setup()
        {
            _fileService               = new Mock <IRoundHouseFileService>();
            _scriptTokenService        = new Mock <ISqlScriptTokenService>();
            _roundhouseManager         = new Mock <IRoundhouseManager>();
            _deploymentRepo            = new Mock <IDeploymentRepository>();
            _availabilityGroupRepo     = new Mock <IAvailabilityGroupRepository>();
            this.connectionFactoryMock = new Mock <IConnectionFactory>();
            this.timeService           = TestUtilities.GetTimeService(60);

            var sprocText = "select 1";

            path = Path.GetTempPath();
            path = Path.Combine(path, $"{Guid.NewGuid()}_ok_to_delete");
            Directory.CreateDirectory(path);
            Directory.CreateDirectory(Path.Combine(path, DeploymentDirectoryStructureConstants.SprocsFolderName));
            Directory.CreateDirectory(Path.Combine(path, DeploymentDirectoryStructureConstants.FunctionsFolderName));
            File.WriteAllText(Path.Combine(path, "test_script.sql"), sprocText);
            _fileService.Setup(fs => fs.UnzipResourceFile(It.IsAny <Byte[]>())).Returns(path);

            settings = new DeploymentSettings()
            {
                CreateScriptName = "create script",
                DatabaseName     = "EDDS",
                Server           = "server",
            };

            this.databaseMigrator = new DatabaseMigrator(
                settings,
                this.connectionFactoryMock.Object,
                _scriptTokenService.Object,
                _roundhouseManager.Object,
                _deploymentRepo.Object,
                _availabilityGroupRepo.Object,
                _fileService.Object,
                this.timeService);

            var connectionString = DatabaseConstants.TestConnectionString;

            this.connectionMock = new Mock <IDbConnection>();
            this.connectionMock.Setup(m => m.ConnectionString).Returns(connectionString);
            this.connectionFactoryMock.Setup(m => m.GetTargetConnection(settings.DatabaseName, settings.Server, null))
            .Returns(this.connectionMock.Object);
        }
Exemplo n.º 24
0
        public void WriteTo(RecipeDefinition recipe, DeploymentSettings settings)
        {
            var recipeDirectory = settings.GetRecipeDirectory(recipe.Name);

            _fileSystem.CreateDirectory(recipeDirectory);

            var controlFilePath = FileSystem.Combine(recipeDirectory, ProfileFiles.RecipesControlFile);

            new FileSystem().WriteToFlatFile(controlFilePath, writer =>
            {
                recipe.Dependencies.Each(d =>
                {
                    var line = "Dependency:{0}".ToFormat(d);
                    writer.WriteLine(line);
                });
            });

            recipe.Hosts().Each(host => new HostWriter(_types).WriteTo(recipe.Name, host, settings));
        }
        public void Init(
            EnvDTE.ProjectItem projItem,
            Database cloneDB,
            MeasureGroup cloneMG)
        {
            Cube selectedCube = projItem.Object as Cube;

            if ((selectedCube != null) && (selectedCube.ParentServer != null))
            {
                // if we are in Online mode there will be a parent server
                this.liveServer = selectedCube.ParentServer;
                this.liveDB     = selectedCube.Parent;
                this.liveCube   = selectedCube;
            }
            else
            {
                // if we are in Project mode we will use the server name from
                // the deployment settings
                DeploymentSettings deploySet = new DeploymentSettings(projItem);
                this.liveServer = new Server();
                this.liveServer.Connect(deploySet.TargetServer);
                this.liveDB   = this.liveServer.Databases.GetByName(deploySet.TargetDatabase);
                this.liveCube = this.liveDB.Cubes.GetByName(selectedCube.Name);
            }
            sCubePath = this.liveServer.ID + "." + this.liveDB.ID + "." + this.liveCube.ID + ".";

            this.cloneMG   = cloneMG;
            this.cloneDB   = cloneDB;
            this.cloneCube = cloneDB.Cubes[liveCube.ID];

            this.lblServer.Text       = this.liveServer.Name;
            this.lblDatabaseName.Text = this.liveDB.Name;
            this.iWindowFullHeight    = this.Height;
            this.iWindowShortHeight   = this.btnExecute.Bottom + 40;
            this.Height             = iWindowShortHeight;
            this.iWindowFullWidth   = this.Width;
            this.iWindowNarrowWidth = this.grpProgress.Left - 30;
            this.Width = iWindowNarrowWidth;
            this.buttonCancel.Visible                  = false;
            this.buttonOK.Visible                      = false;
            this.treeViewAggregation.Visible           = false;
            this.lblUnusedAggregationsToDelete.Visible = false;
        }
Exemplo n.º 26
0
        public void WriteTo(RecipeDefinition recipe, DeploymentSettings settings)
        {
            var recipeDirectory = settings.GetRecipeDirectory(recipe.Name);

            _fileSystem.CreateDirectory(recipeDirectory);

            var controlFilePath = FileSystem.Combine(recipeDirectory, ProfileFiles.RecipesControlFile);

            new FileSystem().WriteToFlatFile(controlFilePath, writer =>
            {
                recipe.Dependencies.Each(d =>
                {
                    var line = "Dependency:{0}".ToFormat(d);
                    writer.WriteLine(line);
                });
            });

            recipe.Hosts().Each(host => new HostWriter(_types).WriteTo(recipe.Name, host, settings));
        }
Exemplo n.º 27
0
        public static IContainer Bootstrap(DeploymentSettings settings)
        {
            return(new Container(x =>
            {
                // TODO -- might come back to this and make it smarter
                x.For <IObjectResolver>().Use(ObjectResolver.Basic());

                x.For <IFileSystem>().Use <FileSystem>();

                x.For <IProfileFinder>().Use <DeploymentFolderFinder>();
                x.For <IPackageExploder>().Use <PackageExploder>();
                x.For <IZipFileService>().Use <ZipFileService>();
                x.For <IPackageExploderLogger>().Use(new PackageExploderLogger(Console.WriteLine));

                x.For <DeploymentSettings>().Use(settings);

                x.AddRegistry <DeploymentRegistry>();
            }));
        }
Exemplo n.º 28
0
 public DatabaseMigrator(
     DeploymentSettings deploymentSettings,
     IConnectionFactory connectionFactory,
     ISqlScriptTokenService sqlScriptTokenService,
     IRoundhouseManager roundhouseManager,
     IDeploymentRepository deploymentRepo,
     IAvailabilityGroupRepository availabilityGroupRepository,
     IRoundHouseFileService roundHouseFileService,
     ITimeService timeService)
 {
     this.deploymentSettings          = deploymentSettings;
     this.connectionFactory           = connectionFactory;
     this.fileService                 = roundHouseFileService;
     this.sqlScriptTokenService       = sqlScriptTokenService;
     this.roundHouseManager           = roundhouseManager;
     this.deploymentRepo              = deploymentRepo;
     this.availabilityGroupRepository = availabilityGroupRepository;
     this.timeService                 = timeService;
 }
Exemplo n.º 29
0
        /// <summary>
        /// Initialize our model of the AzureService located at the given
        /// path along with its DeploymentSettings and SubscriptionId.
        /// </summary>
        /// <param name="rootPath">Root path of the Azure service.</param>
        internal void InitializeSettingsAndCreatePackage(string rootPath)
        {
            Debug.Assert(!string.IsNullOrEmpty(rootPath), "rootPath cannot be null or empty.");
            Debug.Assert(Directory.Exists(rootPath), "rootPath does not exist.");

            _azureService = new AzureService(rootPath, null);

            // If user provided a service name, change current service name to use it.
            //
            if (!string.IsNullOrEmpty(Name))
            {
                _azureService.ChangeServiceName(Name, _azureService.Paths);
            }

            ServiceSettings defaultSettings = ServiceSettings.LoadDefault(
                _azureService.Paths.Settings,
                Slot,
                Location,
                Subscription,
                StorageAccountName,
                Name,
                _azureService.ServiceName,
                out _hostedServiceName);

            subscriptionId =
                new GlobalComponents(GlobalPathInfo.GlobalSettingsDirectory)
                .GetSubscriptionId(defaultSettings.Subscription);

            SafeWriteObjectWithTimestamp(String.Format(Resources.PublishPreparingDeploymentMessage,
                                                       _hostedServiceName, subscriptionId));

            UpdateLocation(_azureService.Paths.Definition, defaultSettings.Location.ToUpper());

            CreatePackage();

            _deploymentSettings = new DeploymentSettings(
                defaultSettings,
                _azureService.Paths.CloudPackage,
                _azureService.Paths.CloudConfiguration,
                _hostedServiceName,
                string.Format(Resources.ServiceDeploymentName, defaultSettings.Slot));
        }
Exemplo n.º 30
0
        public void Init(
           EnvDTE.ProjectItem projItem,
           Database cloneDB,
           MeasureGroup cloneMG)
        {
            Cube selectedCube = projItem.Object as Cube;
            if ((selectedCube != null) && (selectedCube.ParentServer != null))
            {
                // if we are in Online mode there will be a parent server
                this.liveServer = selectedCube.ParentServer;
                this.liveDB = selectedCube.Parent;
                this.liveCube = selectedCube;
            }
            else
            {
                // if we are in Project mode we will use the server name from 
                // the deployment settings
                DeploymentSettings deploySet = new DeploymentSettings(projItem);
                this.liveServer = new Server();
                this.liveServer.Connect(deploySet.TargetServer);
                this.liveDB = this.liveServer.Databases.GetByName(deploySet.TargetDatabase);
                this.liveCube = this.liveDB.Cubes.GetByName(selectedCube.Name);
            }
            sCubePath = this.liveServer.ID + "." + this.liveDB.ID + "." + this.liveCube.ID + ".";

            this.cloneMG = cloneMG;
            this.cloneDB = cloneDB;
            this.cloneCube = cloneDB.Cubes[liveCube.ID];

            this.lblServer.Text = this.liveServer.Name;
            this.lblDatabaseName.Text = this.liveDB.Name;
            this.iWindowFullHeight = this.Height;
            this.iWindowShortHeight = this.btnExecute.Bottom + 40;
            this.Height = iWindowShortHeight;
            this.iWindowFullWidth = this.Width;
            this.iWindowNarrowWidth = this.grpProgress.Left - 30;
            this.Width = iWindowNarrowWidth;
            this.buttonCancel.Visible = false;
            this.buttonOK.Visible = false;
            this.treeViewAggregation.Visible = false;
            this.lblUnusedAggregationsToDelete.Visible = false;
        }
Exemplo n.º 31
0
        public static IContainer Bootstrap(DeploymentSettings settings)
        {
            return new Container(x =>
            {
                // TODO -- might come back to this and make it smarter
                x.For<IObjectResolver>().Use(ObjectResolver.Basic());

                x.For<IFileSystem>().Use<FileSystem>();

                x.For<IProfileFinder>().Use<DeploymentFolderFinder>();
                x.For<IPackageExploder>().Use<PackageExploder>();
                x.For<IZipFileService>().Use<ZipFileService>();
                x.For<IPackageExploderLogger>().Use(new PackageExploderLogger(Console.WriteLine));

                x.For<DeploymentSettings>().Use(settings);

                x.AddRegistry<DeploymentRegistry>();

            });
        }
Exemplo n.º 32
0
        public void build_the_default_ctor()
        {
            setupValidDeploymentFolderAt("dir");

            //review there is a check inside of here
            var settings = new DeploymentSettings("dir");

            settings.BottlesDirectory.ShouldEqual("dir\\bottles");
            settings.RecipesDirectory.ShouldEqual("dir\\recipes");
            settings.EnvironmentFile.ShouldEqual("dir\\environment.settings");
            settings.TargetDirectory.ShouldEqual("dir\\target");
            settings.DeploymentDirectory.ShouldEqual("dir");
            settings.BottleManifestFile.ShouldEqual("dir\\bottles.manifest");

            settings.ProfilesDirectory.ShouldEqual(FileSystem.Combine("dir", ProfileFiles.ProfilesDirectory));
            settings.EnvironmentsDirectory.ShouldEqual(FileSystem.Combine("dir", ProfileFiles.EnvironmentsDirectory));

            settings.GetHost("x", "z").ShouldEqual("dir\\recipes\\x\\z.host");
            settings.GetRecipeDirectory("a").ShouldEqual("dir\\recipes\\a");
        }
Exemplo n.º 33
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".application";
            dlg.Filter     = "Application manifest (.application)|*.application";

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                Settings = DeploymentSettings.Load(dlg.FileName);
                OnPropertyChanged("IsDirty");
                if (Settings != null)
                {
                    MainDockPanel.IsEnabled = true;
                }
                else
                {
                    MainDockPanel.IsEnabled = false;
                }
            }
        }
Exemplo n.º 34
0
        public override bool Execute(CreateDeploymentInput input)
        {
            var settings  = DeploymentSettings.ForDirectory(input.DeploymentFlag);
            var directive = new FubuWebsite();

            if (input.VirtualDirFlag.IsNotEmpty())
            {
                directive.VDir = input.VirtualDirFlag;
            }

            var fileSystem = new FileSystem();

            var hostFile = settings.GetHost(input.RecipeFlag, input.HostFlag);

            Console.WriteLine("Adding a new FubuWebsite directive to " + hostFile);

            fileSystem.WriteToFlatFile(hostFile, file =>
            {
                var writer = new DirectiveWriter(file, new TypeDescriptorCache());
                writer.Write(directive);
            });

            Console.WriteLine("");

            new AddReferenceCommand().Execute(new AddReferenceCommandInput()
            {
                Bottle = input.ApplicationBottleName,
                Host   = input.HostFlag,
                Recipe = input.RecipeFlag
            });

            if (input.OpenFlag)
            {
                fileSystem.LaunchEditor(hostFile);
            }

            return(true);
        }
        public void RunCreateDatabaseScripts()
        {
            // Arrange
            var settings = new DeploymentSettings {
                Server = Config.Server, DatabaseName = Names.Database.EddsPerformance
            };
            var resultSet = new MigrationResultSet(true, new List <LogMessage>());
            var sprocText = "select 1";
            var path      = Path.GetTempPath();

            path = Path.Combine(path, Guid.NewGuid().ToString());
            Directory.CreateDirectory(path);
            var file = Path.Combine(path, "test_sproc.sql");

            File.WriteAllText(file, sprocText);

            // Act
            this.deploymentRepository.RunCreateDatabaseScripts(settings, file, resultSet);

            // Assert
            Assert.That(resultSet.Success, Is.True);
            Assert.That(resultSet.Messages.Count, Is.EqualTo(5));
        }
Exemplo n.º 36
0
        public void Init(
           EnvDTE.ProjectItem projItem,
           MeasureGroup mg,
           string[,] inDimAttributes,
           string[] inDimNames,
           string[] inDimIDs,
           bool inAddNew,
           String inAggDesName)
        {
            bool IsOnlineMode = false;
            Cube selectedCube = projItem.Object as Cube;
            string sTargetDatabase = "";
            if ((selectedCube != null) && (selectedCube.ParentServer != null))
            {
                // if we are in Online mode there will be a parent server
                server = selectedCube.ParentServer;
                sTargetDatabase = selectedCube.Parent.Name;
                IsOnlineMode = true;
            }
            else
            {
                // if we are in Project mode we will use the server name from 
                // the deployment settings
                DeploymentSettings deploySet = new DeploymentSettings(projItem);
                server = new Server();
                server.Connect(deploySet.TargetServer);
                sTargetDatabase = deploySet.TargetDatabase;
            }

            mg1 = mg;
            dimAttributes = inDimAttributes;
            dimNames = inDimNames;
            dimIDs = inDimIDs;
            //Variable defining whether form is invoked to create new aggregation design or add aggregations to exising one.
            addNew = inAddNew;
            aggDesName = inAggDesName;

            strSQLQuery = textBoxSQLQuery.Text;
            textBoxSQLQuery.Text = textBoxSQLQuery.Text +
                                   " Where MSOLAP_Database = '" +
                                   mg1.ParentDatabase.Name +
                                   "' and  MSOLAP_ObjectPath = '" +
                                   server.Name + "." +
                                   sTargetDatabase + "." +
                                   mg1.Parent.ID + "." +
                                   mg1.ID + "'" +
                                   " and duration >= 100";


            textBoxSQLConnectionString.Text = server.ServerProperties.Find("Log\\QueryLog\\QueryLogConnectionString").Value.ToString(); ;
            textBoxSQLConnectionString.Text = MakeConnectionStringRemote(server.Name, textBoxSQLConnectionString.Text);

            if (!addNew)
            {
                textBoxNewAggDesign.Text = inAggDesName;
                textBoxNewAggDesign.Enabled = false;
            }
            txtServerNote.Text = string.Format("Note: the QueryLog details have been taken from the '{0}' server,\n" +
             "which is the one currently configured as the deployment target.", server.Name);
            txtServerNote.Visible = !IsOnlineMode; // hide the note if we are in online mode.
        }
        public void Init(MeasureGroup mg, 
            string strParition,
            EnvDTE.ProjectItem projItem)
        {
            try
            {
                bool IsOnlineMode = false;
                Cube selectedCube = projItem.Object as Cube;
                string serverName = "";
                string databaseName = "";
                string connectionString = "";
                if ((selectedCube != null) && (selectedCube.ParentServer != null))
                {
                    // if we are in Online mode there will be a parent server
                    serverName = selectedCube.ParentServer.Name;
                    databaseName = selectedCube.Parent.Name;
                    IsOnlineMode = true;
                    connectionString = selectedCube.ParentServer.ConnectionString;
                }
                else
                {
                    // if we are in Project mode we will use the server name from 
                    // the deployment settings
                    DeploymentSettings deploySet = new DeploymentSettings(projItem);
                    serverName = deploySet.TargetServer;
                    databaseName = deploySet.TargetDatabase; //use the target database instead of selectedCube.Parent.Name because selectedCube.Parent.Name only reflects the last place it was deployed to, and we want the user to be able to use the deployment settings to control which deployed server/database to check against
                    connectionString = "Data Source=" + serverName;
                }
                mg1 = mg;
                part1 = mg.Partitions.FindByName(strParition);
                aggDes = part1.AggregationDesign;
                this.Text = " Aggregation sizes for partition " + strParition;

                //lblSize.Text = part1.EstimatedRows.ToString() + " records"; //base this not on estimated rows but on actual rows... see below
                lablPartName.Text = strParition;

                txtServerNote.Text = string.Format("Note: The Partition size details have been taken from the currently deployed '{1}' database on the '{0}' server, " +
                "which is the one currently configured as the deployment target.", serverName, databaseName);
                txtServerNote.Visible = !IsOnlineMode;

                //--------------------------------------------------------------------------------
                // Open ADOMD connection to the server and issue DISCOVER_PARTITION_STAT request to get aggregation sizes
                //--------------------------------------------------------------------------------
                AdomdConnection adomdConnection = new AdomdConnection(connectionString);
                adomdConnection.Open();
                partitionDetails = adomdConnection.GetSchemaDataSet(AdomdSchemaGuid.PartitionStat, new object[] { databaseName, mg1.Parent.Name, mg1.Name, strParition });

                DataColumn colItem1 = new DataColumn("Percentage", Type.GetType("System.String"));
                partitionDetails.Tables[0].Columns.Add(colItem1);

                AddGridStyle();

                dataGrid1.DataSource = partitionDetails.Tables[0];

                long iPartitionRowCount = 0;
                if (partitionDetails.Tables[0].Rows.Count > 0)
                {
                    iPartitionRowCount = Convert.ToInt64(partitionDetails.Tables[0].Rows[0]["AGGREGATION_SIZE"]);
                }
                lblSize.Text = iPartitionRowCount + " records";

                double ratio = 0;
                foreach (DataRow row in partitionDetails.Tables[0].Rows)
                {
                    ratio = 100.0 * ((long)row["AGGREGATION_SIZE"] / (double)iPartitionRowCount);
                    row["Percentage"] = ratio.ToString("#0.00") + "%";
                }

                CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
                ((DataView)cm.List).AllowNew = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                try
                {
                    this.Close();
                }
                catch { }
            }
        }
        private void ExecInternal(bool bPreBuildCheckOnly) {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));

                cube = sandbox.Cube;
                if (cube == null) throw new Exception("The workspace database cube doesn't exist.");

                SSAS.TabularDisplayFoldersAnnotation annotationSavedFolders = TabularDisplayFolderPlugin.GetAnnotation(sandbox);
                SSAS.TabularTranslationsAnnotation annotationSaved = GetAnnotation(sandbox); 

                string sTargetDatabase = null;
                string sTargetCubeName = null;
                try
                {
                    //get the deployment settings to display in the translations dialog (rather than the workspace database and cube name)
                    Microsoft.VisualStudio.Project.Automation.OAFileItem fileitem = hierItem.Object as Microsoft.VisualStudio.Project.Automation.OAFileItem;
                    DeploymentSettings deploySet = new DeploymentSettings(fileitem.ContainingProject);
                    sTargetDatabase = deploySet.TargetDatabase;
                    sTargetCubeName = deploySet.TargetCubeName;
                }
                catch { } //this seems to blow up in debug mode on my laptop... oh well


                bool bRestoredDisplayFolders = false;
                List<SSAS.TabularTranslatedItem> translationRows = new List<BIDSHelper.SSAS.TabularTranslatedItem>();

                Microsoft.AnalysisServices.AdomdClient.AdomdRestrictionCollection restrictions = new Microsoft.AnalysisServices.AdomdClient.AdomdRestrictionCollection();
                restrictions.Add(new Microsoft.AnalysisServices.AdomdClient.AdomdRestriction("CUBE_NAME", cube.Name));
                DataSet datasetMeasures = sandbox.AdomdConnection.GetSchemaDataSet("MDSCHEMA_MEASURES", restrictions);
                DataRowCollection rowsMeasures = datasetMeasures.Tables[0].Rows;

                Database db = cube.Parent;
                SSAS.TabularTranslatedItem captionTranslationDatabase = new SSAS.TabularTranslatedItem(null, db, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                if (!string.IsNullOrEmpty(sTargetDatabase)) captionTranslationDatabase.OverrideCaption(sTargetDatabase);
                translationRows.Add(captionTranslationDatabase);
                if (!string.IsNullOrEmpty(db.Description))
                {
                    translationRows.Add(new SSAS.TabularTranslatedItem(null, db, SSAS.TabularTranslatedItemProperty.Description, captionTranslationDatabase, null));
                }

                List<CalculationProperty> calcProperties = new List<CalculationProperty>();
                foreach (Cube c in db.Cubes)
                {
                    SSAS.TabularTranslatedItem captionTranslationCube = new SSAS.TabularTranslatedItem(null, c, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                    if (!string.IsNullOrEmpty(sTargetCubeName)) captionTranslationCube.OverrideCaption(sTargetCubeName);
                    translationRows.Add(captionTranslationCube);
                    if (!string.IsNullOrEmpty(c.Description))
                    {
                        translationRows.Add(new SSAS.TabularTranslatedItem(null, c, SSAS.TabularTranslatedItemProperty.Description, captionTranslationCube, null));
                    }

                    foreach (Perspective p in c.Perspectives)
                    {
                        SSAS.TabularTranslatedItem captionTranslationPerspective = new SSAS.TabularTranslatedItem(null, p, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslationPerspective);
                        if (!string.IsNullOrEmpty(p.Description))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(null, p, SSAS.TabularTranslatedItemProperty.Description, captionTranslationPerspective, null));
                        }
                    }

                    foreach (MdxScript mdx in c.MdxScripts)
                    {
                        foreach (CalculationProperty calc in mdx.CalculationProperties)
                        {
                            if (calc.Visible && !calc.CalculationReference.StartsWith("KPIs."))
                            {
                                calcProperties.Add(calc);
                            }
                        }
                    }
                }

                foreach (Dimension d in db.Dimensions)
                {
                    SSAS.TabularTranslatedItem captionTranslationDimension = new SSAS.TabularTranslatedItem(d.Name, d, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                    translationRows.Add(captionTranslationDimension);
                    if (!string.IsNullOrEmpty(d.Description))
                    {
                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, d, SSAS.TabularTranslatedItemProperty.Description, captionTranslationDimension, null));
                    }

                    foreach (DimensionAttribute da in d.Attributes)
                    {
                        if (da.Type != AttributeType.RowNumber && da.AttributeHierarchyVisible)
                        {
                            if (string.IsNullOrEmpty(da.AttributeHierarchyDisplayFolder))
                            {
                                SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(da);
                                if (a != null)
                                {
                                    da.AttributeHierarchyDisplayFolder = a.DisplayFolder;
                                    bRestoredDisplayFolders = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                                }
                            }
                            SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                            translationRows.Add(captionTranslation);
                            if (!string.IsNullOrEmpty(da.AttributeHierarchyDisplayFolder))
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                            if (!string.IsNullOrEmpty(da.Description))
                            {
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, da, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));
                            }
                        }
                    }
                    foreach (Hierarchy h in d.Hierarchies)
                    {
                        if (string.IsNullOrEmpty(h.DisplayFolder))
                        {
                            SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(h);
                            if (a != null)
                            {
                                h.DisplayFolder = a.DisplayFolder;
                                bRestoredDisplayFolders = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                            }
                        }

                        SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslation);

                        if (!string.IsNullOrEmpty(h.DisplayFolder))
                            translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                        if (!string.IsNullOrEmpty(h.Description))
                            translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, h, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));

                        foreach (Level level in h.Levels)
                        {
                            SSAS.TabularTranslatedItem captionTranslationLevel = new SSAS.TabularTranslatedItem(d.Name, level, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                            translationRows.Add(captionTranslationLevel);

                            if (!string.IsNullOrEmpty(level.Description))
                                translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, level, SSAS.TabularTranslatedItemProperty.Description, captionTranslationLevel, null));
                        }
                    }

                    for (int i = 0; i < rowsMeasures.Count; i++)
                    {
                        DataRow r = rowsMeasures[i];
                        if (Convert.ToString(r["MEASUREGROUP_NAME"]) == d.Name)
                        {
                            foreach (CalculationProperty calc in calcProperties)
                            {
                                if (Convert.ToString(r["MEASURE_UNIQUE_NAME"]) == "[Measures]." + calc.CalculationReference)
                                {
                                    if (string.IsNullOrEmpty(calc.DisplayFolder))
                                    {
                                        SSAS.TabularDisplayFolderAnnotation a = annotationSavedFolders.Find(calc);
                                        if (a != null)
                                        {
                                            calc.DisplayFolder = a.DisplayFolder;
                                            bRestoredDisplayFolders = true; //we have to restore the display folder or the translations on the display folder won't even be visible in the translations dialog
                                        }
                                    }

                                    SSAS.TabularTranslatedItem captionTranslation = new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                                    translationRows.Add(captionTranslation);
                                    if (!string.IsNullOrEmpty(calc.DisplayFolder))
                                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.DisplayFolder, captionTranslation, null));
                                    if (!string.IsNullOrEmpty(calc.Description))
                                        translationRows.Add(new SSAS.TabularTranslatedItem(d.Name, calc, SSAS.TabularTranslatedItemProperty.Description, captionTranslation, null));

                                    rowsMeasures.Remove(r);
                                    i--;
                                    break;
                                }
                            }
                        }
                    }
                }

                foreach (Cube c in db.Cubes)
                {
                    SSAS.TabularActionsAnnotation actionAnnotations = TabularActionsEditorPlugin.GetAnnotation(c);
                    foreach (Microsoft.AnalysisServices.Action a in c.Actions)
                    {
                        SSAS.TabularAction actionAnnotation = actionAnnotations.Find(a.ID);
                        if (actionAnnotation == null) actionAnnotation = new SSAS.TabularAction();

                        if (!string.IsNullOrEmpty(actionAnnotation.OriginalTarget)
                        && !actionAnnotation.IsMasterClone)
                        {
                            continue;
                        }

                        SSAS.TabularTranslatedItem captionTranslationAction = new SSAS.TabularTranslatedItem(null, a, SSAS.TabularTranslatedItemProperty.Caption, null, annotationSaved);
                        translationRows.Add(captionTranslationAction);
                        if (!string.IsNullOrEmpty(a.Description))
                        {
                            translationRows.Add(new SSAS.TabularTranslatedItem(null, a, SSAS.TabularTranslatedItemProperty.Description, captionTranslationAction, null));
                        }
                    }
                }

                bool bRestoredTranslations = false;

                //get a list of all the distinct languages
                List<int> listLanguages = new List<int>();
                foreach (SSAS.TabularTranslatedItem item in translationRows)
                {
                    foreach (int iLang in item.Languages.Keys)
                    {
                        if (!listLanguages.Contains(iLang))
                            listLanguages.Add(iLang);
                    }
                    if (item.RestoredTranslations) bRestoredTranslations = true;
                }
                listLanguages.Sort();

                if (bRestoredTranslations)
                {
                    MessageBox.Show("Some translations have been wiped out by other editing operations. Restoring translations may be possible except when an object like a measure or a hierarchy has been renamed.\r\n\r\nBIDS Helper will attempt to restore the translations now. Be sure to click OK after you finish your edits in the Tabular Translations window.", "BIDS Helper Tabular Translations");
                }
                else if (bRestoredDisplayFolders)
                {
                    MessageBox.Show("Some display folders have been wiped out by other editing operations. Restoring display folders may be possible except when an object like a measure or a hierarchy has been renamed.\r\n\r\nBIDS Helper will attempt to restore the display folders now. Properly restored display folders are necessary for this Tabular Translations dialog to function properly. Be sure to click OK after you finish your edits in the Tabular Translations window.", "BIDS Helper Tabular Translations");
                }
                else if (bPreBuildCheckOnly)
                {
                    return; //if this is just a pre-build check and if there's nothing that needs to be restored, then just return without popping up the dialog
                }

                SSAS.TabularTranslationsEditorWindow form = new SSAS.TabularTranslationsEditorWindow(db.Language, listLanguages);
                form.WindowState = System.Windows.WindowState.Maximized;
                form.dataGrid1.ItemsSource = translationRows;


                if (form.ShowDialog() == true)
                {
                    //count dirty changes and create annotation
                    int iNumberOfChanges = 0;
                    foreach (SSAS.TabularTranslatedItem item in translationRows)
                    {
                        if (item.Dirty)
                        {
                            iNumberOfChanges++;
                        }
                    }

                    if (iNumberOfChanges > 0 || bRestoredDisplayFolders || bRestoredTranslations)
                    {
                        AlterDatabase(translationRows);
                    }
                }


            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "BIDS Helper - Error");
            }
        }
Exemplo n.º 39
0
        public void Init(
           EnvDTE.ProjectItem projItem,
           Database cloneDB,
           Cube cloneCube)
        {
            this.projItem = projItem;
            Cube selectedCube = projItem.Object as Cube;
            if ((selectedCube != null) && (selectedCube.ParentServer != null))
            {
                // if we are in Online mode there will be a parent server
                liveServer = selectedCube.ParentServer;
                liveDB = selectedCube.Parent;
                liveCube = selectedCube;

                try
                {
                    adomdConnection = new AdomdConnection(liveServer.ConnectionString + ";Initial Catalog=" + liveDB.Name);
                    adomdConnection.Open();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting ADOMD.NET to server with connection string: " + liveServer.ConnectionString, ex);
                }
            }
            else
            {
                // if we are in Project mode we will use the server name from 
                // the deployment settings
                DeploymentSettings deploySet = new DeploymentSettings(projItem);
                liveServer = new Server();

                try
                {
                    liveServer.Connect(deploySet.TargetServer);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting AMO to server from deployment properties: " + deploySet.TargetServer, ex);
                }
                
                liveDB = liveServer.Databases.GetByName(deploySet.TargetDatabase);
                liveCube = liveDB.Cubes.GetByName(selectedCube.Name);

                try
                {
                    adomdConnection = new AdomdConnection("Data Source=" + deploySet.TargetServer + ";Initial Catalog=" + deploySet.TargetDatabase);
                    adomdConnection.Open();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting ADOMD.NET to server from deployment properties: " + deploySet.TargetServer, ex);
                }
            }
            sCubePath = liveServer.ID + "." + liveDB.ID + "." + liveCube.ID + ".";

            this.cloneDB = cloneDB;
            this.cloneCube = cloneDB.Cubes[liveCube.ID];

            this.lblServer.Text = liveServer.Name;
            this.lblDatabaseName.Text = this.liveDB.Name;
            this.iWindowFullHeight = this.Height;
            this.iWindowShortHeight = this.btnExecute.Bottom + 40;
            this.Height = iWindowShortHeight;
            this.iWindowFullWidth = this.Width;
            this.iWindowNarrowWidth = this.grpProgress.Left - 30;
            this.Width = iWindowNarrowWidth;
            this.buttonCancel.Visible = false;
            this.buttonOK.Visible = false;
            this.treeViewAggregation.Visible = false;
            this.lblUnusedAggregationsToDelete.Visible = false;
        }
        public static void DeployScript(ProjectItem projItem, DTE2 ApplicationObject)
        {
            Microsoft.AnalysisServices.Cube oCube = (Microsoft.AnalysisServices.Cube)projItem.Object;
            try
            {
                //validate the script because deploying an invalid script makes cube unusable
                Microsoft.AnalysisServices.Design.Scripts script = new Microsoft.AnalysisServices.Design.Scripts(oCube);

            }
            catch (Microsoft.AnalysisServices.Design.ScriptParsingFailed ex)
            {
                string throwaway = ex.Message;
                MessageBox.Show("MDX Script in " + oCube.Name + " is not valid.", "Problem Deploying MDX Script");
                return;
            }

            if (oCube.MdxScripts.Count == 0)
            {
                MessageBox.Show("There is no MDX script defined in this cube yet.");
                return;
            }

            try
            {
                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Deploying MdxScript", 1, 5);

                // Check if the file is read-only (and probably checked in to a source control system)
                // before attempting to save. (issue: 10327 )
                FileAttributes fa = System.IO.File.GetAttributes(projItem.get_FileNames(1));
                if ((fa & FileAttributes.ReadOnly) != FileAttributes.ReadOnly )
                {
                    //TODO - can I check and maybe prompt before saving?
                    //Save the cube
                    projItem.Save("");
                }

                ApplicationObject.StatusBar.Progress(true, "Deploying MdxScript", 2, 5);

                // extract deployment information
                DeploymentSettings deploySet = new DeploymentSettings(projItem);

                // use xlst to create xmla alter command
                XslCompiledTransform xslt = new XslCompiledTransform();
                XmlReader xsltRdr;
                XmlReader xrdr;

                // read xslt from embedded resource
                xsltRdr = XmlReader.Create(new StringReader(BIDSHelper.Resources.Common.DeployMdxScript));
                using ((xsltRdr))
                {
                    // read content from .cube file
                    xrdr = XmlReader.Create(projItem.get_FileNames(1));
                    using (xrdr)
                    {

                        ApplicationObject.StatusBar.Progress(true, "Deploying MdxScript", 3, 5);
                        // Connect to Analysis Services
                        Microsoft.AnalysisServices.Server svr = new Microsoft.AnalysisServices.Server();
                        svr.Connect(deploySet.TargetServer);
                        ApplicationObject.StatusBar.Progress(true, "Deploying MdxScript", 4, 5);
                        // execute the xmla
                        try
                        {
                            Microsoft.AnalysisServices.Scripter scr = new Microsoft.AnalysisServices.Scripter();

                            // Build up the Alter MdxScript command using XSLT against the .cube file
                            XslCompiledTransform xslta = new XslCompiledTransform();
                            StringBuilder sb = new StringBuilder();
                            XmlWriterSettings xws = new XmlWriterSettings();
                            xws.OmitXmlDeclaration = true;
                            xws.ConformanceLevel = ConformanceLevel.Fragment;
                            XmlWriter xwrtr = XmlWriter.Create(sb, xws);

                            xslta.Load(xsltRdr);
                            XsltArgumentList xslarg = new XsltArgumentList();

                            Database targetDB = svr.Databases.FindByName(deploySet.TargetDatabase);
                            if (targetDB == null)
                            {
                                throw new System.Exception(string.Format("A database called {0} could not be found on the {1} server", deploySet.TargetDatabase, deploySet.TargetServer));
                            }
                            string targetDatabaseID = targetDB.ID;
                            xslarg.AddParam("TargetDatabase", "", targetDatabaseID);
                            xslta.Transform(xrdr, xslarg, xwrtr);

                            // Extract the current script from the server and keep a temporary backup copy of it
                            StringBuilder sbBackup = new StringBuilder();
                            XmlWriterSettings xwSet = new XmlWriterSettings();
                            xwSet.ConformanceLevel = ConformanceLevel.Fragment;
                            xwSet.OmitXmlDeclaration = true;
                            xwSet.Indent = true;
                            XmlWriter xwScript = XmlWriter.Create(sbBackup,xwSet);

                            Cube oServerCube = targetDB.Cubes.Find(oCube.ID);
                            if (oServerCube == null)
                            {
                                throw new System.Exception(string.Format("The {0} cube is not yet deployed to the {1} server.", oCube.Name, deploySet.TargetServer));
                            }
                            else if (oServerCube.State == AnalysisState.Unprocessed)
                            {
                                throw new System.Exception(string.Format("The {0} cube is not processed the {1} server.", oCube.Name, deploySet.TargetServer));
                            }
                            if (oServerCube.MdxScripts.Count == 0)
                            {
                                scr.ScriptAlter(new Microsoft.AnalysisServices.MajorObject[] { oServerCube }, xwScript, true);
                            }
                            else
                            {
                                MdxScript mdxScr = oServerCube.MdxScripts[0];
                                scr.ScriptAlter(new Microsoft.AnalysisServices.MajorObject[] { mdxScr }, xwScript, true);
                            }
                            xwScript.Close();

                            // update the MDX Script
                            XmlaResultCollection xmlaRC = svr.Execute(sb.ToString());
                            if (xmlaRC.Count == 1 && xmlaRC[0].Messages.Count == 0)
                            {
                                // all OK - 1 result - no messages
                            }
                            else
                            {
                                    StringBuilder sbErr = new StringBuilder();
                                for (int iRC = 0; iRC < xmlaRC.Count;iRC ++)
                                {
                                    for (int iMsg = 0; iMsg < xmlaRC[iRC].Messages.Count; iMsg++)
                                    {
                                        sbErr.AppendLine(xmlaRC[iRC].Messages[iMsg].Description);
                                    }
                                }
                                MessageBox.Show(sbErr.ToString(),"BIDSHelper - Deploy MDX Script" );
                            }

                            // Test the MDX Script
                            AdomdConnection cn = new AdomdConnection("Data Source=" + deploySet.TargetServer + ";Initial Catalog=" + deploySet.TargetDatabase);
                            cn.Open();
                            AdomdCommand cmd = cn.CreateCommand();
                            string qry = "SELECT {} ON 0 FROM [" + oCube.Name +"];";
                            cmd.CommandText = qry;
                            try
                            {
                                // test that we can query the cube without errors
                                cmd.Execute();

                                // Building the project means that the .asdatabase file gets re-built so that
                                // we do not break the Deployment Wizard.
                                // --
                                // This line is included in this try block so that it is only executed if we can
                                // successfully query the cube without errors.
                                projItem.DTE.Solution.SolutionBuild.BuildProject(projItem.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, projItem.ContainingProject.UniqueName, false);

                            }
                            catch (System.Exception ex)
                            {
                                // undo the deployment if we caught an exception during the deployment
                                svr.Execute(sbBackup.ToString());
                                MessageBox.Show(ex.Message);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            if (MessageBox.Show("The following error occured while trying to deploy the MDX Script\r\n"
                                                + ex.Message
                                                + "\r\n\r\nDo you want to see a stack trace?"
                                            ,"BIDSHelper - Deploy MDX Script"
                                            , MessageBoxButtons.YesNo
                                            , MessageBoxIcon.Error
                                            , MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                MessageBox.Show(ex.StackTrace);
                            }
                        }
                        finally
                        {
                            ApplicationObject.StatusBar.Progress(true, "Deploying MdxScript", 5, 5);
                            // report any results back (status bar?)
                            svr.Disconnect();
                        }
                    }
                }
            }
            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Deploying MdxScript", 5, 5);
            }
        }
Exemplo n.º 41
0
        private void ExecInternal(ProjectItem projItem, DataModelingSandbox sandbox)
        {
            //sandbox.
            // extract deployment information
                DeploymentSettings deploySet = new DeploymentSettings(projItem);

                        ApplicationObject.StatusBar.Progress(true, "Deploying Tabular Database", 3, 5);
                        // Connect to Analysis Services
                        Microsoft.AnalysisServices.Server svr = new Microsoft.AnalysisServices.Server();
                        svr.Connect(deploySet.TargetServer);
                        ApplicationObject.StatusBar.Progress(true, "Deploying Tabular Database", 4, 5);
                        // execute the xmla
            try
            {
                Microsoft.AnalysisServices.Scripter scr = new Microsoft.AnalysisServices.Scripter();

                Database targetDB = svr.Databases.FindByName(deploySet.TargetDatabase);
                if (targetDB == null)
                {
                    throw new System.Exception(
                        string.Format("A database called {0} could not be found on the {1} server",
                                      deploySet.TargetDatabase, deploySet.TargetServer));
                }
                StringBuilder sb = new StringBuilder();
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.ConformanceLevel = ConformanceLevel.Fragment;
                XmlWriter xwrtr = XmlWriter.Create(sb, xws);
                scr.ScriptAlter(new Microsoft.AnalysisServices.MajorObject[] {sandbox.Database}, xwrtr, true);

                // update the MDX Script
                XmlaResultCollection xmlaRC = svr.Execute(sb.ToString());
                if (xmlaRC.Count == 1 && xmlaRC[0].Messages.Count == 0)
                {
                    // all OK - 1 result - no messages    
                }
                else
                {
                    StringBuilder sbErr = new StringBuilder();
                    for (int iRC = 0; iRC < xmlaRC.Count; iRC++)
                    {
                        for (int iMsg = 0; iMsg < xmlaRC[iRC].Messages.Count; iMsg++)
                        {
                            sbErr.AppendLine(xmlaRC[iRC].Messages[iMsg].Description);
                        }
                    }
                    MessageBox.Show(sbErr.ToString(), "BIDSHelper - Deploy Tabular Database");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "BIDSHelper - Deploy Tabular Database - Exception");
            }
        }
        /// <summary>
        /// Initialize our model of the AzureService located at the given
        /// path along with its DeploymentSettings and SubscriptionId.
        /// </summary>
        /// <param name="rootPath">Root path of the Azure service.</param>
        internal void InitializeSettingsAndCreatePackage(string rootPath)
        {
            Debug.Assert(!string.IsNullOrEmpty(rootPath), "rootPath cannot be null or empty.");
            Debug.Assert(Directory.Exists(rootPath), "rootPath does not exist.");

            _azureService = new AzureService(rootPath, null);

            // If user provided a service name, change current service name to use it.
            //
            if (!string.IsNullOrEmpty(ServiceName))
            {
                _azureService.ChangeServiceName(ServiceName, _azureService.Paths);
            }

            ServiceSettings defaultSettings = ServiceSettings.LoadDefault(
                _azureService.Paths.Settings,
                Slot,
                Location,
                Subscription,
                StorageAccountName,
                ServiceName,
                _azureService.ServiceName,
                out _hostedServiceName);

            if (!string.IsNullOrEmpty(defaultSettings.Subscription))
            {
                var globalComponents = GlobalComponents.Load(GlobalPathInfo.GlobalSettingsDirectory);
                CurrentSubscription = globalComponents.Subscriptions.Values.First(
                    subscription => subscription.SubscriptionName == defaultSettings.Subscription);
            }
            else
            {
                defaultSettings.Subscription = CurrentSubscription.SubscriptionName;
            }

            SafeWriteObjectWithTimestamp(String.Format(Resources.PublishPreparingDeploymentMessage,
                _hostedServiceName, CurrentSubscription.SubscriptionId));

            CreatePackage();

            _deploymentSettings = new DeploymentSettings(
                defaultSettings,
                _azureService.Paths.CloudPackage,
                _azureService.Paths.CloudConfiguration,
                _hostedServiceName,
                string.Format(Resources.ServiceDeploymentName, defaultSettings.Slot));
        }
Exemplo n.º 43
0
        private DeploymentSettings createDestination(string destination)
        {
            return LogWriter.Current.Indent(() =>
            {
                LogWriter.Current.Header2("Creating directory " + destination);

                var destinationSettings = new DeploymentSettings(destination.AppendPath(Milkman.ProfileFiles.DeploymentFolder));
                _system.DeleteDirectory(destination);
                _system.CreateDirectory(destination);
                return destinationSettings;
            });
        }
        public void Init(
            EnvDTE.ProjectItem projItem,
            Database cloneDB,
            Cube cloneCube)
        {
            this.projItem = projItem;
            Cube selectedCube = projItem.Object as Cube;

            if ((selectedCube != null) && (selectedCube.ParentServer != null))
            {
                // if we are in Online mode there will be a parent server
                liveServer = selectedCube.ParentServer;
                liveDB     = selectedCube.Parent;
                liveCube   = selectedCube;

                try
                {
                    adomdConnection = new AdomdConnection(liveServer.ConnectionString + ";Initial Catalog=" + liveDB.Name);
                    adomdConnection.Open();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting ADOMD.NET to server with connection string: " + liveServer.ConnectionString, ex);
                }
            }
            else
            {
                // if we are in Project mode we will use the server name from
                // the deployment settings
                DeploymentSettings deploySet = new DeploymentSettings(projItem);
                liveServer = new Server();

                try
                {
                    liveServer.Connect(deploySet.TargetServer);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting AMO to server from deployment properties: " + deploySet.TargetServer, ex);
                }

                liveDB   = liveServer.Databases.GetByName(deploySet.TargetDatabase);
                liveCube = liveDB.Cubes.GetByName(selectedCube.Name);

                try
                {
                    adomdConnection = new AdomdConnection("Data Source=" + deploySet.TargetServer + ";Initial Catalog=" + deploySet.TargetDatabase);
                    adomdConnection.Open();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error connecting ADOMD.NET to server from deployment properties: " + deploySet.TargetServer, ex);
                }
            }
            sCubePath = liveServer.ID + "." + liveDB.ID + "." + liveCube.ID + ".";

            this.cloneDB   = cloneDB;
            this.cloneCube = cloneDB.Cubes[liveCube.ID];

            this.lblServer.Text       = liveServer.Name;
            this.lblDatabaseName.Text = this.liveDB.Name;
            this.iWindowFullHeight    = this.Height;
            this.iWindowShortHeight   = this.btnExecute.Bottom + 40;
            this.Height             = iWindowShortHeight;
            this.iWindowFullWidth   = this.Width;
            this.iWindowNarrowWidth = this.grpProgress.Left - 30;
            this.Width = iWindowNarrowWidth;
            this.buttonCancel.Visible                  = false;
            this.buttonOK.Visible                      = false;
            this.treeViewAggregation.Visible           = false;
            this.lblUnusedAggregationsToDelete.Visible = false;
        }
Exemplo n.º 45
0
 public static void AreEqualDeploymentSettings(DeploymentSettings expected, DeploymentSettings actual)
 {
     AreEqualDeploymentSettings(expected.ServiceSettings, expected.ConfigPath, expected.DeploymentName, expected.Label, expected.PackagePath, expected.SubscriptionId, actual);
 }
Exemplo n.º 46
0
 public DeploymentGraphReader(DeploymentSettings settings)
 {
     _settings = settings;
 }
Exemplo n.º 47
0
        public static void DeployPerspectives(ProjectItem projItem, DTE2 ApplicationObject)
        {
            Microsoft.AnalysisServices.Cube oCube = (Microsoft.AnalysisServices.Cube)projItem.Object;

            if (oCube.Perspectives.Count == 0)
            {
                MessageBox.Show("There are no perspectives defined in this cube yet.");
                return;
            }

            try
            {
                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Deploying perspectives", 1, 5);

                FileAttributes fa = System.IO.File.GetAttributes(projItem.get_FileNames(1));
                if ((fa & FileAttributes.ReadOnly) != FileAttributes.ReadOnly )
                {
                    //Save the cube
                    projItem.Save("");
                }

                ApplicationObject.StatusBar.Progress(true, "Deploying perspectives", 2, 5);

                // extract deployment information
                DeploymentSettings deploySet = new DeploymentSettings(projItem);

                // use xlst to create xmla alter command
                XslCompiledTransform xslt = new XslCompiledTransform();
                XmlReader xsltRdr;
                XmlReader xrdr;

                // read xslt from embedded resource
                xsltRdr = XmlReader.Create(new StringReader(BIDSHelper.Resources.Common.DeployPerspectives));
                using ((xsltRdr))
                {
                    // read content from .cube file
                    xrdr = XmlReader.Create(projItem.get_FileNames(1));
                    using (xrdr)
                    {


                        
                        ApplicationObject.StatusBar.Progress(true, "Deploying perspectives", 3, 5);
                        // Connect to Analysis Services
                        Microsoft.AnalysisServices.Server svr = new Microsoft.AnalysisServices.Server();
                        svr.Connect(deploySet.TargetServer);
                        ApplicationObject.StatusBar.Progress(true, "Deploying perspectives", 4, 5);
                        // execute the xmla
                        try
                        {
                            // Build up the Alter perspectives command using XSLT against the .cube file
                            XslCompiledTransform xslta = new XslCompiledTransform();
                            StringBuilder sb = new StringBuilder();
                            XmlWriterSettings xws = new XmlWriterSettings();
                            xws.OmitXmlDeclaration = true;
                            xws.ConformanceLevel = ConformanceLevel.Fragment;
                            XmlWriter xwrtr = XmlWriter.Create(sb, xws);

                            xslta.Load(xsltRdr);
                            XsltArgumentList xslarg = new XsltArgumentList();

                            Database targetDB = svr.Databases.FindByName(deploySet.TargetDatabase);
                            if (targetDB == null)
                            {
                                throw new System.Exception(string.Format("A database called {0} could not be found on the {1} server", deploySet.TargetDatabase, deploySet.TargetServer));
                            }
                            string targetDatabaseID = targetDB.ID;
                            xslarg.AddParam("TargetDatabase", "", targetDatabaseID);
                            xslta.Transform(xrdr, xslarg, xwrtr);

                            Cube oServerCube = targetDB.Cubes.Find(oCube.ID);
                            if (oServerCube == null)
                            {
                                throw new System.Exception(string.Format("The {0} cube is not yet deployed to the {1} server.", oCube.Name, deploySet.TargetServer));
                            }

                            //drop any perspectives which don't exist
                            svr.CaptureXml = true;
                            for (int i = 0; i < oServerCube.Perspectives.Count; i++)
                            {
                                Perspective p = oServerCube.Perspectives[i];
                                if (!oCube.Perspectives.Contains(p.ID))
                                {
                                    p.Drop();
                                    i--;
                                }
                            }
                            svr.CaptureXml = false;
                            try
                            {
                                if (svr.CaptureLog.Count > 0)
                                    svr.ExecuteCaptureLog(true, false);
                            }
                            catch (System.Exception ex)
                            {
                                throw new System.Exception("Error dropping perspective that were deleted in the source code. " + ex.Message);
                            }


                            // update the perspectives
                            XmlaResultCollection xmlaRC = svr.Execute(sb.ToString());

                            StringBuilder sbErr = new StringBuilder();
                            for (int iRC = 0; iRC < xmlaRC.Count; iRC++)
                            {
                                for (int iMsg = 0; iMsg < xmlaRC[iRC].Messages.Count; iMsg++)
                                {
                                    sbErr.AppendLine(xmlaRC[iRC].Messages[iMsg].Description);
                                }
                            }
                            if (sbErr.Length > 0)
                            {
                                MessageBox.Show(sbErr.ToString(), "BIDSHelper - Deploy Perspectives");
                            }



                            try
                            {
                                // Building the project means that the .asdatabase file gets re-built so that
                                // we do not break the Deployment Wizard.
                                projItem.DTE.Solution.SolutionBuild.BuildProject(projItem.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, projItem.ContainingProject.UniqueName, false);

                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            if (MessageBox.Show("The following error occured while trying to deploy the perspectives\r\n"
                                                + ex.Message
                                                + "\r\n\r\nDo you want to see a stack trace?"
                                            , "BIDS Helper - Deploy Perspectives"
                                            , MessageBoxButtons.YesNo
                                            , MessageBoxIcon.Error
                                            , MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                MessageBox.Show(ex.StackTrace);
                            }
                        }
                        finally
                        {
                            ApplicationObject.StatusBar.Progress(true, "Deploying perspectives", 5, 5);
                            // report any results back (status bar?)
                            svr.Disconnect();
                        }
                    }
                }
            }
            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Deploying perspectives", 5, 5);
            }
        }
        /// <summary>
        /// Initialize our model of the AzureService located at the given
        /// path along with its DeploymentSettings and SubscriptionId.
        /// </summary>
        /// <param name="rootPath">Root path of the Azure service.</param>
        /// <param name="manifest">External runtime manifest to use, mainly for testing purposes</param>
        internal bool InitializeSettingsAndCreatePackage(string rootPath, string manifest = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(rootPath), "rootPath cannot be null or empty.");
            Debug.Assert(Directory.Exists(rootPath), "rootPath does not exist.");

            _azureService = new AzureService(rootPath, null);

            // If user provided a service name, change current service name to use it.
            //
            if (!string.IsNullOrEmpty(ServiceName))
            {
                _azureService.ChangeServiceName(ServiceName, _azureService.Paths);
            }

            ServiceSettings defaultSettings = ServiceSettings.LoadDefault(
                _azureService.Paths.Settings,
                Slot,
                Location,
                AffinityGroup,
                Subscription,
                StorageAccountName,
                ServiceName,
                _azureService.ServiceName,
                out _hostedServiceName);

            if (!string.IsNullOrEmpty(defaultSettings.Subscription))
            {
                var globalComponents = GlobalComponents.Load(GlobalPathInfo.GlobalSettingsDirectory);
                CurrentSubscription = globalComponents.Subscriptions.Values.First(
                    subscription => subscription.SubscriptionName == defaultSettings.Subscription);
            }
            else
            {
                defaultSettings.Subscription = CurrentSubscription.SubscriptionName;
            }

            WriteVerboseWithTimestamp(String.Format(Resources.RuntimeDeploymentStart,
                _hostedServiceName));
            if (PrepareRuntimeDeploymentInfo(_azureService, defaultSettings, manifest))
            {

                WriteVerboseWithTimestamp(String.Format(Resources.PublishPreparingDeploymentMessage,
                    _hostedServiceName, CurrentSubscription.SubscriptionId));

                // Caching worker roles require update to their service configuration settings with
                // the storage service credentials. Before creating the package verify that the storage
                // service exists and fetch its credentials.
                if (!StorageAccountExists(defaultSettings.StorageAccountName))
                {
                    CreateStorageAccount(
                        defaultSettings.StorageAccountName,
                        _hostedServiceName,
                        defaultSettings.Location,
                        defaultSettings.AffinityGroup);
                }

                // Initiate call to all publish listeners.
                this._listeners.ForEach<IPublishListener>(l => l.OnPublish(Channel, _azureService, defaultSettings, CurrentSubscription.SubscriptionId));

                CreatePackage();

                _deploymentSettings = new DeploymentSettings(
                    defaultSettings,
                    _azureService.Paths.CloudPackage,
                    _azureService.Paths.CloudConfiguration,
                    _hostedServiceName,
                    string.Format(Resources.ServiceDeploymentName, defaultSettings.Slot));

                return true;
            }

            return false;
        }
Exemplo n.º 49
0
 public DeploymentFileCopier(IFileSystem system, DeploymentSettings source, DeploymentSettings destination)
 {
     _system = system;
     _source = source;
     _destination = destination;
 }
        public static void DeployAggDesigns(ProjectItem projItem, DTE2 ApplicationObject)
        {
            Microsoft.AnalysisServices.Cube oCube = (Microsoft.AnalysisServices.Cube)projItem.Object;

            bool bFoundAggDesign = false;
            foreach (MeasureGroup mg in oCube.MeasureGroups)
            {
                if (mg.AggregationDesigns.Count > 0)
                {
                    bFoundAggDesign = true;
                    break;
                }
            }
            if (!bFoundAggDesign)
            {
                MessageBox.Show("There are no aggregation designs defined in this cube yet.");
                return;
            }

            if (MessageBox.Show("This command deploys just the aggregation designs in this cube. It does not change which aggregation design is assigned to each partition.\r\n\r\nYou should run a ProcessIndex command from Management Studio on this cube after aggregation designs have been deployed.\r\n\r\nDo you wish to continue?", "BIDS Helper - Deploy Aggregation Designs", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            try
            {
                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 1, 5);

                string sPartitionsFileName = projItem.get_FileNames(1);
                sPartitionsFileName = sPartitionsFileName.Substring(0, sPartitionsFileName.Length - 5) + ".partitions";

                // Check if the file is read-only (and probably checked in to a source control system)
                // before attempting to save. (issue: 10327 )
                FileAttributes fa = System.IO.File.GetAttributes(sPartitionsFileName);
                if ((fa & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
                {
                    //TODO - prompt before saving?
                    //Save the cube
                    projItem.Save("");
                }

                ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 2, 5);

                // extract deployment information
                DeploymentSettings deploySet = new DeploymentSettings(projItem);

                // use xlst to create xmla alter command
                XslCompiledTransform xslt = new XslCompiledTransform();
                XmlReader xsltRdr;
                XmlReader xrdr;

                // read xslt from embedded resource
                xsltRdr = XmlReader.Create(new StringReader(BIDSHelper.Resources.Common.DeployAggDesigns));
                using ((xsltRdr))
                {
                    // read content from .partitions file
                    xrdr = XmlReader.Create(sPartitionsFileName);
                    using (xrdr)
                    {
                        ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 3, 5);
                        // Connect to Analysis Services
                        Microsoft.AnalysisServices.Server svr = new Microsoft.AnalysisServices.Server();
                        svr.Connect(deploySet.TargetServer);
                        ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 4, 5);
                        // execute the xmla
                        try
                        {
                            // Build up the Alter MdxScript command using XSLT against the .partitions file
                            XslCompiledTransform xslta = new XslCompiledTransform();
                            StringBuilder sb = new StringBuilder();
                            XmlWriterSettings xws = new XmlWriterSettings();
                            xws.OmitXmlDeclaration = true;
                            xws.ConformanceLevel = ConformanceLevel.Fragment;
                            XmlWriter xwrtr = XmlWriter.Create(sb, xws);

                            xslta.Load(xsltRdr);
                            XsltArgumentList xslarg = new XsltArgumentList();

                            Database targetDB = svr.Databases.FindByName(deploySet.TargetDatabase);
                            if (targetDB == null)
                            {
                                throw new System.Exception(string.Format("A database called {0} could not be found on the {1} server", deploySet.TargetDatabase, deploySet.TargetServer));
                            }
                            xslarg.AddParam("TargetDatabase", "", targetDB.ID);
                            xslarg.AddParam("TargetCubeID", "", oCube.ID);
                            xslta.Transform(xrdr, xslarg, xwrtr);

                            Cube oServerCube = targetDB.Cubes.Find(oCube.ID);
                            if (oServerCube == null)
                            {
                                throw new System.Exception(string.Format("The {0} cube is not yet deployed to the {1} server.", oCube.Name, deploySet.TargetServer));
                            }

                            // update the agg designs
                            XmlaResultCollection xmlaRC = svr.Execute(sb.ToString());
                            StringBuilder sbErr = new StringBuilder();
                            for (int iRC = 0; iRC < xmlaRC.Count; iRC++)
                            {
                                for (int iMsg = 0; iMsg < xmlaRC[iRC].Messages.Count; iMsg++)
                                {
                                    if (!string.IsNullOrEmpty(xmlaRC[iRC].Messages[iMsg].Description))
                                        sbErr.AppendLine(xmlaRC[iRC].Messages[iMsg].Description);
                                }
                            }
                            if (sbErr.Length > 0)
                                MessageBox.Show(sbErr.ToString(), "BIDSHelper - Deploy Aggregation Designs");

                            projItem.DTE.Solution.SolutionBuild.BuildProject(projItem.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, projItem.ContainingProject.UniqueName, false);
                        }
                        catch (System.Exception ex)
                        {
                            if (MessageBox.Show("The following error occured while trying to deploy the aggregation designs\r\n"
                                                + ex.Message
                                                + "\r\n\r\nDo you want to see a stack trace?"
                                            , "BIDSHelper - Deploy Aggregation Designs"
                                            , MessageBoxButtons.YesNo
                                            , MessageBoxIcon.Error
                                            , MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                MessageBox.Show(ex.StackTrace);
                            }
                        }
                        finally
                        {
                            ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 5, 5);
                            svr.Disconnect();
                        }
                    }
                }
            }
            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Deploying Aggregation Designs", 5, 5);
            }
        }
Exemplo n.º 51
0
 public ConnectionStringResolver(DeploymentSettings settings)
 {
     _settings = settings;
 }
        public void TestDeploymentSettingsTestNullLabelFail()
        {
            string deploymentName = service.ServiceName;

            try
            {
                DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, configPath, null, deploymentName);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));
                Assert.IsTrue(string.Compare(string.Format(Resources.InvalidOrEmptyArgumentMessage, "Label"), ex.Message, true) == 0);
            }
        }
Exemplo n.º 53
0
 public BottleRepository(IFileSystem fileSystem, IZipFileService zipService, DeploymentSettings settings)
 {
     _fileSystem = fileSystem;
     _zipService = zipService;
     _settings = settings;
 }
        public async Task <ConfiguratorSettings> LoadSettingsThroughSSH(DeploymentSettings settings)
        {
            SSHSettings sshSettings = null;
            var         result      = new ConfiguratorSettings()
            {
                DeploymentSettings = settings
            };

            switch (settings.DeploymentType)
            {
            case DeploymentType.RemoteMachine when ModelState.IsValid:
            {
                sshSettings = new SSHSettings()
                {
                    Password = settings.Password,
                    Server   = settings.Host,
                    Username = settings.Username
                };

                break;
            }

            case DeploymentType.ThisMachine when ModelState.IsValid:
            {
                if (IsVerified)
                {
                    sshSettings = _options.Value.ParseSSHConfiguration();
                }
                break;
            }
            }

            using var ssh = await sshSettings.ConnectAsync();

            result.AdvancedSettings ??= new AdvancedSettings();
//                await ssh.RunBash(SSHClientExtensions.LoginAsRoot());

            var x = await ssh.RunBash("cat .env");

            Dictionary <string, string> preloadedEnvVars = new Dictionary <string, string>();

            if (x.ExitStatus == 0)
            {
                preloadedEnvVars = x.Output.Split("\n", StringSplitOptions.RemoveEmptyEntries)
                                   .Select(s => s.Split("=", StringSplitOptions.None)).ToDictionary(strings => strings[0],
                                                                                                    strings => strings.Length > 1 ? strings[1] : "");
            }
            x = await ssh.RunBash("cat /etc/profile.d/btcpay-env.sh");

            if (x.ExitStatus == 0)
            {
                preloadedEnvVars = x.Output.Split("\n", StringSplitOptions.RemoveEmptyEntries)
                                   .Where(s => s.Contains("=") && !s.Contains("==") && s.Contains("export"))
                                   .Select(s => s.Split("=", StringSplitOptions.None)).ToDictionary(strings => strings[0].Replace("export ", ""),
                                                                                                    strings => strings.Length > 1 ? strings[1].Trim('"') : "").Concat(preloadedEnvVars)
                                   .ToDictionary(pair => pair.Key, pair => pair.Value);
            }
            var branch = await
                         ssh.RunBash(
                "if [ -d \"btcpayserver-docker\" ]; then  git -C \"btcpayserver-docker\" rev-parse --abbrev-ref HEAD; fi");

            if (branch.ExitStatus == 0)
            {
                result.AdvancedSettings.BTCPayDockerBranch = branch.Output;
            }

            var repo = await
                       ssh.RunBash(
                "if [ -d \"btcpayserver-docker\" ]; then git -C \"btcpayserver-docker\" config --get remote.origin.url;  fi");

            if (repo.ExitStatus == 0)
            {
                result.AdvancedSettings.BTCPayDockerRepository = repo.Output;
            }


            result.AdvancedSettings.CustomBTCPayImage = await GetVar(preloadedEnvVars, ssh, "BTCPAY_IMAGE");

            result.AdvancedSettings.AdditionalFragments =
                (await GetVar(preloadedEnvVars, ssh, "BTCPAYGEN_ADDITIONAL_FRAGMENTS"))
                .Split(';', StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
            result.AdvancedSettings.ExcludedFragments =
                (await GetVar(preloadedEnvVars, ssh, "BTCPAYGEN_EXCLUDE_FRAGMENTS"))
                .Split(';', StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();


            result.AdditionalServices ??= new AdditionalServices();
            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-librepatron"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-librepatron");
                result.AdditionalServices.LibrePatronSettings.Enabled = true;
                result.AdditionalServices.LibrePatronSettings.Host    =
                    await GetVar(preloadedEnvVars, ssh, "LIBREPATRON_HOST");
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-woocommerce"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-woocommerce");
                result.AdditionalServices.WooCommerceSettings.Enabled = true;
                result.AdditionalServices.WooCommerceSettings.Host    =
                    await GetVar(preloadedEnvVars, ssh, "WOOCOMMERCE_HOST");
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-btctransmuter"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-btctransmuter");
                result.AdditionalServices.BTCTransmuterSettings.Enabled = true;
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-configurator"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-configurator");
                result.AdditionalServices.ConfiguratorAddonSettings.Enabled = true;
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-electrum-ps"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-electrum-ps");
                result.AdditionalServices.ElectrumPersonalServerSettings.Enabled = true;
                result.AdditionalServices.ElectrumPersonalServerSettings.Xpub    =
                    await GetVar(preloadedEnvVars, ssh, "EPS_XPUB ");
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-electrumx"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-electrumx");
                result.AdditionalServices.ElectrumXSettings.Enabled = true;
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-thunderhub"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-thunderhub");
                result.AdditionalServices.ThunderHubSettings.Enabled = true;
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-tor-relay"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-tor-relay");
                result.AdditionalServices.TorRelaySettings.Enabled  = true;
                result.AdditionalServices.TorRelaySettings.Nickname =
                    await GetVar(preloadedEnvVars, ssh, "TOR_RELAY_NICKNAME");

                result.AdditionalServices.TorRelaySettings.Email =
                    await GetVar(preloadedEnvVars, ssh, "TOR_RELAY_EMAIL");
            }

            if (result.AdvancedSettings.AdditionalFragments.Contains("opt-add-pihole"))
            {
                result.AdvancedSettings.AdditionalFragments.Remove("opt-add-pihole");
                result.AdditionalServices.PiHoleSettings.Enabled  = true;
                result.AdditionalServices.PiHoleSettings.ServerIp =
                    await GetVar(preloadedEnvVars, ssh, "PIHOLE_SERVERIP");
            }

            result.LightningSettings ??= new LightningSettings();
            result.LightningSettings.Implementation = await GetVar(preloadedEnvVars, ssh, "BTCPAYGEN_LIGHTNING");

            if (string.IsNullOrEmpty(result.LightningSettings.Implementation))
            {
                result.LightningSettings.Implementation = "none";
            }
            result.LightningSettings.Alias = await GetVar(preloadedEnvVars, ssh, "LIGHTNING_ALIAS");

            var index = 1;

            result.ChainSettings ??= new ChainSettings();
            result.ChainSettings.Bitcoin = false;
            while (true)
            {
                var chain = await GetVar(preloadedEnvVars, ssh, $"BTCPAYGEN_CRYPTO{index}");

                if (string.IsNullOrEmpty(chain))
                {
                    break;
                }

                if (chain.Equals("btc", StringComparison.InvariantCultureIgnoreCase))
                {
                    result.ChainSettings.Bitcoin = true;
                }
                else
                {
                    result.ChainSettings.AltChains.Add(chain);
                }

                index++;
            }

            var matching =
                result.AdvancedSettings.AdditionalFragments.FirstOrDefault(s => s.StartsWith("opt-save-storage"));

            if (string.IsNullOrEmpty(matching))
            {
                result.ChainSettings.PruneMode = PruneMode.NoPruning;
            }
            else
            {
                result.AdvancedSettings.AdditionalFragments.Remove(matching);
                result.ChainSettings.PruneMode = matching.Replace("opt-save-storage", "") switch
                {
                    "" => PruneMode.Minimal,
                    "-s" => PruneMode.Small,
                    "-xs" => PruneMode.ExtraSmall,
                    "-xxs" => PruneMode.ExtraExtraSmall,
                    _ => result.ChainSettings.PruneMode
                };
            }

            if (Enum.TryParse <NetworkType>(await GetVar(preloadedEnvVars, ssh, "NBITCOIN_NETWORK"), true,
                                            out var networkType))
            {
                result.ChainSettings.Network = networkType;
            }

            result.DomainSettings ??= new DomainSettings();
            result.DomainSettings.Domain = await GetVar(preloadedEnvVars, ssh, "BTCPAY_HOST");

            result.DomainSettings.AdditionalDomains =
                (await GetVar(preloadedEnvVars, ssh, "BTCPAY_ADDITIONAL_HOSTS"))
                .Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();

            result.ServerData = await ServerData.Load(ssh);

            return(result);
        }
    }
        public void TestDeploymentSettingsTestNullSettingsFail()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;

            try
            {
                DeploymentSettings deploySettings = new DeploymentSettings(null, packagePath, configPath, label, deploymentName);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentException));
                Assert.AreEqual<string>(Resources.InvalidServiceSettingMessage, ex.Message);
            }
        }
        public static void DeployAggDesigns(ProjectItem projItem, DTE2 ApplicationObject)
        {
            Microsoft.AnalysisServices.Cube oCube = (Microsoft.AnalysisServices.Cube)projItem.Object;

            bool bFoundAggDesign = false;

            foreach (MeasureGroup mg in oCube.MeasureGroups)
            {
                if (mg.AggregationDesigns.Count > 0)
                {
                    bFoundAggDesign = true;
                    break;
                }
            }
            if (!bFoundAggDesign)
            {
                MessageBox.Show("There are no aggregation designs defined in this cube yet.");
                return;
            }

            if (MessageBox.Show("This command deploys just the aggregation designs in this cube. It does not change which aggregation design is assigned to each partition.\r\n\r\nYou should run a ProcessIndex command from Management Studio on this cube after aggregation designs have been deployed.\r\n\r\nDo you wish to continue?", "BIDS Helper - Deploy Aggregation Designs", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            try
            {
                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 1, 5);

                string sPartitionsFileName = projItem.get_FileNames(1);
                sPartitionsFileName = sPartitionsFileName.Substring(0, sPartitionsFileName.Length - 5) + ".partitions";

                // Check if the file is read-only (and probably checked in to a source control system)
                // before attempting to save. (issue: 10327 )
                FileAttributes fa = System.IO.File.GetAttributes(sPartitionsFileName);
                if ((fa & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
                {
                    //TODO - prompt before saving?
                    //Save the cube
                    projItem.Save("");
                }

                ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 2, 5);

                // extract deployment information
                DeploymentSettings deploySet = new DeploymentSettings(projItem);

                // use xlst to create xmla alter command
                XslCompiledTransform xslt = new XslCompiledTransform();
                XmlReader            xsltRdr;
                XmlReader            xrdr;

                // read xslt from embedded resource
                xsltRdr = XmlReader.Create(new StringReader(BIDSHelper.Resources.Common.DeployAggDesigns));
                using ((xsltRdr))
                {
                    // read content from .partitions file
                    xrdr = XmlReader.Create(sPartitionsFileName);
                    using (xrdr)
                    {
                        ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 3, 5);
                        // Connect to Analysis Services
                        Microsoft.AnalysisServices.Server svr = new Microsoft.AnalysisServices.Server();
                        svr.Connect(deploySet.TargetServer);
                        ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 4, 5);
                        // execute the xmla
                        try
                        {
                            // Build up the Alter MdxScript command using XSLT against the .partitions file
                            XslCompiledTransform xslta = new XslCompiledTransform();
                            StringBuilder        sb    = new StringBuilder();
                            XmlWriterSettings    xws   = new XmlWriterSettings();
                            xws.OmitXmlDeclaration = true;
                            xws.ConformanceLevel   = ConformanceLevel.Fragment;
                            XmlWriter xwrtr = XmlWriter.Create(sb, xws);

                            xslta.Load(xsltRdr);
                            XsltArgumentList xslarg = new XsltArgumentList();

                            Database targetDB = svr.Databases.FindByName(deploySet.TargetDatabase);
                            if (targetDB == null)
                            {
                                throw new System.Exception(string.Format("A database called {0} could not be found on the {1} server", deploySet.TargetDatabase, deploySet.TargetServer));
                            }
                            xslarg.AddParam("TargetDatabase", "", targetDB.ID);
                            xslarg.AddParam("TargetCubeID", "", oCube.ID);
                            xslta.Transform(xrdr, xslarg, xwrtr);

                            Cube oServerCube = targetDB.Cubes.Find(oCube.ID);
                            if (oServerCube == null)
                            {
                                throw new System.Exception(string.Format("The {0} cube is not yet deployed to the {1} server.", oCube.Name, deploySet.TargetServer));
                            }

                            // update the agg designs
                            XmlaResultCollection xmlaRC = svr.Execute(sb.ToString());
                            StringBuilder        sbErr  = new StringBuilder();
                            for (int iRC = 0; iRC < xmlaRC.Count; iRC++)
                            {
                                for (int iMsg = 0; iMsg < xmlaRC[iRC].Messages.Count; iMsg++)
                                {
                                    if (!string.IsNullOrEmpty(xmlaRC[iRC].Messages[iMsg].Description))
                                    {
                                        sbErr.AppendLine(xmlaRC[iRC].Messages[iMsg].Description);
                                    }
                                }
                            }
                            if (sbErr.Length > 0)
                            {
                                MessageBox.Show(sbErr.ToString(), "BIDSHelper - Deploy Aggregation Designs");
                            }

                            projItem.DTE.Solution.SolutionBuild.BuildProject(projItem.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, projItem.ContainingProject.UniqueName, false);
                        }
                        catch (System.Exception ex)
                        {
                            if (MessageBox.Show("The following error occured while trying to deploy the aggregation designs\r\n"
                                                + ex.Message
                                                + "\r\n\r\nDo you want to see a stack trace?"
                                                , "BIDSHelper - Deploy Aggregation Designs"
                                                , MessageBoxButtons.YesNo
                                                , MessageBoxIcon.Error
                                                , MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                MessageBox.Show(ex.StackTrace);
                            }
                        }
                        finally
                        {
                            ApplicationObject.StatusBar.Progress(true, "Deploying Aggregation Designs", 5, 5);
                            svr.Disconnect();
                        }
                    }
                }
            }
            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Deploying Aggregation Designs", 5, 5);
            }
        }
        public void TestDeploymentSettingsTestWithDefaultServiceSettings()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;
            settings.Subscription = "TestSubscription2";
            DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, configPath, label, deploymentName);

            AzureAssert.AreEqualDeploymentSettings(settings, configPath, deploymentName, label, packagePath, "f62b1e05-af8f-4205-8f98-325079adc155", deploySettings);
        }
Exemplo n.º 58
0
        private void testAggregationPerformanceToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            Server s = new Server();
            try
            {
                AggregationDesign aggD = ((MeasureGroup)treeView1.SelectedNode.Parent.Parent.Tag).AggregationDesigns.GetByName(treeView1.SelectedNode.Tag.ToString());
                if (aggD.Parent.IsLinked)
                {
                    MessageBox.Show("This measure group is linked.");
                    return;
                }

                string serverName = "";
                string databaseName = "";
                if (aggD.ParentServer != null)
                {
                    // if we are in Online mode there will be a parent server
                    serverName = aggD.ParentServer.Name;
                    databaseName = aggD.ParentDatabase.Name;
                    s.Connect(aggD.ParentServer.ConnectionString);
                }
                else
                {
                    // if we are in Project mode we will use the server name from 
                    // the deployment settings
                    DeploymentSettings deploySet = new DeploymentSettings(mProjItem);
                    serverName = deploySet.TargetServer;
                    databaseName = deploySet.TargetDatabase; //use the target database instead of selectedCube.Parent.Name because selectedCube.Parent.Name only reflects the last place it was deployed to, and we want the user to be able to use the deployment settings to control which deployed server/database to check against
                    s.Connect("Data Source=" + serverName);
                }

                Database db = s.Databases.FindByName(databaseName);
                if (db == null)
                {
                    MessageBox.Show("Database " + databaseName + " isn't deployed to server " + serverName + ".");
                    return;
                }

                Cube cube = db.Cubes.Find(realCube.ID);
                if (cube == null)
                {
                    MessageBox.Show("Cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                MeasureGroup liveMG = cube.MeasureGroups.Find(aggD.Parent.ID);
                if (liveMG == null)
                {
                    MessageBox.Show("Measure group " + aggD.Parent.Name + " in cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                AggregationDesign liveAggD = liveMG.AggregationDesigns.Find(aggD.ID);
                if (liveMG == null)
                {
                    MessageBox.Show("Agg design " + aggD.Name + " in measure group " + aggD.Parent.Name + " in cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                AggregationPerformanceProgress progressForm = new AggregationPerformanceProgress();
                progressForm.Init(liveAggD);
                progressForm.ShowDialog(this);

                if (progressForm.Results.Count > 0)
                {
                    OpenAggPerfReport(progressForm.Results, progressForm.MissingResults, progressForm.chkWithoutIndividualAggs.Checked);
                }
                else if (progressForm.Started)
                {
                    if (string.IsNullOrEmpty(progressForm.Errors))
                    {
                        MessageBox.Show("No processed aggregations found in agg design " + liveAggD.Name + " in measure group " + liveMG.Name + " in cube " + liveMG.Parent.Name + " on database " + liveMG.ParentDatabase.Name + " on server " + liveMG.ParentServer.Name + ".");
                    }
                    else
                    {
                        MessageBox.Show(progressForm.Errors);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    s.Disconnect();
                }
                catch { }
            }
        }
        public void TestDeploymentSettingsTestWithFullServiceSettings()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;
            ServiceSettings fullSettings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Sample1];
            DeploymentSettings deploySettings = new DeploymentSettings(fullSettings, packagePath, configPath, label, deploymentName);

            AzureAssert.AreEqualDeploymentSettings(fullSettings, configPath, deploymentName, label, packagePath, "f62b1e05-af8f-4205-8f98-325079adc155", deploySettings);
        }