0

如果这个问题已经得到回答,我很抱歉,但我已经做了一些研究,还没有找到有意义的东西。

我正在创建一个连接到 Web 服务并将数据转储到 SQL 表中的 SSIS 脚本组件。尽管脚本组件仍在进行中,但我目前收到以下错误:在 System.Collections.Generic.Dictionary`2.get_Item(TKey key) at ScriptMain.CreateNewOutputRows() at UserComponent.PrimeOutput(Int32 Outputs, Int32[] Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput 上的 OutputIDs、PipelineBuffer[] 缓冲区、OutputNameMap OutputMap)(Int32 输出、Int32[] outputIDs、PipelineBuffer[] 缓冲区)

这是我用于脚本组件的代码的核心:

  public Dictionary<string, int> agentStatisticsColumns = new Dictionary<string, int>();

public override void CreateNewOutputRows()
{

    //setSessionParameters sessionParams = new setSessionParameters();
    //sessionParams.viewSettings = new viewSettings
    //{
    //    appType = "Custom",
    //    forceLogoutSession = false,
    //    idleTimeOut = 600,
    //    rollingPeriod = rollingPeriod.Minutes5,
    //    shiftStart = 28800000,
    //    statisticsRange = statisticsRange.CurrentDay,
    //    timeZone = -25200000
    //};


        getStatistics statistics = new getStatistics();

        statistics.statisticTypeSpecified = true;
        statistics.statisticType = statisticType.AgentStatistics;
        statistics.columnNames = null;

        getStatisticsResponse resp = new getStatisticsResponse();

        statistics statistics_return = resp.@return;

        int usernameIdx = agentStatisticsColumns["Username"];

        foreach (row r in statistics_return.rows)
        {
            Output0Buffer.Username = r.values[usernameIdx];
            //string log = r.values[usernameIdx];

            //Output0Buffer.Username = log;
        }

}

任何帮助将不胜感激!

4

1 回答 1

0

你是绝对正确的,这是我的愚蠢疏忽。我需要合并该字段: public static WsSupervisorService supervisorService = null;

这样我就可以包装 getStatisticsResponse resp = supervisorService.getStatistics(statistics); 具有实际价值。

谢谢尼克!

 public Dictionary<string, int> agentStatisticsColumns = new Dictionary<string, int>();
    public static WsSupervisorService supervisorService = null;
    public static void Main(string[] args)
    {
        supervisorService = new WsSupervisorService();
        setSessionParameters sessionParams = new setSessionParameters();

        sessionParams.viewSettings = new viewSettings
        {
            appType = "Custom",
            forceLogoutSession = false,
            idleTimeOut = 600,
            rollingPeriod = rollingPeriod.Minutes5,
            shiftStart = 28800000,
            statisticsRange = statisticsRange.CurrentDay,
            timeZone = -25200000
        };

        getStatistics statistics = new getStatistics();
        statistics.statisticTypeSpecified = true;
        statistics.statisticType = statisticType.AgentStatistics;
        statistics.columnNames = null;

        try
        {
            getStatisticsResponse resp = supervisorService.getStatistics(statistics);
        }
        catch (Exception)
        {

            throw;
        }
    }
于 2017-08-15T04:08:54.523 回答