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

@@ -28,14 +28,11 @@ namespace VEPROMS.CSLA.Library
}
return eds;
}
public DVEnhancedDocument this[int type]
public DVEnhancedDocument GetByType(int type)
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
foreach (DVEnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
public DVEnhancedDocument this[string name]
{
@@ -46,6 +43,15 @@ namespace VEPROMS.CSLA.Library
return null;
}
}
public bool HasSourcePointer
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Type == 0) return true;
return false;
}
}
}
public partial class DVEnhancedDocument
{
@@ -86,7 +92,7 @@ namespace VEPROMS.CSLA.Library
Type = type;
VersionID = versionID;
PdfX = pdfX;
PdfToken = PdfToken;
PdfToken = pdfToken;
}
public override string ToString()
{
@@ -110,6 +116,49 @@ namespace VEPROMS.CSLA.Library
}
set { _MyEnhancedDocuments = value; }
}
public void SaveDVEnhancedDocuments()
{
// 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.
DVEnhancedDocuments edsToAdd = new DVEnhancedDocuments();
foreach (DVEnhancedDocument 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"))
{
DVEnhancedDocument tmp = edsToAdd.GetByType(int.Parse(xn.Attributes["Type"].Value));
if (tmp != null)
{
if (xn.Attributes["Name"].Value != tmp.Name)
xn.Attributes["Name"].Value = tmp.Name;
if (int.Parse(xn.Attributes["Type"].Value) != tmp.Type)
xn.Attributes["Type"].Value = tmp.Type.ToString();
if (int.Parse(xn.Attributes["VersionID"].Value) != tmp.VersionID)
xn.Attributes["VersionID"].Value = tmp.VersionID.ToString();
if (int.Parse(xn.Attributes["PdfX"].Value) != tmp.PdfX)
xn.Attributes["PdfX"].Value = tmp.PdfX.ToString();
if (xn.Attributes["PdfToken"].Value != tmp.PdfToken)
xn.Attributes["PdfToken"].Value = tmp.PdfToken;
edsToAdd.Remove(tmp);
}
}
// WILL NEED THIS FOR New/ADD
//foreach (DVEnhancedDocument 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();
//}
}
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{

View File

@@ -53,7 +53,8 @@ namespace DescriptiveEnum
/// <returns>The description, if any, else the passed name</returns>
public static string GetEnumDescription(System.Type value, string name)
{
FieldInfo fi= value.GetField(name);
FieldInfo fi= value.GetField(name);
if (fi == null) return "";
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);

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
{
@@ -875,6 +876,45 @@ namespace VEPROMS.CSLA.Library
}
set { _MyEnhancedDocuments = value; }
}
public void AddEnhancedDocument(int type, int itemid)
{
MyEnhancedDocuments.Add(type, itemid);
SaveEnhancedDocuments();
}
public void SaveEnhancedDocuments()
{
// 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[int.Parse(xn.Attributes["Type"].Value)];
EnhancedDocument tmp = edsToAdd.GetByType(int.Parse(xn.Attributes["Type"].Value)); // [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
#region IItemConfig Members

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
}
}

View File

@@ -22,14 +22,11 @@ namespace VEPROMS.CSLA.Library
}
return ed;
}
public EnhancedDocument this[int type]
public EnhancedDocument GetByType(int type)
{
get
{
foreach (EnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
foreach (EnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
}
public partial class EnhancedDocument
@@ -396,8 +393,14 @@ namespace VEPROMS.CSLA.Library
// 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[int.Parse(xn.Attributes["Type"].Value)];
if (tmp != null) edsToAdd.Remove(tmp);
//EnhancedDocument tmp = edsToAdd[int.Parse(xn.Attributes["Type"].Value)];
EnhancedDocument tmp = edsToAdd.GetByType(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)
{