zoukankan      html  css  js  c++  java
  • C# Adomd Connection Analysis Service View Cube

    首先需要先引用 C:Program FilesMicrosoft.NETADOMD.NET100Microsoft.AnalysisServices.AdomdClient.dll
                            C:Program FilesMicrosoft SQL Server100SDKAssembliesMicrosoft.AnalysisServices.DLL           
    参照来源为MSDN:http://gallery.technet.microsoft.com/scriptcenter/6901ede5-5d59-4b1f-8f1b-df3c8e645048#content

    -------------------------------------------------------------------------------------------------------------------------------------

                using Microsoft.AnalysisServices;
                using Microsoft.AnalysisServices.Hosting;
    
                String ConnStr;
     
                String OLAPServerName;
                String OLAPDB;
                String OLAPCube;
     
     
                OLAPServerName = "HZSV---008";
                OLAPDB = "Ta-Sales-Subject";
                OLAPCube = "销售主题分析模型";
     
     
                ConnStr = "Provider=MSOLAP;Data Source=" + OLAPServerName + ";";
                //Initial Catalog=Adventure Works DW 2008R2;"; 
     
                Server OLAPServer = new Server();
                OLAPServer.Connect(ConnStr);
     
                Console.WriteLine("ServerName : " + OLAPServerName);
     
                // Database 
                foreach (Database OLAPDatabase in OLAPServer.Databases)
                {
     
                    if (OLAPDB == "" || OLAPDatabase.Name.ToString() == OLAPDB)
                    {
                        Console.WriteLine("DatabaseName : " + OLAPDatabase.Name);
     
                        // Cube 
                        foreach (Cube OLAPCubex in OLAPDatabase.Cubes)
                        {
                            if (OLAPCube == "" || OLAPCubex.Name == OLAPCube)
                            {
                                Console.WriteLine("CubeName : " + OLAPCubex.Name);
     
                                //Cube Dimension 
                                foreach (CubeDimension OLAPDimension in OLAPCubex.Dimensions)
                                {
                                    Console.WriteLine("DimensionName : " + OLAPDimension.Name);
                                    Console.WriteLine("    Attributes : ");
     
                                    //Dimension Attribute 
                                    foreach (CubeAttribute OLAPDimAttribute in OLAPDimension.Attributes)
                                    {
                                        Console.WriteLine("          " + OLAPDimAttribute.Attribute.Name);
                                    }
     
                                    Console.WriteLine("    Hierarchy : ");
     
                                    //Dimension Hierarchy 
                                    foreach (CubeHierarchy OLAPDimHierarchy in OLAPDimension.Hierarchies)
                                    {
                                        Console.WriteLine("          " + OLAPDimHierarchy.Hierarchy.Name);
     
                                        //Dimension Hierarchy Level 
                                        foreach (Level OLAPDimHierachyLevel in OLAPDimHierarchy.Hierarchy.Levels)
                                        {
                                            Console.WriteLine("                " + OLAPDimHierachyLevel.Name);
                                        }
                                    }
     
     
                                    //Measure Group 
                                    foreach (MeasureGroup OLAPMeasureGroup in OLAPCubex.MeasureGroups)
                                    {
                                        Console.WriteLine("Measure Group:" + OLAPMeasureGroup.Name);
                                        Console.WriteLine("Measures:");
     
                                        // Measures 
                                        foreach (Measure OLAPMeasure in OLAPMeasureGroup.Measures)
                                        {
                                            Console.WriteLine("          " + OLAPMeasure.Name);
                                        }
     
                                        Console.WriteLine("Measure Group Dimension:");
     
                                        // Measure Group Dimension 
                                        foreach (MeasureGroupDimension OLAPMeasureGroupDimension in OLAPMeasureGroup.Dimensions)
                                        {
                                            Console.WriteLine("          " + OLAPMeasureGroupDimension.CubeDimension.Name);
                                        }
     
                                        Console.WriteLine("Partition:");
                                        //Partitions 
                                        foreach (Partition OLAPPartition in OLAPMeasureGroup.Partitions)
                                        {
                                            Console.WriteLine("          " + OLAPPartition.Name);
                                        }
     
                                    }
     
     
                                }
                            }
     
                        }
                    }
     
     
     
                }
     
     
                Console.ReadKey(); 

  • 相关阅读:
    webservice 测试窗体只能用于来自本地计算机的请求
    Derby 数据库 客户端 ij使用
    Liunx 命令大全
    Linux 日志命令
    Git with SVN
    Git 重写历史 filter-branch
    Git you are not allowed to push code to protected branches on this project?
    sqlldr 用法
    hibernate_sequence.nextval 序列不存在
    redis持久化方案
  • 原文地址:https://www.cnblogs.com/weschen/p/6264785.html
Copyright © 2011-2022 走看看