This commit is contained in:
Kathy Ruffing 2012-03-12 10:42:39 +00:00
parent aac7de181c
commit b955f6e331

View File

@ -232,6 +232,7 @@ namespace VEPROMS.CSLA.Library
{
Dictionary<string, int> myROImagesList = BuildROImagesList(myROImages);
List<int> myROImageIDs = new List<int>();
List<string> myROsAdded = new List<string>();
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
// Hook this into the current docversion by replacing the rofstid field in the doc version
// association object:
@ -246,7 +247,7 @@ namespace VEPROMS.CSLA.Library
{
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
{
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myROImagesList, myROImageIDs);// TODO: Need to add MyImages
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myROImagesList, myROImageIDs,myROsAdded);// TODO: Need to add MyImages
}
}
}
@ -299,6 +300,7 @@ namespace VEPROMS.CSLA.Library
{
Dictionary<string, int> myROImagesList = BuildROImagesList(myROImages);
List<int> myROImageIDs = new List<int>();
List<string> myROsAdded = new List<string>();
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
{
for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++)
@ -306,7 +308,7 @@ namespace VEPROMS.CSLA.Library
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null)
{
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myROImagesList, myROImageIDs);
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myROImagesList, myROImageIDs,myROsAdded);
}
}
}
@ -495,15 +497,15 @@ namespace VEPROMS.CSLA.Library
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
return retval;
}
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string,int> myROImagesList, List<int> myROImageIDs)
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myROImagesList, List<int> myROImageIDs, List<string> myROsAdded)
{
for (int i = 0; i < rochild.Length; i++)
{
if (rochild[i].type == 8) this.AddGraphic(rdi, rochild[i].value, rodb, rofst, myROImagesList, myROImageIDs);
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myROImagesList, myROImageIDs);
if (rochild[i].type == 8) this.AddGraphic(rdi, rochild[i].value, rodb, rofst, myROImagesList, myROImageIDs, myROsAdded);
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myROImagesList, myROImageIDs, myROsAdded);
}
}
private void AddGraphic(RODbInfo rdi, string p, RODb rodb, ROFst rofst, Dictionary<string, int> myROImagesList, List<int> myROImageIDs)
private void AddGraphic(RODbInfo rdi, string p, RODb rodb, ROFst rofst, Dictionary<string, int> myROImagesList, List<int> myROImageIDs, List<string> myROsAdded)
{
if (p == null) return;
string imgname = p.Substring(0, p.IndexOf('\n'));
@ -531,15 +533,19 @@ namespace VEPROMS.CSLA.Library
}
else
{
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read);
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");
Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID);
if (figure != null) return;
figure = Figure.MakeFigure(rofst, roImg, null);
if (!myROsAdded.Contains(key))
{
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read);
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");
Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID);
if (figure != null) return;
figure = Figure.MakeFigure(rofst, roImg, null);
myROsAdded.Add(key);
}
}
}
}