New Enhanced Document Properties

This commit is contained in:
Rich 2015-10-27 13:28:47 +00:00
parent d720159113
commit a87c8facdb
4 changed files with 293 additions and 55 deletions

View File

@ -8,10 +8,108 @@ using System.Xml;
namespace VEPROMS.CSLA.Library
{
public partial class DVEnhancedDocuments : List<DVEnhancedDocument>
{
public void Add(string name, int type, int versionID, int pdfX, string pdfToken)
{
Add(new DVEnhancedDocument(name, type, versionID,pdfX,pdfToken));
}
public static DVEnhancedDocuments Load(XMLProperties _Xp)
{
DVEnhancedDocuments eds = new DVEnhancedDocuments();
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
eds.Add( xn.Attributes["Name"].Value,
int.Parse(xn.Attributes["Type"].Value),
int.Parse(xn.Attributes["VersionID"].Value),
int.Parse(xn.Attributes["PdfX"].Value),
xn.Attributes["PdfToken"].Value
);
}
return eds;
}
public DVEnhancedDocument this[int type]
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
}
public DVEnhancedDocument this[string name]
{
get
{
foreach (DVEnhancedDocument ed in this)
if (ed.Name == name) return ed;
return null;
}
}
}
public partial class DVEnhancedDocument
{
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
private int _Type;
public int Type
{
get { return _Type; }
set { _Type = value; }
}
private int _VersionID;
public int VersionID
{
get { return _VersionID; }
set { _VersionID = value; }
}
private int _PdfX;
public int PdfX
{
get { return _PdfX; }
set { _PdfX = value; }
}
private string _PdfToken;
public string PdfToken
{
get { return _PdfToken; }
set { _PdfToken = value; }
}
public DVEnhancedDocument() { ;}
public DVEnhancedDocument(string name,int type, int versionID, int pdfX, string pdfToken)
{
Name = name;
Type = type;
VersionID = versionID;
PdfX = pdfX;
PdfToken = PdfToken;
}
public override string ToString()
{
return string.Format("{0}.ItemID={1}", Name,VersionID);
}
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocVersionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
private DVEnhancedDocuments _MyEnhancedDocuments = null;
public DVEnhancedDocuments MyEnhancedDocuments
{
get
{
if (_MyEnhancedDocuments == null)
{
_MyEnhancedDocuments = DVEnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
}
set { _MyEnhancedDocuments = value; }
}
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{

View File

@ -840,7 +840,22 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region EnhancedDocuments
// Enhanced Documents
private EnhancedDocuments _MyEnhancedDocuments = null;
public EnhancedDocuments MyEnhancedDocuments
{
get
{
if (_MyEnhancedDocuments == null)
{
_MyEnhancedDocuments = EnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
}
set { _MyEnhancedDocuments = value; }
}
#endregion
#region IItemConfig Members
[Category("Master/Slave Settings")]

View File

@ -888,6 +888,28 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region Enhanced Documents
[Category("Enhanced Document Settings")]
[DisplayName("LinkEnhanced")]
[RefreshProperties(RefreshProperties.All)]
[Description("Scope Applicability")]
public string LinkEnhanced
{
get
{
return _Xp["Step", "LnkEnh"];
}
set
{
if (value != null)
_Xp["Step", "LnkEnh"] = value;
else
_Xp["Step", "LnkEnh"] = null;
OnPropertyChanged("Edit_LnkEnh");
}
}
#endregion
}
}

View File

@ -3,9 +3,60 @@ using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
public partial class EnhancedDocuments : List<EnhancedDocument>
{
public void Add(int type, int itemID)
{
Add(new EnhancedDocument(type, itemID));
}
public static EnhancedDocuments Load(XMLProperties _Xp)
{
EnhancedDocuments ed = new EnhancedDocuments();
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{
ed.Add(int.Parse(xn.Attributes["Type"].Value), int.Parse(xn.Attributes["ItemID"].Value));
}
return ed;
}
public EnhancedDocument this[int type]
{
get
{
foreach (EnhancedDocument ed in this)
if (ed.Type == type) return ed;
return null;
}
}
}
public partial class EnhancedDocument
{
private int _Type;
public int Type
{
get { return _Type; }
set { _Type = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
public EnhancedDocument() { ;}
public EnhancedDocument(int type, int itemID)
{
Type = type;
ItemID = itemID;
}
public override string ToString()
{
return string.Format("{0}.ItemID={1}", Type, ItemID);
}
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class StepConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
@ -61,6 +112,7 @@ namespace VEPROMS.CSLA.Library
{
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public StepConfig()
{
@ -309,74 +361,125 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Step_Responsibility");
}
}
public string Step_SourceToBackground
// Enhanced Documents
private EnhancedDocuments _MyEnhancedDocuments = null;
public EnhancedDocuments MyEnhancedDocuments
{
get
{
string s = _Xp["Step", "SourceToBackground"];
if (s == string.Empty) return null;
return s;
if (_MyEnhancedDocuments == null)
{
_MyEnhancedDocuments = EnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
}
set
{
string s = _Xp["Step", "SourceToBackground"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "SourceToBackground"] = null;
else _Xp["Step", "SourceToBackground"] = value.ToString();
OnPropertyChanged("Step_SourceToBackground");
_MyEnhancedDocuments = value;
//OnPropertyChanged("EnhancedDocuments");
}
}
public string Step_BackgroundToSource
public void AddEnhancedDocument(int type, int itemid)
{
get
{
string s = _Xp["Step", "BackgroundToSource"];
if (s == string.Empty) return null;
return s;
}
set
{
string s = _Xp["Step", "BackgroundToSource"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "BackgroundToSource"] = null;
else _Xp["Step", "BackgroundToSource"] = value.ToString();
OnPropertyChanged("Step_BackgroundToSource");
}
MyEnhancedDocuments.Add(type, itemid);
SaveEnhancedDocuments();
}
public string Step_SourceToDeviation
public void SaveEnhancedDocuments()
{
get
// 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"))
{
string s = _Xp["Step", "SourceToDeviation"];
if (s == string.Empty) return null;
return s;
EnhancedDocument tmp = edsToAdd[int.Parse(xn.Attributes["Type"].Value)];
if (tmp != null) edsToAdd.Remove(tmp);
}
set
foreach (EnhancedDocument edadd in edsToAdd)
{
string s = _Xp["Step", "SourceToDeviation"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "SourceToDeviation"] = null;
else _Xp["Step", "SourceToDeviation"] = value.ToString();
OnPropertyChanged("Step_SourceToDeviation");
}
}
public string Step_DeviationToSource
{
get
{
string s = _Xp["Step", "DeviationToSource"];
if (s == string.Empty) return null;
return s;
}
set
{
string s = _Xp["Step", "DeviationToSource"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "DeviationToSource"] = null;
else _Xp["Step", "DeviationToSource"] = value.ToString();
OnPropertyChanged("Step_DeviationToSource");
// 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();
}
}
//public string Step_SourceToBackground
//{
// get
// {
// string s = _Xp["Step", "SourceToBackground"];
// if (s == string.Empty) return null;
// return s;
// }
// set
// {
// string s = _Xp["Step", "SourceToBackground"];
// if (value != null && value.ToString() == s) return;
// if (value == null && s != null) _Xp["Step", "SourceToBackground"] = null;
// else _Xp["Step", "SourceToBackground"] = value.ToString();
// OnPropertyChanged("Step_SourceToBackground");
// }
//}
//public string Step_BackgroundToSource
//{
// get
// {
// string s = _Xp["Step", "BackgroundToSource"];
// if (s == string.Empty) return null;
// return s;
// }
// set
// {
// string s = _Xp["Step", "BackgroundToSource"];
// if (value != null && value.ToString() == s) return;
// if (value == null && s != null) _Xp["Step", "BackgroundToSource"] = null;
// else _Xp["Step", "BackgroundToSource"] = value.ToString();
// OnPropertyChanged("Step_BackgroundToSource");
// }
//}
//public string Step_SourceToDeviation
//{
// get
// {
// string s = _Xp["Step", "SourceToDeviation"];
// if (s == string.Empty) return null;
// return s;
// }
// set
// {
// string s = _Xp["Step", "SourceToDeviation"];
// if (value != null && value.ToString() == s) return;
// if (value == null && s != null) _Xp["Step", "SourceToDeviation"] = null;
// else _Xp["Step", "SourceToDeviation"] = value.ToString();
// OnPropertyChanged("Step_SourceToDeviation");
// }
//}
//public string Step_DeviationToSource
//{
// get
// {
// string s = _Xp["Step", "DeviationToSource"];
// if (s == string.Empty) return null;
// return s;
// }
// set
// {
// string s = _Xp["Step", "DeviationToSource"];
// if (value != null && value.ToString() == s) return;
// if (value == null && s != null) _Xp["Step", "DeviationToSource"] = null;
// else _Xp["Step", "DeviationToSource"] = value.ToString();
// OnPropertyChanged("Step_DeviationToSource");
// }
//}
#endregion
#region IItemConfig Members