diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index b5a315c6..1e0046b7 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -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; diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index 18164c4c..f13af1ce 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -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) { diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 8cfb7ed5..70014587 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -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) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 1b956777..2294a74b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -418,6 +418,21 @@ namespace VEPROMS.CSLA.Library foreach (ItemInfo ii in pi.MyItems) SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo); } + //internal static long ticksROUsage; + //internal static long ticksItems; + //internal static long ticksTrans; + //internal static void ResetTicks() + //{ + // ticksROUsage = 0; + // ticksItems = 0; + // ticksTrans = 0; + //} + //internal static void ShowTicks() + //{ + // Console.WriteLine("ROUsage: {0}", TimeSpan.FromTicks(ticksROUsage).TotalSeconds); + // Console.WriteLine("Items: {0}", TimeSpan.FromTicks(ticksItems).TotalSeconds); + // Console.WriteLine("Transitions: {0}", TimeSpan.FromTicks(ticksTrans).TotalSeconds); + //} internal static void SetParentSectionAndDocVersion(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup) { if (itemInfo == null) return; @@ -429,6 +444,7 @@ namespace VEPROMS.CSLA.Library rofstinfo.docVer = docVersionInfo; ROFSTLookup lookup = rofstinfo.ROFSTLookup; lookup.DocVersionInfo = docVersionInfo; + //DateTime dts = DateTime.Now; if (itemInfo.MyContent.ContentRoUsageCount > 0) { foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages) @@ -441,17 +457,22 @@ namespace VEPROMS.CSLA.Library } } } + //TimeSpan ts = DateTime.Now.Subtract(dts); + //ticksROUsage += ts.Ticks; + //dts = DateTime.Now; if (itemInfo.MyContent.ContentPartCount > 0) { foreach (PartInfo pi in itemInfo.MyContent.ContentParts) { foreach (ItemInfo ii in pi.MyItems) { - Console.WriteLine(ii.ItemID.ToString()); SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo, tranLookup); } } } + //ts = DateTime.Now.Subtract(dts); + //ticksItems += ts.Ticks; + //dts = DateTime.Now; if (itemInfo.MyContent.ContentTransitionCount > 0) { //itemInfo.UpdateTransitionText(); @@ -461,6 +482,8 @@ namespace VEPROMS.CSLA.Library itemInfo.MyContent.FixTransitionText(traninfo, tranLookup); } } + //ts = DateTime.Now.Subtract(dts); + //ticksTrans += ts.Ticks; } private int _PrintBias = 0; public int PrintBias @@ -4054,8 +4077,11 @@ namespace VEPROMS.CSLA.Library } public void AddProcLookup(int procID, Dictionary mylookup) { - if(!_MyLookups.ContainsKey(procID)) + if (!_MyLookups.ContainsKey(procID)) + { _MyLookups.Add(procID, mylookup); + //Console.WriteLine("AddProcLookup: {0}", procID); + } } public ItemInfo this[int itemID] { @@ -4084,6 +4110,14 @@ namespace VEPROMS.CSLA.Library [Serializable()] public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly { + public string PDFNumber + { + get + { + string slashReplace = this.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_"; + return DisplayNumber.Replace("/", slashReplace).Replace("\\", slashReplace).Replace("*","Master"); + } + } private DateTime? _ChangeBarDate = null; public DateTime ChangeBarDate { @@ -4172,7 +4206,12 @@ namespace VEPROMS.CSLA.Library (tmp.MyConfig as ProcedureConfig).SelectedSlave = (int)unitID; TransitionLookup tranLookup = new TransitionLookup((int)unitID, (int)itemID, tmp.MyLookup); tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup); + //ItemInfo.ResetTicks(); + //DateTime dt = DateTime.Now; SetParentSectionAndDocVersion(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion, tranLookup); + //TimeSpan ts = DateTime.Now.Subtract(dt); + //ticksItems = ts.Ticks - (ticksROUsage + ticksTrans); + //ItemInfo.ShowTicks(); } return tmp; } @@ -4246,6 +4285,8 @@ namespace VEPROMS.CSLA.Library } else { + //if (dr.GetInt32("ItemID") == 336) + // Console.WriteLine("here"); ItemInfo itemInfo = null; int itemType = dr.GetInt32("Type") / 10000; switch (itemType) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs index 069c865e..2e9c8b78 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs @@ -57,10 +57,12 @@ namespace VEPROMS.CSLA.Library { //different proc //_MyLog.WarnFormat("Transition May Not Be Correct at Location From {0} To {1}", item.SearchPath, myItemToID.SearchPath); - tranLookup.AddProcLookup(myItemToID.MyProcedure.ItemID, ProcedureInfo.GetNewLookup(tranLookup, new TransitionLookupEventArgs(ToID, tranLookup.ApplicabilityUnit, MyItemToID.MyDocVersion, tranLookup)).MyLookup); + if(!tranLookup.MyLookups.ContainsKey(myItemToID.MyProcedure.ItemID)) + tranLookup.AddProcLookup(myItemToID.MyProcedure.ItemID, ProcedureInfo.GetNewLookup(tranLookup, new TransitionLookupEventArgs(myItemToID.MyProcedure.ItemID, tranLookup.ApplicabilityUnit, MyItemToID.MyDocVersion, tranLookup)).MyLookup); if (tranLookup.ContainsKey(ToID)) myItemToID = tranLookup[ToID]; - //Console.WriteLine("Transition May Not Be Correct at Location"); + //else + // Console.WriteLine("Transition May Not Be Correct at Location"); } ItemInfo myItemRangeID = MyItemRangeID; if (tranLookup.ContainsKey(RangeID)) @@ -69,10 +71,12 @@ namespace VEPROMS.CSLA.Library { //different proc //_MyLog.WarnFormat("Transition May Not Be Correct at Location From {0} To {1}", item.SearchPath, myItemRangeID.SearchPath); - tranLookup.AddProcLookup(MyItemRangeID.MyProcedure.ItemID, ProcedureInfo.GetNewLookup(tranLookup, new TransitionLookupEventArgs(RangeID, tranLookup.ApplicabilityUnit,MyItemRangeID.MyDocVersion, tranLookup)).MyLookup); + if (!tranLookup.MyLookups.ContainsKey(MyItemRangeID.MyProcedure.ItemID)) + tranLookup.AddProcLookup(MyItemRangeID.MyProcedure.ItemID, ProcedureInfo.GetNewLookup(tranLookup, new TransitionLookupEventArgs(MyItemRangeID.MyProcedure.ItemID, tranLookup.ApplicabilityUnit, MyItemRangeID.MyDocVersion, tranLookup)).MyLookup); if (tranLookup.ContainsKey(RangeID)) myItemRangeID = tranLookup[RangeID]; - //Console.WriteLine("Transition May Not Be Correct at Location"); + //else + // Console.WriteLine("Transition May Not Be Correct at Location"); //Console.WriteLine("Format = {0}", item.ActiveFormat); //Console.WriteLine("item = {0}", item.ItemID); //Console.WriteLine("TranType = {0}", TranType);