Modified to use newly created ProcedureInfo property PDFNumber

Modified to standardize naming of summary of changes report
Added method to delete existing pdf when creating a new pdf of same name
Created error handler to warn user when trying to view pdf file already open
Created new ProcedureInfo property PDFNumber to handle slashes in procedure number
Corrected error in ResolvePathTo method of TranistionInfo class
This commit is contained in:
Rich
2013-04-10 14:21:07 +00:00
parent a7c689f23a
commit ca6c80487c
5 changed files with 107 additions and 18 deletions

View File

@@ -271,10 +271,7 @@ namespace VEPROMS
if (ProcNum == string.Empty)
txbPDFName.Text = this.UnitNumber + ".pdf";
else
{
string slashReplace = _MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
txbPDFName.Text = string.Format("{0}.pdf", ProcNum.Replace("/", slashReplace).Replace("\\", slashReplace));
}
txbPDFName.Text = string.Format("{0}.pdf", _MyProcedure.PDFNumber);
if (txbPDFName.Text.StartsWith("*"))
txbPDFName.Text = txbPDFName.Text.Replace("*", this.UnitNumber);
ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig;

View File

@@ -979,7 +979,12 @@ namespace VEPROMS
{
ProcedureInfo pi = ap.ProcInfo;
OnStatusUpdated(this, new ApprovalMessageArgs(string.Format("Processing {0}", pi.DisplayNumber)));
RevisionInfo ric = pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0 ? RevisionInfo.GetCurrentByItemIDandUnitID(pi.ItemID,pi.MyDocVersion.DocVersionConfig.SelectedSlave) : RevisionInfo.GetCurrentByItemID(pi.ItemID);
string summaryPDF = string.Format(@"{0}\{1} Summary of Changes.pdf", VlnSettings.TemporaryFolder, pi.PDFNumber);
string pdfTmp = string.Format(@"{0}.pdf", pi.PDFNumber);
string pdfPath = string.Format(@"{0}\{1}", VlnSettings.TemporaryFolder, pdfTmp);
if (!TryToDelete(summaryPDF)) break;
if (!TryToDelete(pdfPath)) break;
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);
DateTime myDTS = pi.DTS;
string cbDTS = (pi.MyConfig as ProcedureConfig).Print_ChangeBarDate;
@@ -995,7 +1000,6 @@ namespace VEPROMS
myDTS = ric.DTS;
// myDTS = DateTime.Parse(pi.ProcedureConfig.Print_RevDate);
}
string summaryPDF = VlnSettings.TemporaryFolder + @"\MySummary.pdf";
ContentAuditInfoList cail;
AnnotationAuditInfoList aail;
if (pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
@@ -1064,8 +1068,6 @@ namespace VEPROMS
DateTime currentDTS = DateTime.Now;
Check check = Check.MakeCheck(revision, Stage.Get(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID);
//make pdf with promsprinter and get byte stream
string pdfTmp = string.Format(@"{0}.pdf", pi.DisplayNumber);
string pdfPath = string.Format(@"{0}\{1}", VlnSettings.TemporaryFolder, pdfTmp);
// Moved to end so that Item and Content are saved at the same time
//UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS);
string waterMark = Stage.Get(RevStage).IsApproved > 0 ? null : Stage.Get(RevStage).Name;
@@ -1118,6 +1120,37 @@ namespace VEPROMS
}
return true;
}
private bool TryToDelete(string pdfFile)
{
int cntr = 0;
while (File.Exists(pdfFile))
{
try
{
File.Delete(pdfFile);
return true;
}
catch
{
cntr++;
StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create");
sb.AppendLine();
sb.AppendLine(pdfFile + ".");
sb.AppendLine();
sb.AppendLine("If it is open, close and retry.");
if (cntr >= 3)
{
sb.Insert(0, "PAY ATTENTION!!!\r\n\r\n");
sb.AppendLine("\r\n\r\nFIRST CLOSE IT, THEN PRESS THE OK BUTTON!!!");
}
if(MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
return false;
Application.DoEvents();
}
}
return true;
}
private void UpdateProcedureDTS(ProcedureInfo pi, DateTime dts)
{

View File

@@ -342,10 +342,24 @@ namespace VEPROMS
else
buffer = args.MyBuffer;
string fileName = Volian.Base.Library.VlnSettings.TemporaryFolder + "\\" + args.MyFilename;
FileStream fs = new FileStream(fileName, FileMode.Create);
fs.Write(buffer, 0, buffer.Length);
fs.Close();
System.Diagnostics.Process.Start(fileName);
try
{
FileStream fs = new FileStream(fileName, FileMode.Create);
fs.Write(buffer, 0, buffer.Length);
fs.Close();
System.Diagnostics.Process.Start(fileName);
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create");
sb.AppendLine();
sb.AppendLine(fileName + ".");
sb.AppendLine();
sb.AppendLine("If it is open, close and retry.");
MessageBox.Show(sb.ToString(), "Error on CreatePdf",MessageBoxButtons.OK,MessageBoxIcon.Warning);
// MessageBox.Show("Could not create " + fileName + ". If it is open, close and retry.", "Error on CreatePdf");
}
}
void displayHistory_AnnotationRestored(AnnotationInfo restoredAnnotationInfo, ItemInfo currentItem)