【问题标题】:Analysis Services - TMSL - Execute from C#分析服务 - TMSL - 从 C# 执行
【发布时间】:2020-10-02 21:10:10
【问题描述】:

我正在寻找一种针对 Microsoft Analysis Services 执行(我认为称为)TMSL 的方法。我正在尝试从 Dot.Net C# 应用程序处理一个表。我需要发送到分析服务的 JOSN 如下所示:

{  
  "refresh": {  
    "type": "full",  
    "objects": [  
      {  
        "database": "BaseName",  
        "table": "TableName"  
      }  
    ]  
  }  
} 

我该怎么做?有没有像 ado.net 这样的东西可以完成这项工作?

彼得

【问题讨论】:

    标签: service refresh analysis


    【解决方案1】:

    我发现这行得通:

                StringBuilder qry = new StringBuilder();
    
                qry.Clear();
                qry.AppendLine(" ");
                qry.AppendLine("{   ");
                qry.AppendLine("  \"refresh\": {   ");
                qry.AppendLine("    \"type\": \"full\",   ");
                qry.AppendLine("    \"objects\": [   ");
    
                bool AddTegn = false;
                foreach (string TableName in TableNames)
                {
                    if (AddTegn)
                    {
                        qry.AppendLine("      ,   ");
                    }
                    AddTegn = true;
    
                    qry.AppendLine("      {   ");
                    qry.AppendLine("        \"database\": \"" + DataBaseName + "\",   ");
                    qry.AppendLine("        \"table\": \"" + TableName + "\"   ");
                    qry.AppendLine("      }   ");
                }
    
                qry.AppendLine("    ]   ");
                qry.AppendLine("  }   ");
                qry.AppendLine("}   ");
    
                AdomdConnection con = "[Connection String]";
                con.Open();
                AdomdCommand cmd = con.CreateCommand(); //new AdomdCommand(qry.ToString(), con);
                cmd.CommandText = qry.ToString();
    
                cmd.CommandTimeout = 3600;
                cmd.CommandType = CommandType.Text;
    
                try
                {
                    int result = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (con != null)
                    {
                        con.Close();
                    }
    
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    if (con != null)
                    {
                        con.Dispose();
                    }
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-31
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 2021-08-07
      • 2019-12-03
      • 2013-09-13
      相关资源
      最近更新 更多