CSLA Config cleanup

This commit is contained in:
2026-08-28 11:15:35 -04:00
parent d0587706a2
commit f88f8a1c75
27 changed files with 566 additions and 2412 deletions
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
using System.Xml;
@@ -11,18 +10,11 @@ namespace VEPROMS.CSLA.Library
[TypeConverter(typeof(ExpandableObjectConverter))]
public class SectionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
{
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return false; }//_Section == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#region DynamicTypeDescriptor
internal override bool IsReadOnly => false;
#endregion
#region XML
private readonly XMLProperties _Xp;
#endregion
#region Constructors
//PROPGRID: Hide ParentLookup
@@ -32,26 +24,13 @@ namespace VEPROMS.CSLA.Library
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Had to comment out NonSerialized to hide AncestorLookup from Property Grid
//[NonSerialized]
private bool _AncestorLookup;
//PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//public bool AncestorLookup
//{
// get { return _AncestorLookup; }
// set { _AncestorLookup = value; }
//}
private Section _Section;
private SectionInfo _SectionInfo;
private readonly Section _Section;
private readonly SectionInfo _SectionInfo;
private static int _SectionConfigUnique = 0;
private static int SectionConfigUnique
{ get { return ++_SectionConfigUnique; } }
private int _MySectionConfigUnique = SectionConfigUnique;
public int MySectionConfigUnique // Absolutely Unique ID - Info
{ get { return _MySectionConfigUnique; } }
private static int SectionConfigUnique => ++_SectionConfigUnique;
private readonly int _MySectionConfigUnique = SectionConfigUnique;
public SectionConfig(Section section)
public SectionConfig(Section section)
{
_Section = section;
string xml = section.MyContent.Config;
@@ -82,9 +61,8 @@ namespace VEPROMS.CSLA.Library
if (retval != string.Empty) return retval;
proc = (ProcedureInfo)proc.ActiveParent;
}
DocVersionInfo docVersion = proc.ActiveParent as DocVersionInfo;
if (docVersion == null) return string.Empty;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (!(proc.ActiveParent is DocVersionInfo docVersion)) return string.Empty;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
@@ -102,23 +80,11 @@ namespace VEPROMS.CSLA.Library
_Xp = new XMLProperties(xml);
if (_SectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
//public SectionConfig(string xml)
//{
// if (xml == string.Empty) xml = "<Config/>";
// _Xp = new XMLProperties(xml);
//}
public SectionConfig()
{
_Xp = new XMLProperties();
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
#region Local Properties
//[Category("Identification")]
[Category("General")]
public SectionConfig() => _Xp = new XMLProperties();
internal string GetValue(string group, string item) => _Xp[group, item];
#endregion
#region Local Properties
[Category("General")]
[DisplayName("Number")]
[Description("Number")]
public string Number
@@ -126,7 +92,6 @@ namespace VEPROMS.CSLA.Library
get { return (_Section != null ? _Section.MyContent.Number : _SectionInfo.MyContent.Number); }
set { if (_Section != null) _Section.MyContent.Number = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
@@ -142,7 +107,7 @@ namespace VEPROMS.CSLA.Library
[Description("Old Sequence")]
public string OldSequence
{
get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent == null ? null : _SectionInfo.MyContent.MyZContent.OldStepSequence)); }
get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent?.OldStepSequence)); }
set { if (_Section != null) _Section.MyContent.MyZContent.OldStepSequence = value; }
}
[Category("Identification")]
@@ -152,7 +117,7 @@ namespace VEPROMS.CSLA.Library
[Description("Dirty")]
public bool Dirty
{
get { return (_Section != null ? _Section.IsDirty : false); }
get { return (_Section != null && _Section.IsDirty); }
}
[Category("Format")]
[DisplayName("Format")]
@@ -171,7 +136,6 @@ namespace VEPROMS.CSLA.Library
if (_Section != null)
{
_Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_Section.ActiveFormat = null;
DocStyleListConverter.MySection = _Section;
}
}
@@ -192,7 +156,7 @@ namespace VEPROMS.CSLA.Library
set
{
if (_Section != null)
_Section.MyContent.MyFormat = value == null ? null : value.GetJustFormat();
_Section.MyContent.MyFormat = value?.GetJustFormat();
}
}
[Category("Format")]
@@ -304,15 +268,13 @@ namespace VEPROMS.CSLA.Library
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<Config/>" || s == "<Config></Config>") return string.Empty;
return s;
}
#endregion
#region SectionCategory // from sequence number in 16-bit database.
[TypeConverter(typeof(EnumDescConverter))]
return s == "<Config/>" || s == "<Config></Config>" ? string.Empty : s;
}
#endregion
#region SectionCategory // from sequence number in 16-bit database.
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionPagination : int
{
//Default = 0, Continuous, Separate
Continuous = 1, Separate = 2
}
[Category("Format")]
@@ -415,7 +377,7 @@ namespace VEPROMS.CSLA.Library
get
{
string tmp = _Xp["Section", "TOC_Group_Title"];
return (tmp == null)? "" : tmp;
return tmp ?? "";
}
set
{
@@ -476,23 +438,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Section_DontIncludeDuplexFoldout");
}
}
//[Category("Section")]
////PROPGRID: Hide AutoGen
//[DisplayName("Section AutoGen")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Section AutoGen")]
//public string Section_AutoGen
//{
// get
// {
// return _Xp["Section", "AutoGen"];
// }
// set
// {
// _Xp["Section", "AutoGen"] = value;
// OnPropertyChanged("Section_AutoGen");
// }
//}
[Category("Section")]
//PROPGRID: Hide Subsection PH
[DisplayName("Section PrintHdr")]
@@ -536,7 +481,6 @@ namespace VEPROMS.CSLA.Library
{
get
{
//return _Xp["Section", "ShwRplWords"];
string tmp = _Xp["Section", "ShwRplWords"];
return tmp == null || tmp == "" ? "Y" : tmp;
}
@@ -568,8 +512,6 @@ namespace VEPROMS.CSLA.Library
// C2020-046 change wording for the column modes to One, Two, Three, and Four
public enum SectionColumnMode : int
{
//[Description("Format Default")]
//Default = 0,
[Description("One Column")]
One = 1,
[Description("Two Columns")]
@@ -595,7 +537,7 @@ namespace VEPROMS.CSLA.Library
// If there is no parent value, then use the volian default
if (s == string.Empty)
{
SectionInfo si = _SectionInfo != null ? _SectionInfo : SectionInfo.Get(_Section.ItemID);
SectionInfo si = _SectionInfo ?? SectionInfo.Get(_Section.ItemID);
if (si != null)
{
E_PurchaseOptions po = (E_PurchaseOptions)(MyFormat ?? MyDefaultFormat).PlantFormat.FormatData.PurchaseOptions;
@@ -607,34 +549,23 @@ namespace VEPROMS.CSLA.Library
{
case FormatColumns.OneColumn:
return SectionColumnMode.One;
break;
case FormatColumns.TwoColumn:
return SectionColumnMode.Two;
break;
case FormatColumns.ThreeColumn:
return SectionColumnMode.Three;
break;
case FormatColumns.FourColumns:
return SectionColumnMode.Four;
break;
//default:
// return SectionColumnMode.One;
// break;
}
}
}
int rval = 0;
if (MyFormat != null)
int rval;
if (MyFormat != null)
{
rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//int rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;//SectionColumnMode.Two; //SectionColumnMode.Default;// default to volian default
}
else
{
//int rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;
}
// if no pmode is defined, i.e. rval = 0, then go up to the procedure level & get
// it's format column.
@@ -646,11 +577,6 @@ namespace VEPROMS.CSLA.Library
}
else
return (SectionColumnMode)int.Parse(s);
//if (s == string.Empty)
// return SectionColumnMode.Default;
//return (SectionColumnMode)int.Parse(s);
}
set
{
@@ -670,13 +596,12 @@ namespace VEPROMS.CSLA.Library
}
else
rval =(int)MyFormat.MyStepSectionLayoutData.PMode;
//parval = ((rval > 0)?((SectionColumnMode)rval).ToString() : "2"); // if PMode is zero default to 2 column mode
}
// if still no value found in inheritance, check if the procedure has a default. if so and value matches, clear out any config item.
if (rval == 0)
{
SectionInfo si = _SectionInfo != null ? _SectionInfo : SectionInfo.Get(_Section.ItemID);
SectionInfo si = _SectionInfo ?? SectionInfo.Get(_Section.ItemID);
if (si != null)
{
switch (si.MyProcedure.ProcedureConfig.Format_Columns)
@@ -708,103 +633,6 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Section_ColumnMode");
}
}
//char * far printtypes[] = {
// "Compressed, 8 lines per inch",
// "Elite, 6 lines per inch",
// "Pica, 6 lines per inch",
// "Default font, 4 Lines Per Inch",
// "Default font, 6 Lines Per Inch",
// "Compressed 6 LPI",
// "Default font, 7 Lines Per Inch",
// "Special Landscape, Elite, 6 lines per inch"
//};
//[TypeConverter(typeof(EnumDescConverter))]
//public enum AttPrintSize : int
//{
// [Description("Compressed, 8 lines per inch")]
// Cmp8lpi = 0,
// [Description("Elite, 6 lines per inch")]
// Elite6lpi = 1,
// [Description("Pica, 6 lines per inch")]
// Pica6lpi = 2,
// [Description("Default font, 4 Lines Per Inch")]
// Def4lpi = 3,
// [Description("Default font, 6 Lines Per Inch")]
// Def6lpi = 4,
// [Description("Compressed 6 LPI")]
// Cmp6lpi = 5,
// [Description("Default font, 7 Lines Per Inch")]
// Def7lpi = 6,
// [Description("Landscape, Elite, 6 lines per inch")]
// landElite6lpi = 7
//}
//[Category("Format")]
//[DisplayName("Attachment PrintSize")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Attachment Print Size")]
//public AttPrintSize Section_AttachmentPrintSize
//{
// get
// {
// string lpiSettings = "*pP46f7L";
// string s = _Xp["Section", "OldType"];
// int idx = -1;
// //If there is no value to get, then get the parent value (a.k.a. default value).
// if (s == string.Empty)
// s = _Xp.ParentValue("Section", "OldType"); // get the parent value
// // If there is no parent value, then use the volian default
// if (s == string.Empty)
// return AttPrintSize.Def6lpi;// default to volian default
// idx = lpiSettings.IndexOf(s[1]);
// if (idx == -1) idx = 4;
// return (AttPrintSize)idx;
// //return (AttPrintSize)int.Parse(s);
// }
// set
// {
// // if value being saved is same as the parent value, then clear the value (save blank). This will
// // reset the data to use the parent value.
// string lpiSettings = "*pP46f7L";
// string parval = _Xp.ParentValue("Section", "OldType"); // get the parent value
// StringBuilder sb = new StringBuilder();
// string curval = parval[1].ToString();
// sb.Append(parval[0]); // save first part of OldType
// if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
// {
// //parval = ((int)(AttPrintSize.Def6lpi)).ToString();
// //sb.Append(((int)(AttPrintSize.Def6lpi)).ToString());
// sb.Append(lpiSettings[(int)(AttPrintSize.Def6lpi)]);
// }
// if (curval.Equals(((int)value).ToString()))
// _Xp["Section", "OldType"] = string.Empty; // reset to parent value
// else
// {
// //sb.Append(((int)value).ToString());
// sb.Append(lpiSettings[(int)value]);
// _Xp["Section", "OldType"] = sb.ToString(); // save selected value
// }
// OnPropertyChanged("Section_AttachmentPrintSize");
// }
//}
/*
int chkOffType = (rid[0] & 0x007F) - '0';
if (chkOffType > 0)
ci.AddItem("Section", "CheckoffSelection", chkOffType.ToString());
if (stype.Length > 1)
{
int chkOffHeading = (stype[1] & 0x007F) - '0';
if (chkOffHeading > 0)
ci.AddItem("Section", "CheckoffHeading", chkOffHeading.ToString());
*/
[Category("Format")]
[DisplayName("Checkoff List Selection")]
[Description("Checkoff List Selection")]
@@ -874,13 +702,10 @@ namespace VEPROMS.CSLA.Library
{
get
{
//if (_SectionInfo != null && _SectionInfo.Sections != null && _SectionInfo.Sections.Count > 0 && _SectionInfo.Steps != null && _SectionInfo.Steps.Count > 0)
if (_SectionInfo != null && _SectionInfo.Sections != null && _SectionInfo.Sections.Count > 0)
return "N";
if (_Section != null && HasSubsections)
return "N";
//if (_Section != null && _Section.MyContent.cont .Sections.Count > 0 && _Section.Steps.Count > 0)
// return "N";
return "Y";
}
}
@@ -1013,8 +838,6 @@ namespace VEPROMS.CSLA.Library
{
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)