logic to save word sections with resolved RO values for exporting the approved procedure

logic to create an export file with unlinked RO and Transition
Commented out debug statements to help evaluate memory usage
This commit is contained in:
2016-02-18 15:29:25 +00:00
parent 6ae1fcda1a
commit 8cd75c0c14
7 changed files with 820 additions and 734 deletions

View File

@@ -572,6 +572,13 @@ namespace VEPROMS.CSLA.Library
}
public static class MSWordToPDF
{
// used to save Word sections with resolved ROs (for export generated from Approve)
private static Dictionary<int, byte[]> _DocReplace;
public static Dictionary<int, byte[]> DocReplace
{
get { return MSWordToPDF._DocReplace; }
set { MSWordToPDF._DocReplace = value; }
}
private static bool _CloseWordWhenDone = true;
public static bool CloseWordWhenDone
{
@@ -615,7 +622,7 @@ namespace VEPROMS.CSLA.Library
string fileName = GetFileName(sect);
FileInfo fi = new FileInfo(fileName);
FileStream fs = fi.Create();
PdfInfo myPdf = PdfInfo.Get(sect);
PdfInfo myPdf = PdfInfo.Get(sect,false);
if (myPdf != null && myPdf.DocPdf != null) fs.Write(myPdf.DocPdf, 0, myPdf.DocPdf.Length);
fs.Close();
return fileName;
@@ -624,7 +631,7 @@ namespace VEPROMS.CSLA.Library
public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor, ItemInfo sect)
{
MSWordToPDF.OverrideColor = overrideColor;
PdfInfo myPdf = PdfInfo.Get(sect);
PdfInfo myPdf = PdfInfo.Get(sect,DocReplace!=null);
return true;
}
public static bool SetDocPdf(DocumentInfo docInfo, ItemInfo sect)
@@ -982,15 +989,32 @@ namespace VEPROMS.CSLA.Library
sel.Range.Font.Color = (LBWdColor)WordColor(OverrideColor == System.Drawing.Color.Transparent ? System.Drawing.Color.Black : OverrideColor);
sect.MSWordPageCount = myDoc.Length;
fileName = CreatePDF(fileName, openPdf,MSWordToPDF.DebugStatus);
if (DocReplace != null)
{
MyApp.ActiveDocument.SaveAs2000();
DocReplace.Add(sect.MyContent.MyEntry.DocID, GetBytes(MyApp.ActiveDocument.FullName)); // save the word document containing resolved ROs
}
CloseDocument();
if (CloseWordWhenDone)
{
CloseAppAfterWait();
}
if (statusChange != null) statusChange(VolianStatusType.Complete, 0, "");
GC.Collect(); //jsj 2-15-2016 - for memeory garbage collection
return fileName;
}
}
// Reads the Word file containing the resolved ROs
// used when adding to DocReplace
private static byte[] GetBytes(string filename)
{
FileInfo fi = new FileInfo(filename);
FileStream fs = fi.Open(FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
byte[] buf = new byte[fi.Length];
fs.Read(buf, 0, buf.Length);
fs.Close();
return buf;
}
private static void CloseDocument()
{
int attempts = 0;
@@ -1323,6 +1347,7 @@ namespace VEPROMS.CSLA.Library
VG.IVGOutput vgOut = new VG.VGOut_Graphics(grfx);
vgOut.DebugStatus = MSWordToPDF.DebugStatus;
myPlot.Process(vgOut);
GC.Collect(); // memory garbage collection (Regex bug)
grfx.Dispose();
GraphicsUnit gu = new GraphicsUnit();
retval = mf.GetBounds(ref gu);