0

我想通过从 SQL 表中获取数据来构建带有自定义标签的 DGML。

桌子:

UCId    UCPre                           UCPost                          UCNext
-----------------------------------------------------------------------------------------------
UC01    User must be Registerd          User is Loggined sucessfully    UC02    
UC02    User is Loggined sucessfully    User is added                   UC03    
UC03    File must be selected           File is added                   NULL    
UC04    File is added                   File is deleted                 NULL  
UC05    User is Loggined sucessfully    User is deleted                 NULL    

我想要节点中带有以下标记的 xml 我想从 UCID 列和 UCNext 列中读取 UCId

<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph Title="TestT" xmlns="http://schemas.microsoft.com/vs/2009/dgml">
  <Nodes>
    <Node Id="UC01"  Label="UC01" />
    <Node Id="UC02"  Label="UC02" />
    <Node Id="UC03"  Label="UC03" />
  </Nodes>

我想根据表格中的上述数据在节点之间建立链接,因为 UC01 下一个状态是 UC02 。我如何通过编码来设置它,以便在节点之间创建正确的链接

  <Links>
    <Link Source="UC01" Target="UC02"  Label="1"/>
    <Link Source="UC02" Target="UC03" Label="2" />
  </Links>
  <Properties>
    <Property Id="Background" Label="Background" Description="The background color" DataType="System.Windows.Media.Brush" />
    <Property Id="Bounds" DataType="System.Windows.Rect" />
    <Property Id="Label" Label="Label" Description="Displayable label of an Annotatable object" DataType="System.String" />
    <Property Id="LabelBounds" DataType="System.Windows.Rect" />
    <Property Id="Stroke" DataType="System.Windows.Media.Brush" />
    <Property Id="Title" DataType="System.String" />
    <Property Id="UseManualLocation" DataType="System.Boolean" />
  </Properties>
</DirectedGraph>

我如何通过 c# 或 java 做到这一点,请帮忙?

4

1 回答 1

0

请参考此代码示例:https ://gist.github.com/azukipochette/4644291

步骤 1:遍历所有记录以创建节点。

第 2 步:再次遍历所有记录以创建链接(通过标签查找在第 1 步中创建的节点对)。

于 2015-02-13T10:47:29.027 回答