Enhanced Document support

Null check
Move DisplayText.cs to CSLA
Enhanced Documents – don’t allow ‘Save’ RO on enhanced step
Enhanced Documents windowing
Enhanced Documents remove unnecessary options
Enhanced Documents – don’t allow ‘Save’ transition on enhanced step
Enhanced Documents/Insert,Delete,Paste
This commit is contained in:
2016-01-20 16:43:23 +00:00
parent 77cdf81736
commit 6366af8b47
17 changed files with 1132 additions and 243 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
@@ -349,11 +350,11 @@ namespace VEPROMS.CSLA.Library
{
get
{
return _Xp["Section", "LnkEnh"];
return _Xp["Step", "LnkEnh"]; //KBR - wrong in data/xml?? is in step node not section node.
}
set
{
_Xp["Section", "LnkEnh"] = value;
_Xp["Step", "LnkEnh"] = value;
OnPropertyChanged("Section_LnkEnh");
}
}
@@ -909,7 +910,74 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Edit_LnkEnh");
}
}
private EnhancedDocuments _MyEnhancedDocuments = null;
public EnhancedDocuments MyEnhancedDocuments
{
get
{
if (_MyEnhancedDocuments == null)
{
_MyEnhancedDocuments = EnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
}
set
{
_MyEnhancedDocuments = value;
//OnPropertyChanged("EnhancedDocuments");
}
}
public void AddEnhancedDocument(int type, int itemid)
{
MyEnhancedDocuments.Add(type, itemid);
SaveEnhancedDocuments();
}
public void SaveEnhancedDocuments()
{
if (MyEnhancedDocuments == null || MyEnhancedDocuments.Count == 0) // clear out the xml node
{
//XmlNode dd = _Xp.XmlContents.SelectSingleNode("//Slave[@index='" + index.ToString() + "']");
//dd.ParentNode.RemoveChild(dd);
List<XmlNode> nodesToDel = new List<XmlNode>();
foreach (XmlNode xnr in _Xp.XmlContents.SelectNodes("//Enhanced")) nodesToDel.Add(xnr);
if (nodesToDel != null)
{
XmlNode par = nodesToDel[0].ParentNode;
foreach (XmlNode xxnr in nodesToDel) par.RemoveChild(xxnr);
}
return;
}
// get all of the current enhanced links from datastructure in code. This list may have been
// modified by adding items during code execution by associating source <--> background etc.
EnhancedDocuments edsToAdd = new EnhancedDocuments();
foreach (EnhancedDocument ed in MyEnhancedDocuments)
edsToAdd.Add(ed);
// from the existing list in xml, remove any that are in the 'editted (edsToAdd) list
// so that what remains are those that need added to xml that will then be written to database
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
EnhancedDocument tmp = edsToAdd.GetByType(int.Parse(xn.Attributes["Type"].Value)); //edsToAdd[int.Parse(xn.Attributes["Type"].Value)];
if (tmp != null)
{
if (int.Parse(xn.Attributes["ItemID"].Value) != tmp.ItemID)
xn.Attributes["ItemID"].Value = tmp.ItemID.ToString();
edsToAdd.Remove(tmp);
}
}
foreach (EnhancedDocument edadd in edsToAdd)
{
// Add (example): <Enhanced Type="Background" ItemID="43138" /><Enhanced Type="Deviation" ItemID="67165" />
// First add 'Enhanced' element:
XmlNode newEnhNode = _Xp.XmlContents.CreateNode(XmlNodeType.Element, "Enhanced", _Xp.XmlContents.NamespaceURI);
XmlNode xnEnh = _Xp.XmlContents.DocumentElement.AppendChild(newEnhNode);
// Now add the 'Type' and 'ItemID' attributes:
XmlAttribute xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("Type"));
xa.Value = edadd.Type.ToString();
xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("ItemID"));
xa.Value = edadd.ItemID.ToString();
}
}
#endregion
}
}