项目作者: HadiFadl

项目描述 :
SQL Server Analysis Services multidimensional databases metadata reader
高级语言: C#
项目地址: git://github.com/HadiFadl/MetaCube.git
创建时间: 2019-04-24T19:10:28Z
项目社区:https://github.com/HadiFadl/MetaCube

开源协议:MIT License

下载


MetaCube

MetaCube is a tool that can be used to read the SQL Server Analysis Server Objects using AMO assemblies and map each object to the related directory and configuration files located in the server data directory (DataDir property).

You can use the Classes within your own solution or you can use the application as a tool.


SSAS Data directory contents hierarchy

After building many multidimensional Cube using SSAS, i can assume that the following tree is the Data directory hierarchy:

  1. |- Data Directory
  2. |- Database (.db)
  3. |- Dimension (.dim)
  4. |- Role (.role)
  5. |- Mining Structure (.dms)
  6. |- Data Source (.ds)
  7. |- Data Source View (.dsv)
  8. |- Multidimensional Cube (.cub)
  9. |- Measure Group (.det)
  10. |- Partition (.prt)
  11. |- AggregationDesign (.agg)

Each object from the tree above can be stored in form of a directory or/and an XML file.

The Actions and Kpis information are stored within the Cube XML configuration file.

Example:

  • Object: Cube
  • Directory: <DataDir>\<database>\<cube ID>.cub\
  • XML file: <DataDir>\<database>\<cube ID>.cub.xml

Link SSAS AMO objects to data directory files

Reading data using AMO

To read SSAS object from deployed Analysis Cube, i improved the code of the following project to add more objects and to link them with the relevant directories/files.

Updated method

To map every AMO object to the relevant directory/XML file we have to loop over objects starting from top level (database) and retrieve the files/directories found in each level and map it using the .ID property and the extensions (as mentioned in the tree above)

The following code is written in C# and it is an updated version of the method published in the link above:

Note that the method only works on local servers or you must have a Mapped network drive with the same letter of the Original drive that contains the data directory. In addition you must have the permission to access the Analysis Server objects

Reading meta data

You can simply read the data by passing the server name to the ReadMeta() function:

  1. dataGridView1.DataSource = MetaCube.SSASAMO.ReadMeta(@"Machine\Instance");

SSASObject Class

The ReadMeta() function returns a List<SSASObject>:

  1. public class SSASObject
  2. {
  3. public enum ObjectType{
  4. Cube = 0,
  5. MeasureGroup = 1,
  6. Dimension = 2,
  7. Partition = 3,
  8. AggregationDesign = 4,
  9. MiningStructure = 5,
  10. Role = 6,
  11. DataSource = 7,
  12. DataSourceView = 8,
  13. Database = 9,
  14. Server = 10,
  15. Kpi = 11,
  16. Action = 12
  17. }
  18. public int ID { get; set; } //incremental ID
  19. public int? ParentID { get; set; } // Parent incremental ID
  20. public ObjectType Type { get; set; } // The Object type
  21. public string ObjectID { get; set; } // Object ID defined in SSAS
  22. public string ObjectName { get; set; } // Object Name defined in SSAS
  23. public string Extension { get; set; } // The Object extension
  24. public string FolderPath { get; set; } // The Object related directory
  25. public string FolderName { get; set; } // The directory name
  26. public DateTime? FolderModifiedDate { get; set; } // The directory last modified date
  27. public string FolderIncremetalID { get; set; } // The Incremental Number mentioned in the directory name
  28. public string XMLFilePath { get; set; } // The Object related XML file
  29. public string XMLFileName { get; set; } // The XML file name
  30. public DateTime? XmlModifiedDate { get; set; } // The XML file last modified date
  31. public string XmlIncremetalID { get; set; } // The incremental number mentioned in the XML file name
  32. }