如果您在Visual Studio中打开SSIS DTSX包,则设计器会创建一些其他包末尾的CDATA块内的DesignTimeProperties。
看起来像
<DTS:DesignTimeProperties >< ![CDATA[<?xml version="1.0"?>
<!--This CDATA section contains the layout information of the package.The section includes information such as (x, y) coordinates, width, and height.-->
<!--If you manually edit this section and make a mistake, you can delete it. -->
<!--The package will still be able to load normally but the previous layout information will be lost and the designer will automatically re-arrange the elements on the design surface.-->
<Objects Version="8">
<!--Each node below will contain properties that do not affect runtime behavior.-->
<Package design-time-name="Package">
<LayoutInfo >
<GraphLayout Capacity="16" xmlns="clr-namespace:Microsoft.SqlServer.IntegrationServices.Designer.Model.Serialization;assembly=Microsoft.SqlServer.IntegrationServices.Graph"
xmlns:mssgle="clr-namespace:Microsoft.SqlServer.Graph.LayoutEngine;assembly=Microsoft.SqlServer.Graph"
xmlns:assembly="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mssgm="clr-namespace:Microsoft.SqlServer.Graph.Model;assembly=Microsoft.SqlServer.Graph">
<NodeLayout
Size="146.5,41.5"
Id="Package\Datenflusstask"
TopLeft="71.9999971389772,45.7600003636678" />
<NodeLayout
Size="155,41.5"
Id="Package\Datenflusstask 1"
TopLeft="126.666661633386,127.573334347195" />
....
问题是,仅当在Visual Studio中打开包,而在集成服务项目。
如果我以编程方式创建带有ManagedDTS
的程序包,则此信息丢失。
我确实在Microsoft.SqlServer.IntegrationServices.Designer.Model.Serialization
中找到了SerializerHelper类程序集Microsoft.SqlServer.IntegrationServices.Graph.dll
中的命名空间,您可以在其中调用
var graphLayoutXml = SerializerHelper.Save(graphModelElement);
但是很遗憾,缺少坐标(NaN或0,0 ..]
我现在所做的是将程序包加载为字符串
string contents = String.Empty;
Microsoft.SqlServer.Dts.Runtime.Package package =
new Microsoft.SqlServer.Dts.Runtime.Package();
using (StreamReader r = new StreamReader("DemoPackageWithoutDesignTimeProperties.dtsx"))
{
contents = r.ReadToEnd();
}
package.LoadFromXML(contents, null);
然后通过]获取ControlFlowElements>
ControlFlowGraphModelElement controlFlowGraphModelElement = new ControlFlowGraphModelElement(); controlFlowGraphModelElement.Initialize(package as IDTSSequence);
随后尝试通过以下方式获取GraphLayoutXml:>
GraphModelElement graphModelElement = new GraphModelElement(); graphModelElement.Container = controlFlowGraphModelElement.Container; var graphLayoutXml = SerializerHelper.Save(graphModelElement);
显然,我缺少一些布局。任何人都可以以正确的方式提供帮助...
我知道
Microsoft.SqlServer.IntegrationServices.Graph.dll
中的其他几个类,例如LayoutGraph
中的GraphLayout
,GraphControl
和Microsoft.SqlServer.Graph.dll
,但不幸的是文档不是那么有用。.
如果在Visual Studio中打开SSIS DTSX包,则设计器会在包末尾的CDATA块内创建一些其他DesignTimeProperty。看起来像<...>
首先,我想以@Fredipux的精彩评论开始: