From a2f1fb06401f0057e5d5e9a16cdbb0381f700ff5 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 6 Dec 2013 19:51:59 +0000 Subject: [PATCH] Fixed separator location logic, added Template logic for Prairie Island Alarms Added ChildIndent for use with Callaway Backgounds --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 26 +++++++- .../Extension/ItemInsertExt.cs | 59 ++++++++++++++++++- .../Format/PlantFormat.cs | 8 +++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 7c879747..9cdc4558 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -2707,7 +2707,24 @@ namespace VEPROMS.CSLA.Library _MyHeader.Text = FormatStepData.Sep; _MyHeader.CleanText = StripRtfFormatting(_MyHeader.Text); - _MyHeader.Justify = ContentAlignment.MiddleCenter; + // per 16-bit format speadsheet, Location can have the following values: + // 0 - Left + // 1 - Right + // 2 or greater - Center + int sepLoc = ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.Separator.Location?? 2; //default to Center + switch (sepLoc) + { + case 0: + _MyHeader.Justify = ContentAlignment.MiddleLeft; + break; + case 1: + _MyHeader.Justify = ContentAlignment.MiddleRight; + break; + default: + _MyHeader.Justify = ContentAlignment.MiddleCenter; + break; + } + //_MyHeader.Justify = ContentAlignment.MiddleCenter; } #region Non Converted Plants tab TODO // Position offset @@ -3209,6 +3226,13 @@ namespace VEPROMS.CSLA.Library if (IsStep && FormatStepData.MyFormat.PlantFormat.FormatData.TopTemplateTypes.ContainsKey((int)MyContent.Type - 20001)) return true; return false; } + public int GetSmartTemplateTopLevelIndxOfThisType(int oftype) + { + FormatData formatData = FormatStepData.MyFormat.PlantFormat.FormatData; + if (formatData.TopTemplateTypes == null || formatData.TopTemplateTypes.Count == 0) return -1; + if (formatData.TopTemplateTypes.ContainsKey(oftype - 20001)) return formatData.TopTemplateTypes[oftype - 20001]; + return -1; + } public int GetSmartTemplateTopLevelIndx() { FormatData formatData = FormatStepData.MyFormat.PlantFormat.FormatData; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 3939eb85..992455da 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -298,6 +298,60 @@ namespace VEPROMS.CSLA.Library ((ItemInfo)ActiveParent).MyContent.RefreshContentParts(); return tmp; } + private ItemInfo InsertSmartTemplateSubStep(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type) + { + int newItemID = 0; + int topType = GetSmartTemplateTopLevelIndxOfThisType(type); + if (topType == -1) return null; + int tpIndx = GetSmartTemplateIndex(topType, type); + if (tpIndx != -1) + { + ItemInfo siblingSmart = null; + ItemInfo firstSmart = null; + int level = FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].level; + string tmptext = FormatStepData.MyFormat.PlantFormat.FormatData.NewTemplateFormat ? text : FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].text; + int prevlevel = level; + while (level > 0) + { + if (firstSmart == null) + { + firstSmart = NewItemInfoFetch(ItemID, adPart, number, tmptext, type, null, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); + siblingSmart = firstSmart; + newItemID = firstSmart.ItemID; + } + else + { + E_FromType fromType = E_FromType.Step; + EAddpingPart addPart = EAddpingPart.Child; // level > previous, add a child. + if (level == prevlevel) addPart = EAddpingPart.After; + if (level < prevlevel) + { + if (FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].type == 39) + { + fromType = E_FromType.RNO; + addPart = EAddpingPart.Child; + } + else + { + addPart = EAddpingPart.After; + } + newItemID = siblingSmart.ItemID; + } + + tmptext = /*FormatStepData.MyFormat.PlantFormat.FormatData.NewTemplateFormat ? " ": */FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].text; + tmp = NewItemInfoFetch(newItemID, addPart, null, tmptext, FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].type + 20001, (int?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); + newItemID = tmp.ItemID; + if (level < prevlevel) siblingSmart = tmp; + } + tpIndx++; + prevlevel = level; + level = tpIndx < FormatStepData.MyFormat.PlantFormat.FormatData.Templates.Count ? + FormatStepData.MyFormat.PlantFormat.FormatData.Templates[tpIndx].level : -1; + } + tmp = firstSmart; + } + return tmp; + } private ItemInfo InsertSmartTemplateSteps(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type) { @@ -575,7 +629,10 @@ namespace VEPROMS.CSLA.Library } public ItemInfo InsertChild(E_FromType fromType, int type, string text, string number) { - ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); + ItemInfo tmp = null; + tmp = InsertSmartTemplateSubStep(text, number, tmp, EAddpingPart.After, type); + if (tmp == null) + tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?)fromType, null, null, DateTime.Now, Volian.Base.Library.VlnSettings.UserID); // if next exists, it is updated in SQL so we have to manually force the iteminfo updates // Refresh ItemInfo to update PreviousID field if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item); diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index 972f0dfd..d9b8b3c6 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -4075,6 +4075,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _AdjHighLevelTab, "@AdjHighLevelTab"); } } + private LazyLoad _ChildIndent; + public float? ChildIndent + { + get + { + return LazyLoad(ref _ChildIndent, "@ChildIndent"); + } + } private LazyLoad _LeftJustifyBorderless; public bool LeftJustifyBorderless {