Cache ROImages so they only have to be read once.
Added Page Number to DebugText.txt when printing.
This commit is contained in:
parent
cc4b8a2020
commit
9ca49944e3
@ -159,13 +159,18 @@ namespace DataLoader
|
||||
FileInfo fi = new FileInfo(imgfile);
|
||||
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))
|
||||
frmMain.AddInfo("Adding RO Image {0}", imgname);
|
||||
//using (roImg = ROImage.GetByRODbID_FileName_DTS(rodb.RODbID, imgname, fi.LastWriteTimeUtc))
|
||||
//{
|
||||
ROImage roImg = null;
|
||||
roImg = GetImageFromAvailable(rodb.RODbID, imgname, fi.LastWriteTimeUtc);
|
||||
if (roImg == null)
|
||||
{
|
||||
roImg = ROImage.GetByRODbID_FileName_DTS(rodb.RODbID, imgname, fi.LastWriteTimeUtc);
|
||||
if (roImg == null)
|
||||
{
|
||||
using (FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
@ -178,21 +183,41 @@ namespace DataLoader
|
||||
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);
|
||||
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)) ;
|
||||
}
|
||||
roImg.Dispose();
|
||||
AddToAvailable(roImg, rodb.RODbID, imgname, fi.LastWriteTimeUtc);
|
||||
}
|
||||
// see if it's already linked to the current rofst..
|
||||
//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)) ;
|
||||
}
|
||||
//roImg.Dispose();
|
||||
}
|
||||
else
|
||||
frmMain.AddError("Cannot Find Image File {0}", imgfile);
|
||||
}
|
||||
|
||||
private void AddToAvailable(ROImage roImg, int dbid, string imgname, DateTime dateTime)
|
||||
{
|
||||
string key = AvailableKey(dbid, imgname, dateTime);
|
||||
_AvaiableROImages.Add(key, roImg);
|
||||
}
|
||||
|
||||
private string AvailableKey(int dbid, string imgname, DateTime dateTime)
|
||||
{
|
||||
return string.Format("{0}|{1}|{2}", dbid, imgname, dateTime.ToString("yyyyMMdd HHmmss"));
|
||||
}
|
||||
|
||||
private ROImage GetImageFromAvailable(int dbid, string imgname, DateTime dateTime)
|
||||
{
|
||||
string key = AvailableKey(dbid, imgname, dateTime);
|
||||
if (_AvaiableROImages.ContainsKey(key)) return _AvaiableROImages[key];
|
||||
return null;
|
||||
}
|
||||
private Dictionary<string, ROImage> _AvaiableROImages = new Dictionary<string, ROImage>();
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ namespace Volian.Print.Library
|
||||
MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, centerpos, msg_yLocation, docstyle.End.Font);
|
||||
}
|
||||
}
|
||||
if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, yLocalypagestart, yPageStart);
|
||||
if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2},{3}", MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, MyItemInfo.ItemID, yLocalypagestart, yPageStart);
|
||||
return yPageStart;
|
||||
}
|
||||
private vlnParagraph TopMostChild
|
||||
|
Loading…
x
Reference in New Issue
Block a user