Exemplo n.º 1
0
        static void TestExport()
        {
            string       databaseName       = "Microsoft_SQLServer_AnalysisServices";
            const string serverName         = @"http://*****:*****@"c:\temp\test4.vpax";

            Console.WriteLine("Exporting...");

            //
            // Get Dax.Model object from the SSAS engine
            //
            Dax.Metadata.Model model = Dax.Metadata.Extractor.TomExtractor.GetDaxModel(serverName, databaseName, applicationName, applicationVersion);

            //
            // Get TOM model from the SSAS engine
            //
            Microsoft.AnalysisServices.Database database = includeTomModel ? Dax.Metadata.Extractor.TomExtractor.GetDatabase(serverName, databaseName) : null;

            //
            // Create VertiPaq Analyzer views
            //
            Dax.ViewVpaExport.Model viewVpa = new Dax.ViewVpaExport.Model(model);

            //
            // Save VPAX file
            //
            // TODO: export of database should be optional
            Dax.Vpax.Tools.VpaxTools.ExportVpax(path, model, viewVpa, database);

            Console.WriteLine("Completed");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add dimension into Cube dataBase, instead of cube
 /// </summary>
 /// <param name="cubedb">Cube dataBase</param>
 /// <param name="datasourcename">dataSourceName</param>
 /// <param name="dimensionid">dimension id</param>
 /// <param name="dimensionname">dimension id</param>
 /// <param name="dim_type">dimension type, eg..time、regular</param>
 /// <returns></returns>
 public static Microsoft.AnalysisServices.Dimension ADD_DIMENSION(
     Microsoft.AnalysisServices.Database cubedb,
     String datasourcename,
     String dimensionid,
     String dimensionname,
     String dim_type)
 {
     Microsoft.AnalysisServices.Dimension dim = cubedb.Dimensions.FindByName(dimensionname);
     try
     {
         String[] nullvalue = new String[] { "null" };
         if (!nullvalue.Contains(dimensionname))
         {
             dim      = cubedb.Dimensions.Add(dimensionid);
             dim.Name = dimensionname;
             dim.Type = Microsoft.AnalysisServices.DimensionType.Regular;
             if (dim_type.ToLower() == "time")
             {
                 dim.Type = Microsoft.AnalysisServices.DimensionType.Time;
             }
             dim.Source          = new Microsoft.AnalysisServices.DataSourceViewBinding(datasourcename);
             dim.StorageMode     = Microsoft.AnalysisServices.DimensionStorageMode.Molap;
             dim.ProcessingGroup = Microsoft.AnalysisServices.ProcessingGroup.ByAttribute;
         }
         //module_helper.helper.print_message_to_client( u"Added dimension ["+dimensionname+"]")
     }
     finally
     {
     }
     return(dim);
 }
Exemplo n.º 3
0
        public void ExportDatabase(Microsoft.AnalysisServices.Database database)
        {
            Uri uriTom = PackUriHelper.CreatePartUri(new Uri(VpaxFormat.TOMMODEL, UriKind.Relative));

            using (TextWriter tw = new StreamWriter(this.Package.CreatePart(uriTom, "application/json", CompressionOption.Maximum).GetStream(), Encoding.UTF8))
            {
                tw.Write(Microsoft.AnalysisServices.JsonSerializer.SerializeDatabase(database));
                tw.Close();
            }
        }
Exemplo n.º 4
0
 public static Microsoft.AnalysisServices.Database GetDatabase(string serverName, string databaseName)
 {
     Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
     server.Connect(serverName);
     Microsoft.AnalysisServices.Database db = server.Databases.FindByName(databaseName);
     // if db is null either it does not exist or we do not have admin rights to it
     if (db == null)
     {
         throw new ArgumentException($"The database '{databaseName}' could not be found. Either it does not exist or you do not have admin rights to it.");
     }
     return(db);
 }
Exemplo n.º 5
0
        static void TestExportStream()
        {
            string       databaseName       = "Microsoft_SQLServer_AnalysisServices";
            const string serverName         = @"http://*****:*****@"c:\temp\test5.vpax";

            Console.WriteLine("Exporting...");

            //
            // Get Dax.Model object from the SSAS engine
            //
            Dax.Metadata.Model model = Dax.Metadata.Extractor.TomExtractor.GetDaxModel(serverName, databaseName, applicationName, applicationVersion);

            //
            // Get TOM model from the SSAS engine
            //
            Microsoft.AnalysisServices.Database database = includeTomModel ? Dax.Metadata.Extractor.TomExtractor.GetDatabase(serverName, databaseName) : null;

            //
            // Create VertiPaq Analyzer views
            //
            Dax.ViewVpaExport.Model viewVpa = new Dax.ViewVpaExport.Model(model);

            //
            // Save VPAX file
            //

            using (var stream = File.Open(path, FileMode.Create, FileAccess.ReadWrite))
            {
                Dax.Vpax.Tools.VpaxTools.ExportVpax(stream, model, viewVpa, database);
            }

            using (var fileStream = File.OpenWrite(path))
                using (var memoryStream = new MemoryStream())
                {
                    Dax.Vpax.Tools.VpaxTools.ExportVpax(memoryStream, model, viewVpa, database);
                    memoryStream.CopyTo(fileStream);
                }

            Console.WriteLine("Completed");
        }
Exemplo n.º 6
0
 public static void ADD_CUBE_DIMENSION(
     Microsoft.AnalysisServices.Database cubedb,
     Microsoft.AnalysisServices.Cube cube,
     String dimID,
     String dimension_type,
     String cube_dimName = "",
     bool visible        = true)
 {
     Microsoft.AnalysisServices.Dimension dim = cubedb.Dimensions.Find(dimID);
     if (dim == null)
     {
         //   module_helper.helper.print_message_to_client( "Dimension name ["+dimName+"] is not existed in current cube","warning");
     }
     Microsoft.AnalysisServices.CubeDimension cube_dim = cube.Dimensions.Add(dim.ID);
     cube_dim.Visible = visible;
     cube_dim.Name    = dim.Name;
     //module_helper.helper.print_message_to_client( "Added dimension ["+cube.Dimensions.FindByName(dim.Name).Name+"] to cube");
 }
Exemplo n.º 7
0
        public static Dax.Metadata.Model GetDaxModel(string serverName, string databaseName, string applicationName, string applicationVersion, bool readStatisticsFromData = true)
        {
            Microsoft.AnalysisServices.Database      db       = GetDatabase(serverName, databaseName);
            Microsoft.AnalysisServices.Tabular.Model tomModel = db.Model;

            var daxModel = Dax.Metadata.Extractor.TomExtractor.GetDaxModel(tomModel, applicationName, applicationVersion);

            var connectionString = GetConnectionString(serverName, databaseName);

            using (var connection = new OleDbConnection(connectionString))
            {
                // Populate statistics from DMV
                Dax.Metadata.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, serverName, databaseName, applicationName, applicationVersion);

                // Populate statistics by querying the data model
                if (readStatisticsFromData)
                {
                    Dax.Metadata.Extractor.StatExtractor.UpdateStatisticsModel(daxModel, connection);
                }
            }
            return(daxModel);
        }
Exemplo n.º 8
0
            public static Dax.Model.Model GetDaxModel(string serverName, string databaseName, bool readStatisticsFromData = true)
            {
                Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
                server.Connect(serverName);
                Microsoft.AnalysisServices.Database      db       = server.Databases[databaseName];
                Microsoft.AnalysisServices.Tabular.Model tomModel = db.Model;
                var daxModel = Dax.Model.Extractor.TomExtractor.GetDaxModel(tomModel, "TestDaxModel", "0.1");

                var connectionString = GetConnectionString(serverName, databaseName);

                using (var connection = new OleDbConnection(connectionString)) {
                    // Populate statistics from DMV
                    Dax.Model.Extractor.DmvExtractor.PopulateFromDmv(daxModel, connection, databaseName, "TestDaxModel", "0.1");

                    // Populate statistics by querying the data model
                    if (readStatisticsFromData)
                    {
                        Dax.Model.Extractor.StatExtractor.UpdateStatisticsModel(daxModel, connection);
                    }
                }
                return(daxModel);
            }
Exemplo n.º 9
0
 /// <summary>
 /// Export to VertiPaq Analyzer (VPAX) file
 /// </summary>
 /// <param name="databaseName"></param>
 /// <param name="pathOutput"></param>
 /// <param name="viewVpa"></param>
 /// <param name="database"></param>
 public static void ExportVpax(string path, Dax.Metadata.Model model, Dax.ViewVpaExport.Model viewVpa = null, Microsoft.AnalysisServices.Database database = null)
 {
     using (ExportVpax exportVpax = new ExportVpax(path))
     {
         if (model != null)
         {
             exportVpax.ExportModel(model);
         }
         if (viewVpa != null)
         {
             exportVpax.ExportViewVpa(viewVpa);
         }
         if (database != null)
         {
             exportVpax.ExportDatabase(database);
         }
         exportVpax.Close();
     }
 }
        public List <mycOLAPuser> listUsers; // общий список юзеров

        public mycOLAPdb()
        {
            DBolap    = new Microsoft.AnalysisServices.Database();
            listRole  = new List <mycOLAProle>();
            listUsers = new List <mycOLAPuser>();
        }
Exemplo n.º 11
0
 internal static void InternalExportVpax(ExportVpax exportVpax, Dax.Metadata.Model model, Dax.ViewVpaExport.Model viewVpa = null, Microsoft.AnalysisServices.Database database = null)
 {
     if (model != null)
     {
         exportVpax.ExportModel(model);
     }
     if (viewVpa != null)
     {
         exportVpax.ExportViewVpa(viewVpa);
     }
     if (database != null)
     {
         exportVpax.ExportDatabase(database);
     }
     exportVpax.Close();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Export to VertiPaq Analyzer (VPAX) file
 /// </summary>
 public static void ExportVpax(string path, Dax.Metadata.Model model, Dax.ViewVpaExport.Model viewVpa = null, Microsoft.AnalysisServices.Database database = null)
 {
     using (ExportVpax exportVpax = new ExportVpax(path))
     {
         InternalExportVpax(exportVpax, model, viewVpa, database);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Export to VertiPaq Analyzer (VPAX) stream
        /// </summary>
        public static void ExportVpax(Stream stream, Dax.Metadata.Model model, Dax.ViewVpaExport.Model viewVpa = null, Microsoft.AnalysisServices.Database database = null)
        {
            using (ExportVpax exportVpax = new ExportVpax(stream))
            {
                InternalExportVpax(exportVpax, model, viewVpa, database);
            }

            stream.Position = 0L;
        }