B2017-149 Timeout during Summary of Change Report causes Approval to crash. Added code to keep approval running even if the Summary of Changes fail. Also allow the user to decide if they want the summary of change report to be created.

This commit is contained in:
Rich 2017-08-01 15:53:48 +00:00
parent 2b7ac6131b
commit b1e3532734

View File

@ -1060,32 +1060,6 @@ namespace VEPROMS
myDTS = ric.DTS;
// myDTS = DateTime.Parse(pi.ProcedureConfig.Print_RevDate);
}
ContentAuditInfoList cail;
AnnotationAuditInfoList aail;
if (pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
{
pi = ProcedureInfo.GetItemAndChildrenByUnit(pi.ItemID, 0, pi.MyDocVersion.DocVersionConfig.SelectedSlave);
pi.ChangeBarDate = myDTS;
cail = ContentAuditInfoList.GetSummaryByUnit(pi.ItemID, pi.ItemID, false, pi.MyDocVersion.DocVersionConfig.SelectedSlave, pi.ChangeBarDate);
aail = AnnotationAuditInfoList.GetChronologyByUnit(pi.ItemID, pi.ItemID, pi.MyDocVersion.DocVersionConfig.SelectedSlave, pi.ChangeBarDate);
}
else
{
if (pi.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier)
pi = ProcedureInfo.GetItemAndChildrenByUnit(pi.ItemID, 0, pi.MyDocVersion.DocVersionConfig.SelectedSlave);
else
pi = ProcedureInfo.GetItemAndChildren(pi.ItemID);
pi.ChangeBarDate = myDTS;
cail = ContentAuditInfoList.GetSummary(pi.ItemID, pi.ItemID, false, pi.ChangeBarDate);
aail = AnnotationAuditInfoList.GetChronology(pi.ItemID, pi.ItemID, pi.ChangeBarDate);
}
Volian.Print.Library.PDFChronologyReport myChronoRpt = new Volian.Print.Library.PDFChronologyReport(summaryPDF, pi, cail, aail);
myChronoRpt.BuildSummary(ViewPDF);
FileInfo pdfFile = new FileInfo(summaryPDF);
FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] summaryBuf = new byte[pdfFile.Length];
fs.Read(summaryBuf, 0, summaryBuf.Length);
fs.Close();
Revision revision = null;
if (ap.ProcInfo.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
{
@ -1134,6 +1108,10 @@ namespace VEPROMS
revision = revision.Save();
}
}
byte[] summaryBuf = null;
//B2017-149 Allow the user to choose if they want the Summary of Changes report created during the approval process
if (MessageBox.Show("Do you want to save the Summary of Changes along with the Approved PDF?", "Create Summary of Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
summaryBuf = CreateSummary(ref pi, summaryPDF, myDTS);
DateTime currentDTS = DateTime.Now;
Check check = Check.MakeCheck(revision, Stage.GetJustStage(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID);
//make pdf with promsprinter and get byte stream
@ -1172,8 +1150,8 @@ namespace VEPROMS
// frm.ShowDialog();
// }
//}
pdfFile = new FileInfo(pdfPath);
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
FileInfo pdfFile = new FileInfo(pdfPath);
FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] buf = new byte[pdfFile.Length];
fs.Read(buf, 0, buf.Length);
fs.Close();
@ -1203,6 +1181,48 @@ namespace VEPROMS
}
return true;
}
private byte[] CreateSummary(ref ProcedureInfo pi, string summaryPDF, DateTime myDTS)
{
//B2017-149 Added error handler so that the code will not crash if the Summary of Change report fails
try
{
ContentAuditInfoList cail;
AnnotationAuditInfoList aail;
if (pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
{
pi = ProcedureInfo.GetItemAndChildrenByUnit(pi.ItemID, 0, pi.MyDocVersion.DocVersionConfig.SelectedSlave);
pi.ChangeBarDate = myDTS;
cail = ContentAuditInfoList.GetSummaryByUnit(pi.ItemID, pi.ItemID, false, pi.MyDocVersion.DocVersionConfig.SelectedSlave, pi.ChangeBarDate);
aail = AnnotationAuditInfoList.GetChronologyByUnit(pi.ItemID, pi.ItemID, pi.MyDocVersion.DocVersionConfig.SelectedSlave, pi.ChangeBarDate);
}
else
{
if (pi.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier)
pi = ProcedureInfo.GetItemAndChildrenByUnit(pi.ItemID, 0, pi.MyDocVersion.DocVersionConfig.SelectedSlave);
else
pi = ProcedureInfo.GetItemAndChildren(pi.ItemID);
pi.ChangeBarDate = myDTS;
cail = ContentAuditInfoList.GetSummary(pi.ItemID, pi.ItemID, false, pi.ChangeBarDate);
aail = AnnotationAuditInfoList.GetChronology(pi.ItemID, pi.ItemID, pi.ChangeBarDate);
}
Volian.Print.Library.PDFChronologyReport myChronoRpt = new Volian.Print.Library.PDFChronologyReport(summaryPDF, pi, cail, aail);
myChronoRpt.BuildSummary(ViewPDF);
FileInfo pdfFile1 = new FileInfo(summaryPDF);
FileStream fs1 = pdfFile1.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] summaryBuf = new byte[pdfFile1.Length];
fs1.Read(summaryBuf, 0, summaryBuf.Length);
fs1.Close();
return summaryBuf;
}
catch (Exception ex)
{
while (!(ex is System.Data.SqlClient.SqlException) && ex.InnerException != null)
ex = ex.InnerException;
MessageBox.Show(ex.Message +"\r\n\r\nApproval will continue without the Summary of Change Report", ex.GetType().Name + " while trying to create Summary of Changes." , MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return null;
}
}
private bool TryToDelete(string pdfFile)
{
int cntr = 0;