C2026-007 Upgrade - Generate Missing Word Attachments/B2026-027 Update Refresh Tables For Search Tooltip
This commit is contained in:
@@ -1003,40 +1003,34 @@ namespace VEPROMS.CSLA.Library
|
||||
if (pdfTmp == null) return false;
|
||||
|
||||
FileInfo pdfFile = new FileInfo(pdfTmp);
|
||||
FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
Byte[] buf = new byte[pdfFile.Length];
|
||||
fs.Read(buf, 0, buf.Length);
|
||||
fs.Close();
|
||||
Byte[] buf = new byte[pdfFile.Length];
|
||||
|
||||
// B2023-022 & B2023-023 commented out the deletion of the temporary Word section PDF file
|
||||
// These files are deleted when the procedure pdf file is closed after being generated.
|
||||
// PROMS was crashing because it could not find these temporary files to delete.
|
||||
//try
|
||||
//{
|
||||
// pdfFile.Delete();
|
||||
//}
|
||||
//catch { }
|
||||
|
||||
using (Document doc = docInfo.Get())
|
||||
using (FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
DocStyle myDocStyle = sect.ActiveSection.MyDocStyle;
|
||||
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
|
||||
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
|
||||
|
||||
if (sc != null && sc.Section_WordMargin == "Y")
|
||||
{
|
||||
using (Pdf myPdf = Pdf.MakePdf(doc, ss * 10 + MSWordToPDF.DebugStatus, 0, 0, 0, 0, (double)sect.MSWordPageCount, buf)) {; }
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pdf myPdf1 = Pdf.MakePdf(doc, ss * 10 + MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopMargin, (int)myDocStyle.Layout.PageLength,
|
||||
(int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth, (double)sect.MSWordPageCount, buf)) {; }
|
||||
}
|
||||
|
||||
doc.UpdateDRoUsages(roids);
|
||||
doc.Save();
|
||||
fs.Read(buf, 0, buf.Length);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
using (Document doc = docInfo.Get())
|
||||
{
|
||||
DocStyle myDocStyle = sect.ActiveSection.MyDocStyle;
|
||||
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
|
||||
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
|
||||
|
||||
if (sc != null && sc.Section_WordMargin == "Y")
|
||||
{
|
||||
using (Pdf myPdf = Pdf.MakePdf(doc, ss * 10 + MSWordToPDF.DebugStatus, 0, 0, 0, 0, (double)sect.MSWordPageCount, buf)) {; }
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pdf myPdf1 = Pdf.MakePdf(doc, ss * 10 + MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopMargin, (int)myDocStyle.Layout.PageLength,
|
||||
(int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth, (double)sect.MSWordPageCount, buf)) {; }
|
||||
}
|
||||
|
||||
doc.UpdateDRoUsages(roids);
|
||||
doc.Save();
|
||||
}
|
||||
|
||||
docInfo.RefreshConfig();
|
||||
|
||||
return true;
|
||||
@@ -1482,12 +1476,22 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (CloseWordWhenDone)
|
||||
try
|
||||
{
|
||||
if (CloseWordWhenDone)
|
||||
{
|
||||
CloseAppAfterWait();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CloseAppAfterWait();
|
||||
}
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
_MyLog.Error("Failed to close Microsoft Word. Collecting reclaimable memory.", ex);
|
||||
GC.Collect();
|
||||
_MyLog.Warn("Finished collecting reclaimable memory.");
|
||||
}
|
||||
|
||||
if (statusChange != null) statusChange(VolianStatusType.Complete, 0, string.Empty);
|
||||
if (statusChange != null) statusChange(VolianStatusType.Complete, 0, string.Empty);
|
||||
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("++EndTxt++");
|
||||
|
||||
// [jpr 2022.07.26] - For memory optimization
|
||||
|
||||
@@ -522,19 +522,22 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Pdf MakePdf(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf)
|
||||
{
|
||||
Pdf tmp = Pdf.New(myDocument, debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount, docPdf);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
else
|
||||
using (Pdf tmp = Pdf.New(myDocument, debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount, docPdf))
|
||||
{
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
tmp._ErrorMessage = "Failed Validation:";
|
||||
foreach (Csla.Validation.BrokenRule br in brc)
|
||||
if (tmp.IsSavable)
|
||||
return tmp.Save();
|
||||
else
|
||||
{
|
||||
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
|
||||
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
|
||||
tmp._ErrorMessage = "Failed Validation:";
|
||||
foreach (Csla.Validation.BrokenRule br in brc)
|
||||
{
|
||||
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
|
||||
}
|
||||
public static Pdf Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,38 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error in vesp_GetOtherActiveSessions: retrieving data failed", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region Get Docs by Unit
|
||||
//C2026-007 Get Missing Docs by Unit
|
||||
// for Generating/Regenerating Pdf table
|
||||
// can be ran overnight to assist with Printing when RO Updates
|
||||
// and large Word Sections conatining ROs
|
||||
public static DataTable GetMissingDocsByUnit()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "GetMissingDocsByUnit";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SqlDataAdapter da = new SqlDataAdapter(cm))
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
da.Fill(dt);
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error in GetMissingDocsByUnit: retrieving data failed", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user