Fixed the code to add Parent /Child information as needed
This commit is contained in:
parent
5c99687073
commit
2822368d57
@ -49,22 +49,42 @@ namespace VEPROMS.CSLA.Library
|
||||
_Procedure = procedure;
|
||||
string xml = procedure.MyContent.Config;
|
||||
if (xml == string.Empty)
|
||||
{
|
||||
if (_Procedure.MyProcedureInfo.MyDocVersion.MultiUnitCount > 1)
|
||||
{
|
||||
xml = "<Config><Slaves>";
|
||||
for (int i = 1; i <= _Procedure.MyProcedureInfo.MyDocVersion.MultiUnitCount; i++)
|
||||
{
|
||||
xml = xml + "<Slave index='" + i.ToString() + "'/>";
|
||||
}
|
||||
xml = xml + "</Slaves></Config>";
|
||||
}
|
||||
else
|
||||
xml = "<Config/>";
|
||||
}
|
||||
_Xp = new XMLProperties(xml);
|
||||
// Correct Slaves nodes for Parent Child
|
||||
ValidateSlaves(_Xp.XmlContents, _Procedure.MyProcedureInfo.MyDocVersion.MultiUnitCount);
|
||||
if (procedure.MyProcedureInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
|
||||
}
|
||||
/// <summary>
|
||||
/// Fix Slaves Nodes for Parent Child
|
||||
///
|
||||
/// At some point it may be better to use a more forrmal structure to indentify which nodes are required and
|
||||
/// which are optional.
|
||||
/// </summary>
|
||||
/// <param name="xd">XmlDocument</param>
|
||||
/// <param name="unitCount">Number of slave nodes supported</param>
|
||||
private static void ValidateSlaves(XmlDocument xd, int unitCount)
|
||||
{
|
||||
if (unitCount < 1) return; // No Slave nodes necessary
|
||||
XmlNode xn = xd.DocumentElement.SelectSingleNode("Slaves");
|
||||
if (xn == null)// Missing required Slaves node - Add it.
|
||||
{
|
||||
XmlElement xe = xd.CreateElement("Slaves");
|
||||
xn = xd.DocumentElement.AppendChild(xe);
|
||||
}
|
||||
for (int i = 1; i <= unitCount; i++)
|
||||
{
|
||||
XmlNode xnc = xn.SelectSingleNode(string.Format("Slave[@index='{0}']", i));
|
||||
if (xnc == null) // Missing Required Slave Node (index=i) - Add it.
|
||||
{
|
||||
XmlElement xec = xd.CreateElement("Slave");
|
||||
xnc = xn.AppendChild(xec);
|
||||
XmlAttribute xa = xd.CreateAttribute("index");
|
||||
xa.Value = i.ToString();
|
||||
xnc.Attributes.Append(xa);
|
||||
}
|
||||
}
|
||||
}
|
||||
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
|
||||
{
|
||||
if (args.AncestorLookup || ParentLookup)
|
||||
@ -111,20 +131,10 @@ namespace VEPROMS.CSLA.Library
|
||||
_ProcedureInfo = procedureInfo;
|
||||
string xml = procedureInfo.MyContent.Config;
|
||||
if (xml == string.Empty)
|
||||
{
|
||||
if (_ProcedureInfo.MyDocVersion.MultiUnitCount > 0)
|
||||
{
|
||||
xml = "<Config><Slaves>";
|
||||
for (int i = 1; i <= _ProcedureInfo.MyDocVersion.MultiUnitCount; i++)
|
||||
{
|
||||
xml = xml + "<Slave index='" + i.ToString() + "'/>";
|
||||
}
|
||||
xml = xml + "</Slaves></Config>";
|
||||
}
|
||||
else
|
||||
xml = "<Config/>";
|
||||
}
|
||||
_Xp = new XMLProperties(xml);
|
||||
// Fix Slaves nodes for Parent Child
|
||||
ValidateSlaves(_Xp.XmlContents, _ProcedureInfo.MyDocVersion.MultiUnitCount);
|
||||
_Xp.AncestorLookup = true;
|
||||
if (procedureInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user