Esempio n. 1
0
        /// <summary>
        /// Deploys the specified database to the specified target server and database ID, using the specified options.
        /// Returns a list of DAX errors (if any) on objects inside the database, in case the deployment was succesful.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="targetConnectionString"></param>
        /// <param name="targetDatabaseID"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        internal static DeploymentResult Deploy(TOM.Database db, string targetConnectionString, string targetDatabaseID, DeploymentOptions options, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(targetConnectionString))
            {
                throw new ArgumentNullException("targetConnectionString");
            }
            var s = new TOM.Server();

            s.Connect(targetConnectionString);

            var tmsl = GetTMSL(db, s, targetDatabaseID, options, true);

            cancellationToken.Register(s.CancelCommand);
            var result = s.Execute(tmsl);

            if (result.ContainsErrors)
            {
                throw new Exception(string.Join("\n", result.Cast <XmlaResult>().SelectMany(r => r.Messages.Cast <XmlaMessage>().Select(m => m.Description)).ToArray()));
            }

            s.Refresh();
            var deployedDB = s.Databases[targetDatabaseID];

            return
                (new DeploymentResult(
                     TabularModelHandler.CheckErrors(deployedDB).Select(t => string.Format("Error on {0}: {1}", GetName(t.Item1), t.Item2)),
                     TabularModelHandler.GetObjectsNotReady(deployedDB).Where(t => t.Item2 == TOM.ObjectState.DependencyError || t.Item2 == TOM.ObjectState.EvaluationError || t.Item2 == TOM.ObjectState.SemanticError)
                     .Select(t => string.Format("Warning! Object not in \"Ready\"-state: {0} ({1})", GetName(t.Item1), t.Item2.ToString())),
                     TabularModelHandler.GetObjectsNotReady(deployedDB).Where(t => t.Item2 == TOM.ObjectState.CalculationNeeded || t.Item2 == TOM.ObjectState.NoData)
                     .Select(t => string.Format("Information: Unprocessed object: {0} ({1})", GetName(t.Item1), t.Item2.ToString()))
                     ));
        }
Esempio n. 2
0
        /// <summary>
        /// Deploys the specified database to the specified target server and database ID, using the specified options.
        /// Returns a list of DAX errors (if any) on objects inside the database, in case the deployment was succesful.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="targetConnectionString"></param>
        /// <param name="targetDatabaseName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        internal static DeploymentResult Deploy(TOM.Database db, string targetConnectionString, string targetDatabaseName, DeploymentOptions options, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(targetConnectionString))
            {
                throw new ArgumentNullException("targetConnectionString");
            }
            var destinationServer = new TOM.Server();

            destinationServer.Connect(targetConnectionString);
            if (!destinationServer.SupportedCompatibilityLevels.Contains(db.CompatibilityLevel.ToString()))
            {
                throw new DeploymentException($"The specified server does not support Compatibility Level {db.CompatibilityLevel}");
            }

            var tmsl = GetTMSL(db, destinationServer, targetDatabaseName, options, true);

            cancellationToken.Register(destinationServer.CancelCommand);
            var result = destinationServer.Execute(tmsl);

            if (result.ContainsErrors)
            {
                throw new DeploymentException(string.Join("\n", result.Cast <XmlaResult>().SelectMany(r => r.Messages.Cast <XmlaMessage>().Select(m => m.Description)).ToArray()));
            }

            // Refresh the server object to make sure we get an updated list of databases, in case a new database was made:
            destinationServer.Refresh();

            // Fully refresh the deployed database object, to make sure we get updated error messages for the full object tree:
            var deployedDB = destinationServer.Databases.GetByName(targetDatabaseName);

            deployedDB.Refresh(true);
            return(GetLastDeploymentResults(deployedDB));
        }
Esempio n. 3
0
        public void TestNewDeploymentCalcColumnError()
        {
            var newDbName = "AdventureWorks_UT_New3";
            var server    = new TOM.Server();

            server.Connect("localhost");
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }

            var handler = new TabularModelHandler("AdventureWorks.bim");

            handler.Model.Tables["Employee"].AddCalculatedColumn("ErrorTest", "xxx");

            var results = TabularDeployer.Deploy(handler, "localhost", newDbName);

            Assert.AreNotEqual(0, results.Issues.Count);
            Assert.AreNotEqual(0, results.Unprocessed.Count);
            Assert.AreNotEqual(0, results.Warnings.Count);

            server.Refresh();
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }
        }
Esempio n. 4
0
        public void TestNewDeploymentNoErrors()
        {
            var newDbName = "AdventureWorks_UT_New1";
            var server    = new TOM.Server();

            server.Connect("localhost");
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }

            var handler = new TabularModelHandler("AdventureWorks.bim");

            var results = TabularDeployer.Deploy(handler, "localhost", newDbName);

            Assert.AreEqual(0, results.Issues.Count);
            Assert.AreNotEqual(0, results.Unprocessed.Count);
            Assert.AreEqual(0, results.Warnings.Count);

            server.Refresh();
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }
        }
Esempio n. 5
0
        public void TestNewDeploymentMeasureError()
        {
            var newDbName = "AdventureWorks_UT_New2";
            var server    = new TOM.Server();

            server.Connect(Constants.ServerName);
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }

            var handler = new TabularModelHandler("TestData\\AdventureWorks.bim");

            handler.Model.Tables["Employee"].AddMeasure("ErrorTest", "xxx");

            var results = TabularDeployer.Deploy(handler, Constants.ServerName, newDbName);

            Assert.AreNotEqual(0, results.Issues.Count);
            Assert.AreNotEqual(0, results.Unprocessed.Count);
            Assert.AreEqual(0, results.Warnings.Count);

            server.Refresh();
            if (server.Databases.ContainsName(newDbName))
            {
                server.Databases[newDbName].Drop();
            }
        }
Esempio n. 6
0
        public static void Deploy(TOM.Database db, TOM.Server s, string targetDatabaseID, DeploymentOptions options)
        {
            var tmsl   = GetTMSL(db, s, targetDatabaseID, options, true);
            var result = s.Execute(tmsl);

            if (result.ContainsErrors)
            {
                throw new Exception(string.Join("\n", result.Cast <XmlaResult>().SelectMany(r => r.Messages.Cast <XmlaMessage>().Select(m => m.Description)).ToArray()));
            }

            s.Refresh();
            var deployedDB = s.Databases[targetDatabaseID];
        }
Esempio n. 7
0
        /// <summary>
        /// Deploys the specified database to the specified target server and database ID, using the specified options.
        /// Returns a list of DAX errors (if any) on objects inside the database, in case the deployment was succesful.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="targetConnectionString"></param>
        /// <param name="targetDatabaseName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        internal static DeploymentResult Deploy(TOM.Database db, string targetConnectionString, string targetDatabaseName, DeploymentOptions options, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(targetConnectionString))
            {
                throw new ArgumentNullException("targetConnectionString");
            }
            var destinationServer = new TOM.Server();

            destinationServer.Connect(targetConnectionString);
            if (!destinationServer.SupportedCompatibilityLevels.Contains(db.CompatibilityLevel.ToString()))
            {
                throw new DeploymentException($"The specified server does not support Compatibility Level {db.CompatibilityLevel}");
            }

            var tmsl = GetTMSL(db, destinationServer, targetDatabaseName, options, true);

            cancellationToken.Register(destinationServer.CancelCommand);
            var result = destinationServer.Execute(tmsl);

            if (result.ContainsErrors)
            {
                throw new DeploymentException(string.Join("\n", result.Cast <XmlaResult>().SelectMany(r => r.Messages.Cast <XmlaMessage>().Select(m => m.Description)).ToArray()));
            }

            // Refresh the server object to make sure we get an updated list of databases, in case a new database was made:
            destinationServer.Refresh();

            // Fully refresh the deployed database object, to make sure we get updated error messages for the full object tree:
            var deployedDB = destinationServer.Databases.GetByName(targetDatabaseName);

            deployedDB.Refresh(true);
            return
                (new DeploymentResult(
                     TabularModelHandler.CheckErrors(deployedDB).Select(t => string.Format("Error on {0}: {1}", GetName(t.Item1), t.Item2)),
                     TabularModelHandler.GetObjectsNotReady(deployedDB).Where(t => t.Item2 == TOM.ObjectState.DependencyError || t.Item2 == TOM.ObjectState.EvaluationError || t.Item2 == TOM.ObjectState.SemanticError)
                     .Select(t => string.Format("Warning! Object not in \"Ready\"-state: {0} ({1})", GetName(t.Item1), t.Item2.ToString())),
                     TabularModelHandler.GetObjectsNotReady(deployedDB).Where(t => t.Item2 == TOM.ObjectState.CalculationNeeded || t.Item2 == TOM.ObjectState.NoData)
                     .Select(t => string.Format("Information: Unprocessed object: {0} ({1})", GetName(t.Item1), t.Item2.ToString())),
                     destinationServer
                     ));
        }
Esempio n. 8
0
        /// <summary>
        /// Deploys the specified database to the specified target server and database ID, using the specified options.
        /// Returns a list of DAX errors (if any) on objects inside the database, in case the deployment was succesful.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="targetConnectionString"></param>
        /// <param name="targetDatabaseID"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        internal static void Deploy(TOM.Database db, string targetConnectionString, string targetDatabaseID, DeploymentOptions options)
        {
            if (string.IsNullOrWhiteSpace(targetConnectionString))
            {
                throw new ArgumentNullException("targetConnectionString");
            }
            var s = new TOM.Server();

            s.Connect(targetConnectionString);

            var tmsl   = GetTMSL(db, s, targetDatabaseID, options, true);
            var result = s.Execute(tmsl);

            if (result.ContainsErrors)
            {
                throw new Exception(string.Join("\n", result.Cast <XmlaResult>().SelectMany(r => r.Messages.Cast <XmlaMessage>().Select(m => m.Description)).ToArray()));
            }

            s.Refresh();
            var deployedDB = s.Databases[targetDatabaseID];
        }