Removed ROFSTLookup property from ROFST class

Removed DocVersionInfo property from ROFST class
Added GetROFSTLookup method to ROFST class with a passed DocVersionInfo object
Removed un-used methods from ROFST class
Changed how ROFSTLookup object was obtained based on correct DocVersion
Added support for passing an override DocVersion ID as a 1-time fix to Braidwood data
Changed IsSetpointB method to add additional DocVersionInfo object parameter
This commit is contained in:
Rich 2014-02-07 17:38:22 +00:00
parent f864d03eec
commit d3cf9be087

View File

@ -34,19 +34,19 @@ namespace VEPROMS.CSLA.Library
//public static int CacheCountList //public static int CacheCountList
//{ get { return _CacheList.Count; } } //{ get { return _CacheList.Count; } }
[NonSerialized] //[NonSerialized]
private ROFSTLookup _ROFSTLookup; //private ROFSTLookup _ROFSTLookup;
public ROFSTLookup ROFSTLookup //public ROFSTLookup ROFSTLookup
{ //{
get // get
{ // {
if (_ROFSTLookup == null) // if (_ROFSTLookup == null)
{ // {
_ROFSTLookup = new ROFSTLookup(this); // _ROFSTLookup = new ROFSTLookup(this);
} // }
return _ROFSTLookup; // return _ROFSTLookup;
} // }
} //}
public static ROFst GetJustROFst(int rOFstID) public static ROFst GetJustROFst(int rOFstID)
{ {
if (!CanGetObject()) if (!CanGetObject())
@ -138,37 +138,44 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region PropertiesAndData #region PropertiesAndData
private DocVersionInfo _docVer; // private DocVersionInfo _docVer;
public DocVersionInfo docVer // public DocVersionInfo docVer
{ // {
get // get
{ // {
if (_docVer == null) // if (_docVer == null)
{ // {
if (ROFstAssociations.Count == 0) return null; // if (ROFstAssociations.Count == 0) return null;
// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID); //// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID);
_docVer = this.ROFstAssociations[0].MyDocVersion; // _docVer = this.ROFstAssociations[0].MyDocVersion;
} // }
return _docVer; // return _docVer;
} // }
set // set
{ // {
_docVer = value; // _docVer = value;
} // }
} // }
[NonSerialized] //[NonSerialized]
private ROFSTLookup _ROFSTLookup; //private ROFSTLookup _ROFSTLookup;
public ROFSTLookup ROFSTLookup //public ROFSTLookup ROFSTLookup
//{
// get
// {
// if (_ROFSTLookup == null)
// {
// _ROFSTLookup = new ROFSTLookup(this);
// }
// return _ROFSTLookup;
// }
//}
private Dictionary<int, ROFSTLookup> dicLookups = new Dictionary<int, ROFSTLookup>();
public ROFSTLookup GetROFSTLookup(DocVersionInfo dvi)
{ {
get if (!dicLookups.ContainsKey(dvi.VersionID))
{ dicLookups.Add(dvi.VersionID, new ROFSTLookup(this, dvi));
if (_ROFSTLookup == null) return dicLookups[dvi.VersionID];
{
_ROFSTLookup = new ROFSTLookup(this);
}
return _ROFSTLookup;
}
} }
#endregion #endregion
#region AppSupport #region AppSupport
@ -183,20 +190,20 @@ namespace VEPROMS.CSLA.Library
// } // }
// return null; // return null;
//} //}
public string GetDefaultROPrefix() //public string GetDefaultROPrefix()
{ //{
if (docVer != null) // if (docVer != null)
return docVer.DocVersionConfig.RODefaults_setpointprefix; // return docVer.DocVersionConfig.RODefaults_setpointprefix;
else // else
return "SP1"; // Not Sure about this... // return "SP1"; // Not Sure about this...
} //}
public string GetDefaultGraphicsPrefix() //public string GetDefaultGraphicsPrefix()
{ //{
if (docVer != null) // if (docVer != null)
return docVer.DocVersionConfig.RODefaults_graphicsprefix; // return docVer.DocVersionConfig.RODefaults_graphicsprefix;
else // else
return "IG1"; // Not Sure about this... // return "IG1"; // Not Sure about this...
} //}
#region Add New Ro Fst #region Add New Ro Fst
/// <summary> /// <summary>
/// Adds an ro.fst into a sql database. /// Adds an ro.fst into a sql database.
@ -241,16 +248,16 @@ namespace VEPROMS.CSLA.Library
// association object: // association object:
docver.DocVersionAssociations.Add(rofst); docver.DocVersionAssociations.Add(rofst);
docver.Save(); docver.Save();
ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID));
// Now load any images in... type 8 - integrated graphics ro type // 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: // 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)) 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. /// the current one.
/// <param name="docver" - hook into this doc version></param> /// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns> /// <returns>ROFst: Returns the created rofst object</returns>
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); DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
string rofstfilepath = rdi.FolderPath + @"\ro.fst"; string rofstfilepath = rdi.FolderPath + @"\ro.fst";
@ -284,7 +291,7 @@ namespace VEPROMS.CSLA.Library
{ {
docver.DocVersionAssociations[0].MyROFst = rofst; docver.DocVersionAssociations[0].MyROFst = rofst;
docver.Save(); docver.Save();
UpdateROValuesText(origROFst, rofst,docver.VersionID.ToString()); UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID), odv);
return rofst; return rofst;
} }
@ -300,6 +307,7 @@ namespace VEPROMS.CSLA.Library
// association object: // association object:
dva.MyROFst = rofst; dva.MyROFst = rofst;
docver.Save(); docver.Save();
ROFSTLookup myLookup = ROFstInfo.GetJustROFst(rofst.ROFstID).GetROFSTLookup(DocVersionInfo.Get(docver.VersionID));
// Now load any images in... type 8 - integrated graphics ro type // Now load any images in... type 8 - integrated graphics ro type
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID)) using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID))
{ {
@ -308,12 +316,12 @@ namespace VEPROMS.CSLA.Library
List<string> myAddedROImages = new List<string>(); List<string> myAddedROImages = new List<string>();
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID)) 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: // 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 // Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
// values, deleted ros, etc. // values, deleted ros, etc.
UpdateROValuesText(origROFst, rofst, docver.VersionID.ToString()); UpdateROValuesText(origROFst, rofst, DocVersionInfo.Get(docver.VersionID), odv);
return rofst; return rofst;
} }
} }
@ -349,13 +357,18 @@ namespace VEPROMS.CSLA.Library
} }
return sb.ToString(); 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 dtStart = DateTime.Now;
//DateTime dtLast = 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"); //dtLast = ShowDuration(dtLast, "origLU");
ROFSTLookup newLU = new ROFSTLookup(newROFst); ROFSTLookup newLU = new ROFSTLookup(newROFst, dvi);
//dtLast = ShowDuration(dtLast, "newLU"); //dtLast = ShowDuration(dtLast, "newLU");
List<string> delList = new List<string>(); List<string> delList = new List<string>();
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList); List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
@ -679,9 +692,9 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#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) foreach (ROFSTLookup.rodbi rodbi in dbs)
{ {
if (id == rodbi.dbiID) if (id == rodbi.dbiID)