我在尝试设置通过自定义表单创建的数据流组件的自定义属性时遇到了真正的问题。
我正在分配的值刚刚被设置,自定义属性要么保持原始值,要么保持为空。
在我的 TaskClass 中,我覆盖了 ProvideComponentProperties() 方法并创建了自定义属性,如下所示。
IDTSCustomProperty100 componentCustomProperty = ComponentMetaData.CustomPropertyCollection.New();
componentCustomProperty.Name = "PAFProvider";
componentCustomProperty.Description = "PAF Provider";
componentCustomProperty.Value = "testinitial";
我创建了一个继承自 IDtsComponentUI 接口(interface)的 TaskClassUI。我实现了所有必需的方法。
我的初始化方法。
public void Initialize(IDTSComponentMetaData100 dtsComponentMetadata, IServiceProvider serviceProvider)
{
this._dtsComponentMetaData = dtsComponentMetadata;
this._serviceprovider = serviceProvider;
}
我的编辑方法的实现
public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
{
bool flag;
try
{
PAFUIMainWnd ui = new PAFUIMainWnd(this._dtsComponentMetaData, this._serviceprovider, connections);
DialogResult result = ui.ShowDialog(parentWindow);
bool flag1 = result != DialogResult.OK;
if(!flag1)
{
flag = true;
return flag;
}
}
catch(Exception exe)
{
MessageBox.Show(exe.ToString());
}
flag = false;
return flag;
}
以及我的 UIFORM 的实现。
public PAFUIMainWnd(IDTSComponentMetaData100 iDTSComponentMetaData100, IServiceProvider serviceProvider, Connections connections)
{
this.components = null;
this.InitializeComponent();
this._dtsComponentMetaData = iDTSComponentMetaData100;
this._designTimeComponent = this._dtsComponentMetaData.Instantiate();
textBox1.Text = _dtsComponentMetaData.CustomPropertyCollection["PAFProvider"].Value.ToString();
}
出于测试目的,我在表单上添加了一个文本框和一个按钮。甚至按钮的 OnClick 也在下面。我只是从文本框中获取值并将其分配给自定义属性,但它没有分配它。我可以从分配给文本框的自定义属性中读取原始值。我只是不明白为什么我不能分配它。我完全遵循了 MSDN 和其他各种示例。如果有人能指出我做错了什么,我将非常感激。已经到了爆头阶段。
private void btnOK_Click(object sender, EventArgs e)
{
_designTimeComponent.SetComponentProperty("PAFProvider", textBox1.Text);
this.Close();
}
最佳答案
重启解决了这个问题。代码非常好。
关于C# 通过自定义 UI 设置 SSIS 自定义数据流组件的自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13609818/