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) if (ProcNum == string.Empty)
txbPDFName.Text = this.UnitNumber + ".pdf"; txbPDFName.Text = this.UnitNumber + ".pdf";
else else
{ txbPDFName.Text = string.Format("{0}.pdf", _MyProcedure.PDFNumber);
string slashReplace = _MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
txbPDFName.Text = string.Format("{0}.pdf", ProcNum.Replace("/", slashReplace).Replace("\\", slashReplace));
}
if (txbPDFName.Text.StartsWith("*")) if (txbPDFName.Text.StartsWith("*"))
txbPDFName.Text = txbPDFName.Text.Replace("*", this.UnitNumber); txbPDFName.Text = txbPDFName.Text.Replace("*", this.UnitNumber);
ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig; ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig;

View File

@ -979,7 +979,12 @@ namespace VEPROMS
{ {
ProcedureInfo pi = ap.ProcInfo; ProcedureInfo pi = ap.ProcInfo;
OnStatusUpdated(this, new ApprovalMessageArgs(string.Format("Processing {0}", pi.DisplayNumber))); 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); // RevisionInfo rip = RevisionInfo.GetPreviousByItemID(pi.ItemID);
DateTime myDTS = pi.DTS; DateTime myDTS = pi.DTS;
string cbDTS = (pi.MyConfig as ProcedureConfig).Print_ChangeBarDate; string cbDTS = (pi.MyConfig as ProcedureConfig).Print_ChangeBarDate;
@ -995,7 +1000,6 @@ namespace VEPROMS
myDTS = ric.DTS; myDTS = ric.DTS;
// myDTS = DateTime.Parse(pi.ProcedureConfig.Print_RevDate); // myDTS = DateTime.Parse(pi.ProcedureConfig.Print_RevDate);
} }
string summaryPDF = VlnSettings.TemporaryFolder + @"\MySummary.pdf";
ContentAuditInfoList cail; ContentAuditInfoList cail;
AnnotationAuditInfoList aail; AnnotationAuditInfoList aail;
if (pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0) if (pi.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
@ -1064,8 +1068,6 @@ namespace VEPROMS
DateTime currentDTS = DateTime.Now; DateTime currentDTS = DateTime.Now;
Check check = Check.MakeCheck(revision, Stage.Get(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID); Check check = Check.MakeCheck(revision, Stage.Get(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID);
//make pdf with promsprinter and get byte stream //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 // Moved to end so that Item and Content are saved at the same time
//UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS); //UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS);
string waterMark = Stage.Get(RevStage).IsApproved > 0 ? null : Stage.Get(RevStage).Name; string waterMark = Stage.Get(RevStage).IsApproved > 0 ? null : Stage.Get(RevStage).Name;
@ -1118,6 +1120,37 @@ namespace VEPROMS
} }
return true; 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) private void UpdateProcedureDTS(ProcedureInfo pi, DateTime dts)
{ {

View File

@ -342,11 +342,25 @@ namespace VEPROMS
else else
buffer = args.MyBuffer; buffer = args.MyBuffer;
string fileName = Volian.Base.Library.VlnSettings.TemporaryFolder + "\\" + args.MyFilename; string fileName = Volian.Base.Library.VlnSettings.TemporaryFolder + "\\" + args.MyFilename;
try
{
FileStream fs = new FileStream(fileName, FileMode.Create); FileStream fs = new FileStream(fileName, FileMode.Create);
fs.Write(buffer, 0, buffer.Length); fs.Write(buffer, 0, buffer.Length);
fs.Close(); fs.Close();
System.Diagnostics.Process.Start(fileName); 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) void displayHistory_AnnotationRestored(AnnotationInfo restoredAnnotationInfo, ItemInfo currentItem)
{ {

View File

@ -418,6 +418,21 @@ namespace VEPROMS.CSLA.Library
foreach (ItemInfo ii in pi.MyItems) foreach (ItemInfo ii in pi.MyItems)
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo); 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) internal static void SetParentSectionAndDocVersion(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
{ {
if (itemInfo == null) return; if (itemInfo == null) return;
@ -429,6 +444,7 @@ namespace VEPROMS.CSLA.Library
rofstinfo.docVer = docVersionInfo; rofstinfo.docVer = docVersionInfo;
ROFSTLookup lookup = rofstinfo.ROFSTLookup; ROFSTLookup lookup = rofstinfo.ROFSTLookup;
lookup.DocVersionInfo = docVersionInfo; lookup.DocVersionInfo = docVersionInfo;
//DateTime dts = DateTime.Now;
if (itemInfo.MyContent.ContentRoUsageCount > 0) if (itemInfo.MyContent.ContentRoUsageCount > 0)
{ {
foreach (RoUsageInfo rousage in itemInfo.MyContent.ContentRoUsages) 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) if (itemInfo.MyContent.ContentPartCount > 0)
{ {
foreach (PartInfo pi in itemInfo.MyContent.ContentParts) foreach (PartInfo pi in itemInfo.MyContent.ContentParts)
{ {
foreach (ItemInfo ii in pi.MyItems) foreach (ItemInfo ii in pi.MyItems)
{ {
Console.WriteLine(ii.ItemID.ToString());
SetParentSectionAndDocVersion(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, docVersionInfo, tranLookup); 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) if (itemInfo.MyContent.ContentTransitionCount > 0)
{ {
//itemInfo.UpdateTransitionText(); //itemInfo.UpdateTransitionText();
@ -461,6 +482,8 @@ namespace VEPROMS.CSLA.Library
itemInfo.MyContent.FixTransitionText(traninfo, tranLookup); itemInfo.MyContent.FixTransitionText(traninfo, tranLookup);
} }
} }
//ts = DateTime.Now.Subtract(dts);
//ticksTrans += ts.Ticks;
} }
private int _PrintBias = 0; private int _PrintBias = 0;
public int PrintBias public int PrintBias
@ -4054,8 +4077,11 @@ namespace VEPROMS.CSLA.Library
} }
public void AddProcLookup(int procID, Dictionary<int, ItemInfo> mylookup) public void AddProcLookup(int procID, Dictionary<int, ItemInfo> mylookup)
{ {
if(!_MyLookups.ContainsKey(procID)) if (!_MyLookups.ContainsKey(procID))
{
_MyLookups.Add(procID, mylookup); _MyLookups.Add(procID, mylookup);
//Console.WriteLine("AddProcLookup: {0}", procID);
}
} }
public ItemInfo this[int itemID] public ItemInfo this[int itemID]
{ {
@ -4084,6 +4110,14 @@ namespace VEPROMS.CSLA.Library
[Serializable()] [Serializable()]
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly 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; private DateTime? _ChangeBarDate = null;
public DateTime ChangeBarDate public DateTime ChangeBarDate
{ {
@ -4172,7 +4206,12 @@ namespace VEPROMS.CSLA.Library
(tmp.MyConfig as ProcedureConfig).SelectedSlave = (int)unitID; (tmp.MyConfig as ProcedureConfig).SelectedSlave = (int)unitID;
TransitionLookup tranLookup = new TransitionLookup((int)unitID, (int)itemID, tmp.MyLookup); TransitionLookup tranLookup = new TransitionLookup((int)unitID, (int)itemID, tmp.MyLookup);
tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup); tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup);
//ItemInfo.ResetTicks();
//DateTime dt = DateTime.Now;
SetParentSectionAndDocVersion(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion, tranLookup); SetParentSectionAndDocVersion(tmp, tmp.MyDocVersion, null, tmp.MyDocVersion, tranLookup);
//TimeSpan ts = DateTime.Now.Subtract(dt);
//ticksItems = ts.Ticks - (ticksROUsage + ticksTrans);
//ItemInfo.ShowTicks();
} }
return tmp; return tmp;
} }
@ -4246,6 +4285,8 @@ namespace VEPROMS.CSLA.Library
} }
else else
{ {
//if (dr.GetInt32("ItemID") == 336)
// Console.WriteLine("here");
ItemInfo itemInfo = null; ItemInfo itemInfo = null;
int itemType = dr.GetInt32("Type") / 10000; int itemType = dr.GetInt32("Type") / 10000;
switch (itemType) switch (itemType)

View File

@ -57,10 +57,12 @@ namespace VEPROMS.CSLA.Library
{ {
//different proc //different proc
//_MyLog.WarnFormat("Transition May Not Be Correct at Location From {0} To {1}", item.SearchPath, myItemToID.SearchPath); //_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)) if (tranLookup.ContainsKey(ToID))
myItemToID = tranLookup[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; ItemInfo myItemRangeID = MyItemRangeID;
if (tranLookup.ContainsKey(RangeID)) if (tranLookup.ContainsKey(RangeID))
@ -69,10 +71,12 @@ namespace VEPROMS.CSLA.Library
{ {
//different proc //different proc
//_MyLog.WarnFormat("Transition May Not Be Correct at Location From {0} To {1}", item.SearchPath, myItemRangeID.SearchPath); //_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)) if (tranLookup.ContainsKey(RangeID))
myItemRangeID = tranLookup[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("Format = {0}", item.ActiveFormat);
//Console.WriteLine("item = {0}", item.ItemID); //Console.WriteLine("item = {0}", item.ItemID);
//Console.WriteLine("TranType = {0}", TranType); //Console.WriteLine("TranType = {0}", TranType);