This commit is contained in:
Kathy Ruffing 2009-11-03 16:32:28 +00:00
parent afc16fb9f9
commit 391cbaea39
3 changed files with 424 additions and 5 deletions

View File

@ -283,6 +283,16 @@ namespace VEPROMS.CSLA.Library
#region ItemInfo
public partial class ItemInfo:IVEDrillDownReadOnly
{
public bool HasHeader
{
get
{
if (MyHeader==null)return false;
if (MyHeader.CleanText==null) return false;
if (MyHeader.CleanText=="") return false;
return true;
}
}
protected void ExtensionRefreshFields(Item tmp)
{
_ActiveParent = null;
@ -484,6 +494,7 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region IsType
public bool IsCautionStructure
{
get
@ -516,6 +527,7 @@ namespace VEPROMS.CSLA.Library
public bool IsType(string type)
{
if ((int)MyContent.Type < 20000) return false;
int stepType = ((int)MyContent.Type) % 10000;
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
if (stepType > sdlist.Count)
@ -659,6 +671,8 @@ namespace VEPROMS.CSLA.Library
return parent.IsInRNO;
}
}
#endregion
#region Level Columns Relationships
public int RNOLevel
{
get
@ -736,6 +750,8 @@ namespace VEPROMS.CSLA.Library
if (myitems != null) return myitems[0];
return null;
}
#endregion
#region More IsType
public bool IsSubStep
{
get
@ -841,6 +857,8 @@ namespace VEPROMS.CSLA.Library
}
return tmp;
}
#endregion
#region Ordinal CslaType and Tostring
private int? _Ordinal;
public int Ordinal
{
@ -876,6 +894,8 @@ namespace VEPROMS.CSLA.Library
//{
// return ToString();
//}
#endregion
#region Search
internal string _SearchDVPath;
public string SearchDVPath
{
@ -905,6 +925,8 @@ namespace VEPROMS.CSLA.Library
{
get { return _SearchAnnotationType; }
}
#endregion
#region ProcedureConfig
private ProcedureConfig _ProcedureConfig = null;
public ProcedureConfig.PrintChangeBar PrintChangeBar
{
@ -959,6 +981,8 @@ namespace VEPROMS.CSLA.Library
if (pi == null) return;
_ProcedureConfig = pi.MyConfig as ProcedureConfig;
}
#endregion
#region Formatting of Text
public string DisplayText
{
get { return ConvertToDisplayText(MyContent.Text); }
@ -1022,6 +1046,8 @@ namespace VEPROMS.CSLA.Library
retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter));
return retval;
}
#endregion
#region Path and Parent
public string Path
{
get
@ -1063,6 +1089,8 @@ namespace VEPROMS.CSLA.Library
return parentContent.ContentItems[0];
}
}
#endregion
#region Lookups and More Related
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
{
if (itemInfoList == null)
@ -1169,6 +1197,8 @@ namespace VEPROMS.CSLA.Library
// AddList(nd, "Tables", Tables);
// return xn.OwnerDocument;
//}
#endregion
#region UI Tab
public string TabToolTip
{
get
@ -1202,6 +1232,7 @@ namespace VEPROMS.CSLA.Library
return DisplayText.Replace("\u2011", "-").Split(" ,.;:-_".ToCharArray())[0]+ "...";
}
}
#endregion
#region Change Bar
public bool HasChangeBar()
{
@ -1405,6 +1436,7 @@ namespace VEPROMS.CSLA.Library
public Color BackColor
{ get { return (ItemAnnotationCount > 0 ? Color.Yellow : Color.White); } }
#endregion
#region Constructor
internal ItemInfo(SafeDataReader dr, bool forIRichtem)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode());
@ -1423,8 +1455,93 @@ namespace VEPROMS.CSLA.Library
{
_MyContent = new ContentInfo(dr, true);
}
#endregion
#region MetaTags - Tabs, Headers, Footers
protected Tab _MyTab;
public Tab MyTab
{
get
{
if (!_TagsSetup) SetupTags();
return _MyTab;
}
set
{
_MyTab = value;
}
}
protected MetaTag _MyHeader;
public MetaTag MyHeader
{
get
{
if (!_TagsSetup) SetupTags();
return _MyHeader;
}
set { _MyHeader = value; }
}
protected MetaTag _MyFooter;
public MetaTag MyFooter
{
get
{
if (!_TagsSetup) SetupTags();
return _MyFooter;
}
set { _MyFooter = value; }
}
protected bool _TagsSetup = false;
public virtual void SetupTags()
{
_MyTab = new Tab(_ActiveFormat.PlantFormat.FormatData.Font);
_MyHeader = null;
_MyFooter = null;
_MyTab.CleanText = DisplayNumber;
_TagsSetup = true;
}
public static void ResetTabString(int itemID)
{
ConvertListToDictionary();
string key = itemID.ToString();
if (key != null && _CacheByPrimaryKey.ContainsKey(key))
{
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
foreach (ItemInfo item in items)
{
item._TagsSetup = false;
}
}
}
#endregion
}
#endregion ItemInfo
#region Tab
public class MetaTag
{
public VE_Font MyFont;
public ContentAlignment Justify = ContentAlignment.MiddleLeft;
public string Text; // may include tokens, such as macros for circles/diamonds, etc
public string CleanText; // all tokens removed
public MetaTag()
{
}
public MetaTag(VE_Font font)
{
MyFont = new VE_Font(font.XmlNode);
}
}
public class Tab : MetaTag
{
public Tab(VE_Font font)
{
MyFont = font;
}
public int Offset;
}
public class Header : MetaTag
{
}
#endregion
#region ItemInfoList
public partial class ItemInfoList
{
@ -1871,6 +1988,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
{
public override void SetupTags()
{
base.SetupTags();
}
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);
@ -1989,6 +2110,16 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
{
public override void SetupTags()
{
MyTab = new Tab(ActiveFormat.PlantFormat.FormatData.SectData.SectionNumber.Font);
_MyTab.Text = DisplayNumber;
_MyTab.CleanText = DisplayNumber.PadRight(20);
MyHeader = new MetaTag(ActiveFormat.PlantFormat.FormatData.SectData.SectionHeader.Font);
_MyHeader.Text = null; // this.DisplayText;
MyFooter = null;
_TagsSetup = true;
}
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);
@ -2031,7 +2162,6 @@ namespace VEPROMS.CSLA.Library
{
return (Section)(_Editable = Section.Get(ItemID));
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
@ -2105,6 +2235,247 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public partial class StepInfo : ItemInfo
{
#region Tab
public override void SetupTags()
{
_TagsSetup = true;
MyTab = new Tab(FormatStepData.TabData.Font);
MyHeader = new MetaTag(FormatStepData.TabData.Font);
MyFooter = new MetaTag(FormatStepData.TabData.Font); ;
SetTabText();
}
private void SetTabText()
{
string cltext = null;
if (IsParagraph) // TODO: Do we need this?
{
_MyTab.Text = "";
_MyTab.CleanText = "";
return;
}
int stepType = (int)(MyContent.Type % 10000);
string tbformat = IsInRNO ? FormatStepData.TabData.RNOIdentPrint : FormatStepData.TabData.IdentPrint;
// rno gets parent tab
if (IsRNO)
{
try
{
if ((((ItemInfo)ActiveParent).IsHigh && FormatStepData.NumberHighLevel) || ((!((ItemInfo)ActiveParent).IsHigh) && ((tbformat == null || tbformat == "") && (RNOLevel <= ColumnMode))))
{
_MyTab.CleanText = ((ItemInfo)ActiveParent).MyTab.CleanText;
_MyTab.Text = ((ItemInfo)ActiveParent).MyTab.Text;
return;
}
}
catch (Exception ex)
{
Console.WriteLine("SetTabText IsRNO error {0}", ex.Message);
}
}
if (tbformat == null)
{
_MyTab.Text = "";
_MyTab.CleanText = "";
return;
}
// Start with basic cases of alpha/numeric/seq:
if (tbformat.IndexOf("{seq}") > -1)
{
int level = 0;
ItemInfo par = this;
while (!par.IsHigh)
{
// 16bit TODO:
//if (par.IsRNO) // do I need to save 'lastrnoptr'
//if (!IsRNO(ptr) && (IsSequential(ptr) ||
// (!IsText(ptr) && CountAllSubLevels))) - Add this line of code for non-hlp
if (!par.IsRNO && par.IsSequential) level++;
par = par.MyParent;
}
SeqTabFmtList seqtabs = ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.SeqTabFmtList;
tbformat = seqtabs[level % seqtabs.Count].PrintTabFormat;
// If token includes 'Wpar', the parent tab prefix's the tab.
if (level > 0 && (tbformat.IndexOf("{numericWpar}")>-1 || tbformat.IndexOf("{alphaWpar}")>-1 || tbformat.IndexOf("{ALPHAWpar}")>-1))
{
string parentTab = ((ItemInfo)(ActiveParent)).MyTab.CleanText.Trim();
tbformat = parentTab + (parentTab.EndsWith(".")?"":".") + tbformat.TrimStart();
}
if (tbformat.IndexOf("#2#") > -1 || tbformat.IndexOf("#1#") > -1)
{
string ofst = tbformat.Substring(0, 3);
_MyTab.Offset = Convert.ToInt32(ofst.Substring(1, 1));
cltext = tbformat.Replace("#2#", "");
cltext = cltext.Replace("#1#", "");
}
}
// if this is a caution/note type determine where 'NOTE/CAUTION' tab goes, as tab or as 'header'
// and also determine whether the tab itself gets converted to a bullet.
if (IsCaution || IsNote) tbformat = CheckNoteCautionTab(tbformat);
int ordinal = Ordinal;
string alpha = AlphabeticalNumbering(ordinal);
tbformat = tbformat.Replace("{alpha}", alpha.ToLower());
tbformat = tbformat.Replace("{alphaWpar}", alpha.ToLower());
tbformat = tbformat.Replace("{ALPHA}", alpha);
tbformat = tbformat.Replace("{ALPHAWpar}", alpha);
string roman = RomanNumbering(ordinal);
tbformat = tbformat.Replace("{roman}", roman.ToLower());
tbformat = tbformat.Replace("{ROMAN}", roman);
tbformat = tbformat.Replace("{numeric}", ordinal.ToString().PadLeft(2));
tbformat = tbformat.Replace("{numericWpar}", ordinal.ToString());
if (tbformat.IndexOf("{!C0}") > -1)
{
cltext = cltext==null?tbformat.Replace("{!C0}", ""):cltext.Replace("{!C0}","");
}
if (FormatStepData.Sep != null && MyPrevious != null)
{
if (_MyHeader == null) _MyHeader = new MetaTag(FormatStepData.TabData.Font);
_MyHeader.Text = _MyHeader.CleanText = FormatStepData.Sep;
MyHeader.Justify = ContentAlignment.MiddleCenter;
}
#region Non HLP tab TODO
// other possible 'tokens'
// Position offset - do this one here, so don't get background substitution below..
// ##-3# - Offset of -3 from Parent (FNP)
// "{Pos-3}"
// Background/Deviation Documents - check for E_PurchaseOptions.(ENHANCEDBACKGROUNDS or ENHANCEDDEVIATIONS)
// # - Related Caution or Note number
// ~ - Linked Step Number
//"{LNK C/N Num}"
//"{LNK Step Num}"
//Section Numbers
// % - Prefix with section number (works string in 16 bit, ie.e For 4.3 the prefix becomes 4.
// wid that would be stored.
//"{Section Prefix}"
// Position offset
// \257 - Indent (CALLOWAY BACKGROUNDS)
// Newline within a tab (calbck)
//"{indent}");
//"{par}");
//Macros
// <!diamond> - draws a diamond around the stepnumber
// <!diamond1> - A macro
// <!asterisk>
// <> - ignored
// \241 - circle macro around step, same as <!circle>
// Also note, the format files had "<>", these get converted during input in this
// format converter code.
//wkstr = wkstr.Replace("{!asterisk}", "\\fs10 \\b*\\b0"); // was font size 20 in 16-bit
//wkstr = Regex.Replace(wkstr, @"{![.*?]}", @"{!$1}");
//wkstr = wkstr.Replace("{}", "");
//wkstr = wkstr.Replace("ñ", "{!C0}");
//if (vefont != null && vefont.HasCircleString2()) wkstr.Insert(0,"{!C0}");
//wkstr = wkstr.Replace("ê", @"{Box Step}");
#endregion
_MyTab.Text = tbformat;
_MyTab.CleanText = cltext!=null?cltext:tbformat;
}
private string CheckNoteCautionTab(string tbformat)
{
string prevTbFormat = null;
string nextTbFormat = null;
StepData nextStepData = null;
if (MyPrevious != null)
{
int prevStepType = ((int)MyPrevious.MyContent.Type) % 10000;
StepData prevStepData = ActiveFormat.PlantFormat.FormatData.StepDataList[prevStepType];
prevTbFormat = MyPrevious.IsInRNO ? prevStepData.TabData.RNOIdentPrint : prevStepData.TabData.IdentPrint;
}
if (NextItem != null)
{
int nextStepType = ((int)NextItem.MyContent.Type) % 10000;
nextStepData = ActiveFormat.PlantFormat.FormatData.StepDataList[nextStepType];
// tried to duplicate functionality from 16-bit code.
nextTbFormat = NextItem.IsInRNO ? nextStepData.TabData.RNOIdentPrint : nextStepData.TabData.IdentPrint;
}
// Handle the centered tab - if this tab is centered make it a header.
if (FormatStepData.TabData.Justify == "Center")
{
if (_MyHeader == null) _MyHeader = new MetaTag(FormatStepData.TabData.Font);
MyHeader.Justify = ContentAlignment.MiddleCenter;
MyHeader.Text = MyHeader.CleanText = tbformat.Trim(); ;
// if there is only step in the group - no bullet is used, if more that one replace the tab
// with a bullet
if (MyPrevious == null && NextItem == null)
tbformat = "";
else
{
if (MyPrevious != null) MyHeader = null;
tbformat = ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
if ((FormatStepData.TabData.Font.Style & E_Style.Underline) > 0)
{
FontStyle style = FontStyle.Regular;
if ((FormatStepData.TabData.Font.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((FormatStepData.TabData.Font.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
_MyTab.MyFont.WindowsFont = new Font(FormatStepData.TabData.Font.WindowsFont.FontFamily, FormatStepData.TabData.Font.WindowsFont.Size, style);
}
}
return tbformat;
}
// If this has a previous, and the tabs of this & previous match
if (tbformat != null && MyPrevious != null && !FormatStepData.AlwaysTab && (!FormatStepData.MixCautionsAndNotes || (tbformat == prevTbFormat)))
{
tbformat = tbformat + ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
}
// else if this has a next
else if (tbformat != null && NextItem != null && !FormatStepData.AlwaysTab &&
(!FormatStepData.MixCautionsAndNotes ||
(FormatStepData.TabData.UsePreviousStyle && !nextStepData.TabData.UsePreviousStyle && tbformat == nextTbFormat) ||
((prevTbFormat != tbformat && (NextItem.MyContent.Type == (int)(MyContent.Type % 10000))))))
{
tbformat = tbformat + ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
}
return tbformat;
}
private string AlphabeticalNumbering(int number)
{
string retval = string.Empty;
if (number > 26) retval += Letter((number - 1) / 26);
retval += Letter(1 + ((number - 1) % 26));
return retval;
}
private string Letter(int number)
{
char c = (char)(number + 64);
return c.ToString();
}
private enum RomanOffset : int
{
Hundreds = 2,
Tens = 4,
Units = 6
}
private string _Romans = "MDCLXVI";
private string RomanPart(RomanOffset offset, int value)
{
int iFive = value / 5;
int iUnits = value % 5;
int iFour = iUnits / 4;
return _Romans.Substring(((int)offset), iFour) +
_Romans.Substring(((int)offset) - iFive - iFour, iFive | iFour) +
"".PadRight(iUnits % 4, _Romans[((int)offset)]);
}
private string RomanNumbering(int number)
{
int thousands = number / 1000;
int hundreds = (number % 1000) / 100;
int tens = (number % 100) / 10;
int units = number % 10;
return "".PadRight(thousands, _Romans[0]) +
RomanPart(RomanOffset.Hundreds, hundreds) +
RomanPart(RomanOffset.Tens, tens) +
RomanPart(RomanOffset.Units, units);
}
#endregion
protected override void RefreshFields(Item tmp)
{
base.RefreshFields(tmp);

View File

@ -125,7 +125,7 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertSiblingBefore(string text, string number)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName);
// this item is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update Previous
using (Item item = Get()) ItemInfo.Refresh(item);
@ -145,14 +145,46 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName);
//tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
// 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);
RefreshNextItems();
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText();
return tmp;
}
private ItemInfo NewItemInfoFetch(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
{
ItemInfo tmp;
if (addType == EAddpingPart.Child)
{
// adding children. Type is based on 'fromType'
switch ((E_FromType)fromType)
{
case E_FromType.Procedure:
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
case E_FromType.Section:
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
default:
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
}
}
else
{
if (GetType() == typeof(ProcedureInfo))
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else if (GetType() == typeof(SectionInfo))
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
}
return tmp;
}
public void UpdateTransitionText()
{
// Update Ordinals from here down
@ -179,7 +211,7 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertChild(E_FromType fromType, int type, string text, string number)
{
ItemInfo tmp = DataPortal.Fetch<ItemInfo>(new AddingPartCriteria(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName));
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName);
// 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);
@ -356,6 +388,7 @@ namespace VEPROMS.CSLA.Library
{
//Console.WriteLine("item = {0}, ordinal = {1}",item,item.Ordinal);
item._Ordinal = null;
item._TagsSetup = false;
if (key == null && item.NextItem != null)
key = item.NextItem.ItemID.ToString();
}
@ -428,6 +461,7 @@ namespace VEPROMS.CSLA.Library
try
{
ItemInfo nextItem = item.NextItem;
ItemInfo prevItem = item.MyPrevious;
DataPortal.Delete(new DeleteCriteria(item.ItemID,Environment.UserName));
if (nextItem != null) // Adjust PreviousID for NextItem
{
@ -436,6 +470,8 @@ namespace VEPROMS.CSLA.Library
nextItem.RefreshItemParts();
nextItem.UpdateTransitionText();
}
else if (prevItem != null)
prevItem.RefreshNextItems();
ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
}
catch (Exception ex)

View File

@ -87,6 +87,10 @@ namespace VEPROMS.CSLA.Library
}
return _WindowsFont;
}
set
{
_WindowsFont = value;
}
}
[Description("Font Family")]
public string Family
@ -2163,7 +2167,7 @@ namespace VEPROMS.CSLA.Library
public int? MaxRNO
{
get
{
{
return LazyLoad(ref _MaxRNO, "@MaxRNO");
}
}
@ -3990,6 +3994,14 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _CheckOff, "TabData/@CheckOff");
}
}
private LazyLoad<bool> _UsePreviousStyle;
public bool UsePreviousStyle
{
get
{
return LazyLoad(ref _UsePreviousStyle, "TabData/@UsePreviousStyle");
}
}
private VE_Font _Font;
public VE_Font Font
{