B2022-026 RO Memory reduction coding

This commit is contained in:
2022-05-26 19:55:07 +00:00
parent 61febac1a0
commit 27993553cb
21 changed files with 6827 additions and 5160 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -48,10 +48,13 @@ namespace VEPROMS.CSLA.Library
get
{
if (DocVersionAssociations == null || DocVersionAssociations.Count == 0) return false;
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) return false;
FileInfo fiRofst = new FileInfo(rofstPath);
// if the database Ro.Fst is newer or if the files have identical DTS,
@@ -60,7 +63,11 @@ namespace VEPROMS.CSLA.Library
// next see if the data is the same size, i.e. byte count of record and byte count
// of file. If different sizes, the date/time stamp check will hold.
if (fiRofst.Length != roFstInfo.ROLookup.Length) return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
// B2022-026 RO Memory reduction - new logic
var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
if (bytes != null && fiRofst.Length != bytes.Length)
return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
// rofsts of the size of the file & compare bytes.
@@ -249,15 +256,18 @@ namespace VEPROMS.CSLA.Library
get
{
if (DocVersionAssociations == null || DocVersionAssociationCount==0) return false;
ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
string rofstPath = rdi.FolderPath + @"\ro.fst";
//if (!File.Exists(rofstPath)) return false;
if (!pathExists(rofstPath))
{
_MyLog.WarnFormat("RO Path '{0}' could not be found", rofstPath);
return false;
}
FileInfo fiRofst = new FileInfo(rofstPath);
// if the database Ro.Fst is newer or if the files have identical DTS,
@@ -265,14 +275,21 @@ namespace VEPROMS.CSLA.Library
// put this in a dictionary so we don't have to keep testing to see if the file version of ro.fst is newer than database version
string key = string.Format("{0}-{1}", DocVersionAssociations[0].ROFstID, fiRofst.LastWriteTimeUtc);
if (NewerRoFstLookup.ContainsKey(key)) return NewerRoFstLookup[key];
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return AddToRoFstLookup(key, false);
TimeSpan ts = roFstInfo.DTS - fiRofst.LastWriteTimeUtc;
if (ts.TotalSeconds > -1F) return AddToRoFstLookup(key, false);
// next see if the data is the same size, i.e. byte count of record and byte count
// of file. If different sizes, the date/time stamp check will hold.
if (fiRofst.Length != roFstInfo.ROLookup.Length) return AddToRoFstLookup(key,fiRofst.LastWriteTimeUtc > roFstInfo.DTS);
// B2022-026 RO Memory reduction - new logic
var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
if (bytes != null && fiRofst.Length != bytes.Length)
return AddToRoFstLookup(key, fiRofst.LastWriteTimeUtc > roFstInfo.DTS);
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
// rofsts of the size of the file & compare bytes.

View File

@@ -326,26 +326,31 @@ namespace VEPROMS.CSLA.Library
public partial class ItemInfo : IVEDrillDownReadOnly
{
private bool _PrintAllAtOnce = false;
public bool PrintAllAtOnce
{
get { return _PrintAllAtOnce; }
set { _PrintAllAtOnce = value; }
}
public SectionInfo GetSectionInfo()
{
if (this is SectionInfo) return this as SectionInfo;
return SectionInfo.Get(ItemID);
}
public StepInfo GetStepInfo()
{
if (this is StepInfo) return this as StepInfo;
return StepInfo.Get(ItemID);
}
public ProcedureInfo GetProcedureInfo()
{
if (this is ProcedureInfo) return this as ProcedureInfo;
return ProcedureInfo.Get(ItemID);
}
private string _EnhType = null;
public string EnhType
{
@@ -379,10 +384,12 @@ namespace VEPROMS.CSLA.Library
if (id == ItemID) return true;
return false;
}
public static bool IsInCache(int itemID)
{
return _CacheByPrimaryKey.ContainsKey(itemID.ToString());
}
public static string ReplaceLinkWithNewID(string tmpForLink)
{
tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject:<NewID> ");
@@ -394,6 +401,7 @@ namespace VEPROMS.CSLA.Library
tmpForLink = tmpForLink.Replace(@"\u8211 ", @"-"); // Replace EN Dash with hyphen
return tmpForLink;
}
public void SetHeader(VE_Font myFont, string myText)
{
_MyHeader = new MetaTag(myFont);
@@ -402,6 +410,7 @@ namespace VEPROMS.CSLA.Library
_MyHeader.Text = myText;
_MyHeader.Justify = ContentAlignment.MiddleCenter;
}
public void MoveItem(IVEDrillDownReadOnly pInfo, int index)
{
using (ItemInfoList movedItems = ItemInfoList.GetMoveItem(ItemID, index))
@@ -416,6 +425,7 @@ namespace VEPROMS.CSLA.Library
if (parentInfo != null)
ItemInfo.ResetParts(parentInfo.ItemID);
}
public static void Refresh(ItemInfo tmp)
{
string key = tmp.ItemID.ToString();
@@ -424,6 +434,7 @@ namespace VEPROMS.CSLA.Library
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemInfo tmp)
{
if (_PreviousID != tmp.PreviousID)
@@ -574,6 +585,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
/// <summary>
/// The following method is used only in print because the 'printed' data is loaded into
/// memory before printing. Find the next item from memory (do not go out to database).
@@ -596,43 +608,35 @@ namespace VEPROMS.CSLA.Library
}
return null;
}
public static void ResetTranCounters()
{
TranCheckCount = 0;
TranFixCount = 0;
TranConvertCount = 0;// B2018-002 - Invalid Transitions - Initialize Transition Conversion Count
}
public static int TranCheckCount = 0;
public static int TranFixCount = 0;
public static int TranConvertCount = 0;// B2018-002 - Invalid Transitions - Declare Transition Conversion Count
internal static TransitionInfoList TransitionsToDisconnected;
internal static TransitionInfoList TransitionsToNonEditable;
internal static void MyRefreshTransitions(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{
//TransitionInfoList til = TransitionInfoList.GetByFromID(itemInfo.ItemID);
//Console.WriteLine("Procedure: {0}, transitions: {1}", (itemInfo as ProcedureInfo).DisplayNumber, til.Count);
//foreach (TransitionInfo traninfo in til)
//{
// string oldText = itemInfo.MyContent.Text;
// itemInfo.MyContent.FixTransitionText(traninfo, tranLookup);
// string newText = itemInfo.MyContent.Text;
// if (newText != oldText)
// {
// Content content = Content.Get(itemInfo.MyContent.ContentID);
// content.FixTransitionText(traninfo);
// content.Save();
// }
//}
if (itemInfo == null) return;
if (itemInfo.MyContent.ContentPartCount > 0)
{
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
{
//List<ItemInfo> myItems = new List<ItemInfo>();
foreach (ItemInfo ii in pi.MyItems)
// myItems.Add(ii);
//foreach (ItemInfo ii in myItems)
{
MyRefreshTransitions(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo, tranLookup);
}
}
}
// B2018-002 - Invalid Transitions - Convert Invalid Transitions to Text
// An invalid transition is a transition embedded in the content text that does not match the transition table record.
if(ConvertInvalidTransitionsToText(itemInfo))
@@ -642,18 +646,7 @@ namespace VEPROMS.CSLA.Library
{
bool forceConvertToText = false;
TranCheckCount++;
//if (TransitionsToNonEditable != null)
//{
// if (IsTransitionToNonEditable(traninfo))
// {
// forceConvertToText = true;
// TranFixCount++;
// itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Non-Editable Step");
// Content content = Content.Get(itemInfo.MyContent.ContentID);
// content.FixTransitionText(traninfo, true);
// content.Save();
// }
//}
if (!forceConvertToText)
{
if (traninfo.MyItemToID.ActiveSection != null)
@@ -661,6 +654,7 @@ namespace VEPROMS.CSLA.Library
SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig;
forceConvertToText = (sc.SubSection_Edit == "N" && traninfo.MyItemToID.IsStep); // Bug fix B2016-081 also check if transition is to a step element
}
if (forceConvertToText)
{
TranFixCount++;
@@ -670,11 +664,14 @@ namespace VEPROMS.CSLA.Library
content.Save();
}
}
if (!forceConvertToText)
{
if (itemInfo.MyProcedure.ItemID != traninfo.MyItemToID.MyProcedure.ItemID) //different proc
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
if (itemInfo.MyProcedure.ItemID != traninfo.MyItemToID.MyProcedure.ItemID) //different proc
{
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
{
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
{
forceConvertToText = true;
TranFixCount++;
@@ -683,13 +680,17 @@ namespace VEPROMS.CSLA.Library
content.FixTransitionText(traninfo, true);
content.Save();
}
}
}
}
if (!forceConvertToText)
{
if (itemInfo.MyDocVersion != null && traninfo.MyItemToID.MyDocVersion != null && itemInfo.MyDocVersion.VersionID != traninfo.MyItemToID.MyDocVersion.VersionID) //different doc version
{
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
{
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
{
forceConvertToText = true;
TranFixCount++;
@@ -698,8 +699,10 @@ namespace VEPROMS.CSLA.Library
content.FixTransitionText(traninfo, true);
content.Save();
}
}
}
}
if (!forceConvertToText)
{
string oldText = itemInfo.MyContent.Text;
@@ -718,6 +721,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
// // B2018-002 - Invalid Transitions - Method to check for invalid transitions and convert them to text
public static bool ConvertInvalidTransitionsToText(ItemInfo itemInfo)
{
@@ -729,25 +733,30 @@ namespace VEPROMS.CSLA.Library
retval = false;
if (itemInfo.MyContent.Text.Contains("Link:Transition"))
{
//Console.WriteLine("\"TranCount\"\t\"{0}\"\t{1}\t{2}\t{3}", itemInfo.ShortPath, itemInfo.ItemID, mc.Count, itemInfo.MyContent.ContentTransitionCount);
Content content = Content.Get(itemInfo.MyContent.ContentID);
//if (itemInfo.InList(616031, 615898, 5516866))
// Console.WriteLine("here");
if (itemInfo.MyContent.ContentTransitions != null)
{
foreach (TransitionInfo ct in itemInfo.MyContent.ContentTransitions)
{
Transition.Delete(ct.TransitionID);
}
}
itemInfo.MyContent.RefreshContentTransitions();
//if (content.Text.Contains("Link:TransitionRange"))
// Console.WriteLine("Here");
while (content.Text.Contains("Link:Transition"))
{
TranCheckCount++;
TranConvertCount++;
if (content.FixTransitionText(null, true))
{
ContentInfo.OnStaticContentInfoChange(itemInfo, new StaticContentInfoEventArgs("", "", ""));
if (itemInfo.MyContent.MyGrid != null)
{
content.ConvertTransitionToTextInGrid(null, null);
}
content.Save();
}
else // B2018-043 Eliminate infinite loop for invalid transition structure
@@ -759,14 +768,21 @@ namespace VEPROMS.CSLA.Library
}
}
}
// B2021-008: Delete the transition record if there is no link in the text
if (mc.Count == 0 && itemInfo.MyContent.ContentTransitionCount > 0)
{
TranCheckCount++;
TranFixCount++;
if (itemInfo.MyContent.ContentTransitions != null)
{
foreach (TransitionInfo ct in itemInfo.MyContent.ContentTransitions)
{
Transition.Delete(ct.TransitionID);
}
}
itemInfo.MyContent.RefreshContentTransitions();
}
@@ -800,10 +816,12 @@ namespace VEPROMS.CSLA.Library
string txt = myContent.Text;
string regDelete = @"(\\v |)\<START\]\#Link\:Transition(|Range)\:[0-9]+ [0-9]+ [0-9]+(| [0-9]+)\[END\>(\\v0 |)";
string txt2=txt;
do{
txt = txt2;
txt2 = Regex.Replace(txt, regDelete, "");
} while(txt2 != txt);
if(txt2 != myContent.Text)
{
using(Content tmp = myContent.Get())
@@ -814,15 +832,7 @@ namespace VEPROMS.CSLA.Library
AddInvalidTransitionAnnotation(itemInfo, "Removed Empty Transition Text");
}
}
//private static bool IsTransitionToDisconnected(TransitionInfo ti)
//{
// foreach (TransitionInfo til in TransitionsToDisconnected)
// {
// if (ti.TransitionID == til.TransitionID)
// return true;
// }
// return false;
//}
private static bool IsTransitionToNonEditable(TransitionInfo ti)
{
foreach (TransitionInfo til in TransitionsToNonEditable)
@@ -832,32 +842,39 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public static void ResetROCounters()
{
ROCheckCount = 0;
ROFixCount = 0;
}
public static int ROCheckCount = 0;
public static int ROFixCount = 0;
private static AnnotationType _VolianCommentType = null; // Using this to flag ro value issues with byron to braidwood
public static AnnotationType VolianCommentType
{
get
{
if (_VolianCommentType == null)
_VolianCommentType = AnnotationType.GetByName("Volian Comment");
if (_VolianCommentType == null)
_VolianCommentType = AnnotationType.MakeAnnotationType("Volian Comment", null);
return _VolianCommentType;
}
}
public void UpdateROText()
{
if (this.MyDocVersion.DocVersionAssociationCount == 0) return;
ROFstInfo rofstinfo = this.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup lookup = rofstinfo.GetROFSTLookup(this.MyDocVersion);
lookup.MyDocVersionInfo = this.MyDocVersion;
lookup.MyItemInfo = this; // B2022-020 to pass information into error log if needed
if (this.MyContent.ContentRoUsageCount > 0)
{
foreach (RoUsageInfo rousage in this.MyContent.ContentRoUsages)
@@ -878,33 +895,39 @@ namespace VEPROMS.CSLA.Library
using (Item myitem = content.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when RO is converted to text
// B2016-225 (follow through) added more descriptive Annotation Type when RO is converted to text
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
}
}
else
{
content.FixContentText(rousage, roval, roch.type, rofstinfo);
}
content.Save();
}
}
}
}
}
internal static void MyRefreshReferenceObjects(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo)
// B2022-026 RO Memory Reduction code - pass in ROFstInfo
internal static void MyRefreshReferenceObjects(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, ROFstInfo origROFst)
{
if (itemInfo.MyContent.ContentPartCount > 0)
{
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
{
//List<ItemInfo> myItems = new List<ItemInfo>();
foreach (ItemInfo ii in pi.MyItems)
// myItems.Add(ii);
//foreach (ItemInfo ii in myItems)
MyRefreshReferenceObjects(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo);
{
MyRefreshReferenceObjects(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo, origROFst);
}
}
ROFstInfo rofstinfo = docVersionInfo.DocVersionAssociations[0].MyROFst;
ROFSTLookup lookup = rofstinfo.GetROFSTLookup(docVersionInfo);
lookup.MyDocVersionInfo = docVersionInfo;
}
// B2022-026 RO Memory Reduction code - get ROLookup from passed in ROFstInfo
ROFSTLookup lookup = origROFst.GetROFSTLookup(docVersionInfo);
lookup.MyItemInfo = itemInfo; // B2022-020 to pass information into error log if needed
if (itemInfo.MyContent.ContentRoUsageCount > 0)
{
foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages)
@@ -915,8 +938,9 @@ namespace VEPROMS.CSLA.Library
string oldText = itemInfo.MyContent.Text;
string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
itemInfo.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, itemInfo);
itemInfo.MyContent.FixContentText(rousage, roval, roch.type, origROFst, itemInfo);
string newText = itemInfo.MyContent.Text;
if (DifferentROtext(newText,oldText))
{
//ShowDifference(oldText, newText); // debug - display in Visual Studio Output window
@@ -924,7 +948,7 @@ namespace VEPROMS.CSLA.Library
Content content = Content.Get(itemInfo.MyContent.ContentID);
if (roval == "?")
{
oldText = content.ConvertROToText(rousage, roval, roch.type, rofstinfo);
oldText = content.ConvertROToText(rousage, roval, roch.type, origROFst);
using (Item myitem = content.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
@@ -934,7 +958,7 @@ namespace VEPROMS.CSLA.Library
}
else
{
content.FixContentText(rousage, roval, roch.type, rofstinfo);
content.FixContentText(rousage, roval, roch.type, origROFst);
}
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
@@ -949,12 +973,17 @@ namespace VEPROMS.CSLA.Library
{
string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
string ot = oldText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
if (nt.Equals(ot))
{
return false;
}
return true;
}
#region debug
#region Debug Code
//private static void ShowDifference(string oldText, string newText)
//{
// string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
@@ -974,7 +1003,9 @@ namespace VEPROMS.CSLA.Library
// }
// Console.WriteLine("{0}='{1}'",title,sb.ToString());
//}
#endregion // debug
internal static void SetParentSectionAndDocVersionPageNum(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{
if (itemInfo.MyContent.ContentPartCount > 0)
@@ -995,21 +1026,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
//internal static long ticksROUsage;
//internal static long ticksItems;
//internal static long ticksTrans;
//internal static void ResetTicks()
//{
// ticksROUsage = 0;
// ticksItems = 0;
// ticksTrans = 0;
//}
//internal static void ShowTicks()
//{
// Console.WriteLine("ROUsage: {0}", TimeSpan.FromTicks(ticksROUsage).TotalSeconds);
// Console.WriteLine("Items: {0}", TimeSpan.FromTicks(ticksItems).TotalSeconds);
// Console.WriteLine("Transitions: {0}", TimeSpan.FromTicks(ticksTrans).TotalSeconds);
//}
public static string GetCombinedTab(ItemInfo itemInfo, string parTab)
{
string pTab = parTab == null ? "" : parTab;
@@ -1034,6 +1051,7 @@ namespace VEPROMS.CSLA.Library
if (itemInfo.HasParentTab) return thisTab.Trim(); // F2020-023: if tab includes parent tab already, don't concatenate it
return pTab + thisTab.Trim();
}
internal static void SetParentSectionAndDocVersion(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{
if (itemInfo == null) return;
@@ -1044,17 +1062,20 @@ namespace VEPROMS.CSLA.Library
itemInfo.ActiveSection = sectionInfo;
itemInfo.ActiveFormat = itemInfo.MyContent.MyFormat != null ? itemInfo.MyContent.MyFormat : sectionInfo == null ? itemParent.ActiveFormat : sectionInfo.ActiveFormat;
itemInfo.MyDocVersion = docVersionInfo;
if (itemInfo.IsStep)
{
ItemInfo ip = itemParent as ItemInfo;
itemInfo.CombinedTab = (ip == null) ? itemInfo.MyTab.CleanText.Trim() : GetCombinedTab(itemInfo, ip.CombinedTab);
}
if (docVersionInfo.DocVersionAssociationCount == 1)
{
string otherChildUnit = null;
ROFstInfo rofstinfo = docVersionInfo.DocVersionAssociations[0].MyROFst;
//rofstinfo.docVer = docVersionInfo;
string rawPrcNum = itemInfo.MyProcedure.MyContent.Number;
// C2022-001 see if we need to get the Other child info from ROLookUp
if (rawPrcNum.ToUpper().StartsWith("<U\\U8209?OTHER")) // proc number has <u-otherxxx> in its definiation (procedure property page)
{
@@ -1064,11 +1085,11 @@ namespace VEPROMS.CSLA.Library
}
ROFSTLookup lookup = rofstinfo.GetROFSTLookup(docVersionInfo, otherChildUnit);
lookup.MyDocVersionInfo = docVersionInfo;
lookup.MyItemInfo = itemInfo; // B2022-020 to pass information into error log if needed
//DateTime dts = DateTime.Now;
if (itemInfo.MyContent.ContentGridCount > 0)
itemInfo.MyContent.LoadNonCachedGrid();
if (itemInfo.MyContent.ContentRoUsageCount > 0)
{
foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages)
@@ -1087,39 +1108,27 @@ namespace VEPROMS.CSLA.Library
// Force Error Message
docVersionInfo.GetROFst(0);
}
//TimeSpan ts = DateTime.Now.Subtract(dts);
//ticksROUsage += ts.Ticks;
//dts = DateTime.Now;
if (itemInfo.MyContent.ContentPartCount > 0)
{
foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
{
//ItemInfo il = null;
foreach (ItemInfo ii in pi.MyItems)
{
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo, tranLookup);
//if(ii._MyPrevious == null)
// ii.MyPrevious = il;
//if (il != null) il.NextItem = ii;
//il = ii;
}
}
}
//ts = DateTime.Now.Subtract(dts);
//ticksItems += ts.Ticks;
//dts = DateTime.Now;
if (itemInfo.MyContent.ContentTransitionCount > 0)
{
//itemInfo.UpdateTransitionText();
foreach (TransitionInfo traninfo in itemInfo.MyContent.ContentTransitions)
{
//itemInfo.UpdateTransitionText();
itemInfo.MyContent.FixTransitionText(traninfo, tranLookup, itemInfo);
}
}
//ts = DateTime.Now.Subtract(dts);
//ticksTrans += ts.Ticks;
}
private int _PrintBias = 0;
public int PrintBias
{
@@ -7127,10 +7136,11 @@ namespace VEPROMS.CSLA.Library
if (tmp.MyDocVersion.DocVersionConfig.SelectedSlave <= 0)
MyRefreshTransitions(tmp, tmp.MyDocVersion, null, tmp, tmp.MyDocVersion, tranLookup);
}
public static void RefreshReferenceObjects(ProcedureInfo tmp)
// B2022-026 RO Memory Reduction code - added ROFstInfo parameter
public static void RefreshReferenceObjects(ProcedureInfo tmp, ROFstInfo origROFst)
{
if (tmp.MyDocVersion.DocVersionConfig.SelectedSlave <= 0)
MyRefreshReferenceObjects(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion);
MyRefreshReferenceObjects(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion, origROFst);
}
public static void RefreshPageNumTransitions(ProcedureInfo tmp)
{

View File

@@ -16,6 +16,7 @@ namespace VEPROMS.CSLA.Library
Procedure = 0, Document = 1, DocVersion = 2, Folder = 3, Session = 4
}
#endregion
#region SessionInfoList stuff
public partial class SessionInfoList
{
@@ -67,6 +68,7 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region SessionInfo stuff
public partial class SessionInfo
{
@@ -750,6 +752,7 @@ namespace VEPROMS.CSLA.Library
#endregion
}
#endregion
#region OwnerInfo stuff
public partial class OwnerInfoList
{
@@ -1072,29 +1075,36 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region UserInfo stuff
public partial class UserInfo
{
public static bool CanEdit(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo!=null && myDVI!=null && (myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsWriter(myDVI));
}
public static bool CanEditROs(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsROEditor(myDVI);
}
public static bool CanCreateFolders(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI);
}
public static bool CanCreateFolders(UserInfo myUserInfo, FolderInfo fi)
{
return myUserInfo != null && fi != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(fi.MyParent); //B2020-111 allow if set amin controls parent
}
public bool IsAdministrator()
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1108,6 +1118,7 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
//B2020-111, B2020-114, C2020-035 this was setting the passed in parameter, such that the first time this
// was called, the passed in parameter was set to the top node (VEPROMS). The check of other folders
// would then be skipped (from where is called)
@@ -1115,6 +1126,7 @@ namespace VEPROMS.CSLA.Library
{
if (this.UserMembershipCount == 0 || fldinf == null)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1137,10 +1149,12 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public bool IsSetAdministrator(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1162,10 +1176,12 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public bool IsWriter(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1187,10 +1203,12 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public bool IsReviewer(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1212,10 +1230,12 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public bool IsROEditor(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
@@ -1237,6 +1257,7 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
// B2018-112 added for easy check if user's PROMS Security allows making edits - used in StepTabRibbon - SetButtonAndMenuEnabling()
public bool IsAllowedToEdit(DocVersionInfo dvi)
{
@@ -1259,6 +1280,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on UserInfo.GetByUserID", ex);
}
}
[Serializable()]
protected class GetByUserIDCriteria
{
@@ -1270,6 +1292,7 @@ namespace VEPROMS.CSLA.Library
_UserID = userID;
}
}
private void DataPortal_Fetch(GetByUserIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.DataPortal_Fetch", GetHashCode());
@@ -1307,5 +1330,6 @@ namespace VEPROMS.CSLA.Library
}
}
}
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -435,7 +435,8 @@ namespace VEPROMS.CSLA.Library
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROLookup = (byte[])dr.GetValue("ROFst_ROLookup");
//_ROFst_ROLookup = (byte[])dr.GetValue("ROFst_ROLookup");
_ROFst_ROLookup = null; // B2022-026 RO Memory reduction - use ROlookup of null to know if we loaded the RO.FST file
_ROFst_Config = dr.GetString("ROFst_Config");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");

View File

@@ -81,12 +81,20 @@ namespace VEPROMS.CSLA.Library
}
ClearRefreshList();
}
#endregion
#region Collection
private static List<ROFst> _CacheList = new List<ROFst>();
protected static void AddToCache(ROFst rOFst)
{
if (!_CacheList.Contains(rOFst)) _CacheList.Add(rOFst); // In AddToCache
if (!_CacheList.Contains(rOFst))
{
rOFst.ROLookup = null; // B2022-026 RO Memory reduction
_CacheList.Add(rOFst); // In AddToCache
}
}
protected static void RemoveFromCache(ROFst rOFst)
{
@@ -105,6 +113,7 @@ namespace VEPROMS.CSLA.Library
_CacheByPrimaryKey[pKey] = new List<ROFst>(); // Add new list for PrimaryKey
_CacheByRODbID_DTS[tmp.RODbID.ToString() + "_" + tmp.DTS.ToString()] = new List<ROFst>(); // Add new list for RODbID_DTS
}
tmp.ROLookup = null; // B2022-026 RO Memory reduction
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheByRODbID_DTS[tmp.RODbID.ToString() + "_" + tmp.DTS.ToString()].Add(tmp); // Unique Index
_CacheList.RemoveAt(0); // Remove the first ROFst
@@ -124,8 +133,11 @@ namespace VEPROMS.CSLA.Library
if (_CacheByRODbID_DTS.ContainsKey(key)) return _CacheByRODbID_DTS[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
@@ -180,14 +192,21 @@ namespace VEPROMS.CSLA.Library
}
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROLookup", true);
return _ROLookup;
return null; // B2022-026 RO Memory reduction
//if (_ROLookup == null)
//{
// _ROLookup = ROFSTLookup.GetRofstLookupBytes(_ROFstID);
//}
//return _ROLookup;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
@@ -200,6 +219,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
private string _Config = string.Empty;
public string Config
{
@@ -557,6 +577,7 @@ namespace VEPROMS.CSLA.Library
_Disposed = true;
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
@@ -580,6 +601,7 @@ namespace VEPROMS.CSLA.Library
_CacheByRODbID_DTS.Remove(myKey); // remove the list
}
}
public static ROFst New()
{
if (!CanAddObject())
@@ -593,6 +615,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on ROFst.New", ex);
}
}
public static ROFst New(RODb myRODb, byte[] rOLookup)
{
ROFst tmp = ROFst.New();
@@ -600,6 +623,7 @@ namespace VEPROMS.CSLA.Library
tmp.ROLookup = rOLookup;
return tmp;
}
public static ROFst New(RODb myRODb, byte[] rOLookup, string config, DateTime dts, string userID)
{
ROFst tmp = ROFst.New();
@@ -610,22 +634,7 @@ namespace VEPROMS.CSLA.Library
tmp.UserID = userID;
return tmp;
}
public static ROFst MakeROFst(RODb myRODb, byte[] rOLookup, string config, DateTime dts, string userID)
{
ROFst tmp = ROFst.New(myRODb, rOLookup, config, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static ROFst New(RODb myRODb, byte[] rOLookup, string config)
{
ROFst tmp = ROFst.New();
@@ -634,11 +643,23 @@ namespace VEPROMS.CSLA.Library
tmp.Config = config;
return tmp;
}
public static ROFst MakeROFst(RODb myRODb, byte[] rOLookup, string config)
public static ROFst MakeROFst(RODb myRODb, byte[] rOLookup, string config, DateTime dts, string userID)
{
ROFst tmp = ROFst.New(myRODb, rOLookup, config);
ROFst tmp = ROFst.New(myRODb, rOLookup, config, dts, userID);
if (tmp.IsSavable)
{
tmp = tmp.Save();
// B2022-026 RO Memory reduction
if (tmp.ROLookup != null && tmp.ROFstID > 0)
{
//Force Load the new Lookup Data
var RofstLookup = new ROFSTLookup(tmp.ROFstID);
tmp.ROLookup = null;
}
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
@@ -648,8 +669,36 @@ namespace VEPROMS.CSLA.Library
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static ROFst MakeROFst(RODb myRODb, byte[] rOLookup, string config)
{
ROFst tmp = ROFst.New(myRODb, rOLookup, config);
if (tmp.IsSavable)
{
tmp = tmp.Save();
// B2022-026 RO Memory reduction
//Force Load the new Lookup Data
var RofstLookup = new ROFSTLookup(tmp.ROFstID);
tmp.ROLookup = null;
}
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static ROFst Get(int rOFstID)
{
if (!CanGetObject())
@@ -662,11 +711,13 @@ namespace VEPROMS.CSLA.Library
tmp = DataPortal.Fetch<ROFst>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFst
tmp = null;
}
return tmp;
}
catch (Exception ex)
@@ -674,6 +725,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on ROFst.Get", ex);
}
}
public static ROFst GetByRODbID_DTS(int rODbID, DateTime dts)
{
if (!CanGetObject())
@@ -735,6 +787,7 @@ namespace VEPROMS.CSLA.Library
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(rOFst);//Refresh the item in AllList
ProcessRefreshList();
rOFst.ROLookup = null; // B2022-026 RO Memory reduction
return rOFst;
}
catch (Exception ex)
@@ -781,6 +834,7 @@ namespace VEPROMS.CSLA.Library
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.ReadData", GetHashCode());
@@ -788,7 +842,8 @@ namespace VEPROMS.CSLA.Library
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROLookup = (byte[])dr.GetValue("ROLookup");
//_ROLookup = (byte[])dr.GetValue("ROLookup");
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
@@ -804,6 +859,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFst.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.DataPortal_Fetch", GetHashCode());
@@ -846,6 +902,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFst.DataPortal_Fetch", ex);
}
}
private void DataPortal_Fetch(RODbID_DTSCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.DataPortal_Fetch", GetHashCode());
@@ -883,6 +940,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFst.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
@@ -908,6 +966,7 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
@@ -921,12 +980,14 @@ namespace VEPROMS.CSLA.Library
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addROFst";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", _ROLookup);
cm.Parameters.AddWithValue("@Config", _Config);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int);
param_ROFstID.Direction = ParameterDirection.Output;
@@ -934,11 +995,15 @@ namespace VEPROMS.CSLA.Library
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_ROFstID = (int)cm.Parameters["@newROFstID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
// Clear Out Any Rofst Binary (Bytes[]) - B2022-026 RO Memory reduction
_ROLookup = null;
}
MarkOld();
// update child objects
@@ -953,6 +1018,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFst.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int rOFstID, RODb myRODb, byte[] rOLookup, string config, DateTime dts, string userID)
{
@@ -964,12 +1030,14 @@ namespace VEPROMS.CSLA.Library
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "addROFst";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RODbID", myRODb.RODbID);
cm.Parameters.AddWithValue("@ROLookup", rOLookup);
cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_ROFstID = new SqlParameter("@newROFstID", SqlDbType.Int);
param_ROFstID.Direction = ParameterDirection.Output;
@@ -977,8 +1045,12 @@ namespace VEPROMS.CSLA.Library
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Clear Out Any Rofst Binary (Bytes[]) - B2022-026 RO Memory reduction
rOLookup = null;
// Save all values being returned from the Procedure
rOFstID = (int)cm.Parameters["@newROFstID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
@@ -990,6 +1062,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFst.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
@@ -1013,6 +1086,7 @@ namespace VEPROMS.CSLA.Library
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLUpdate()
{
@@ -1029,20 +1103,23 @@ namespace VEPROMS.CSLA.Library
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "updateROFst";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ROFstID", _ROFstID);
cm.Parameters.AddWithValue("@RODbID", RODbID);
cm.Parameters.AddWithValue("@ROLookup", _ROLookup);
cm.Parameters.AddWithValue("@ROLookup", ROFSTLookup.GetRofstLookupBytes(_ROFstID)); // B2022-026 RO Memory reduction - new calls
cm.Parameters.AddWithValue("@Config", _Config);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
@@ -1059,6 +1136,7 @@ namespace VEPROMS.CSLA.Library
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update()
{
if (!this.IsDirty) return;
@@ -1074,17 +1152,23 @@ namespace VEPROMS.CSLA.Library
if (_ROFstAssociations != null) _ROFstAssociations.Update(this);
if (_ROFstFigures != null) _ROFstFigures.Update(this);
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rOFstID, int rODbID, byte[] rOLookup, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.Update", 0);
try
{
// B2022-026 RO Memory reduction - check if we need to get the rOLookup
if (rOLookup == null)
rOLookup = ROFSTLookup.GetRofstLookupBytes(rOFstID);
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandTimeout = Database.SQLTimeout;
cm.CommandText = "updateROFst";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ROFstID", rOFstID);
cm.Parameters.AddWithValue("@RODbID", rODbID);
@@ -1093,12 +1177,14 @@ namespace VEPROMS.CSLA.Library
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}

View File

@@ -39,7 +39,11 @@ namespace VEPROMS.CSLA.Library
private static List<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo)) _CacheList.Add(rOFstInfo); // In AddToCache
if (!_CacheList.Contains(rOFstInfo))
{
rOFstInfo.ClearROLookupBytes(); // B2022-026 RO Memory reduction
_CacheList.Add(rOFstInfo); // In AddToCache
}
}
protected static void RemoveFromCache(ROFstInfo rOFstInfo)
{
@@ -56,6 +60,7 @@ namespace VEPROMS.CSLA.Library
{
_CacheByPrimaryKey[pKey] = new List<ROFstInfo>(); // Add new list for PrimaryKey
}
tmp.ClearROLookupBytes(); // B2022-026 RO Memory reduction
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ROFstInfo
}
@@ -122,6 +127,7 @@ namespace VEPROMS.CSLA.Library
return _MyRODb;
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
@@ -129,9 +135,17 @@ namespace VEPROMS.CSLA.Library
get
{
CanReadProperty("ROLookup", true);
return _ROLookup;
//if (_ROLookup == null)
//{
// _ROLookup = ROFSTLookup.GetRofstLookupBytes(_ROFstID);
//}
//return _ROLookup;
// B2022-026 RO Memory reduction
return null;
}
}
private string _Config = string.Empty;
public string Config
{
@@ -238,16 +252,7 @@ namespace VEPROMS.CSLA.Library
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstFigureCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base ROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ROFstInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
@@ -256,8 +261,11 @@ namespace VEPROMS.CSLA.Library
{
return MyROFstInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
@@ -272,6 +280,7 @@ namespace VEPROMS.CSLA.Library
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
@@ -309,6 +318,12 @@ namespace VEPROMS.CSLA.Library
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
// B2022-026 RO Memory reduction
public void ClearROLookupBytes()
{
_ROLookup = null;
}
protected virtual void RefreshFields(ROFst tmp)
{
if (_RODbID != tmp.RODbID)
@@ -318,7 +333,8 @@ namespace VEPROMS.CSLA.Library
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value
_ROLookup = tmp.ROLookup;
//_ROLookup = tmp.ROLookup;
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -335,7 +351,8 @@ namespace VEPROMS.CSLA.Library
}
protected virtual void RefreshFields(RODbROFst tmp)
{
_ROLookup = tmp.ROLookup;
//_ROLookup = tmp.ROLookup;
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
@@ -344,8 +361,6 @@ namespace VEPROMS.CSLA.Library
}
public static ROFstInfo Get(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
@@ -354,11 +369,18 @@ namespace VEPROMS.CSLA.Library
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
if (tmp != null)
{
tmp.ClearROLookupBytes(); // B2022-026 RO Memory reduction
}
return tmp;
}
catch (Exception ex)
@@ -366,8 +388,11 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.Constructor", GetHashCode());
@@ -381,6 +406,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
@@ -392,6 +418,7 @@ namespace VEPROMS.CSLA.Library
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.ReadData", GetHashCode());
@@ -399,7 +426,8 @@ namespace VEPROMS.CSLA.Library
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROLookup = (byte[])dr.GetValue("ROLookup");
//_ROLookup = (byte[])dr.GetValue("ROLookup");
_ROLookup = null; // B2022-026 RO Memory reduction
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
@@ -413,6 +441,7 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.DataPortal_Fetch", GetHashCode());
@@ -449,7 +478,9 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
@@ -463,7 +494,9 @@ namespace VEPROMS.CSLA.Library
}
#endregion
} // Class
#region Converter
internal class ROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
@@ -476,5 +509,6 @@ namespace VEPROMS.CSLA.Library
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace