zoukankan      html  css  js  c++  java
  • SSAS: Discover 何处寻? 一切尽在GetSchemaDataSet

    在之前,我们谈到过,在ADOMDCommand中是不可以执行Discover命令的,它基本上都对应了Execute命令

    但是,如果我们确实需要通过ADOMD来完成Discover的操作,除了像上一篇讲到的,利用直接发送XMLA Envelope之外,是否还有其他方法

    答案是:有

    所有与Discover有关的操作,都可以通过ADOMDConnection的一个方法来完成:GetSchemaDataSet,很好的一点是,它直接返回一个DataSet

    http://msdn.microsoft.com/zh-tw/library/microsoft.analysisservices.adomdclient.adomdconnection.getschemadataset.aspx

    名稱
    Description

    AdomdConnection.GetSchemaDataSet (Guid, Object[])

    Returns schema information from a data source by using a Guid object to specify which schema information to return and by applying any specified restrictions to the information.

    AdomdConnection.GetSchemaDataSet (String, AdomdRestrictionCollection)

    Returns schema information from a data source by using a schema name to identify which schema to retrieve and by applying any specified restrictions to the information.

    AdomdConnection.GetSchemaDataSet (Guid, Object[], Boolean)

    Returns schema information from a data source by using a Guid object to identify the information, applying any specified restrictions on the information, and optionally throwing an exception when inline errors occur.

    AdomdConnection.GetSchemaDataSet (String, AdomdRestrictionCollection, Boolean)

    Returns schema information from a data source by using a schema name to identify the information, applying any specified restrictions to the information, and optionally throwing an exception when inline errors occur.

    AdomdConnection.GetSchemaDataSet (String, String, AdomdRestrictionCollection)

    Returns schema information from a data source by using a schema name and namespace to identify the information, and by applying any specified restrictions to the information.

    AdomdConnection.GetSchemaDataSet (String, String, AdomdRestrictionCollection, Boolean)

    Returns schema information from a data source by using a schema name and namespace to identify the information, applying any specified restrictions to the information, and, optionally throwing an exception when inline errors occur.

    关于Guid参数,可以参考


    Actions
    Contains the GUID of the MDSCHEMA_ACTIONS rowset.

    Catalogs
    Contains the GUID of the DBSCHEMA_CATALOGS schema rowset.

    Columns
    Contains the GUID of the DBSCHEMA_COLUMNS schema rowset.

    Connections
    Contains the GUID of the DISCOVER_CONNECTIONS schema rowset.

    Cubes
    Contains the GUID of the MDSCHEMA_CUBES schema rowset.

    DataSources
    Contains the GUID of the DISCOVER_DATASOURCES schema rowset.

    DBConnections
    Contains the GUID of the DISCOVER_DB_CONNECTIONS schema rowset.

    Dimensions
    Contains the GUID of the MDSCHEMA_DIMENSIONS schema rowset.

    DimensionStat
    Contains the GUID of the DISCOVER_DIMENSION_STAT schema rowset.
    Enumerators
    Contains the GUID of the DISCOVER_ENUMERATORS schema rowset.
    Functions
    Contains the GUID of the MDSCHEMA_FUNCTIONS schema rowset.
    Hierarchies
    Contains the GUID of the MDSCHEMA_HIERARCHIES schema rowset.
    InputDataSources
    Contains the GUID of the MDSCHEMA_INPUT_DATASOURCES schema rowset.
    Instances
    Contains the GUID of the DISCOVER_INSTANCES schema rowset.
    Jobs
    Contains the GUID of the DISCOVER_JOBS schema rowset.
    Keywords
    Contains the GUID of the DISCOVER_KEYWORDS schema rowset.
    Kpis
    Contains the GUID of the MDSCHEMA_KPIS schema rowset.
    Levels
    Contains the GUID of the MDSCHEMA_LEVELS schema rowset.
    Literals
    Contains the GUID of the DISCOVER_LITERALS schema rowset.
    Locations
    Contains the GUID of the DISCOVER_LOCATIONS schema rowset.
    Locks
    Contains the GUID of the DISCOVER_LOCKS schema rowset.
    MasterKey
    Contains the GUID of the DISCOVER_MASTER_KEY schema rowset.
    MeasureGroupDimensions
    Contains the GUID of the MDSCHEMA_MEASUREGROUP_DIMENSIONS schema rowset.
    MeasureGroups
    Contains the GUID of the MDSCHEMA_MEASUREGROUPS schema rowset.
    Measures
    Contains the GUID of the MDSCHEMA_MEASURES schema rowset.
    MemberProperties
    Contains the GUID of the MDSCHEMA_PROPERTIES schema rowset.
    Members
    Contains the GUID of the MDSCHEMA_MEMBERS schema rowset.
    MemoryGrant
    Contains the GUID of the DISCOVER_MEMORYGRANT schema rowset.
    MemoryUsage
    Contains the GUID of the DISCOVER_MEMORYUSAGE schema rowset.
    MiningColumns
    Contains the GUID of the MINING_COLUMNS schema rowset.
    MiningFunctions
    Contains the GUID of the MINING_FUNCTIONS schema rowset.
    MiningModelContent
    Contains the GUID of the MINING_MODEL_CONTENT schema rowset.
    MiningModelContentPmml
    Contains the GUID of the DMSCHEMA_MINING_MODEL_CONTENT_PMML schema rowset.
    MiningModels
    Contains the GUID of the MINING_MODELS schema rowset.
    MiningModelXml
    Contains the GUID of the DMSCHEMA_MINING_MODEL_XML schema rowset.
    MiningServiceParameters
    Contains the GUID of the SERVICE_PARAMETERS schema rowset.
    MiningServices
    Contains the GUID of the MINING_SERVICES schema rowset.
    MiningStructureColumns
    Contains the GUID of the DMSCHEMA_MINING_STRUCTURE_COLUMNS schema rowset.
    MiningStructures
    Contains the GUID of the DMSCHEMA_MINING_STRUCTURES schema rowset.
    PartitionDimensionStat
    Contains the GUID of the DISCOVER_PARTITION_DIMENSION_STAT schema rowset.
    PartitionStat
    Contains the GUID of the DISCOVER_PARTITION_STAT schema rowset.
    PerformanceCounters
    Contains the GUID of the DISCOVER_PERFORMANCE_COUNTERS schema rowset.
    ProviderTypes
    Contains the GUID of the PROVIDER_TYPES schema rowset.
    SchemaRowsets
    Contains the GUID of the DISCOVER_SCHEMA_ROWSETS schema rowset.
    Sessions
    Contains the GUID of the DISCOVER_SESSIONS schema rowset.
    Sets
    Contains the GUID of the MDSCHEMA_SETS schema rowset.
    Tables
    Contains the GUID of the DBSCHEMA_TABLES schema rowset.
    TablesInfo
    Contains the GUID of the DBSCHEMA_TABLES_INFO schema rowset.
    TraceColumns
    Contains the GUID of the DISCOVER_TRACE_COLUMNS schema rowset.
    TraceDefinitionProviderInfo
    Contains the GUID of the DISCOVER_TRACE_DEFINITION_PROVIDERINFO schema rowset.
    TraceEventCategories
    Contains the GUID of the DISCOVER_TRACE_EVENT_CATEGORIES schema rowset.
    Traces
    Contains the GUID of the DISCOVER_TRACES schema rowset.
    Transactions
    Contains the GUID of the DISCOVER_TRANSACTIONS schema rowset.
    XmlaProperties
    Contains the GUID of the DISCOVER_PROPERTIES schema rowset.
    XmlMetadata
    Contains the GUID of the DISCOVER_XML_METADATA schema rowset.

    最后,我用一个比较简单的例子来让大家理解

    我们用下面的代码连接到本地服务器,并且查询服务器所有的Session

    AdomdConnection conn = new AdomdConnection("data source=localhost;catalog=Adventureworks");
    conn.Open();
    conn.GetSchemaDataSet(AdomdSchemaGuid.Sessions, null).WriteXml("../../sessions.xml");
    conn.Close();

    返回的结果大致如下,这是一个标准的DataSet,可以作为数据源绑定和处理

    <?xml version="1.0" standalone="yes"?>
    <NewDataSet>
      <rowsetTable>
        <SESSION_ID>995BFC52-8D0C-49E1-AD1C-39773B05F1B3</SESSION_ID>
        <SESSION_SPID>1098</SESSION_SPID>
        <SESSION_CONNECTION_ID>54</SESSION_CONNECTION_ID>
        <SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
        <SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
        <SESSION_START_TIME>2009-06-25T23:46:18+08:00</SESSION_START_TIME>
        <SESSION_ELAPSED_TIME_MS>3426078</SESSION_ELAPSED_TIME_MS>
        <SESSION_LAST_COMMAND_START_TIME>2009-06-25T23:46:19+08:00</SESSION_LAST_COMMAND_START_TIME>
        <SESSION_LAST_COMMAND_END_TIME>2009-06-25T23:46:20+08:00</SESSION_LAST_COMMAND_END_TIME>
        <SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
        <SESSION_IDLE_TIME_MS>3424515</SESSION_IDLE_TIME_MS>
        <SESSION_CPU_TIME_MS>125</SESSION_CPU_TIME_MS>
        <SESSION_LAST_COMMAND>DISCOVER_XML_METADATA</SESSION_LAST_COMMAND>
        <SESSION_LAST_COMMAND_CPU_TIME_MS>109</SESSION_LAST_COMMAND_CPU_TIME_MS>
      </rowsetTable>
      <rowsetTable>
        <SESSION_ID>D241E8DB-6B59-4A65-9B61-017B159CB51D</SESSION_ID>
        <SESSION_SPID>1106</SESSION_SPID>
        <SESSION_CONNECTION_ID>55</SESSION_CONNECTION_ID>
        <SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
        <SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
        <SESSION_START_TIME>2009-06-25T23:46:40+08:00</SESSION_START_TIME>
        <SESSION_ELAPSED_TIME_MS>3404468</SESSION_ELAPSED_TIME_MS>
        <SESSION_LAST_COMMAND_START_TIME>2009-06-25T23:46:40+08:00</SESSION_LAST_COMMAND_START_TIME>
        <SESSION_LAST_COMMAND_END_TIME>2009-06-25T23:46:40+08:00</SESSION_LAST_COMMAND_END_TIME>
        <SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
        <SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
        <SESSION_CPU_TIME_MS>0</SESSION_CPU_TIME_MS>
        <SESSION_LAST_COMMAND>MDSCHEMA_DIMENSIONS</SESSION_LAST_COMMAND>
        <SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
      </rowsetTable>
      <rowsetTable>
        <SESSION_ID>5A4AEF84-10F8-42BF-A0A4-87652233D2D5</SESSION_ID>
        <SESSION_SPID>1000</SESSION_SPID>
        <SESSION_CONNECTION_ID>42</SESSION_CONNECTION_ID>
        <SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
        <SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
        <SESSION_START_TIME>2009-06-25T23:41:37+08:00</SESSION_START_TIME>
        <SESSION_ELAPSED_TIME_MS>3707515</SESSION_ELAPSED_TIME_MS>
        <SESSION_LAST_COMMAND_START_TIME>2009-06-26T00:06:49+08:00</SESSION_LAST_COMMAND_START_TIME>
        <SESSION_LAST_COMMAND_END_TIME>2009-06-26T00:06:49+08:00</SESSION_LAST_COMMAND_END_TIME>
        <SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
        <SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
        <SESSION_CPU_TIME_MS>0</SESSION_CPU_TIME_MS>
        <SESSION_LAST_COMMAND>DISCOVER_PROPERTIES</SESSION_LAST_COMMAND>
        <SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
      </rowsetTable>
      <rowsetTable>
        <SESSION_ID>072281F3-BE2C-4670-B614-C0FD9B3D2D43</SESSION_ID>
        <SESSION_SPID>2256</SESSION_SPID>
        <SESSION_CONNECTION_ID>97</SESSION_CONNECTION_ID>
        <SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
        <SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
        <SESSION_START_TIME>2009-06-26T00:43:24+08:00</SESSION_START_TIME>
        <SESSION_ELAPSED_TIME_MS>31</SESSION_ELAPSED_TIME_MS>
        <SESSION_LAST_COMMAND_START_TIME>2009-06-26T00:43:24+08:00</SESSION_LAST_COMMAND_START_TIME>
        <SESSION_LAST_COMMAND_END_TIME>2009-06-26T00:43:24+08:00</SESSION_LAST_COMMAND_END_TIME>
        <SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
        <SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
        <SESSION_CPU_TIME_MS>15</SESSION_CPU_TIME_MS>
        <SESSION_LAST_COMMAND>DISCOVER_SESSIONS</SESSION_LAST_COMMAND>
        <SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
      </rowsetTable>
    </NewDataSet>

    本文由作者:陈希章 于 2009/6/26 18:19:07 发布在:http://www.cnblogs.com/chenxizhang/
    本文版权归作者所有,可以转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    更多博客文章,以及作者对于博客引用方面的完整声明以及合作方面的政策,请参考以下站点:陈希章的博客中心
  • 相关阅读:
    (难)Codeforces Round #406 (Div. 2) C题Berzerk(有向图博弈)解题报告
    jquery清空kindEditor
    处理用户误输入html标签引起的网站布局混乱
    自动闭合所有标签的方法,用于获得textBox等值的时候,标签都是闭合的
    .NET一个页面多个Button按钮事件避免数据验证控件RequiredFieldValidator
    基类包括字段(),但其类型()与控件()的类型不兼容
    关于ajax回调数据类型为Json,如何获得他的值
    如何查找Repeater控件中嵌套的控件
    网站功能
    WIN7系统IIS上发布站点后水印效果失效的解决方法
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/1511877.html
Copyright © 2011-2022 走看看