From 8708d0bbfcac19e8bb2e14c69b6234a0b92c908e Mon Sep 17 00:00:00 2001 From: John Date: Fri, 23 Oct 2015 18:13:53 +0000 Subject: [PATCH] Continuous Action Summary logic Added a LazyLoad that passes in the default value --- .../VEPROMS.CSLA.Library/Config/StepConfig.cs | 36 ++++++++++++------ .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 37 ++++++++++++++++++ .../Format/PlantFormat.cs | 38 +++++++++++++++++++ .../VEPROMS.CSLA.Library/Format/vlnFormat.cs | 15 ++++++++ 4 files changed, 114 insertions(+), 12 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs index ad9df915..6908e428 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs @@ -112,29 +112,41 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_FloatingFoldout"); } } - //[Category("Step Attributes")] - //[DisplayName("Step Continuous Action Summary")] - //[RefreshProperties(RefreshProperties.All)] - //[Description("Step Continuous Action Summary")] - public bool Step_CAS + public string Step_CAS { get { string s = _Xp["Step", "ContActSum"]; - - //If there is no value to get, then get the parent value (a.k.a. default value). - if (s == string.Empty) return false; - if (s == "True") return true; - return false; + //If there is no value in the config, then return null. This will tell us to check the step type and format flag (ExcludeFromContActSum). + if (s == string.Empty) return null; + return s; } set { string s = _Xp["Step", "ContActSum"]; - if (value.ToString() == s) return; - _Xp["Step", "ContActSum"] = value.ToString(); + if (value == s) return; + _Xp["Step", "ContActSum"] = value; OnPropertyChanged("Step_CAS"); } } + //// Alternate text to use on the Continuous Action Summary + //public string Step_AlternateContActSumText + //{ + // get + // { + // string s = _Xp["Step", "AlternateContActSumText"]; + // //If there is no value to get, then we use the actual step text + // if (s == string.Empty) return null; + // return s; + // } + // set + // { + // string s = _Xp["Step", "AlternateContActSumText"]; + // if (value == s) return; + // _Xp["Step", "AlternateContActSumText"] = value; + // OnPropertyChanged("Step_AlternateContActSumText"); + // } + //} //[Category("Step Attributes")] //[DisplayName("Step Placekeeper")] //[RefreshProperties(RefreshProperties.All)] diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 36e7d791..bf98a6b3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -1511,6 +1511,43 @@ namespace VEPROMS.CSLA.Library StepData sd = sdlist[stepType]; return (sd.Type == type); } + + // determine if the the current step should automatically be placed on the Continuous Action Summary + // Note, this logic only checks the format setting of the step. We will check the value of the Tag's Check Box later on. + public bool IncludeOnContActSum + { + get + { + bool includeOnCAS = false; + if ((int)MyContent.Type < 20000) return includeOnCAS; + int stepType = ((int)MyContent.Type) % 10000; + StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList; + if (stepType > sdlist.MaxIndex) + { + //Console.WriteLine("IncludeOnContActSum - Error getting type - contentid = {0}", MyContent.ContentID); + _MyLog.InfoFormat(string.Format("IncludeOnContActSum - Error getting type - contentid = {0}", MyContent.ContentID)); + return false; + } + // By default the PROMS step types that are initally identified as a Continuous Action type will return True, + // unless the format flag "ExcludeFromContActSum" is set on that step type + StepData sd = sdlist[stepType]; + switch (stepType) + { + case 9: // Continuous Action High Level Step + case 44: // Continuous Action Sequential sub-step + case 45: // Continuous Action AND sub-step + case 46: // Continuous Action OR sub-step + case 47: //Continuous Actoin Paragraph sub-step + includeOnCAS = !sd.ExcludeFromContActSum; // if flag is not set then Automatically include this step/sub-step on the Continuous Action Summary + break; + default: + includeOnCAS = !sd.ExcludeFromContActSum; //false; // don't automatically include this step/sub-step on the Continuous Action Summary + break; + } + return includeOnCAS; + } + } + public bool IsCautionOrNotePart { get diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index f59d1c33..ea7a9f67 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -3792,6 +3792,14 @@ namespace VEPROMS.CSLA.Library return (_TableOfContentsData == null ? _TableOfContentsData = new TableOfContentsData(SelectSingleNode("TableOfContentsData")) : _TableOfContentsData); } } + private ConitnuousActionSummaryData _ContinuousActionSummaryData; + public ConitnuousActionSummaryData ContinuousActionSummaryData + { + get + { + return (_ContinuousActionSummaryData == null? _ContinuousActionSummaryData = new ConitnuousActionSummaryData(SelectSingleNode("ConitnuousActionSummaryData")) : _ContinuousActionSummaryData); + } + } } #endregion #region TableOfContentsData @@ -3889,6 +3897,28 @@ namespace VEPROMS.CSLA.Library } } #endregion + #region ConitnuousActionSummary + public class ConitnuousActionSummaryData : vlnFormatItem + { + public ConitnuousActionSummaryData(XmlNode xmlNode) : base(xmlNode) { } + private LazyLoad _IncludeSectionNumAndTitle; + public bool IncludeSectionNumAndTitle + { + get + { + return LazyLoad(ref _IncludeSectionNumAndTitle, "@IncludeSectionNumAndTitle"); + } + } + private VE_Font _Font; + public VE_Font Font + { + get + { + return (_Font == null) ? _Font = new VE_Font(base.XmlNode) : _Font; + } + } + } + #endregion #endregion #region MetaSectionAll #region MetaSection @@ -4690,6 +4720,14 @@ namespace VEPROMS.CSLA.Library { return string.Format("{0}", Type); } + private LazyLoad _ExcludeFromContActSum; + public bool ExcludeFromContActSum + { + get + { + return LazyLoad(ref _ExcludeFromContActSum, "@ExcludeFromContActSum", true); // the default setting is true (as is yes, dont include on Continuous Action Summary) + } + } } #endregion #region StepDataList diff --git a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs index a8ab4953..2cda70d8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/vlnFormat.cs @@ -353,6 +353,21 @@ namespace VEPROMS.CSLA.Library { return xn != null && xn.InnerText.ToUpper() == "TRUE"; } + // a LaxyLoad that allows you to pass in the default setting + public bool LazyLoad(ref LazyLoad ll, string xPath, bool defaultReturn) + { + if (ll == null) + { + XmlNode xn = SelectSingleNode(xPath); + ll = new LazyLoad(RetrieveBool(xn, defaultReturn)); + } + return ll.Value; + } + // if nothing is set for this node, then use the passed in default value + protected static bool RetrieveBool(XmlNode xn, bool defaultReturn) + { + return (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn; + } public string LazyLoad(ref LazyLoad ll, string xPath) { if (ll == null)