c# - 如何以编程方式分析数据流任务?

标签 c# ssis

我正在使用一个工具(C#.Net)来分析SSIS包。 在这里,我使用 Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100(dts.interop 中的类)类来迭代数据流任务(MainPipe)。请找到下面的代码。

//Cast the Executable as a data flow
MainPipe pipe = (MainPipe)taskHost.InnerObject;
foreach (IDTSComponentMetaData100 comp in pipe.ComponentMetaDataCollection)
{
//Here i need
//1. Source details
//2. Destination details

}

是否可以将每个 IDTSComponentMetaData100 对象类型转换为数据流组件的某些对象,例如 XMLSource、OLEDB Destination 等?如果可能的话,我将如何识别来源、目的地等?

如果不可能,请提供一些实现此目的的提示。

最佳答案

简短的回答是,没有特别有用的方法将 IDTSComponentMetaData100 转换为“数据流组件的对象”,很大程度上是因为没有“数据流组件的对象”数据流组件”。在幕后,SSIS 是COM 驱动的应用程序,特别是对于库存组件,而不是 native .NET 应用程序。这就是为什么以编程方式创建 SSIS 数据流如此痛苦的部分原因。 (有关更详细的讨论,请参阅 MSDN 中的 Adding Data Flow Components Programmatically 。)

也就是说,IDTSComponentMetaData100 接口(interface)确实公开了 ObjectType 属性,它是 DTSObjectType枚举。数据流中的源将具有 ObjectTypeOT_SOURCEADAPTER、目标为 OT_DESTINATIONADAPTER 和转换为 OT_TRANSFORM

或者,您可以研究将包保存为 .dtsx 文件并解析生成的 XML 本身。

关于c# - 如何以编程方式分析数据流任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15500284/

相关文章:

c# - 使用本地数据库为 winForms 创建安装程序

.net - 如何以编程方式将 ADO 变量设置为 SSIS 中的 ForEach 循环枚举器?

sql-server - 集成服务错误 - "There is a potential ... in the ProvideComponentProperties"

c# - 如何使用RestSharp处理可选的UrlSegment参数?

c# - 来自内存流的电子邮件附件在 C# 中显示为空白

c# - 是否有在 UserNamePasswordValidator 之前调用的 WCF 扩展点?

c# - "Unable to read data from the transport connection: net_io_connectionclosed."- Windows Vista 商业版和 SMTP

c# - UWP MVVM : refresh page after change of language

sql-server - 查找 "not matched"与查询 "NOT IN"

sql-server - SSIS OLE DB 源 - 移动缓存位置