0

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

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;
        }



    }
}

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

4

1 回答 1

2

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

于 2020-05-12T20:46:27.773 回答