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 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] [Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
public class DocVersionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged 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 #region DynamicTypeDescriptor
internal override bool IsReadOnly internal override bool IsReadOnly
{ {

View File

@ -840,7 +840,22 @@ namespace VEPROMS.CSLA.Library
} }
} }
#endregion #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 #region IItemConfig Members
[Category("Master/Slave Settings")] [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 #endregion
} }
} }

View File

@ -3,9 +3,60 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.ComponentModel; using System.ComponentModel;
using DescriptiveEnum; using DescriptiveEnum;
using System.Xml;
namespace VEPROMS.CSLA.Library 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] [Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
public class StepConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig public class StepConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
@ -61,6 +112,7 @@ namespace VEPROMS.CSLA.Library
{ {
if (xml == string.Empty) xml = "<Config/>"; if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml); _Xp = new XMLProperties(xml);
} }
public StepConfig() public StepConfig()
{ {
@ -309,74 +361,125 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Step_Responsibility"); OnPropertyChanged("Step_Responsibility");
} }
} }
public string Step_SourceToBackground // Enhanced Documents
private EnhancedDocuments _MyEnhancedDocuments = null;
public EnhancedDocuments MyEnhancedDocuments
{ {
get get
{ {
string s = _Xp["Step", "SourceToBackground"]; if (_MyEnhancedDocuments == null)
if (s == string.Empty) return null; {
return s; _MyEnhancedDocuments = EnhancedDocuments.Load(_Xp);
}
return _MyEnhancedDocuments;
} }
set set
{ {
string s = _Xp["Step", "SourceToBackground"]; _MyEnhancedDocuments = value;
if (value != null && value.ToString() == s) return; //OnPropertyChanged("EnhancedDocuments");
if (value == null && s != null) _Xp["Step", "SourceToBackground"] = null;
else _Xp["Step", "SourceToBackground"] = value.ToString();
OnPropertyChanged("Step_SourceToBackground");
} }
} }
public string Step_BackgroundToSource public void AddEnhancedDocument(int type, int itemid)
{ {
get MyEnhancedDocuments.Add(type, itemid);
SaveEnhancedDocuments();
}
public void SaveEnhancedDocuments()
{ {
string s = _Xp["Step", "BackgroundToSource"]; // get all of the current enhanced links from datastructure in code. This list may have been
if (s == string.Empty) return null; // modified by adding items during code execution by associating source <--> background etc.
return s; EnhancedDocuments edsToAdd = new EnhancedDocuments();
} foreach (EnhancedDocument ed in MyEnhancedDocuments)
set 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", "BackgroundToSource"]; EnhancedDocument tmp = edsToAdd[int.Parse(xn.Attributes["Type"].Value)];
if (value != null && value.ToString() == s) return; if (tmp != null) edsToAdd.Remove(tmp);
if (value == null && s != null) _Xp["Step", "BackgroundToSource"] = null;
else _Xp["Step", "BackgroundToSource"] = value.ToString();
OnPropertyChanged("Step_BackgroundToSource");
} }
} foreach (EnhancedDocument edadd in edsToAdd)
public string Step_SourceToDeviation
{ {
get // Add (example): <Enhanced Type="Background" ItemID="43138" /><Enhanced Type="Deviation" ItemID="67165" />
{ // First add 'Enhanced' element:
string s = _Xp["Step", "SourceToDeviation"]; XmlNode newEnhNode = _Xp.XmlContents.CreateNode(XmlNodeType.Element, "Enhanced", _Xp.XmlContents.NamespaceURI);
if (s == string.Empty) return null; XmlNode xnEnh = _Xp.XmlContents.DocumentElement.AppendChild(newEnhNode);
return s; // Now add the 'Type' and 'ItemID' attributes:
} XmlAttribute xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("Type"));
set xa.Value = edadd.Type.ToString();
{ xa = xnEnh.Attributes.Append(_Xp.XmlContents.CreateAttribute("ItemID"));
string s = _Xp["Step", "SourceToDeviation"]; xa.Value = edadd.ItemID.ToString();
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");
} }
} }
//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 #endregion
#region IItemConfig Members #region IItemConfig Members