Corrected processing of RO values in grids when printing individual unit of multiunit site

Added SetData method to GridInfo class to allow updating grid data
Added GetNonCached method to GridInfo class to allowing retrieving noncached grid data
Added code to retrieve noncached grid data during printing of procedure with grids
This commit is contained in:
Rich 2014-01-10 03:14:04 +00:00
parent c97f0d38e0
commit 3c7c853d00
3 changed files with 47 additions and 6 deletions

View File

@ -131,7 +131,7 @@ namespace VEPROMS.CSLA.Library
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
if (MyGrid != null)
{
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
@ -164,7 +164,7 @@ namespace VEPROMS.CSLA.Library
}
}
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
if (MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
@ -180,18 +180,30 @@ namespace VEPROMS.CSLA.Library
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(MyGrid.Data, lookForXml);
//int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(mmg.Value, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != newvalue)
// MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
if (g.ToString() != newvalue)
{
string prefix1 = MyGrid.Data.Substring(0,mmg.Index);
string prefix2 = mmg.Value.Substring(0,g.Index);
string suffix1 = MyGrid.Data.Substring(mmg.Index + mmg.Length);
string suffix2 = mmg.Value.Substring(g.Index + g.Length);
MyGrid.SetData(prefix1 + prefix2 + newvalue + suffix2 + suffix1);
break;
}
}
}
}
}
}
public void LoadNonCachedGrid()
{
_MyGrid = GridInfo.GetNonCached(ContentID);
Console.WriteLine("LoadNonCachedGrid {0},{1},{2}",ContentID,_MyGrid==null,_MyContentInfoUnique);
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace VEPROMS.CSLA.Library
{
@ -10,5 +11,29 @@ namespace VEPROMS.CSLA.Library
{
RefreshFields(myGrid);
}
public void SetData(string myData)
{
_Data = myData;
RemoveFromCache(this);
}
public static GridInfo GetNonCached(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Grid");
try
{
GridInfo tmp = DataPortal.Fetch<GridInfo>(new PKCriteria(contentID));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up GridInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GridInfo.Get", ex);
}
}
}
}

View File

@ -427,6 +427,8 @@ namespace VEPROMS.CSLA.Library
itemInfo.ActiveSection = sectionInfo;
itemInfo.MyProcedure = procInfo;
itemInfo.MyDocVersion = docVersionInfo;
if (itemInfo.MyContent.ContentGridCount > 0)
itemInfo.MyContent.LoadNonCachedGrid();
if (itemInfo.MyContent.ContentPartCount > 0)
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
foreach (ItemInfo ii in pi.MyItems)
@ -460,6 +462,8 @@ namespace VEPROMS.CSLA.Library
ROFSTLookup lookup = rofstinfo.ROFSTLookup;
lookup.DocVersionInfo = docVersionInfo;
//DateTime dts = DateTime.Now;
if (itemInfo.MyContent.ContentGridCount > 0)
itemInfo.MyContent.LoadNonCachedGrid();
if (itemInfo.MyContent.ContentRoUsageCount > 0)
{
foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages)