SSIS自定义转换接收变量 [英] SSIS Custom transformation receive variable

查看:236
本文介绍了SSIS自定义转换接收变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#中创建一个用于SSIS的自定义转换。我已经能够创建和添加自定义组件,并从数据库源接收和更改数据,但我需要更多数据才能在日志表中注册。这些数据只能通过变量传递,但我找不到如何向我的组件添加 readonlyvariable 的很好的解释。

I am creating a custom transformation in C# to be used in SSIS. I have already been able creating and adding the custom component and receive and alter data from a db source but I need more data to register in a log table. This data can only be passed with variables but I can't find a good explanation of how to add a readonlyvariable to my component.

我试过使用 IDTSVa​​riable100 VariableDispenser ,但我无法理解如何使用。

I have tried to use IDTSVariable100 and VariableDispenser but I can't make sense of how to.

 public override void ProvideComponentProperties()
                    {
                        base.ProvideComponentProperties();
                        base.RemoveAllInputsOutputsAndCustomProperties();
                        VariableDispenser varDispenser = this.VariableDispenser();

                        IDTSVariable100 vr = this.VariableDispenser.GetVariables();
                        IDTSInput100 input = this.ComponentMetaData.InputCollection.New();
                        input.Name = "Input_B";

                        IDTSOutput100 output=this.ComponentMetaData.OutputCollection.New();
                        output.Name = "Output_B";

                        // the output is synchronous with the input
                        output.SynchronousInputID = input.ID;

                     }

基本上我想定义 readonlyvariables ,我可以在我的自定义组件像原始脚本组件一样运行之前更改该值。

Basically i want to define readonlyvariables that I can alter the value before my custom component runs like the original "script component" has.

推荐答案

好吧,我研究了一些并偶然发现了一个答案:
似乎要访问SSIS公共变量我们必须使用ProcessInput方法中的代码来获取它们:

Well i researched a bit more and stumbled on a answer: It seems that to access the SSIS public variables we have to get them with code on the ProcessInput Method:

var dimSrcId ="";

IDTSVariables100 variables = null;

this.VariableDispenser.LockForRead("User::dimSrcId");

this.VariableDispenser.GetVariables(out variables);

dimSrcId = variables["User::dimSrcId"].Value.ToString();

variables.Unlock();

通过使用 VariableDispenser.LockForRead(),我们能够搜索为我们的变量和访问值。

By using the VariableDispenser.LockForRead() we're capable of searching for our variables and access there value.

这篇关于SSIS自定义转换接收变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆