diff --git a/PROMS/DataLoader/RoFst.cs b/PROMS/DataLoader/RoFst.cs index 8fb4f52d..1aa4e269 100644 --- a/PROMS/DataLoader/RoFst.cs +++ b/PROMS/DataLoader/RoFst.cs @@ -90,7 +90,8 @@ namespace DataLoader { // walk through the rofst 'database' searching for // all nodes that are integrated graphics, i.e. type 8. - if (rofstinfo.ROFSTLookup.myHdr.myDbs[i].children != null) MigrateRoFstGraphics(roDbpath, rofstinfo.ROFSTLookup.myHdr.myDbs[i].children, rodb); + if (rofstinfo.ROFSTLookup.myHdr.myDbs[i].children != null) + MigrateRoFstGraphics(roDbpath, rofstinfo.ROFSTLookup.myHdr.myDbs[i].children, rodb); } } } @@ -145,24 +146,34 @@ namespace DataLoader frmMain.Status = "Processing Image " + fname; // if the roimage record exists, don't create a new one... ROImage roImg = null; + //Console.WriteLine("ROImage Key {0} List {1} ID {2}", ROImage.CacheCountPrimaryKey, ROImage.CacheCountList, ROImage.CacheCountByRODbID); + //Console.WriteLine("ROImageInfo Key {0} List {1}", ROImageInfo.CacheCountPrimaryKey, ROImageInfo.CacheCountList); + //Console.WriteLine("ROFst Key {0} List {1} ID {2}", ROFst.CacheCountPrimaryKey, ROFst.CacheCountList, ROFst.CacheCountByRODbID_DTS); + //Console.WriteLine("ROFstInfo Key {0} List {1}", ROFstInfo.CacheCountPrimaryKey, ROFstInfo.CacheCountList); using (roImg = ROImage.GetByRODbID_FileName_DTS(rodb.RODbID, imgname, fi.LastWriteTimeUtc)) { if (roImg == null) { - FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read); - // Create an instance of StreamReader that can read characters from the FileStream. - BinaryReader r = new BinaryReader(fsIn); - byte[] ab = r.ReadBytes((int)fsIn.Length); - r.Close(); - fsIn.Close(); - roImg = ROImage.MakeROImage(rodb, imgname, ab, null, fi.LastWriteTimeUtc, "Migration"); + using (FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + // Create an instance of StreamReader that can read characters from the FileStream. + BinaryReader r = new BinaryReader(fsIn); + byte[] ab = r.ReadBytes((int)fsIn.Length); + r.Close(); + fsIn.Close(); + roImg = ROImage.MakeROImage(rodb, imgname, ab, null, fi.LastWriteTimeUtc, "Migration"); + } } // see if it's already linked to the current rofst.. - Figure figure = Figure.GetByROFstID_ImageID(rofstinfo.ROFstID, roImg.ImageID); - if (figure != null) return; - //using (ROFst rofst = rofstinfo.Get()) - ROFst rofst = rofstinfo.Get(); // Use the cached ROFST rather than creating and disposing - figure = Figure.MakeFigure(rofst, roImg, null); + //Figure figure = Figure.GetByROFstID_ImageID(rofstinfo.ROFstID, roImg.ImageID); + using (Figure figure = Figure.GetByROFstID_ImageID(rofstinfo.ROFstID, roImg.ImageID)) + { + if (figure != null) return; + //using (ROFst rofst = rofstinfo.Get()) + ROFst rofst = rofstinfo.Get(); // Use the cached ROFST rather than creating and disposing + //figure = Figure.MakeFigure(rofst, roImg, null); + using (Figure tfig = Figure.MakeFigure(rofst, roImg, null)) ; + } } } else