From de9081036c80b484ee1f8dced99ccae715a6b041 Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 1 Sep 2009 14:25:59 +0000 Subject: [PATCH] --- .../Config/ROFSTLookup.cs | 42 ++++++++++++++----- .../Extension/ContentExt.cs | 11 +++++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index eae53a15..dbcb0e2d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -94,7 +94,7 @@ namespace VEPROMS.CSLA.Library _ROFstInfo = null; using (ROFstInfo rfi = ROFstInfo.Get(_ROFst.ROFstID)) { - _DocVersionInfo = DocVersionInfo.Get(rfi.docVer.VersionID); + _DocVersionInfo = rfi.docVer==null?null: DocVersionInfo.Get(rfi.docVer.VersionID); } ParseIntoDictionary(rofst.ROLookup); } @@ -102,15 +102,19 @@ namespace VEPROMS.CSLA.Library { _ROFstInfo = rofstinfo; _ROFst = null; - _DocVersionInfo = DocVersionInfo.Get(_ROFstInfo.docVer.VersionID); + // docversion will be null if we're working with an ro.fst that is not currently connected + // to a docversion. One example of this is when updating ro.fst and comparing the original + // with the new to find differences. The docversioninfo is only used to get unit/master + // slave info, thus is not needed to compare the raw values. + _DocVersionInfo = _ROFstInfo.docVer==null?null: DocVersionInfo.Get(_ROFstInfo.docVer.VersionID); ParseIntoDictionary(rofstinfo.ROLookup); } #endregion #region PropertiesAndData public roHdr myHdr; private int TableID; - private HybridDictionary dicRos; - private HybridDictionary dicRosIntIDs; + private Dictionary dicRos; + private Dictionary dicRosIntIDs; #endregion #region AppSupport public void Close() @@ -121,6 +125,22 @@ namespace VEPROMS.CSLA.Library if (dicRos != null)dicRos.Clear(); dicRos = null; } + public List GetValueDifferences(ROFSTLookup origROFst, ref List delList) + { + // use this list to see what differences are between it and the original + List modList = new List(); + // assume each rofstlookup has a parsed dictionary + foreach (string key in origROFst.dicRos.Keys) + { + string cvalue = null; + string ovalue = origROFst.dicRos[key].value; + if (dicRos.ContainsKey(key)) cvalue = dicRos[key].value; + if (cvalue == null && cvalue != ovalue) + delList.Add(key); + else if (cvalue != ovalue) modList.Add(key); + } + return modList; + } //public static ROImageInfo Get(RODbInfo rodbinfo, string filename) //{ // if (rodbinfo.RODbROImageCount != 0) @@ -138,7 +158,7 @@ namespace VEPROMS.CSLA.Library { if (dicRos == null) ParseIntoDictionary(_ROFst!=null?_ROFst.ROLookup:_ROFstInfo.ROLookup); // Use the ROID to get the value from the dictionary - if (dicRos.Contains(ROID)) + if (dicRos.ContainsKey(ROID)) { rochild rochld = (rochild)dicRos[ROID]; return rochld.value; @@ -149,7 +169,7 @@ namespace VEPROMS.CSLA.Library { if (dicRos == null) ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup); // Use the ROID to get the value from the dictionary - if (dicRos.Contains(ROID)) + if (dicRos.ContainsKey(ROID)) { rochild rochld = (rochild)dicRos[ROID]; return rochld; @@ -162,7 +182,7 @@ namespace VEPROMS.CSLA.Library { if (dicRosIntIDs == null) ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup); // Use the id to get the value from the dictionary - if (dicRosIntIDs.Contains(id)) + if (dicRosIntIDs.ContainsKey(id)) { rochild rochld = (rochild)dicRosIntIDs[id]; return rochld; @@ -369,7 +389,7 @@ namespace VEPROMS.CSLA.Library tmp.appid = tmpg.appid; tmp.roid = TableID.ToString("X4") + tmp.ID.ToString("X8"); dicRos.Add(tmp.roid, tmp); - if (!dicRosIntIDs.Contains(tmp.ID)) dicRosIntIDs.Add(tmp.ID, tmp); + if (!dicRosIntIDs.ContainsKey(tmp.ID)) dicRosIntIDs.Add(tmp.ID, tmp); int j; for (j = i - 1; j >= 0 && tmp.ID < myGrp.children[j].ID; j--) { @@ -437,8 +457,8 @@ namespace VEPROMS.CSLA.Library private void ParseIntoDictionary(byte[] ab) { - if (dicRos == null) dicRos = new HybridDictionary(); - if (dicRosIntIDs == null) dicRosIntIDs = new HybridDictionary(); + if (dicRos == null) dicRos = new Dictionary(); + if (dicRosIntIDs == null) dicRosIntIDs = new Dictionary(); myHdr.hSize = BitConverter.ToInt32(ab, 0); myHdr.hYear = BitConverter.ToInt16(ab, 4); @@ -477,7 +497,7 @@ namespace VEPROMS.CSLA.Library { lstRoValues = new List(); DictROVar = new Dictionary(); // set up a dictionary of RO defined Variables - string tmp = ProcessRO(_DocVersionInfo.ProcessDocVersionSpecificInfo(roval), false); + string tmp = _DocVersionInfo==null?roval:ProcessRO(_DocVersionInfo.ProcessDocVersionSpecificInfo(roval), false); if (lstRoValues.Count == 0) // was not a multiple return value lstRoValues.Add(tmp); return lstRoValues; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs index 1c562eb9..f7bb350c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs @@ -28,6 +28,17 @@ namespace VEPROMS.CSLA.Library Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length); } } + public void FixContentText(RoUsageInfo rousg, string newvalue) + { + string lookFor = string.Format(@"", rousg.ROUsageID); + Match m = Regex.Match(Text, lookFor); + if (m != null && m.Groups.Count > 1) + { + System.Text.RegularExpressions.Group g = m.Groups[1]; + if (g.ToString() != newvalue) + Text = Text.Substring(0, g.Index) + newvalue + Text.Substring(g.Index + g.Length); + } + } } public partial class ContentInfo {