【问题标题】:How to access abstract Server class of MicrosoftAnalysisServices?如何访问 Microsoft AnalysisServices 的抽象 Server 类?
【发布时间】:2020-05-12 19:12:26
【问题描述】:

我正在尝试在脚本任务组件中使用 SSAS 和 Visual Studio 实现动态立方体分区。我正在尝试实现以下代码 sn-p:

Server srv = new Server();

但是,它一直给我错误,指出无法创建抽象类 obj。因此,我创建了一个 Servertest 类并实现了 Server 类。 错误的一个例子是:

    Error   CS0534  'Servertest' does not implement inherited abstract member
    Error   CS0534  'Servertest' does not implement inherited abstract member 'Server.CreateSessionTrace()' 
 and so on for very method inside Server class

我的整个代码如下:

using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.AnalysisServices.Core;
namespace ST_f9f3ba4b76c64ba5bbe76f4be0e05d3c
{


    public class Servertest : Server {
        public void Connect(String s) {
            throw new NotImplementedException();

        }
    }

    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        Byte[] dataByte;
        int IsPartitionExists = 0;

        public void Main()
        {
            // TODO: Add your code here

            try
            {
                String  Database_Name = Dts.Variables["User::Database_Name"].Value.ToString();
                String  Cube_Name = Dts.Variables["User::Cube_Name"].Value.ToString();
                String  Measure_Group_Name = Dts.Variables["User::Measure_Group_Name"].Value.ToString();
                String PartitionName = Dts.Variables["User::PartitionName"].Value.ToString();

                ConnectionManager ConnManager = Dts.Connections[Database_Name];
                String ServerName = ConnManager.Properties["ServerName"].GetValue(ConnManager).ToString();
                String DatabaseName = ConnManager.Properties["InitialCatalog"].GetValue(ConnManager).ToString();
                String CubeName = Cube_Name;
                String MeasureGroupName = Measure_Group_Name;

                IsPartitionExists = VerifyPartition(ServerName, DatabaseName, CubeName, MeasureGroupName, PartitionName);
                if (IsPartitionExists == -1)
                {
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
                else 
                {
                    Dts.Variables["User::IsPartitionExists"].Value = IsPartitionExists;
                    Dts.TaskResult = (int)ScriptResults.Success;
                }
            }
            catch (Exception ex) 
            {
                //Dts.Log("Error Message: "+ ex.Message,0);
                Dts.TaskResult = (int)ScriptResults.Failure;
            }
            Dts.TaskResult = (int)ScriptResults.Success;
        }



        public int VerifyPartition(String ServerName, String DatabaseName, String CubeName, String MeasureGroupName,String ParitionName) 
        {

            string ConnectionString = "Data Source=" + ServerName + ";Catalog=" + DatabaseName + ";";

            string ConnectionString = "Data Source=" + ServerName + ";Catalog=" + DatabaseName + ";";
            Servertest t = new Servertest();
            t.Connect(ConnectionString);
                ................
            return 1;
        }



    }
}

它要求我实现服务器类的所有方法。请帮我找到解决此问题的方法 谢谢!!

【问题讨论】:

  • Microsoft.AnalysisServices.Core.Server 类是抽象的,但其实现 Microsoft.AnalysisServices.Server 不是。您是否可能是要导入(或限定)后者而不是前者?
  • 而不是导入Microsoft.AnalysisServices.Core;我需要导入 Microsoft.AnalysisServices;

标签: c# server ssas visual-studio-2019 analysisservices


【解决方案1】:

在使用不同的在线教程进行数小时研究后,我认为我需要导入 Microsoft.AnalysisServices 而不是 Microsoft.AnalysisServices.Core。通过更改我的导入语句,我能够使用 Server.Connect 方法。 感谢您花时间查看我的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    • 2015-07-24
    • 2019-07-09
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多