Page Num Transition (for grids)
This commit is contained in:
@@ -138,8 +138,8 @@ namespace VEPROMS.CSLA.Library
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
//if (g.ToString() != transText)
|
||||
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
if (g.ToString() != transText)
|
||||
MyGrid.SetData(MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -434,6 +434,26 @@ namespace VEPROMS.CSLA.Library
|
||||
foreach (ItemInfo ii in pi.MyItems)
|
||||
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo);
|
||||
}
|
||||
internal static void SetParentSectionAndDocVersionPageNum(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
|
||||
{
|
||||
if (itemInfo.MyContent.ContentPartCount > 0)
|
||||
{
|
||||
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
|
||||
{
|
||||
foreach (ItemInfo ii in pi.MyItems)
|
||||
{
|
||||
SetParentSectionAndDocVersionPageNum(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo, tranLookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemInfo.MyContent.ContentTransitionCount > 0)
|
||||
{
|
||||
foreach (TransitionInfo traninfo in itemInfo.MyContent.ContentTransitions)
|
||||
{
|
||||
itemInfo.MyContent.FixTransitionText(traninfo, tranLookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
//internal static long ticksROUsage;
|
||||
//internal static long ticksItems;
|
||||
//internal static long ticksTrans;
|
||||
@@ -528,6 +548,18 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
set { _PrintLevel = value; }
|
||||
}
|
||||
// The following property tracks the page number that this item is on if the resolved
|
||||
// transition text has a Page Number associated with it. Formats that have this either
|
||||
// have the UseTransitionModfier flag or have '{Page Num}' in respective transition formats.
|
||||
// If the format requires page numbers in transitions text, two passes are run through the
|
||||
// data for printing. The first determines page numbers, the seconds resolves the transition
|
||||
// text.
|
||||
private int _PageNumber = 0;
|
||||
public int PageNumber
|
||||
{
|
||||
get { return _PageNumber; }
|
||||
set { _PageNumber = value; }
|
||||
}
|
||||
private float _MSWordPageCount = 0;
|
||||
public float MSWordPageCount
|
||||
{
|
||||
@@ -1194,7 +1226,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (ActiveSection != null)
|
||||
{
|
||||
SectionInfo si = null;
|
||||
if (IsSection) si = (SectionInfo) this;
|
||||
if (IsSection) si = this as SectionInfo;
|
||||
else si = ActiveSection as SectionInfo;
|
||||
if(si == null)
|
||||
si = SectionInfo.Get(ActiveSection.ItemID); //ActiveSection as SectionInfo;
|
||||
@@ -4583,6 +4615,12 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
return (Procedure) (_Editable = Procedure.Get(ItemID));
|
||||
}
|
||||
public static void RefreshPageNumTransitions(ProcedureInfo tmp)
|
||||
{
|
||||
TransitionLookup tranLookup = new TransitionLookup(0, tmp.ItemID, tmp.MyLookup);
|
||||
tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup);
|
||||
SetParentSectionAndDocVersionPageNum(tmp, tmp.MyDocVersion, null, tmp, tmp.MyDocVersion, tranLookup);
|
||||
}
|
||||
//jcb add 20120501 item and children by unit
|
||||
public static ProcedureInfo GetItemAndChildrenByUnit(int? itemID, int? parentID, int? unitID)
|
||||
{
|
||||
|
@@ -31,16 +31,50 @@ namespace VEPROMS.CSLA.Library
|
||||
return MyContent.ContentItems[0].Path;
|
||||
}
|
||||
}
|
||||
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, int tranType, ItemInfo toitem, ItemInfo rangeitem)
|
||||
[NonSerialized]
|
||||
private TransitionConfig _TransitionConfig;
|
||||
public TransitionConfig TransitionConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TransitionConfig == null)
|
||||
{
|
||||
_TransitionConfig = new TransitionConfig(this);
|
||||
}
|
||||
return _TransitionConfig;
|
||||
}
|
||||
}
|
||||
public bool HasPageNum
|
||||
{
|
||||
get
|
||||
{
|
||||
return TransitionConfig.Transition_Formatted.ToUpper() == "TRUE";
|
||||
}
|
||||
}
|
||||
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, int tranType, ItemInfo toitem, ItemInfo rangeitem, bool hasPageNum)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, rangeitem);
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, rangeitem, HasPageNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (tranType == 2 && ex.Message == "Cannot find Next Item")
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, toitem);
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, toitem, HasPageNum);
|
||||
_MyLog.Error("Error Processing Transition Text", ex);
|
||||
return "(Resolved Transition Text)";
|
||||
}
|
||||
}
|
||||
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, int tranType, ItemInfo toitem, ItemInfo rangeitem)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, rangeitem, HasPageNum);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (tranType == 2 && ex.Message == "Cannot find Next Item")
|
||||
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, toitem, HasPageNum);
|
||||
_MyLog.Error("Error Processing Transition Text", ex);
|
||||
return "(Resolved Transition Text)";
|
||||
}
|
||||
@@ -61,13 +95,22 @@ namespace VEPROMS.CSLA.Library
|
||||
MyContent.RefreshContentItems();
|
||||
ItemInfo item = MyContent.ContentItems[0];
|
||||
ItemInfo myItemToID = MyItemToID;
|
||||
if (tranLookup.ContainsKey(item.ItemID)) item = tranLookup[item.ItemID];
|
||||
bool hasPageNum = false;
|
||||
if (item.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier)
|
||||
{
|
||||
TransitionConfig tc = new TransitionConfig(Config);
|
||||
if (tc != null && tc.Transition_Formatted.ToUpper() == "TRUE") hasPageNum = true;
|
||||
}
|
||||
if (tranLookup.ContainsKey(ToID))
|
||||
{
|
||||
myItemToID = tranLookup[ToID];
|
||||
}
|
||||
else
|
||||
{
|
||||
//different proc
|
||||
//_MyLog.WarnFormat("Transition May Not Be Correct at Location From {0} To {1}", item.SearchPath, myItemToID.SearchPath);
|
||||
if(!tranLookup.MyLookups.ContainsKey(myItemToID.MyProcedure.ItemID))
|
||||
if (!tranLookup.MyLookups.ContainsKey(myItemToID.MyProcedure.ItemID))
|
||||
tranLookup.AddProcLookup(myItemToID.MyProcedure.ItemID, ProcedureInfo.GetNewLookup(tranLookup, new TransitionLookupEventArgs(myItemToID.MyProcedure.ItemID, tranLookup.ApplicabilityUnit, MyItemToID.MyDocVersion, tranLookup)).MyLookup);
|
||||
if (tranLookup.ContainsKey(ToID))
|
||||
myItemToID = tranLookup[ToID];
|
||||
@@ -94,7 +137,7 @@ namespace VEPROMS.CSLA.Library
|
||||
//Console.WriteLine("MyItemToID = {0}", MyItemToID);
|
||||
//Console.WriteLine("MyItemRangeID = {0}", MyItemRangeID);
|
||||
}
|
||||
return ResolvePathTo(item.ActiveFormat, item, TranType, myItemToID, myItemRangeID);
|
||||
return ResolvePathTo(item.ActiveFormat, item, TranType, myItemToID, myItemRangeID, hasPageNum);
|
||||
}
|
||||
}
|
||||
#region AffectedTransitons
|
||||
@@ -457,18 +500,46 @@ namespace VEPROMS.CSLA.Library
|
||||
_AppendMethods.Add("{?.Sect Num}", AddOptionalTranGetSectionNum);
|
||||
_AppendMethods.Add("{Sect Num}", AddTranGetSectionNumber);
|
||||
_AppendMethods.Add("{Sect Number}", AddTranGetSectionNumber); // WCN2, tran type 6
|
||||
|
||||
_AppendMethods.Add("{Page Num}", AddPageNumber);
|
||||
}
|
||||
public static string GetResolvedText(ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem)
|
||||
public static string GetResolvedText(ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem, bool hasPageNum)
|
||||
{
|
||||
return GetResolvedText(fromInfo.ActiveFormat, fromInfo, tranType, toItem, rangeItem);
|
||||
return GetResolvedText(fromInfo.ActiveFormat, fromInfo, tranType, toItem, rangeItem, hasPageNum);
|
||||
}
|
||||
public static string GetResolvedText(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem)
|
||||
public static string GetResolvedText(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem, bool pagenum)
|
||||
{
|
||||
if (!pagenum)
|
||||
{
|
||||
TransitionInfo ct = fromInfo.MyContent.ContentTransitionCount > 0 ? fromInfo.MyContent.ContentTransitions[0] : null;
|
||||
int trIU = -1;
|
||||
string cfg = string.Empty;
|
||||
if (ct != null)
|
||||
{
|
||||
trIU = fromInfo.MyContent.ContentTransitions[0].MyTransitionInfoUnique;
|
||||
cfg = fromInfo.MyContent.ContentTransitions[0].Config;
|
||||
}
|
||||
else
|
||||
{
|
||||
string pattern = string.Format(@".*\\v <START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:[0-9]+ <CTID=-[0-9]+>( [0-9]*){{1,2}}\[END>");
|
||||
Match m = Regex.Match(fromInfo.MyContent.Text, pattern);
|
||||
if (m.Groups.Count > 1 && m.Groups[1].Value.Contains("(Page ~)"))
|
||||
pagenum = true;
|
||||
}
|
||||
}
|
||||
if (toItem == null || rangeItem == null || toItem.IsDeleted || rangeItem.IsDeleted)
|
||||
return "Invalid Transition Destination";
|
||||
TransitionBuilder tb = SetupTransitionBuilder(formatInfo, fromInfo, tranType, toItem,
|
||||
toItem.ItemID==rangeItem.ItemID && !toItem.IsHigh?toItem.LastSibling:rangeItem);
|
||||
if (pagenum && (tranType==1||tranType==2||tranType==4))
|
||||
{
|
||||
// if range transition, the page number token needs to go after the first step, else it's at the end:
|
||||
if (tranType == 2 && tb._TransFormat.Contains("{First Step"))
|
||||
{
|
||||
tb._TransFormat = tb._TransFormat.Insert(tb._TransFormat.IndexOf("{First Step}")+12, " {Page Num}");
|
||||
}
|
||||
else
|
||||
tb._TransFormat = tb._TransFormat + " {Page Num}";
|
||||
}
|
||||
if(_AppendMethods==null)
|
||||
SetupMethods();
|
||||
string retval = BuildString(tb);
|
||||
@@ -732,7 +803,35 @@ namespace VEPROMS.CSLA.Library
|
||||
sret = sret.Trim(" .)".ToCharArray());
|
||||
return sret;
|
||||
}
|
||||
|
||||
private static bool AddPageNumber(TransitionBuilder tb)
|
||||
{
|
||||
if (tb._ToItem.PageNumber != 0 && tb._FromItem.PageNumber != 0)
|
||||
{
|
||||
int pgoffset = tb._ToItem.PageNumber - tb._FromItem.PageNumber;
|
||||
switch (pgoffset)
|
||||
{
|
||||
case 1:
|
||||
tb.Append(" (Next Page)");
|
||||
Console.WriteLine("Next Page: {0}", tb._FromItem.ShortPath);
|
||||
break;
|
||||
case -1:
|
||||
tb.Append(" (Previous Page)");
|
||||
Console.WriteLine("Prev Page: {0}", tb._FromItem.ShortPath);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
tb.Append(string.Format(" (Page {0})", tb._ToItem.PageNumber + 1));
|
||||
Console.WriteLine("Page: {0}, {1}", tb._FromItem.ShortPath, tb._ToItem.PageNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.Append(" (Page ~)");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static bool AddStepNumber(TransitionBuilder tb)
|
||||
{
|
||||
// If we're on a step put out the step number.
|
||||
|
@@ -17,6 +17,7 @@ using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla.Validation;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@@ -589,6 +590,12 @@ namespace VEPROMS.CSLA.Library
|
||||
// if we're not dirty then don't update the database
|
||||
if (!this.IsDirty) return;
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
string pattern = string.Format(@"<START\]\\v0([^#]*)\\v #Link:Transition(|Range):[0-9]* <CTID={0}>( [0-9]*){{1,2}}\[END>", _TransitionID);
|
||||
Match m = Regex.Match(myContent.Text, pattern);
|
||||
if (m.Groups.Count > 1 && m.Groups[1].Value.Contains("(Page ~)"))
|
||||
_Config = "<Config><Transition Formatted=\"True\" /></Config>";
|
||||
else
|
||||
_Config = string.Empty;
|
||||
_LastChanged = Transition.Add(cn, ref _TransitionID, myContent, _MyItemToID, _MyItemRangeID, _IsRange, _TranType, _Config, _DTS, _UserID);
|
||||
MarkOld();
|
||||
}
|
||||
|
Reference in New Issue
Block a user