diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index 44cc93e4..e8a86f57 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -34,19 +34,19 @@ namespace VEPROMS.CSLA.Library //public static int CacheCountList //{ get { return _CacheList.Count; } } - [NonSerialized] - private ROFSTLookup _ROFSTLookup; - public ROFSTLookup ROFSTLookup - { - get - { - if (_ROFSTLookup == null) - { - _ROFSTLookup = new ROFSTLookup(this); - } - return _ROFSTLookup; - } - } + //[NonSerialized] + //private ROFSTLookup _ROFSTLookup; + //public ROFSTLookup ROFSTLookup + //{ + // get + // { + // if (_ROFSTLookup == null) + // { + // _ROFSTLookup = new ROFSTLookup(this); + // } + // return _ROFSTLookup; + // } + //} public static ROFst GetJustROFst(int rOFstID) { if (!CanGetObject()) @@ -138,37 +138,44 @@ namespace VEPROMS.CSLA.Library private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion #region PropertiesAndData - private DocVersionInfo _docVer; - public DocVersionInfo docVer - { - get - { - if (_docVer == null) - { - if (ROFstAssociations.Count == 0) return null; -// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID); - _docVer = this.ROFstAssociations[0].MyDocVersion; - } - return _docVer; - } - set - { - _docVer = value; +// private DocVersionInfo _docVer; +// public DocVersionInfo docVer +// { +// get +// { +// if (_docVer == null) +// { +// if (ROFstAssociations.Count == 0) return null; +//// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID); +// _docVer = this.ROFstAssociations[0].MyDocVersion; +// } +// return _docVer; +// } +// set +// { +// _docVer = value; - } - } - [NonSerialized] - private ROFSTLookup _ROFSTLookup; - public ROFSTLookup ROFSTLookup +// } +// } + //[NonSerialized] + //private ROFSTLookup _ROFSTLookup; + //public ROFSTLookup ROFSTLookup + //{ + // get + // { + // if (_ROFSTLookup == null) + // { + // _ROFSTLookup = new ROFSTLookup(this); + // } + // return _ROFSTLookup; + // } + //} + private Dictionary dicLookups = new Dictionary(); + public ROFSTLookup GetROFSTLookup(DocVersionInfo dvi) { - get - { - if (_ROFSTLookup == null) - { - _ROFSTLookup = new ROFSTLookup(this); - } - return _ROFSTLookup; - } + if (!dicLookups.ContainsKey(dvi.VersionID)) + dicLookups.Add(dvi.VersionID, new ROFSTLookup(this, dvi)); + return dicLookups[dvi.VersionID]; } #endregion #region AppSupport @@ -183,20 +190,20 @@ namespace VEPROMS.CSLA.Library // } // return null; //} - public string GetDefaultROPrefix() - { - if (docVer != null) - return docVer.DocVersionConfig.RODefaults_setpointprefix; - else - return "SP1"; // Not Sure about this... - } - public string GetDefaultGraphicsPrefix() - { - if (docVer != null) - return docVer.DocVersionConfig.RODefaults_graphicsprefix; - else - return "IG1"; // Not Sure about this... - } + //public string GetDefaultROPrefix() + //{ + // if (docVer != null) + // return docVer.DocVersionConfig.RODefaults_setpointprefix; + // else + // return "SP1"; // Not Sure about this... + //} + //public string GetDefaultGraphicsPrefix() + //{ + // if (docVer != null) + // return docVer.DocVersionConfig.RODefaults_graphicsprefix; + // else + // return "IG1"; // Not Sure about this... + //} #region Add New Ro Fst /// /// Adds an ro.fst into a sql database. @@ -241,16 +248,16 @@ namespace VEPROMS.CSLA.Library // association object: docver.DocVersionAssociations.Add(rofst); docver.Save(); - + ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID)); // Now load any images in... type 8 - integrated graphics ro type - for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++) + for (int i = 0; i < myLookup.myHdr.myDbs.Length; i++) { // walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8: - if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null) + if (myLookup.myHdr.myDbs[i].children != null) { using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID)) { - rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);// TODO: Need to add MyImages + rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);// TODO: Need to add MyImages } } } @@ -271,7 +278,7 @@ namespace VEPROMS.CSLA.Library /// the current one. /// /// ROFst: Returns the created rofst object - public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst) + public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst, DocVersionInfo odv) { DirectoryInfo di = new DirectoryInfo(rdi.FolderPath); string rofstfilepath = rdi.FolderPath + @"\ro.fst"; @@ -284,7 +291,7 @@ namespace VEPROMS.CSLA.Library { docver.DocVersionAssociations[0].MyROFst = rofst; docver.Save(); - UpdateROValuesText(origROFst, rofst,docver.VersionID.ToString()); + UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID), odv); return rofst; } @@ -300,6 +307,7 @@ namespace VEPROMS.CSLA.Library // association object: dva.MyROFst = rofst; docver.Save(); + ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID)); // Now load any images in... type 8 - integrated graphics ro type using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID)) { @@ -308,12 +316,12 @@ namespace VEPROMS.CSLA.Library List myAddedROImages = new List(); using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID)) { - for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++) + for (int i = 0; i < myLookup.myHdr.myDbs.Length; i++) { // walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8: - if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null) + if (myLookup.myHdr.myDbs[i].children != null) { - rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages); + rfi.MigrateRoFstGraphics(rdi, myLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages); } } } @@ -323,7 +331,7 @@ namespace VEPROMS.CSLA.Library } // Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified // values, deleted ros, etc. - UpdateROValuesText(origROFst, rofst, docver.VersionID.ToString()); + UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID), odv); return rofst; } } @@ -349,13 +357,18 @@ namespace VEPROMS.CSLA.Library } return sb.ToString(); } - private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, string versionList) + private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, DocVersionInfo dvi, DocVersionInfo odv) { + string versionList = dvi.VersionID.ToString(); //DateTime dtStart = DateTime.Now; //DateTime dtLast = DateTime.Now; - ROFSTLookup origLU = new ROFSTLookup(origROFstInfo); + ROFSTLookup origLU; + if(odv != null) + origLU = new ROFSTLookup(origROFstInfo, odv); + else + origLU = new ROFSTLookup(origROFstInfo, dvi); //dtLast = ShowDuration(dtLast, "origLU"); - ROFSTLookup newLU = new ROFSTLookup(newROFst); + ROFSTLookup newLU = new ROFSTLookup(newROFst, dvi); //dtLast = ShowDuration(dtLast, "newLU"); List delList = new List(); List chgList = newLU.GetValueDifferences(origLU, ref delList); @@ -679,9 +692,9 @@ namespace VEPROMS.CSLA.Library } #endregion #endregion - public bool IsSetpointDB(int id) + public bool IsSetpointDB(int id, DocVersionInfo dvi) { - ROFSTLookup.rodbi[] dbs = ROFSTLookup.GetRODatabaseList(); + ROFSTLookup.rodbi[] dbs = GetROFSTLookup(dvi).GetRODatabaseList(); foreach (ROFSTLookup.rodbi rodbi in dbs) { if (id == rodbi.dbiID)