C2021-063 logic to generate an Alarm Point List text file

This commit is contained in:
John Jenko 2021-12-08 17:24:27 +00:00
parent 7bd4dace4c
commit 74128ed79e

View File

@ -84,7 +84,7 @@ namespace Volian.Print.Library
_docVersionInfo = dvi;
}
// the following merges the procedure pdfs into a single pdf
public bool DoTheMerge(Dictionary<string, List<int>> MergedLandscapPages)
public bool DoTheMerge(Dictionary<string, List<int>> MergedLandscapPages, bool generatePointListFile)
{
if (MergedPdfs == null)
{
@ -95,6 +95,14 @@ namespace Volian.Print.Library
string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
MergedFileName = _folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf";
MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName);
// C2021-063 file name of Alarm Point List file containing Serial Number, Title, and merged Page Number
StreamWriter sw = null;
string PointListPageNums = MergedFileName.Replace(".pdf", "_PointList.txt");
if (generatePointListFile)
{
FileInfo fi = new FileInfo(PointListPageNums);
sw = fi.CreateText();
}
PdfWriter writer = null;
// see if it can be created and if not, see if it is open and tell user:
try
@ -119,8 +127,15 @@ namespace Volian.Print.Library
foreach (MergedPdfProc mpp in MergedPdfs) totalPages += mpp.PageCount;
bool doPageNum = GetPageOfInfo(); // get the format and location of page number - this can be reused for each procedure
// the MergedPdfs contains a list of all of the procedures' pdfs that will be merged into the final pdf
int idxSerialNum = 0; // used to generate the Alarm serial number for Point List file
foreach (MergedPdfProc mpp in MergedPdfs)
{
// C2021-063 write Alarm Point List information to the text file
if (generatePointListFile)
{
// write Serial Number, Title, and Page Number in the Point List file
sw.WriteLine("{0}\t{1}\t{2}", idxSerialNum++, mpp.Title, mergedPageNumber + 1);
}
string pdffilename = _folder + @"\" + mpp.PdfFileName;
if (!File.Exists(pdffilename))
{
@ -175,6 +190,12 @@ namespace Volian.Print.Library
_MyLog.Error(tmp, ex);
}
}
// C2021-063 display the generated Alarm Point List text in NotePad
if (generatePointListFile)
{
sw.Close();
System.Diagnostics.Process.Start(PointListPageNums);
}
doc.Close();
return true;
}