我正在使用EzAPI通过.NET创建SSIS包,但是当我将现有包作为模板加载时,EzExec集合是空的,而DTS Executables集合有许多成员。我需要将这些现有组件中的一些作为父组件和先例引用到要通过EzAPI添加到包中的任务。
我是不是在包的初始化过程中遗漏了什么,或者这是可能的吗?
下面是我正在尝试删除布局信息的代码的编辑示例,这仍然不起作用,可执行文件的计数是7,EzExexs的计数是0。
谢谢,安德鲁
public static EzPackage loadPackageTemplate(string templateLocation)
{
EzPackage ezPackage = new EzPackage();
try
{
StreamReader s = new StreamReader(templateLocation);
string templateContents = s.ReadToEnd();
s.Close();
templateContents = removeLayoutInformation(templateContents);
ezPackage.LoadFromXML(templateContents);
}
catch (Exception)
{
throw;
}
//need to remove layout from template
return ezPackage;
}
public static string removeLayoutInformation(string strXML)
{
try
{
//Remove the layout information.
while (strXML.IndexOf("<DTS:PackageVariable>") > -1)
{
strXML = strXML.Remove(strXML.IndexOf("<DTS:PackageVariable>"), strXML.IndexOf("</DTS:PackageVariable>") - strXML.IndexOf("<DTS:PackageVariable>") + 22);
}
}
catch (Exception)
{
throw;
}
return strXML;
}
public static EzExecutable GetExecutable(EzPackage ezPac, string identifier)
{
EzExecutable toReturn = null;
foreach (EzExecutable ezEx in ezPac.EzExecs)
{
if (ezEx.EzName == identifier)
{
toReturn = ezEx;
break;
}
}
return toReturn;
}
EzPackage pac = SSISGen.loadPackageTemplate(@"C:\Temp\SSISPackageTemplates\LoadFact.dtsx");发布于 2013-05-18 01:52:06
问题是布局数据脱离了API。在Codeplex网站上有一个关于这个问题的讨论。伪装者乔希·罗宾逊( Josh Robinson )也在博客上谈论了他的experience。
无论如何,SSIS的疯狂之处在于,BIDS/SSDT呈现的布局内容被固定在实际的包标记上。这会干扰ezapi的内容,因此修复方法是如Josh所演示的那样将其剥离。
将代码复制到此处以备将来保存
//Save the package object to XML
string strXML = null;
strXML = TestPackage.SaveToXML();
//Count instances of existing SSIS layout code in package.
int LayoutCount = Regex.Matches(strXML, "<DTS:PackageVariable>").Count;
//Remove the layout information.
for (int i = 0; i < LayoutCount; i++)
{
strXML = strXML.Remove(strXML.IndexOf("<DTS:PackageVariable>"), strXML.IndexOf("</DTS:PackageVariable>") - strXML.IndexOf("<DTS:PackageVariable>") + 22);
}https://stackoverflow.com/questions/16612803
复制相似问题