C#에서 사용자 지정 컨트롤 흐름 SSIS 작업을 처음 작성했습니다. 내 작업 UI 편집기에서 속성 표가 있고 옵션 중 하나에서 사용 가능한 모든 작업 변수의 드롭 다운 목록을 채우고 사용자에게 새 옵션을 만들 수있는 옵션을 제공 할 수 있기를 바랍니다. 나는 며칠 동안 연구를 해왔고 포럼에서 좋은 예를 발견했지만 지금은 조금 잃어버린다. 내 코드는 다음과 같이 컴파일되고 편집기는 드롭 다운 목록을 표시하지만 비어 있습니다. 단계별로 살펴보면 다음과 같이 표시됩니다.C# SSIS 사용자 지정 컨트롤 흐름 작업 목록 속성 드롭 다운 목록의 변수 목록
taskHostProperty = context.Instance.GetType().GetProperty("TransferTask", typeof(TaskHost));The "TransferTask" being the name of my control flow task. I'm wondering if this is correct?
내 전체 코드는 다음과 같습니다.
//Property Grid Property
[Category("General"),
Description("Specifies the local Path for this task"),
Browsable(true),
ReadOnly(false),
DesignOnly(false),
TypeConverter(typeof(VariableConverter)),
DisplayName("Local Path")]
public string LocalPath
{
get
{
return this.stLocalPath;
}
set
{
dtsVariableService = serviceProvider.GetService(typeof(IDtsVariableService)) as IDtsVariableService;
dtsVariableService.PromptAndCreateVariable(parentWindow, dtsContainer,"Local Path","User",typeof(string));
this.stLocalPath = value;
}
}
//Variable Converter
internal class VariableConverter : TypeConverter
{
StandardValuesCollection svc = new StandardValuesCollection(new ArrayList());
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
TaskHost taskHost = null;
PropertyInfo taskHostProperty = null;
List<string> values = new List<string>();
values.Add(NEW_VARIABLE);
if (context == null)
{
return svc;
}
if (context.Instance == null)
{
return svc;
}
taskHostProperty = context.Instance.GetType().GetProperty("TransferTask", typeof(TaskHost));
if (taskHostProperty == null)
{
return svc;
}
taskHost = taskHostProperty.GetValue(context.Instance, null) as TaskHost;
foreach(Variable v in taskHost.Variables)
{
if (!v.SystemVariable && v.DataType == TypeCode.String)
{
values.Add(v.QualifiedName);
}
}
values.Sort();
return new StandardValuesCollection(values);
}