C2021-020 Updated the message box that displays when a PDF is open of the same procedure you are trying to approve.

This commit is contained in:
John Jenko 2021-03-22 13:09:52 +00:00
parent 8567015267
commit 822c9136d0

View File

@ -10,6 +10,7 @@ using Volian.Base.Library;
using Volian.Print.Library; using Volian.Print.Library;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Globalization;
using DevComponents.DotNetBar; using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
@ -351,7 +352,7 @@ namespace VEPROMS
private void btnApprove_Click(object sender, EventArgs e) private void btnApprove_Click(object sender, EventArgs e)
{ {
this.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor;
if(!_MyApproval.Approve(new Point(Left,Bottom))) if(!_MyApproval.Approve(new Point(Left,Bottom),cmbRevisionStage2.Text)) // C2021-020 pass in the revision stage name
this.DialogResult = DialogResult.None; this.DialogResult = DialogResult.None;
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
} }
@ -1041,7 +1042,8 @@ namespace VEPROMS
} }
return s1.CompareTo(s2); return s1.CompareTo(s2);
} }
public bool Approve(Point location) // C2021-020 pass in the name of the revision stage
public bool Approve(Point location, string revisionStage)
{ {
// The following is a description of the tables used to defined the various revisions of the procedure set. // The following is a description of the tables used to defined the various revisions of the procedure set.
// Revision: // Revision:
@ -1105,8 +1107,8 @@ namespace VEPROMS
string summaryPDF = string.Format(@"{0}\{1} Summary of Changes.pdf", VlnSettings.TemporaryFolder, pi.PDFNumber); string summaryPDF = string.Format(@"{0}\{1} Summary of Changes.pdf", VlnSettings.TemporaryFolder, pi.PDFNumber);
string pdfTmp = string.Format(@"{0}.pdf", pi.PDFNumber); string pdfTmp = string.Format(@"{0}.pdf", pi.PDFNumber);
string pdfPath = string.Format(@"{0}\{1}", VlnSettings.TemporaryFolder, pdfTmp); string pdfPath = string.Format(@"{0}\{1}", VlnSettings.TemporaryFolder, pdfTmp);
if (!TryToDelete(summaryPDF)) break; if (!TryToDelete(summaryPDF, "Change Summary")) break;
if (!TryToDelete(pdfPath)) break; if (!TryToDelete(pdfPath,revisionStage)) break;
procsApproved.Add(ap.ProcInfo.DisplayNumber + " " + ap.ProcInfo.DisplayText); procsApproved.Add(ap.ProcInfo.DisplayNumber + " " + ap.ProcInfo.DisplayText);
RevisionInfo ric = pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0 ? RevisionInfo.GetCurrentByItemIDandUnitID(pi.ItemID, pi.MyDocVersion.DocVersionConfig.SelectedSlave) : RevisionInfo.GetCurrentByItemID(pi.ItemID); RevisionInfo ric = pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0 ? RevisionInfo.GetCurrentByItemIDandUnitID(pi.ItemID, pi.MyDocVersion.DocVersionConfig.SelectedSlave) : RevisionInfo.GetCurrentByItemID(pi.ItemID);
// RevisionInfo rip = RevisionInfo.GetPreviousByItemID(pi.ItemID); // RevisionInfo rip = RevisionInfo.GetPreviousByItemID(pi.ItemID);
@ -1316,7 +1318,7 @@ namespace VEPROMS
return null; return null;
} }
} }
private bool TryToDelete(string pdfFile) private bool TryToDelete(string pdfFile, string revisionStage)
{ {
int cntr = 0; int cntr = 0;
while (File.Exists(pdfFile)) while (File.Exists(pdfFile))
@ -1328,19 +1330,20 @@ namespace VEPROMS
} }
catch catch
{ {
// C2021-020 updated the information in the message box when a PDF file of the same name is opened while
// we try to create the Revision Stage. Also added the name of revision stage in the message box title.
cntr++; cntr++;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create"); sb.AppendLine("Could not create");
sb.AppendLine(); sb.AppendLine();
sb.AppendLine(pdfFile + "."); sb.AppendLine(pdfFile + ".");
sb.AppendLine(); sb.AppendLine();
sb.AppendLine("If it is open, close and retry."); sb.AppendLine("If it is open, close it then press the OK button.");
if (cntr >= 3) if (cntr >= 3) // after two tries offer additional troubleshooting information
{ sb.AppendLine("\r\nIf the PDF file will not close, try ending the process that is holding it open.");
sb.Insert(0, "PAY ATTENTION!!!\r\n\r\n"); TextInfo txInfo = new CultureInfo("en-US", false).TextInfo; // will allow call to method to put the revison stage name in title case
sb.AppendLine("\r\n\r\nFIRST CLOSE IT, THEN PRESS THE OK BUTTON!!!"); string mgTitle = string.Format("Problem Creating the \"{0}\" Revision Stage Pdf", txInfo.ToTitleCase(revisionStage));
} if (MessageBox.Show(sb.ToString(), mgTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
if(MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
return false; return false;
Application.DoEvents(); Application.DoEvents();
} }