diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index 1ce8d719..60b296e6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -179,21 +179,85 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _Name, "@Name"); } } - //private LazyLoad _XtraFlags; - //public string XtraFlags - //{ - // get - // { - // return LazyLoad(ref _XtraFlags, "XtraFlags"); - // } - //} - //public bool XtraOptions(string attr) - //{ - // XmlNode nd = this.SelectSingleNode("XtraFlags/@" + attr); - // if (nd == null) return false; - // if (nd.InnerText.ToUpper() == "TRUE") return true; - // return false; - //} + // TPL represents Templates which are sizes of columns for 'table' type data. If the format + // has the 'UseSmartTemplate' format flag, this table will have starting location & widths, and + // other data for the listed step types. Data from this table overrides width data as specified + // by the step type format data. The only active format that has 'UseSmartTemplate' is WCNCKL. + // The TPL data is also used by other formats, many of which are using it for Enhanced Background + // & Deviations. The actual format of the template can be in an old or new format. The old format + // uses spaces as delimiters, the new uses commas. + private LazyLoad _TPL; + public string TPL + { + get + { + return LazyLoad(ref _TPL, "@TPL"); + } + } + private List _Templates; + public List Templates + { + get + { + if (_Templates == null) // Load template class from format's string data. + { + bool oldformat = true; + // count newlines - which gives number of template records. + int NumTemplates = 0; + int indx = TPL.IndexOf('\n'); + while (indx > -1) + { + NumTemplates++; + indx = TPL.Length > indx + 1 ? TPL.IndexOf('\n', indx + 1) : -1; + } + if (NumTemplates == 0) return null; + + _Templates = new List(NumTemplates); + // for each item, create and add to list + if (TPL.IndexOf(',') > -1) oldformat = false; + int cnt = 0; + + int tmpStrIndxStart = 0; + int tmpStrIndxEnd = 0; + while (cnt < NumTemplates) + { + tmpStrIndxEnd = TPL.IndexOf("\n", tmpStrIndxStart); + string tpl = TPL.Substring(tmpStrIndxStart, tmpStrIndxEnd-tmpStrIndxStart); + tmpStrIndxStart = tmpStrIndxEnd + 1; + int level = 0; + int type = 0; + int start = 0; + int width = 0; + int nocol = 0; + int row = 0; + string stmp = null; + if (oldformat) + { + string[] tmpOld = tpl.Split(" ".ToCharArray()); + level = Convert.ToInt32(tmpOld[0]); + type = Convert.ToInt32(tmpOld[1]); + stmp = tmpOld.Length <= 2 ? null : tmpOld[2]; + } + else + { + string[] tmpNew = tpl.Split(",".ToCharArray()); + level = Convert.ToInt32(tmpNew[0]); + type = Convert.ToInt32(tmpNew[1]); + start = Convert.ToInt32(tmpNew[2]); + width = Convert.ToInt32(tmpNew[3]); + row = Convert.ToInt32(tmpNew[4]); + nocol = Convert.ToInt32(tmpNew[5]); + stmp = tmpNew.Length <= 6 ? null : tmpNew[6]; + } + TPlate tp = new TPlate(level, type, start, width, row, nocol, stmp); + _Templates.Add(tp); + cnt++; + } + } + return _Templates; + } + } + private LazyLoad _PurchaseOptions; public E_PurchaseOptions? PurchaseOptions { @@ -455,6 +519,28 @@ namespace VEPROMS.CSLA.Library public SymbolList(XmlNodeList xmlNodeList) : base(xmlNodeList) { } } #endregion + #region Templates + public class TPlate + { + public int level; // sub-step level + public int type; // type of step/substep + public int start; // starting position (for horizontal only) + public int width; // width of text in characters (") + public int row; + public int nocolm; // 1 or 2 columns - default(0) is one column + public string text; // text to be automatically entered + public TPlate(int l, int t, int s, int w, int r, int c, string x) + { + level = l; + type = t; + start = s; + width = w; + row = r; + nocolm = c; + text = x; + } + } + #endregion #region EditData [TypeConverter(typeof(ExpandableObjectConverter))] public class EditData : vlnFormatItem