1438 lines
		
	
	
		
			65 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1438 lines
		
	
	
		
			65 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| using System.IO;
 | |
| using VEPROMS.CSLA.Library;
 | |
| using Volian.Print.Library;
 | |
| //using Volian.Controls.Library;
 | |
| using Volian.Base.Library;
 | |
| using JR.Utils.GUI.Forms;
 | |
| 
 | |
| namespace VEPROMS
 | |
| {
 | |
| 	public partial class DlgPrintProcedure : DevComponents.DotNetBar.Office2007Form
 | |
| 	{
 | |
| 		public bool SaveLinks
 | |
| 		{
 | |
| 			get 
 | |
| 			{ 
 | |
| 				return swtbtnPDFLinks.Value;
 | |
| 			}
 | |
| 		}
 | |
| 		public int RemoveTrailingHardReturnsAndManualPageBreaks
 | |
| 		{
 | |
| 			get 
 | |
| 			{
 | |
| 				// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
 | |
| 				//	return values: 0=None; 1=Trailing; 2=ManualPgBrk; 3=Both.
 | |
| 				//	The designer file has the additional controls
 | |
| 				if (!cbxRemoveManualPgBrk.Checked && !cbxRemoveTrailing.Checked) return 0;
 | |
| 				if (!cbxRemoveManualPgBrk.Checked && cbxRemoveTrailing.Checked) return 1;
 | |
| 				if (cbxRemoveManualPgBrk.Checked && !cbxRemoveTrailing.Checked) return 2;
 | |
| 				return 3; 
 | |
| 			}
 | |
| 		}
 | |
| 		private string _Prefix = "";  // RHM20150506 Multiline ItemID TextBox
 | |
| 		public string Prefix
 | |
| 		{
 | |
| 			get { return _Prefix; }
 | |
| 			set { _Prefix = value; }
 | |
| 		}
 | |
| 		public bool OpenAfterCreate  // RHM20150506 Multiline ItemID TextBox
 | |
| 		{
 | |
| 			get { return cbxOpenAfterCreate2.Checked; }
 | |
| 			set { cbxOpenAfterCreate2.Checked = value; }
 | |
| 		}
 | |
| 		private SessionInfo _MySessionInfo;
 | |
| 		public SessionInfo MySessionInfo
 | |
| 		{
 | |
| 			get { return _MySessionInfo; }
 | |
| 			set { _MySessionInfo = value; }
 | |
| 		}
 | |
| 		private bool _Automatic;
 | |
| 		public bool Automatic
 | |
| 		{
 | |
| 			get { return _Automatic; }
 | |
| 			set { _Automatic = value; }
 | |
| 		}
 | |
| 		private int _prtSectID = -1;
 | |
| 		public int PrtSectID
 | |
| 		{
 | |
| 			get { return _prtSectID; }
 | |
| 			set { _prtSectID = value; }
 | |
| 		}
 | |
| 
 | |
| 		private bool _OverwritePDF;
 | |
| 		public bool OverwritePDF
 | |
| 		{
 | |
| 			get { return cbxOverwritePDF2.Checked; }
 | |
| 			set { cbxOverwritePDF2.Checked = value; }
 | |
| 		}
 | |
| 
 | |
| 		// C2018-033 Used to turn off using the date/time PDF file prefix and suffix when doing batch file autmatic baseline print testing (frmVEPROMS.cs RunAutomatic())
 | |
| 		//           This is needed so the the automatic baselines can compare results from different runs of PROMS
 | |
| 		private bool _AllowDateTimePrefixSuffix = true;
 | |
| 		public bool AllowDateTimePrefixSuffix
 | |
| 		{
 | |
| 			get { return _AllowDateTimePrefixSuffix; }
 | |
| 			set 
 | |
| 			{ 
 | |
| 				_AllowDateTimePrefixSuffix = value;
 | |
| 				swtbtnPDFdtPrefixSuffix.Value = swtbtnPDFdtPrefixSuffix.Enabled = _AllowDateTimePrefixSuffix;
 | |
| 			}
 | |
| 		}
 | |
| 		private DateTime _PrefixSuffixDTS = DateTime.Now; // C2018-033 date/time used for the date/time PDF file prefix and suffix
 | |
| 		private bool _DateTimePrefixSuffixPrintingAllProcedures = true; // C2018-033 to control adding the Date/Time Prefix/Suffix to PFD name when printing All procedures
 | |
| 		private bool _IncludeWordSecTextInMetafile = true; // C2018-023 so that we can turn off including Word attachment text in metafile
 | |
| 		private void RunAutomatic()
 | |
| 		{
 | |
| 			cbxDebugPagination.Checked = true;
 | |
| 			cbxDebugText.Checked = true;
 | |
|       cbxMetaFile.Checked = true; // C2018-004 create meta file for baseline compares
 | |
| 			_IncludeWordSecTextInMetafile = true;
 | |
| 			Application.DoEvents();
 | |
| 			string[] parameters = System.Environment.CommandLine.Split(" ".ToCharArray());
 | |
| 			bool ranAuto = false;
 | |
| 			foreach (string parameter in parameters)
 | |
| 			{
 | |
| 				if (parameter.ToUpper() == "/NT")
 | |
| 					cbxDebugText.Checked = false;
 | |
| 				else if (parameter.ToUpper() == "/NP")
 | |
| 					cbxDebugPagination.Checked = false;
 | |
| 				else if (parameter.ToUpper() == "/NC")
 | |
| 					cbxDebug.Checked = false;
 | |
| 				else if (parameter.ToUpper() == "/NM")
 | |
| 					cbxMetaFile.Checked = false; // C2018-004 turn off create meta file for baseline compares
 | |
|         else if (parameter.ToUpper() == "/NW")
 | |
| 					_IncludeWordSecTextInMetafile = false; // C2018-023 turn off putting Word attachment text in the meta file for baseline compares
 | |
| 			}
 | |
| 			CreatePDFs();
 | |
| 			this.Close();
 | |
| 		}
 | |
| 		private DocVersionInfo _DocVersionInfo = null;
 | |
| 		private bool _AllProcedures;
 | |
| 		private DocVersionConfig _DocVersionConfig;
 | |
| 		public string RevNum
 | |
| 		{
 | |
| 			get { return txbRevNum.Text; }
 | |
| 			set { txbRevNum.Text = value; }
 | |
| 		}
 | |
| 		public string RevNumAndDate
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				// the RevDate and Rev number are stored in the procedure config separtly as strings
 | |
| 				// we put these two strings to gether to pass into the Print module.
 | |
| 				// the Rev Number followed by a forward slash or backslash logic is from the 16-bit code
 | |
| 				// and is treated as just string.
 | |
| 				// Therefore we need to build a revison number string with a revdate appended to it but only
 | |
| 				// if either the DoRevDate or the RevDateWithForwardSlash is true. otherwise we should use
 | |
| 				// only the RevNumber.
 | |
| 				if (RevDate == "" ||
 | |
| 					(RevNum.Contains("\\") || RevNum.Contains("/")) ||
 | |
| 					(!MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash &&
 | |
| 					!MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate))
 | |
| 					return RevNum;
 | |
| 				if (MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash)
 | |
| 					return RevNum + "\\" + RevDate;
 | |
| 				else
 | |
| 					return RevNum + "/" + RevDate;
 | |
| 			}
 | |
| 		}
 | |
| 		public string ProcNum
 | |
| 		{
 | |
| 			get { return MyProcedure.DisplayNumber; }
 | |
| 		}
 | |
| 		public string PDFPath
 | |
| 		{
 | |
| 			get {// B2018-069 Revert to Temporary for Baseline testing
 | |
| 				if (PromsPrinter.BaselineTesting)
 | |
| 					return VlnSettings.TemporaryFolder;
 | |
| 				return txbPDFLocation.Text; 
 | |
| 			}
 | |
| 			set { txbPDFLocation.Text = value; }
 | |
| 		}
 | |
| 		public string RevDate
 | |
| 		{
 | |
| 			get { return txbRevDate.Text; }
 | |
| 			set { txbRevDate.Text = value; }
 | |
| 		}
 | |
| 		public string ReviewDate
 | |
| 		{
 | |
| 			get { return txbReviewDate.Text; }
 | |
| 			set { txbReviewDate.Text = value; }
 | |
| 		}
 | |
| 		public bool CreateContinuousActionSummary
 | |
| 		{
 | |
| 			get { return cbxGenerateConActSum.Checked; }
 | |
| 			set { cbxGenerateConActSum.Checked = value; }
 | |
| 		}
 | |
| 		public bool CreateTimeCriticalActionSummary
 | |
| 		{
 | |
| 			get { return cbxGenerateTimeCritActSum.Checked; }
 | |
| 			set { cbxGenerateTimeCritActSum.Checked = value; }
 | |
| 		}
 | |
| 		private bool _CreateButtonClicked = false; // B2020-062 control the toggle of date/time prefix/suffix on pdf file name
 | |
| 		public DlgPrintProcedure(DocVersionInfo dvi, bool automatic)
 | |
| 		{
 | |
| 			_Automatic = automatic;
 | |
| 			InitializeComponent();
 | |
| 			_AllProcedures = true;
 | |
| 			_DocVersionConfig = dvi.DocVersionConfig;
 | |
| 			_DocVersionInfo = dvi;
 | |
| 			MyProcedure = dvi.Procedures[0].MyProcedure;
 | |
| 
 | |
| 			// C2019-004: Allow user to define duplex lank page text at the docversion level (this is used in baselines) 
 | |
| 			//  2nd line was added to other constructors (1st line already existed)
 | |
| 			swtbtnBlankPgsForDuplex.Value = dvi.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
 | |
| 			tbBlankPage.Text = dvi.DocVersionConfig.Print_DuplexBlankPageText;
 | |
| 
 | |
| 			// B2017-188: Don't allow user to uncheck the checkbox for printing blank pages if procedure has supplemental information
 | |
| 			//		This change was made to each of the DlgPrintProcedure methods.
 | |
| 			if (_MyProcedure != null && _MyProcedure.ProcHasSupInfoData)
 | |
| 			{
 | |
| 				swtbtnBlankPgsForDuplex.Enabled = false;
 | |
| 				tbBlankPage.Enabled = true;		// C2019-004: Allow user to define duplex blank page text (similar changes throughout file are not commented)
 | |
| 			}
 | |
| 			btnCreatePDF.Text = "Create PDFs";
 | |
| 			HandleDocVersionSettings();
 | |
| 			PrepForAllOrOne(false);
 | |
| 			// don't open all PDFs if doing All Procedures
 | |
| 			//cbxOpenAfterCreate2.Checked = dvi.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
 | |
| 			// C2018-033 added the Prefix / Suffix switch to the expand Additional Settings check
 | |
| 			expPrnSetting.Expanded = swtbtnBlankPgsForDuplex.Value || swtbtnChgBar.Value || swtbtnGeneratePlacekeeper.Value || swtbtnPDFLinks.Value || swtbtnPROMSVersion.Value || swtbtnWaterMark.Value || swtbtnPDFdtPrefixSuffix.Value;
 | |
| 		}
 | |
| 		public DlgPrintProcedure(DocVersionInfo dvi)
 | |
| 		{
 | |
| 			_Automatic = false;
 | |
| 			InitializeComponent();
 | |
| 			_AllProcedures = true;
 | |
| 			_DocVersionConfig = dvi.DocVersionConfig;
 | |
| 			_DocVersionInfo = dvi;
 | |
| 			swtbtnBlankPgsForDuplex.Value = dvi.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
 | |
| 			tbBlankPage.Text = dvi.DocVersionConfig.Print_DuplexBlankPageText;
 | |
| 			tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value;
 | |
| 			MyProcedure = dvi.Procedures[0].MyProcedure;
 | |
| 			if (_MyProcedure != null && _MyProcedure.ProcHasSupInfoData)
 | |
| 			{
 | |
| 				swtbtnBlankPgsForDuplex.Enabled = false;
 | |
| 				tbBlankPage.Enabled = true;
 | |
| 			}
 | |
| 			btnCreatePDF.Text = "Create PDFs";
 | |
| 			HandleDocVersionSettings();
 | |
| 			PrepForAllOrOne(false);
 | |
| 			// don't open all PDFs if doing All Procedures
 | |
| 			// C2018-033 added the Prefix / Suffix switch to the expand Additional Settings check
 | |
| 			expPrnSetting.Expanded = swtbtnBlankPgsForDuplex.Value || swtbtnChgBar.Value || swtbtnGeneratePlacekeeper.Value || swtbtnPDFLinks.Value || swtbtnPROMSVersion.Value || swtbtnWaterMark.Value || swtbtnPDFdtPrefixSuffix.Value;
 | |
| 		}
 | |
| 		private void PrepForAllOrOne(bool oneProcedure)
 | |
| 		{
 | |
| 			txbPDFName.Visible = lblPDFFileName.Visible = oneProcedure;
 | |
| 			txbReviewDate.Visible = lblReviewDate.Visible = oneProcedure;
 | |
| 			txbRevDate.Visible = lblRevDate.Visible = oneProcedure;
 | |
| 			cbxOpenAfterCreate2.Visible = oneProcedure;
 | |
| 			cbxOpenAfterCreate2.Checked = false;
 | |
| 			cbxOverwritePDF2.Visible = oneProcedure;
 | |
| 			gpnlDebug.Visible = Volian.Base.Library.VlnSettings.DebugMode;
 | |
| 			swtbtnGeneratePlacekeeper.Value = false;
 | |
| 			cbxGenerateConActSum.Checked = false;
 | |
| 			swtbtnGeneratePlacekeeper.Visible = lblGeneratePlacekeeper.Visible = oneProcedure && 
 | |
| 				((MyProcedure.ActiveFormat.PlantFormat.FormatData.PurchaseOptions & E_PurchaseOptions.AutoPlacekeeper) == E_PurchaseOptions.AutoPlacekeeper);
 | |
| 			// C2021-062 make visable the check box to assign rev number for all procedures being printed
 | |
| 			//           also make visable the Rev Num entry field.
 | |
| 			txbRevNum.Enabled = oneProcedure;
 | |
| 			cbxAssignRevToAllMergedPrcs.Visible = btnMergePDFs.Visible = !oneProcedure;
 | |
| 			// C2021-063 make the Generate Alarm Point List text checkbox visable in the format flag is set.
 | |
| 			cbxAlmPtTxt.Visible = !oneProcedure && MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.ChkBoxToGeneratePointListText;
 | |
| 		}
 | |
| 		private string _UnitNumber;
 | |
| 		public string UnitNumber
 | |
| 		{
 | |
| 			get { return _UnitNumber; }
 | |
| 			set { _UnitNumber = value; }
 | |
| 		}
 | |
| 		private int _UnitIndex;
 | |
| 		public int UnitIndex
 | |
| 		{
 | |
| 			get { return _UnitIndex; }
 | |
| 			set { _UnitIndex = value; }
 | |
| 		}
 | |
| 
 | |
| 		// C2018-012 - Code Cleanup - redesigned the Print Dialog to include a sliding panel and remplaced check boxes with ON/OFF switches
 | |
| 		public DlgPrintProcedure(ProcedureInfo pi)
 | |
| 		{
 | |
| 			InitializeComponent();
 | |
| 			_AllProcedures = false;
 | |
| 			_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
 | |
| 			swtbtnBlankPgsForDuplex.Value = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
 | |
| 			tbBlankPage.Text = pi.MyDocVersion.DocVersionConfig.Print_DuplexBlankPageText;
 | |
| 			tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value;
 | |
| 			MyProcedure = pi;
 | |
| 			if (_MyProcedure != null && _MyProcedure.ProcHasSupInfoData)
 | |
| 			{
 | |
| 				swtbtnBlankPgsForDuplex.Enabled = false;
 | |
| 				tbBlankPage.Enabled = true;
 | |
| 			}
 | |
| 			btnCreatePDF.Text = "Create PDF";
 | |
| 			HandleDocVersionSettings();
 | |
| 			PrepForAllOrOne(true);
 | |
| 			cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
 | |
| 			// C2018-033 added the Prefix / Suffix switch to the expand Additional Settings check
 | |
| 			expPrnSetting.Expanded = swtbtnBlankPgsForDuplex.Value || swtbtnChgBar.Value || swtbtnGeneratePlacekeeper.Value || swtbtnPDFLinks.Value || swtbtnPROMSVersion.Value || swtbtnWaterMark.Value || swtbtnPDFdtPrefixSuffix.Value;
 | |
| 		}
 | |
| 		public DlgPrintProcedure(ProcedureInfo pi, bool automatic)  // RHM20150506 Multiline ItemID TextBox
 | |
| 		{		
 | |
| 			InitializeComponent();
 | |
| 			Automatic = automatic;
 | |
| 			_AllProcedures = false;
 | |
| 			_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
 | |
| 			swtbtnBlankPgsForDuplex.Value = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
 | |
| 			tbBlankPage.Text = pi.MyDocVersion.DocVersionConfig.Print_DuplexBlankPageText;
 | |
| 			tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value;
 | |
| 			MyProcedure = pi;
 | |
| 			if (_MyProcedure != null && _MyProcedure.ProcHasSupInfoData)
 | |
| 			{
 | |
| 				swtbtnBlankPgsForDuplex.Enabled = false;
 | |
| 				tbBlankPage.Enabled = true;
 | |
| 			}
 | |
| 			btnCreatePDF.Text = "Create PDF";
 | |
| 			HandleDocVersionSettings();
 | |
| 			PrepForAllOrOne(true);
 | |
| 			cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
 | |
| 			// C2018-033 added the Prefix / Suffix switch to the expand Additional Settings check
 | |
| 			expPrnSetting.Expanded = swtbtnBlankPgsForDuplex.Value || swtbtnChgBar.Value || swtbtnGeneratePlacekeeper.Value || swtbtnPDFLinks.Value || swtbtnPROMSVersion.Value || swtbtnWaterMark.Value || swtbtnPDFdtPrefixSuffix.Value;
 | |
| 		}
 | |
| 		/// <summary>
 | |
| 		/// RHM 20120925 Added so that the dialog would center over the PROMS window
 | |
| 		/// </summary>
 | |
| 		/// <param name="e"></param>
 | |
| 		protected override void OnActivated(EventArgs e)
 | |
| 		{
 | |
| 			base.OnActivated(e);
 | |
| 			if (Owner != null)
 | |
| 				Location = new Point(Owner.Left + Owner.Width / 2 - Width / 2, Owner.Top + Owner.Height/2 - Height/2);
 | |
| 		}
 | |
| 		private void HandleDocVersionSettings()
 | |
| 		{
 | |
| 
 | |
| 			GetDocVersionSettings();
 | |
| 
 | |
| 			// set to a default PDF location if none was specified in the DocVersions property
 | |
| 			if (txbPDFLocation.Text == null || txbPDFLocation.Text.Length == 0 || !Directory.Exists(txbPDFLocation.Text))
 | |
| 				txbPDFLocation.Text = VlnSettings.TemporaryFolder;
 | |
| 			SetCompareVisibility();
 | |
| 			// if the default setting is 'SelectBeforePrinting', expand the Additional Print Settings panel
 | |
| 			if (_DocVersionConfig.Print_ChangeBar == PrintChangeBar.SelectBeforePrinting)
 | |
| 			{
 | |
| 					swtbtnChgBar.Value = false;
 | |
| 					cbxOvrrideDefChgBars.Checked = false;
 | |
| 					expPrnSetting.Expanded = true;
 | |
| 				}
 | |
| 		}
 | |
| 
 | |
| 		private void GetDocVersionSettings()
 | |
| 		{
 | |
| 			_DocVersionConfig.SaveChangesToDocVersionConfig = false;
 | |
| 			_DocVersionConfig.ParentLookup = false;
 | |
| 			// PDF Location
 | |
| 			PDFPath = _DocVersionConfig.Print_PDFLocation;
 | |
| 			// Overwrite PDF
 | |
| 			cbxOverwritePDF2.Checked = _DocVersionConfig.Print_AlwaysOverwritePDF;
 | |
| 			// Open PDF After Create
 | |
| 			cbxOpenAfterCreate2.Checked = _DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
 | |
| 			// Changebars on/off
 | |
| 			if (_DocVersionConfig.Print_ChangeBar == PrintChangeBar.Without)
 | |
| 				swtbtnChgBar.Value = false; 
 | |
| 			else
 | |
| 				swtbtnChgBar.Value = true; 
 | |
| 			// Watermark on/off
 | |
| 			if (_DocVersionConfig.Print_Watermark == PrintWatermark.None)
 | |
| 				swtbtnWaterMark.Value = false; 
 | |
| 			else
 | |
| 				swtbtnWaterMark.Value = true; 
 | |
| 			// Auto Duplexing on/off - Auto duplex was used only by Point Beach formats These buttons were removed from the dialog
 | |
| 			//                         There was not print coding to support this format flag
 | |
| 
 | |
| 			//if ((_MyProcedure.ActiveParent as DocVersionInfo).ActiveFormat.PlantFormat.FormatData.PrintData.AllowDuplex)
 | |
| 			//{
 | |
| 			//	lblAutoDuplexing.Visible = true;
 | |
| 			//	btnDuplxOff.Visible = true;
 | |
| 			//	btnDuplxOn.Visible = true;
 | |
| 			//	if (_DocVersionConfig.Print_DisableDuplex)
 | |
| 			//		btnDuplxOff.PerformClick();
 | |
| 			//	else
 | |
| 			//		btnDuplxOn.PerformClick();
 | |
| 			//}
 | |
| 			//else
 | |
| 			//{
 | |
| 			//	lblAutoDuplexing.Visible = false;
 | |
| 			//	btnDuplxOff.Visible = false;
 | |
| 			//	btnDuplxOn.Visible = false;
 | |
| 			//}
 | |
| 			SetCompareVisibility();
 | |
| 
 | |
| 			// default to using OriginalPageBreaks (16bit page breaks) if App.config is set
 | |
| 			// to true:
 | |
| 			//cbxOrPgBrk.Visible = VlnSettings.OriginalPageBreak && VlnSettings.DebugMode;
 | |
|       cbxOrPgBrk.Visible = false; //per Harry
 | |
| 			cbxOrPgBrk.Checked = false;
 | |
| 		}
 | |
| 
 | |
| 		private void SetCompareVisibility()
 | |
| 		{
 | |
| 			// default to print Debug info if App.config is set to debug mode
 | |
| 			// This checkbox is now labeled as "Compare PDF"
 | |
| 			// If the PDF location has a Compare folder or we are in Debug Mode
 | |
| 			// then make the checkbox visible
 | |
| 			string cmpfldr = txbPDFLocation.Text;
 | |
| 			if (!cmpfldr.EndsWith("\\")) cmpfldr += "\\";
 | |
| 			cmpfldr += "Compare";
 | |
| 			cbxDebug.Visible = Directory.Exists(cmpfldr) || VlnSettings.DebugMode;
 | |
| 			cbxDebug.Checked = false;// C2022-031 VlnSettings.DebugMode;
 | |
| 		}
 | |
| 
 | |
| 		private void DlgPrintProcedure_Load(object sender, EventArgs e)
 | |
| 		{
 | |
| 			SetupForProcedure();
 | |
| 			_MyTimer = new Timer();
 | |
| 			_MyTimer.Tick -= new EventHandler(_MyTimer_Tick);
 | |
| 			_MyTimer.Tick += new EventHandler(_MyTimer_Tick);
 | |
| 			_MyTimer.Interval = 100;
 | |
| 			_MyTimer.Enabled = true;
 | |
| 			btnCreatePDF.Select();
 | |
| 		}
 | |
| 
 | |
| 		void _MyTimer_Tick(object sender, EventArgs e)
 | |
| 		{
 | |
| 			_MyTimer.Enabled = false;
 | |
| 			BringToFront();
 | |
| 			if (Automatic) RunAutomatic();
 | |
| 		}
 | |
| 
 | |
| 		private Timer _MyTimer;
 | |
| 		public void SetupForProcedure() // RHM20150506 Multiline ItemID TextBox
 | |
| 		{
 | |
| 			if(_DocVersionInfo == null)this.Text = "Create PDF for " + ProcNum;
 | |
| 			// get list of previous pdf files
 | |
| 			// if no previous pdf file, then get path from frmVersionProperties
 | |
| 			// dlgSelectFile.InitialDirectory = pdf path from frmVersionProperties
 | |
| 			//cbxPDF.Text = string.Format(@"{0}\{1}.pdf", _PDFPath, _ProcNum);
 | |
| 			// General 2 settings
 | |
| 			//txbPDFLocation.Text = _PDFPath;
 | |
| 			BuildPDFFileName();
 | |
| 			ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			// C2025-033 set which Child procedure is being printed used for PageStyle items
 | |
| 			VlnSvgPageHelper.PrintingChild = SelectedSlave;
 | |
| 			if (SelectedSlave > 0)
 | |
| 			{
 | |
| 				pc.SelectedSlave = SelectedSlave;
 | |
| 			}
 | |
| 			if (pc != null)
 | |
| 			{
 | |
| 				//C2021-062 use the save rev number for all procedures if set, or just use the rev number in the current procedure config
 | |
| 				RevNum = (_NewRevForAllProcs == null) ? pc.Print_Rev : _NewRevForAllProcs;
 | |
| 				RevDate = pc.Print_RevDate; //== null || pc.Print_RevDate=="" ? DateTime.Today : Convert.ToDateTime(pc.Print_RevDate);
 | |
| 				ReviewDate = pc.Print_ReviewDate; // == null ? DateTime.Today : Convert.ToDateTime(pc.Print_ReviewDate);
 | |
| 				 //Now check the format flags to determine if/how the Rev string should be parsed.
 | |
| 				// This will covert the old way (16-bit) of setting a RevDate (appending it to the RevNumber)
 | |
| 				// to the new way saving the RevNumber and RevDate in there own config fields
 | |
| 				if ((_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate && RevNum.Contains("/"))
 | |
| 				    || (_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash && RevNum.Contains("\\")))
 | |
| 				{
 | |
| 				    int indx = RevNum.IndexOf(_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash ? '\\' : '/');
 | |
| 					pc.Print_RevDate = RevDate = RevNum.Substring(indx + 1);
 | |
| 					pc.Print_Rev = RevNum = RevNum.Substring(0, indx);
 | |
| 					// save the RevNumber and RevDate to the procedure's config.
 | |
| 					using (Item itm = Item.Get(MyProcedure.ItemID))
 | |
| 					{
 | |
| 						itm.MyContent.Config = MyProcedure.MyConfig.ToString();
 | |
| 						itm.Save();
 | |
| 					}
 | |
| 				}
 | |
| 				// C2021-019: Override Watermark Text and Color from PSI
 | |
| 				string waterMarkTextOverride = pc.GetValue("PSI", "WATERMARKOVERRIDE");
 | |
| 				if (waterMarkTextOverride != null && waterMarkTextOverride != "")
 | |
| 				{
 | |
| 					cbxWaterMark.Visible = false;
 | |
| 					lblWaterMarkOvrd.Visible = true;
 | |
| 					lblWaterMarkOvrd.Text = waterMarkTextOverride;
 | |
| 				}
 | |
| 				// do color override
 | |
| 				//	if there is override text, label contains overridden text in the color selected from color override
 | |
| 				//	if no override text, combo box text color is override color
 | |
| 				string waterMarkColorOverride = pc.GetValue("PSI", "WATERMARKOVERRIDECLR");
 | |
| 				if (waterMarkColorOverride != null && waterMarkColorOverride != "")
 | |
| 				{
 | |
| 					string strColor = waterMarkColorOverride.ToUpper().Contains("DEFAULT") ? "BLUE" : waterMarkColorOverride;
 | |
| 					if (lblWaterMarkOvrd.Visible)
 | |
| 						lblWaterMarkOvrd.ForeColor = Color.FromName(strColor);
 | |
| 					else
 | |
| 						cbxWaterMark.ForeColor = Color.FromName(strColor);
 | |
| 				}
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				RevNum = "0";
 | |
| 				RevDate = DateTime.Today.ToShortDateString();
 | |
| 				ReviewDate = null;
 | |
| 				cbxWaterMark.Visible = true;
 | |
| 			}
 | |
| 			// B2019-044 use Enum without the "None" option for the print dialog
 | |
| 			cbxWaterMark.DataSource = EnumDetail<PrintDlgWatermarkList>.Details();
 | |
| 			cbxWaterMark.ValueMember = "EValue";
 | |
| 			PrintWatermark pw = _DocVersionConfig.Print_Watermark; // MyProcedure.ProcedureConfig.Print_Watermark;
 | |
| 			string pwstr = pw.ToString().ToUpper();
 | |
| 			if (!pwstr.Equals("NONE")) //B2019-044 check setting from folder level
 | |
| 			{
 | |
| 				if (pwstr.Equals("INFORMATIONONLY"))
 | |
| 					cbxWaterMark.Text = "Information Only";
 | |
| 				else if (pwstr.Equals("UNITDESIGNATOR"))// C2022-004 unit designator option
 | |
| 					cbxWaterMark.Text = "Unit Designator";
 | |
| 				else
 | |
| 					cbxWaterMark.Text = pw.ToString(); // position print dialog list to setting from folder level
 | |
| 			}
 | |
| 			else
 | |
| 				swtbtnWaterMark.Value = false; // set to None at folder level so set Watermark switch to the off position
 | |
| 
 | |
| 			//ppCmbxChgBarPos.DataSource = EnumDetail<PrintChangeBarLoc>.Details();
 | |
| 			//ppCmbxChgBarPos.DisplayMember = "Description";
 | |
| 			//ppCmbxChgBarPos.ValueMember = "EValue";
 | |
| 			//ppCmbxChgBarPos.SelectedIndex = (int)MyProcedure.MyDocVersion.DocVersionConfig.Print_ChangeBarLoc;
 | |
| 
 | |
| 			ppCmbxChgBarTxtType.DataSource = EnumDetail<PrintChangeBarText>.Details();
 | |
| 			ppCmbxChgBarTxtType.DisplayMember = "Description";
 | |
| 			ppCmbxChgBarTxtType.ValueMember = "EValue";
 | |
| 			ppCmbxChgBarTxtType.SelectedIndex = (int)_DocVersionConfig.Print_ChangeBarText;
 | |
| 
 | |
| 			ppTxbxChangeBarUserMsgOne.Text = _DocVersionConfig.Print_UserCBMess1;
 | |
| 			ppTxbxChangeBarUserMsgTwo.Text = _DocVersionConfig.Print_UserCBMess2;
 | |
| 			ppGpbxUserSpecTxt.Enabled = ppCmbxChgBarTxtType.SelectedIndex == (int)PrintChangeBarText.UserDef;
 | |
| 			bool hasReviewDate = _MyProcedure.ActiveFormat.PlantFormat.HasPageListToken("{REVIEWDATE}");
 | |
| 			bool usesRevDate = _MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate || _MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash;
 | |
| 			if (_MyProcedure.Sections != null)
 | |
| 			{
 | |
| 				foreach (SectionInfo mysection in _MyProcedure.Sections)
 | |
| 					hasReviewDate |= mysection.ActiveFormat.PlantFormat.HasPageListToken("{REVIEWDATE}");
 | |
| 			}
 | |
| 			// Only the New HLP format and the MYA format use this
 | |
| 			// South Texas does not use their new HLP format and MYA (Main Yankee) has dropped us (they closed)
 | |
| 			// thus there is no supporting code to print a Review Date
 | |
| 			// thus setting "hasReviewDate" to false so the Review Date entry box does not appear on the print dialog
 | |
| 			// - jsj 4/3/2013
 | |
| 			hasReviewDate = false; // jsj 4/3/2013
 | |
| 			lblReviewDate.Visible = txbReviewDate.Visible = !_AllProcedures && hasReviewDate;
 | |
| 			lblRevDate.Visible = txbRevDate.Visible = !_AllProcedures && usesRevDate;
 | |
| 		}
 | |
| 
 | |
| 		// C2018-033 add the Prefix and/or Suffix to PDF file name if defined and wanted by the user
 | |
| 		//           this piece of code was functionalized from SetupForProcedure()
 | |
| 		private void BuildPDFFileName()
 | |
| 		{
 | |
| 			if (MyProcedure == null) return;
 | |
| 			string PDFFilePrefix = _DocVersionConfig.Print_PDFFilePrefix;
 | |
| 			string PDFFileSuffix = _DocVersionConfig.Print_PDFFileSuffix;
 | |
| 			string PDFFileName = "";
 | |
| 			PDFDTPrefix dtPre = _DocVersionConfig.Print_PDFdtFilePrefix;
 | |
| 			PDFDTSuffix dtSuf = _DocVersionConfig.Print_PDFdtFileSuffix;
 | |
| 			if (dtPre != PDFDTPrefix.None) PDFFilePrefix = ""; // incase user entered prefix text but then selected a date/time (in working draft properties)
 | |
| 			if (dtSuf != PDFDTSuffix.None) PDFFileSuffix = ""; // incase user entered suffix text but then selected a date/time (in working draft properties)
 | |
| 			// B2020-062 control the toggle of date/time prefix/suffix on pdf file name
 | |
| 			//           disable the date/time Prefix/Suffix switch if no date/time was selected
 | |
| 			//           This switch is does not affect the use of it if the user typed in text for prefix/suffix
 | |
| 			if (!AllowDateTimePrefixSuffix || (dtPre == PDFDTPrefix.None && dtSuf == PDFDTSuffix.None))
 | |
| 			{
 | |
| 				swtbtnPDFdtPrefixSuffix.Value = false;
 | |
| 				swtbtnPDFdtPrefixSuffix.Enabled = false;
 | |
| 			}
 | |
| 			if (AllowDateTimePrefixSuffix && swtbtnPDFdtPrefixSuffix.Value)
 | |
| 			{
 | |
| 				//DateTime dts = DateTime.Now;
 | |
| 				if (dtPre != PDFDTPrefix.None)
 | |
| 					PDFFilePrefix = (_PrefixSuffixDTS.ToString(dtPre.ToString())).Replace("__", " ").Replace("_", "-") + "_";
 | |
| 				if (dtSuf != PDFDTSuffix.None)
 | |
| 					PDFFileSuffix = "_" + (_PrefixSuffixDTS.ToString(dtSuf.ToString())).Replace("__", " ").Replace("_", "-");
 | |
| 			}
 | |
| 			if (ProcNum == string.Empty)
 | |
| 				//txbPDFName.Text = this.UnitNumber + ".pdf";
 | |
| 				PDFFileName = this.UnitNumber;
 | |
| 			else
 | |
| 				//txbPDFName.Text = string.Format("{0}.pdf", _MyProcedure.PDFNumber);
 | |
| 				PDFFileName = string.Format("{0}", _MyProcedure.PDFNumber);
 | |
| 			//if (txbPDFName.Text.StartsWith("*"))
 | |
| 			//    txbPDFName.Text = txbPDFName.Text.Replace("*", this.UnitNumber);
 | |
| 			if ((PDFFileName ?? "") == "") PDFFileName = "NoProcNumber";
 | |
| 			if (PDFFileName.StartsWith("*"))
 | |
| 				PDFFileName = PDFFileName.Replace("*", this.UnitNumber);
 | |
| 			if (PDFFileName.Contains("?")) PDFFileName = PDFFileName.Replace("?", "_");  // for wcn sys/BM-2xxA??, etc
 | |
| 			txbPDFName.Text = PDFFilePrefix + PDFFileName + PDFFileSuffix + ".pdf";
 | |
| 		}
 | |
| 
 | |
| 		// C2018-033 Enable/disable the switch to control whether to add Prefix and/or Suffix to PDF file name
 | |
| 		private void SetupPrefixSuffixSwitch()
 | |
| 		{
 | |
| 			if (_CreateButtonClicked) return; // B2020-062 control the toggle of date/time prefix/suffix on pdf file name
 | |
| 			// note that MyProcedure must be set before calling this because BuildPDFFileName() will be called when the swbtnPDFPrefixSuffix is set
 | |
| 			string PDFFilePrefix = _DocVersionConfig.Print_PDFFilePrefix;
 | |
| 			string PDFFileSuffix = _DocVersionConfig.Print_PDFFileSuffix;
 | |
| 			PDFDTPrefix dtPre = _DocVersionConfig.Print_PDFdtFilePrefix;
 | |
| 			PDFDTSuffix dtSuf = _DocVersionConfig.Print_PDFdtFileSuffix;
 | |
| 			bool hasPrefixSuffix = _DateTimePrefixSuffixPrintingAllProcedures && (PDFFilePrefix.Length > 0 || PDFFileSuffix.Length > 0 || dtPre != PDFDTPrefix.None || dtSuf != PDFDTSuffix.None);
 | |
| 			swtbtnPDFdtPrefixSuffix.Value = hasPrefixSuffix; // this will call BuildPDFFileName() thus MyProcedure must be set
 | |
| 			swtbtnPDFdtPrefixSuffix.Enabled = hasPrefixSuffix;
 | |
| 		}
 | |
| 
 | |
| 		private void btnCancel_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			this.Close();
 | |
| 		}
 | |
| 
 | |
| 		private void swtbtnChgBar_ValueChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			// C2019-031 - disable the override change bar grouping when default change bar is set to format default or no change bar
 | |
| 			cbxOvrrideDefChgBars.Checked = false; // uncheck the override change bar check box inside the grouping
 | |
| 			cbxOvrrideDefChgBars.Enabled = swtbtnChgBar.Value; // C2022-015 enable if Change Bars are turned on
 | |
| 
 | |
| 			if (swtbtnChgBar.Value)
 | |
| 			{
 | |
| 				switch (_DocVersionConfig.Print_ChangeBar)
 | |
| 				{
 | |
| 					case PrintChangeBar.WithUserSpecified:
 | |
| 						cbxOvrrideDefChgBars.Enabled = true; // change bar text is pre-selected in procedure set properties, allow user to change change bar text
 | |
| 						cbxOvrrideDefChgBars.Checked = true;
 | |
| 						break;
 | |
| 					case PrintChangeBar.SelectBeforePrinting:
 | |
| 						cbxOvrrideDefChgBars.Enabled = true; // allow user to select change bar text every time procedure is printed 
 | |
| 						break;
 | |
| 					case PrintChangeBar.Without:
 | |
| 					case PrintChangeBar.WithDefault:
 | |
| 						cbxOvrrideDefChgBars.Enabled = false; // printing with format default change bars - don't allow override
 | |
| 						cbxOvrrideDefChgBars.Checked = false;
 | |
| 						break;
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void swtbtnWaterMark_ValueChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (!swtbtnWaterMark.Value)		// C2021-019: make both invisible
 | |
| 			{
 | |
| 				cbxWaterMark.Visible = swtbtnWaterMark.Value;
 | |
| 				lblWaterMarkOvrd.Visible = swtbtnWaterMark.Value;
 | |
| 			}
 | |
| 			else    // C2021-019: determine whether combo box or lable needs to be made visible
 | |
| 			{
 | |
| 				ProcedureConfig pc = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 				string waterMarkTextOverride = pc.GetValue("PSI", "WATERMARKOVERRIDE");
 | |
| 				if (waterMarkTextOverride != null && waterMarkTextOverride != "")
 | |
| 				{
 | |
| 					cbxWaterMark.Visible = false;
 | |
| 					lblWaterMarkOvrd.Visible = true;
 | |
| 				}
 | |
| 				else
 | |
| 				{
 | |
| 					cbxWaterMark.Visible = true;
 | |
| 					lblWaterMarkOvrd.Visible = false;
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void txbPDFLocation_Leave(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (!Directory.Exists(PDFPath))
 | |
| 			{
 | |
| 				string msg = string.Format("'{0}' does not exist. \n\nCreate it?", PDFPath);
 | |
| 				DialogResult dr= MessageBox.Show(msg, "Folder Not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | |
| 				if (dr == DialogResult.Yes)
 | |
| 				{
 | |
| 					try
 | |
| 					{
 | |
| 						Directory.CreateDirectory(PDFPath);
 | |
| 					}
 | |
| 					catch (Exception ex)
 | |
| 					{
 | |
| 						MessageBox.Show(ex.Message, "Error trying to create folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
 | |
| 						PDFPath = _DocVersionConfig.Print_PDFLocation;
 | |
| 					}
 | |
| 				}
 | |
| 				else
 | |
| 				{
 | |
| 					PDFPath = _DocVersionConfig.Print_PDFLocation;
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void DlgPrintProcedure_FormClosed(object sender, FormClosedEventArgs e)
 | |
| 		{
 | |
| 			_DocVersionConfig.SaveChangesToDocVersionConfig = true;
 | |
| 			//_DocVersionConfig.ParentLookup = true;
 | |
| 
 | |
| 			ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			if (SelectedSlave > 0) pc.SelectedSlave = 0;
 | |
| 		}
 | |
| 
 | |
| 		private ProcedureInfo _MyProcedure;
 | |
| 
 | |
| 		public ProcedureInfo MyProcedure
 | |
| 		{
 | |
| 			get { return _MyProcedure; }
 | |
| 			set 
 | |
| 			{
 | |
| 				_MyProcedure = value;
 | |
| 				// if procedure has supplemental information, the automatially check the add blank pages for duplex printing
 | |
| 				if (_MyProcedure.ProcHasSupInfoData)
 | |
| 				{
 | |
| 					swtbtnBlankPgsForDuplex.Value = true;
 | |
| 					tbBlankPage.Enabled = true;
 | |
| 				}
 | |
| 				SetupPrefixSuffixSwitch();  // C2018-033 Enable the switch to control whether to add Prefix and/or Suffix to PDF file name
 | |
| 			}
 | |
| 		}
 | |
| 		private int _SelectedSlave = 0;
 | |
| 		public int SelectedSlave
 | |
| 		{
 | |
| 			get { return _SelectedSlave; }
 | |
| 			set
 | |
| 			{
 | |
| 				_SelectedSlave = value;
 | |
| 				lblMultiunitPdfLocation.Visible = cbxMultiunitPdfLocation.Visible = (value > -1);
 | |
| 				cbxMultiunitPdfLocation.SelectedIndex = 1;
 | |
| 			}
 | |
| 		}
 | |
| 		private string _MultiunitPdfLocation = string.Empty;
 | |
| 		private MergedPdf _MergedPfd = null;
 | |
| 		private string _MergedPdfPath = null;
 | |
| 		private void CreatePDFs()
 | |
| 		{
 | |
| 			if (VlnSettings.GetCommandFlag("PROFILE")) ProfileTimer.TurnOnTracking("Profile.txt");
 | |
| 			VEPROMS.CSLA.Library.Database.TrackDBUsage = VlnSettings.GetCommandFlag("DBTrack");
 | |
| 			ProfileTimer.Reset();
 | |
| 			int profileDepth = ProfileTimer.Push(">>>> CreatePdf");
 | |
| 			StringBuilder sb = new StringBuilder();
 | |
| 			if (MySessionInfo != null)
 | |
| 			{
 | |
| 				foreach (ProcedureInfo myProc in _DocVersionInfo.Procedures)
 | |
| 				{
 | |
| 					string message = string.Empty;
 | |
| 					if (!MySessionInfo.CanCheckOutItem(myProc.ItemID, CheckOutType.Procedure, ref message))
 | |
| 					{
 | |
| 						sb.AppendLine(message);
 | |
| 					}
 | |
| 				}
 | |
| 				if (sb.Length > 0)
 | |
| 				{
 | |
| 					if (MessageBox.Show(sb.ToString() + Environment.NewLine + Environment.NewLine + "Do you want to continue to print all procedures?", "Procedures Already Checked Out", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
 | |
| 						return;
 | |
| 				}
 | |
| 			}
 | |
| 			CreateDebugFiles();
 | |
| 			// If file exists, determine if overwrite checkbox allows overwrite, if not prompt.
 | |
| 			Volian.Print.Library.Rtf2Pdf.PdfDebug = cbxDebug.Checked;
 | |
| 			// B2019-128: The combo box list did not include the 'None' option so the selected value was not the correct watermark (had to add 1 to the selected index)
 | |
| 			string waterMarkText = (swtbtnWaterMark.Value) ? cbxWaterMark.Text : "None";    // C2021-019
 | |
| 			string watermarkColor = "Blue"; // this is the default watermark color
 | |
| 			// Determine change bar settings.  First get from config & then see if override from dialog. 
 | |
| 			// Also check that format allows override.
 | |
| 			ChangeBarDefinition cbd = DetermineChangeBarSettings();
 | |
| 			int n = _DocVersionInfo.Procedures.Count;
 | |
| 			int i = 0;
 | |
| 			pbPDFsStatus.Maximum = n;
 | |
| 			pbPDFsStatus.Visible = true;
 | |
| 			VlnSvgPageHelper.CountInApplProcs = 1;	// B2021-127: BNPPalr - Auto set of serial #, skip Front Matter as per PAL 11/1/21 (set to 1 not 0)
 | |
| 			this.Text = string.Format("Processing {0}", _DocVersionInfo.MyFolder.Name);
 | |
| 			foreach (ProcedureInfo myProc in _DocVersionInfo.Procedures)
 | |
| 			{
 | |
| 				string locpdfname = null;		// get pdf file name for later merge code
 | |
| 				MyProcedure = myProc;
 | |
| 				// C2021-019: Override Watermark Text, 'waterMarkText' will have whatever watermark text should be printed
 | |
| 				ProcedureConfig procConfig = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 				string waterMarkTextOverride = "";
 | |
| 				if (procConfig != null) waterMarkTextOverride = procConfig.GetValue("PSI", "WATERMARKOVERRIDE");
 | |
| 				// C2020-002 paper size is now set in the format files - default is Letter
 | |
| 				Volian.Print.Library.Rtf2Pdf.PaperSize = myProc.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize;
 | |
| 				if (myProc.Sections != null)
 | |
| 				{
 | |
| 					// This is master/slave & a slave has been selected for printing (SelectedSlave > 0)
 | |
| 					if (SelectedSlave > 0)
 | |
| 					{
 | |
| 						bool includeProc = MyProcedure.ApplInclude(SelectedSlave);     // C2021-027: Procedure level PC/PC?
 | |
| 						if (!includeProc) VlnSvgPageHelper.CountInApplProcs++;      // B2021-127: BNPPalr - Auto set of serial #
 | |
| 						if (includeProc)
 | |
| 						{
 | |
| 							MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = SelectedSlave;
 | |
| 							SetupForProcedure();
 | |
| 							//B2022-030 moved the watermark stuff after SetupForProcedure so that DisplayNumber is properly resolved and the proper unit watermark is found
 | |
| 							//          also moved the setting of override watermark to after SetUnitWatermark so that it truely overrrides
 | |
| 							frmPDFStatusForm.SetUnitWatermark(MyProcedure, ref waterMarkText, ref watermarkColor); //C2022-004 Unit Designator watermark																												   // C2021-062 save the entered Rev Number to all of the procedures that are being printed
 | |
| 							if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
 | |
| 							if (_NewRevForAllProcs != null) SaveRevNumToProcedureConfig(_NewRevForAllProcs);
 | |
| 							pbPDFsStatus.TextVisible = true;
 | |
| 							pbPDFsStatus.Text = string.Format("Creating PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 							pbPDFsStatus.Value = i;
 | |
| 							//						this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 
 | |
| 							// B2021-102 we now get this information in frmPDFStatusForm()
 | |
| 							//MyProcedure = ProcedureInfo.GetItemAndChildrenByUnit(MyProcedure.ItemID, 0, MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave);
 | |
| 							// C2018-015 add the procedure tree path and the procedure number and title to the meta file
 | |
| 							//if (BaselineMetaFile.IsOpen && i == 1) BaselineMetaFile.WriteLine("!! {0}", MyProcedure.SearchDVPath.Replace("\a", " | "));
 | |
| 							//if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
 | |
| 
 | |
| 							string myPDFPath = GetMultiunitPDFPath();
 | |
| 							_MergedPdfPath = myPDFPath;     // If Slave, need its subdirectory/unit path for merging
 | |
| 															// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
 | |
| 							// B2021-102 put in the using for better memory management
 | |
| 							using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked,
 | |
| 								cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, myPDFPath, cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
 | |
| 								swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID))//;//C2018-009 print PROMS version
 | |
| 							{
 | |
| 								frmStatus.CloseWhenDone = true;
 | |
| 								Application.DoEvents();
 | |
| 								frmStatus.CancelStop = true;
 | |
| 								frmStatus.ShowDialog();
 | |
| 								locpdfname = frmStatus.PdfFile;
 | |
| 								if (frmStatus.CancelPrinting) break;
 | |
| 								AddToMergeList(myProc, locpdfname);
 | |
| 							}
 | |
| 						}
 | |
| 					}
 | |
| 					// This is a master/slave for printing of all slaves (SelectedSave == 0)
 | |
| 					else if (SelectedSlave == 0)
 | |
| 					{
 | |
| 						for (int k = 1; k <= MyProcedure.MyDocVersion.MultiUnitCount; k++)
 | |
| 						{
 | |
| 							MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = k;
 | |
| 							SetupForProcedure();
 | |
| 							//B2022-030 moved the watermark stuff after SetupForProcedure so that DisplayNumber is properly resolved and the proper unit watermark is found
 | |
| 							//          also moved the setting of override watermark to after SetUnitWatermark so that it truely overrrides
 | |
| 							frmPDFStatusForm.SetUnitWatermark(MyProcedure, ref waterMarkText, ref watermarkColor); //C2022-004 Unit Designator watermark																												   // C2021-062 save the entered Rev Number to all of the procedures that are being printed
 | |
| 							if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
 | |
| 							// C2021-062 save the entered Rev Number to all of the procedures that are being printed
 | |
| 							if (_NewRevForAllProcs != null) SaveRevNumToProcedureConfig(_NewRevForAllProcs);
 | |
| 							pbPDFsStatus.TextVisible = true;
 | |
| 							pbPDFsStatus.Text = string.Format("Creating PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 							pbPDFsStatus.Value = i;
 | |
| 							//							this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 
 | |
| 							// B2021-102 we now get this information in frmPDFStatusForm()
 | |
| 							//MyProcedure = ProcedureInfo.GetItemAndChildrenByUnit(MyProcedure.ItemID, 0, MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave);
 | |
| 							// C2018-015 add the procedure tree path and the procedure number and title to the meta file
 | |
| 							//if (BaselineMetaFile.IsOpen && i == 1) BaselineMetaFile.WriteLine("!! {0}", MyProcedure.SearchDVPath.Replace("\a", " | "));
 | |
| 							//if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
 | |
| 
 | |
| 							// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
 | |
| 							// B2016-249 Output Procedure to folder associated with Parent Child
 | |
| 							// B2021-102 put in the using for better memory management
 | |
| 							using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked,
 | |
| 								cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
 | |
| 								swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor)) // ;//C2018-009 print PROMS version
 | |
| 							{
 | |
| 								frmStatus.CloseWhenDone = true;
 | |
| 								Application.DoEvents();
 | |
| 								frmStatus.CancelStop = true;
 | |
| 								frmStatus.ShowDialog();
 | |
| 								locpdfname = frmStatus.PdfFile;
 | |
| 								if (frmStatus.CancelPrinting) break;
 | |
| 								AddToMergeList(myProc, locpdfname);
 | |
| 							}
 | |
| 						}
 | |
| 					}
 | |
| 					// Not master/slave
 | |
| 					else
 | |
| 					{
 | |
| 						SetupForProcedure();
 | |
| 						//B2022-030 moved the watermark stuff after SetupForProcedure so that DisplayNumber is properly resolved and the proper unit watermark is found
 | |
| 						//          also moved the setting of override watermark to after SetUnitWatermark so that it truely overrrides
 | |
| 						frmPDFStatusForm.SetUnitWatermark(MyProcedure, ref waterMarkText, ref watermarkColor); //C2022-004 Unit Designator watermark																												   // C2021-062 save the entered Rev Number to all of the procedures that are being printed
 | |
| 						if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
 | |
| 						pbPDFsStatus.TextVisible = true;
 | |
| 						pbPDFsStatus.Text = string.Format("Creating PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 						pbPDFsStatus.Value = i;
 | |
| 						//						this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
 | |
| 						// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
 | |
| 						int profileDepth1 = ProfileTimer.Push(">>>> GetItemAndChildren");
 | |
| 						// B2021-102 we now get this information in frmPDFStatusForm()
 | |
| 						//if (MyProcedure.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier || MyProcedure.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier)
 | |
| 						//	MyProcedure = ProcedureInfo.GetItemAndChildrenByUnit(MyProcedure.ItemID, 0, MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave);
 | |
| 						//else
 | |
| 						//	MyProcedure = ProcedureInfo.GetItemAndChildren(MyProcedure.ItemID);
 | |
| 						//// C2018-015 add the procedure tree path and the procedure number and title to the meta file
 | |
| 						//if (BaselineMetaFile.IsOpen && i == 1) BaselineMetaFile.WriteLine("!! {0}", MyProcedure.SearchDVPath.Replace("\a", " | "));
 | |
| 						//if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
 | |
| 
 | |
| 						ProfileTimer.Pop(profileDepth1);
 | |
| 						// B2021-102 put in the using for better memory management
 | |
| 						// B2016-249 Output Procedure to folder associated with Parent Child
 | |
| 						using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked,
 | |
| 							cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text,
 | |
| 							new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID)) // ;//C2018-009 print PROMS version
 | |
| 						{
 | |
| 							frmStatus.PrtSectID = PrtSectID;
 | |
| 							frmStatus.CloseWhenDone = true;
 | |
| 							Application.DoEvents();
 | |
| 							frmStatus.CancelStop = true;
 | |
| 							frmStatus.ShowDialog();
 | |
| 							locpdfname = frmStatus.PdfFile;
 | |
| 							if (frmStatus.CancelPrinting) break;
 | |
| 							AddToMergeList(myProc, locpdfname);
 | |
| 						}
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 			pbPDFsStatus.Visible = false;
 | |
| 			if(!Automatic) 
 | |
| 				ShowDebugFiles();
 | |
| 			ProfileTimer.Pop(profileDepth);
 | |
| 			ProfileTimer.ShowTimerTable();
 | |
| 			if (VlnSettings.GetCommandFlag("DBTrack"))
 | |
| 			{
 | |
| 				VEPROMS.CSLA.Library.Database.TrackDBUsage = false;
 | |
| 				VEPROMS.CSLA.Library.Database.ShowDBTracking("DBTracking.txt");
 | |
| 			}
 | |
| 		}
 | |
| 		private void AddToMergeList(ProcedureInfo myProc, string locpdfname)
 | |
| 		{
 | |
| 			// if doing a merge and this procedure should be included, add it to _MergedPdf:
 | |
| 			if (_MergedPfd != null && !(myProc.MyConfig as ProcedureConfig).Print_NotInMergeAll)
 | |
| 			{
 | |
| 				// pdf name from printing has the path, remove it.  
 | |
| 				string pdfname = locpdfname.Substring(locpdfname.LastIndexOf(@"\") + 1);
 | |
| 				MergedPdfProc mpp = new MergedPdfProc(myProc.DisplayText, pdfname);
 | |
| 				// F2021-046: flag if cover page section doesn't print page number on first page of merged pdf:
 | |
| 				if (myProc.Sections != null)
 | |
| 				{
 | |
| 					foreach (ItemInfo ii in myProc.Sections) if (ii.MyDocStyle != null && ii.MyDocStyle.CoverNoMergedPageNum) mpp.FirstPageNoPageNum = true;
 | |
| 				}
 | |
| 				if (_MergedPfd.MergedPdfs == null) _MergedPfd.MergedPdfs = new List<MergedPdfProc>();
 | |
| 				mpp.PageCount = PromsPrinter.ProcPageCount;
 | |
| 				_MergedPfd.MergedPdfs.Add(mpp);
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private string GetMultiunitPDFPath()
 | |
| 		{
 | |
| 			string newPDFPath = string.Empty;
 | |
| 			if (_MultiunitPdfLocation == "None")
 | |
| 				newPDFPath = PDFPath;
 | |
| 			if (_MultiunitPdfLocation == "Unit Name")
 | |
| 				newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_Name;
 | |
| 			if (_MultiunitPdfLocation == "Unit Number")
 | |
| 				newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_Number;
 | |
| 			if (_MultiunitPdfLocation == "Unit Text")
 | |
| 				newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_Text;
 | |
| 			if (_MultiunitPdfLocation == "Unit ID")
 | |
| 				newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_ID;
 | |
| 			if (newPDFPath == "") newPDFPath = Volian.Base.Library.VlnSettings.TemporaryFolder;
 | |
| 			// B2016-255 Non-P/C PC proceduress need to remove that \0 that the code above addds
 | |
| 			if (newPDFPath.EndsWith("\\0")) newPDFPath = newPDFPath.Substring(0, newPDFPath.Length - 2);
 | |
| 			if (!Directory.Exists(newPDFPath))
 | |
| 				Directory.CreateDirectory(newPDFPath);
 | |
| 			return newPDFPath;
 | |
| 		}
 | |
| 		private void CreateDebugFiles()
 | |
| 		{
 | |
| 			if (cbxDebugPagination.Checked)
 | |
| 				Volian.Base.Library.DebugPagination.Open(PDFPath + "\\DebugPagination.txt"); // RHM 20120925 Corrected spelling
 | |
| 			if (cbxDebugText.Checked)
 | |
| 				Volian.Base.Library.DebugText.Open(PDFPath + "\\DebugText.txt");
 | |
| 			if (cbxMetaFile.Checked) // C2018-004 create meta file for baseline compares
 | |
| 			{
 | |
| 				Volian.Base.Library.BaselineMetaFile.Open(PDFPath + "\\DebugMeta.txt");
 | |
| 				// C2018-015 add the PROMS Version, SQL Server, and Database to top of the meta file
 | |
| 				Volian.Base.Library.BaselineMetaFile.WriteLine("!! Ver {0}  {1} {2}", AboutVEPROMS.PROMSVersion, AboutVEPROMS.SQLServerName, AboutVEPROMS.DatabaseName);
 | |
| 				// C2018-023 set as to whether we are going to include the Word attment text in the baseline metafile
 | |
| 				Volian.Base.Library.BaselineMetaFile.IncludeWordSecText = _IncludeWordSecTextInMetafile;
 | |
| 			}
 | |
| 			Rtf2Pdf._lastPageNum = 0; // reset page number
 | |
| 		}
 | |
| 		private void ShowDebugFiles()
 | |
| 		{
 | |
| 			if (cbxDebugPagination.Checked)
 | |
| 				Volian.Base.Library.DebugPagination.Show();
 | |
| 			if (cbxDebugText.Checked)
 | |
| 				Volian.Base.Library.DebugText.Show();
 | |
| 			if (cbxMetaFile.Checked)// C2018-004 create meta file for baseline compares
 | |
|         Volian.Base.Library.BaselineMetaFile.Show(); // baseline
 | |
| 		}
 | |
| 		public void CreatePDF()  // RHM20150506 Multiline ItemID TextBox
 | |
| 		{
 | |
| 			if (VlnSettings.GetCommandFlag("PROFILE")) ProfileTimer.TurnOnTracking("Profile.txt");
 | |
| 			VEPROMS.CSLA.Library.Database.TrackDBUsage = VlnSettings.GetCommandFlag("DBTrack");
 | |
| 			ProfileTimer.Reset();
 | |
| 			int profileDepth = ProfileTimer.Push(">>>> CreatePdf");
 | |
| 			string message = string.Empty;
 | |
| 			if (!MySessionInfo.CanCheckOutItem(MyProcedure.ItemID, CheckOutType.Procedure, ref message))
 | |
| 			{
 | |
| 				if (MessageBox.Show(this, message + Environment.NewLine + Environment.NewLine + "Do you want to continue to print the procedure?", "Procedure Is Checked Out", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
 | |
| 					return;
 | |
| 			}
 | |
| 			MyProcedure.SelectedChildToPrint = SelectedSlave; // B2023-035 for BNPP Alarms save the number of the child selected to print
 | |
| 			// B2021-127: BNPPalr - Auto set of serial #, skip Front Matter as per PAL 11/1/21 (set to 1 not 0)
 | |
| 			//		Only do if set has applicability, printing an individual procedure, need to determine 
 | |
| 			//		applicability count.
 | |
| 			if (MyProcedure.MyDocVersion.MultiUnitCount > 1)
 | |
| 			{
 | |
| 				VlnSvgPageHelper.CountInApplProcs = 1;
 | |
| 				foreach (ProcedureInfo pi in MyProcedure.MyDocVersion.Procedures)
 | |
| 				{
 | |
| 					if (pi.ItemID == MyProcedure.ItemID) break;
 | |
| 					bool includeProc = pi.ApplInclude(SelectedSlave);
 | |
| 					if (!includeProc) VlnSvgPageHelper.CountInApplProcs++;
 | |
| 				}
 | |
| 			}
 | |
| 			CreateDebugFiles();
 | |
| 			// If file exists, determine if overwrite checkbox allows overwrite, if not prompt.
 | |
| 
 | |
| 			Volian.Print.Library.Rtf2Pdf.PdfDebug = cbxDebug.Checked;
 | |
| 			// B2019-044 don't print the watermark if the watermark switch on the print dialog is turned off
 | |
| 			cbxWaterMark.Visible = true;
 | |
| 			string waterMarkText = (swtbtnWaterMark.Value) ? cbxWaterMark.Text : "None" ; // B2018-124 use text of watermark form drop down list instead of enum value
 | |
| 			string watermarkColor = "Blue"; // this is the default watermark color
 | |
| 			frmPDFStatusForm.SetUnitWatermark(MyProcedure, ref waterMarkText, ref watermarkColor); //C2022-004 Unit Designator Watermark
 | |
| 			ProcedureConfig procConfig = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			string waterMarkTextOverride = "";
 | |
| 			if (procConfig != null) waterMarkTextOverride = procConfig.GetValue("PSI", "WATERMARKOVERRIDE");	// C2021-019: override watermark text
 | |
| 			if (swtbtnWaterMark.Value && waterMarkTextOverride != null && waterMarkTextOverride != "") waterMarkText = waterMarkTextOverride;
 | |
| 			// Determine change bar settings.  First get from config & then see if override from dialog. 
 | |
| 			// Also check that format allows override.
 | |
| 			ChangeBarDefinition cbd = DetermineChangeBarSettings();
 | |
| 			int profileDepth2 = ProfileTimer.Push(">>>> CreatePdf.GetItemAndChildren");
 | |
| 
 | |
| 			// B2021-088 moved this if/else to frmPDFStatusForm() so that the Approval logic will have access to this logic
 | |
| 			//if (MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave > 0 || MyProcedure.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier || MyProcedure.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier)
 | |
| 			//	MyProcedure = ProcedureInfo.GetItemAndChildrenByUnit(MyProcedure.ItemID, 0, MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave);
 | |
| 			//else
 | |
| 			//	MyProcedure = ProcedureInfo.GetItemAndChildren(MyProcedure.ItemID);
 | |
| 			// C2018-015 add the procedure tree path and the procedure number and title to the meta file
 | |
| 			//if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0}", MyProcedure.SearchDVPath.Replace("\a"," | "));
 | |
| 			//if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
 | |
| 
 | |
| 			// B2022-088: Find Doc Ro button not working in Word Sections
 | |
| 			// Initialize Print Cache 
 | |
| 			MSWordToPDF.RoPrintCache = new Dictionary<string, ROFSTLookup.rochild>();
 | |
| 
 | |
| 
 | |
| 			// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
 | |
| 			ProfileTimer.Pop(profileDepth2);
 | |
| 			// B2016-249 Output Procedure to folder associated with Parent Child
 | |
| 			// B2018-124 use text of watermark form drop down list instead of enum value
 | |
| 			using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked,
 | |
| 				cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
 | |
| 				swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, false, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID))//; //C2018-009 print PROMS version
 | |
| 			{
 | |
| 				frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value;
 | |
| 				frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked;
 | |
| 				if (Automatic && cbxGenerateConActSum.Checked)
 | |
| 					frmStatus.OnlyShowContinuousActionSummary = true;
 | |
| 
 | |
| 				// F2022-024 Time Critical Action Summary
 | |
| 				frmStatus.MakeTimeCriticalActionSummary = cbxGenerateTimeCritActSum.Checked;
 | |
| 				if (Automatic && cbxGenerateTimeCritActSum.Checked)
 | |
| 					frmStatus.OnlyShowTimeCriticalActionSummary = true;
 | |
| 
 | |
| 				int profileDepth3 = ProfileTimer.Push(">>>> frmStatus");
 | |
| 				frmStatus.ShowDialog();
 | |
| 				ProfileTimer.Pop(profileDepth3);
 | |
| 			}
 | |
| 
 | |
| 			// B2022-088: Find Doc Ro button not working in Word Sections
 | |
| 			// Cleanup Print Cache 
 | |
| 			MSWordToPDF.RoPrintCache.Clear();
 | |
| 			MSWordToPDF.RoPrintCache = null;
 | |
| 
 | |
| 
 | |
| 			MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0;
 | |
| 			MyProcedure.SelectedChildToPrint = 0; // B2023-035 reset
 | |
| 			this.Close();
 | |
| 			ShowDebugFiles();
 | |
| 			ProfileTimer.Pop(profileDepth);
 | |
| 			ProfileTimer.ShowTimerTable();
 | |
| 			if (VlnSettings.GetCommandFlag("DBTrack"))
 | |
| 			{
 | |
| 				VEPROMS.CSLA.Library.Database.TrackDBUsage = false;
 | |
| 				VEPROMS.CSLA.Library.Database.ShowDBTracking("DBTracking.txt");
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		// Determine if any dialog selections for change bars have overridden the data
 | |
| 		// supplied in the DocVconfig data or format file.  Settings are location and text.
 | |
| 		private ChangeBarDefinition DetermineChangeBarSettings()
 | |
| 		{
 | |
| 			ChangeBarDefinition cbd = new ChangeBarDefinition();
 | |
| 
 | |
| 			// if the dialog has 'without change bar' selected, then just set without and return
 | |
| 			if (!swtbtnChgBar.Value)
 | |
| 			{
 | |
| 				cbd.MyChangeBarType = PrintChangeBar.Without;
 | |
| 				return cbd;
 | |
| 			}
 | |
| 			// Get settings from dialog because these are used to set the initial dialog values and
 | |
| 			// any changes from user overrides the initial settings.
 | |
| 			ChangeBarData changeBarData = MyProcedure.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData;
 | |
| 			if (!cbxOvrrideDefChgBars.Checked || _DocVersionConfig == null || _DocVersionConfig.Print_ChangeBar == PrintChangeBar.WithDefault)
 | |
| 			{
 | |
| 				cbd.MyChangeBarType = PrintChangeBar.WithDefault;
 | |
| 				cbd.MyChangeBarText = changeBarData.ChangeBarMessage == "ChgID" ? PrintChangeBarText.ChgID :
 | |
| 					changeBarData.ChangeBarMessage == "DateAndChgID" ? PrintChangeBarText.DateChgID :
 | |
| 					changeBarData.ChangeBarMessage == "None" ? PrintChangeBarText.None :
 | |
| 					changeBarData.ChangeBarMessage == "RevNum" ? PrintChangeBarText.RevNum : PrintChangeBarText.UserDef;
 | |
| 			}
 | |
| 			else if (cbxOvrrideDefChgBars.Checked || _DocVersionConfig.Print_ChangeBar == PrintChangeBar.WithUserSpecified)
 | |
| 			{
 | |
| 				cbd.MyChangeBarLoc = _DocVersionConfig.Print_ChangeBarLoc; // (PrintChangeBarLoc)ppCmbxChgBarPos.SelectedIndex;
 | |
| 				cbd.MyChangeBarText = (PrintChangeBarText)ppCmbxChgBarTxtType.SelectedIndex;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				cbd.MyChangeBarLoc = _DocVersionConfig.Print_ChangeBarLoc;
 | |
| 				cbd.MyChangeBarText = _DocVersionConfig.Print_ChangeBarText;
 | |
| 			}
 | |
| 
 | |
| 			// now figure out the location.
 | |
| 			if (cbd.MyChangeBarType != PrintChangeBar.Without)
 | |
| 			{
 | |
| 				// if the format has the absolutefixedchangecolumn format flag, then always use the fixedchangecolumn from the
 | |
| 				// format, otherwise, use the default column based on the selected location, stored in the base format.
 | |
| 				cbd.MyChangeBarColumn = (changeBarData.AbsoluteFixedChangeColumn) ?
 | |
| 					(int)changeBarData.FixedChangeColumn :
 | |
| 					System.Convert.ToInt32(changeBarData.DefaultCBLoc.Split(" ,".ToCharArray())[System.Convert.ToInt32(cbd.MyChangeBarLoc)]);
 | |
| 				//cbd.MyChangeBarColumn = (int)changeBarData.FixedChangeColumn;
 | |
| 				if (cbd.MyChangeBarText == PrintChangeBarText.UserDef && !string.IsNullOrEmpty(ppTxbxChangeBarUserMsgOne.Text))
 | |
| 					cbd.MyChangeBarMessage = ppTxbxChangeBarUserMsgOne.Text + @"\n" + ppTxbxChangeBarUserMsgTwo.Text;
 | |
| 				else if (cbd.MyChangeBarText == PrintChangeBarText.UserDef)
 | |
| 					cbd.MyChangeBarMessage = _DocVersionConfig.Print_UserCBMess1 + @"\n" + _DocVersionConfig.Print_UserCBMess2;
 | |
| 
 | |
| 			}
 | |
| 			return cbd;
 | |
| 		}
 | |
| 		private void btnCreatePDF_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			// B2024-058  Add validation for Revision Date field of the Print dialog
 | |
| 			if (txbRevDate.Visible)
 | |
| 			{
 | |
| 				if (!validateDate(txbRevDate))
 | |
| 				{
 | |
| 					//txbRevDate.Focus();
 | |
| 					return;
 | |
| 				}
 | |
| 			}
 | |
| 			DoCreatePDF();
 | |
| 		}
 | |
| 
 | |
| 		public void QPCreatePDF()
 | |
| 		{
 | |
| 			DoCreatePDF();
 | |
| 		}
 | |
| 
 | |
| 		private void DoCreatePDF()
 | |
| 		{
 | |
| 			if (_AllProcedures)
 | |
| 			{
 | |
| 				this.Cursor = Cursors.WaitCursor;
 | |
| 				DateTime dtStart = DateTime.Now;
 | |
| 				_MultiunitPdfLocation = cbxMultiunitPdfLocation.SelectedItem.ToString();
 | |
| 				PromsPrinter.ClearTransPageNumProblems();
 | |
| 				CreatePDFs();
 | |
| 				PromsPrinter.ReportTransPageNumProblems();
 | |
| 				this.Cursor = Cursors.Default;
 | |
| 				if (_MergedPfd == null)
 | |
| 				{
 | |
| 					if (VlnSettings.DebugMode)
 | |
| 					{
 | |
| 						MessageBox.Show(string.Format("{0} Minutes to Print All Procedures"
 | |
| 							, TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes),
 | |
| 							"Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | |
| 					}
 | |
| 					else // Production or Demo mode
 | |
| 					{
 | |
| 						MessageBox.Show("Completed Successfully", "Print All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | |
| 					}
 | |
| 					this.Close();
 | |
| 				}
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				// B2016-249 Output Procedure to folder associated with Parent Child
 | |
| 				// B2017-009 If the selected item is null don't add a folder
 | |
| 				if (cbxMultiunitPdfLocation.SelectedItem != null)
 | |
| 					_MultiunitPdfLocation = cbxMultiunitPdfLocation.SelectedItem.ToString();
 | |
| 				this.Cursor = Cursors.WaitCursor;
 | |
| 				_CreateButtonClicked = true; // B2020-062 control the toggle of date/time prefix/suffix on pdf file name
 | |
| 				CreatePDF();
 | |
| 				_CreateButtonClicked = false;
 | |
| 				this.Cursor = Cursors.Default;
 | |
| 			}
 | |
| 		}
 | |
| 		private bool _Initializing = false;
 | |
| 
 | |
| 		private void btnPdfLocation_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			DlgBrowseFolder.SelectedPath = PDFPath;
 | |
| 			DialogResult drslt = DlgBrowseFolder.ShowDialog();
 | |
| 			if (drslt == DialogResult.OK)
 | |
| 			{
 | |
| 				txbPDFLocation.Text = DlgBrowseFolder.SelectedPath;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void rbFormatDefault_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			SetCustomControls(false);
 | |
| 			// Make Custom controls invisible
 | |
| 			ppGpbxUserSpecCB.Visible = false;
 | |
| 		}
 | |
| 
 | |
| 		private void SetCustomControls(bool enabled)
 | |
| 		{
 | |
| 			ppCmbxChgBarTxtType.Enabled = enabled;
 | |
| 			lblCbTxtType.Enabled = enabled;
 | |
| 			ppTxbxChangeBarUserMsgOne.Enabled = enabled;
 | |
| 			ppTxbxChangeBarUserMsgTwo.Enabled = enabled;
 | |
| 		}
 | |
| 		private void cbxOvrrideDefChgBars_CheckStateChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			SetCustomControls(cbxOvrrideDefChgBars.Checked);
 | |
| 		}
 | |
| 
 | |
| 		private void rbCustom_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			SetCustomControls(true);
 | |
| 			// Make Custom controls visible
 | |
| 			ppGpbxUserSpecCB.Visible = true;
 | |
| 		}
 | |
| 
 | |
| 		private void rbFormatDefault_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			SetCustomControls(false);
 | |
| 			// Make Custom controls invisible
 | |
| 			ppGpbxUserSpecCB.Visible = false;
 | |
| 		}
 | |
| 
 | |
| 		private void ppCmbxChgBarTxtType_SelectedIndexChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (_Initializing) return;
 | |
| 			ppGpbxUserSpecTxt.Enabled = ppCmbxChgBarTxtType.SelectedIndex == (int)PrintChangeBarText.UserDef;
 | |
| 		}
 | |
| 		// B2024-058  Add validation for Revision Date field of the Print dialog
 | |
| 		private bool validateDate(TextBox txtDate)
 | |
| 		{
 | |
| 			DateTime dDate;
 | |
| 			if (!(txtDate.Text == ""))
 | |
| 			{
 | |
| 
 | |
| 				if (DateTime.TryParse(txtDate.Text, out dDate))
 | |
| 				{
 | |
| 					return true;
 | |
| 				}
 | |
| 				else
 | |
| 				{
 | |
| 					string txtDate2 = txtDate.Text;
 | |
| 					string message = String.Format("Date {0} in wrong format" + System.Environment.NewLine + "Correct the revision date.", txtDate2);
 | |
| 					string txtTitle = "Invalid Format";
 | |
| 					MessageBox.Show(message, txtTitle);
 | |
| 					return false;
 | |
| 				}
 | |
| 			}
 | |
| 			return true;
 | |
| 		}
 | |
| 
 | |
| 		private void txbRevDate_Enter(object sender, EventArgs e)
 | |
| 		{
 | |
| 			txbDate = txbRevDate;
 | |
| 			grpDateSelector.Text = "Select Revision Date";
 | |
| 			grpDateSelector.Visible = calDateSelector.Visible = true;
 | |
| 			//C2021-007 position the calendar to the current RevDate or if no RevDate, position to today's date
 | |
| 			DateTime dDate;
 | |
| 			// B2024-058  Add validation for Revision Date field of the Print dialog
 | |
| 			if (!validateDate(txbDate))
 | |
| 			{
 | |
| 				txbRevDate.Focus();
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				DateTime initSelDate = (txbDate.Text != null && txbDate.Text.Length != 0) ? Convert.ToDateTime(txbDate.Text) : DateTime.Today;
 | |
| 				calDateSelector.DisplayMonth = calDateSelector.SelectedDate = initSelDate;
 | |
| 			}
 | |
| 		}
 | |
| 		private void txbRevDate_Leave(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (_Initializing) return;
 | |
| 			if (this.ActiveControl == calDateSelector)
 | |
| 			{
 | |
| 				txbRevDate.Focus();  //B2018-059 keep the calendar open until a different field on the print dialog is selected
 | |
| 				return;
 | |
| 			}
 | |
| 			txbDate = null;
 | |
| 			grpDateSelector.Visible = calDateSelector.Visible = false;
 | |
| 			// save the RevDate to the procedure's config.
 | |
| 			ProcedureConfig pc = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			if (pc == null) return;
 | |
| 			pc.Print_RevDate = txbRevDate.Text;
 | |
| 			using (Item itm = Item.Get(MyProcedure.ItemID))
 | |
| 			{
 | |
| 				itm.MyContent.Config = MyProcedure.MyConfig.ToString();
 | |
| 				itm.Save();
 | |
| 			}
 | |
| 
 | |
| 		}
 | |
| 
 | |
| 		private void txbReviewDate_Leave(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (_Initializing) return;
 | |
| 			txbDate = null;
 | |
| 			grpDateSelector.Visible = calDateSelector.Visible = false;
 | |
| 			// save the ReviewDate to the procedure's config.
 | |
| 			ProcedureConfig pc = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			if (pc == null) return;
 | |
| 			pc.Print_ReviewDate = txbReviewDate.Text;
 | |
| 			using (Item itm = Item.Get(MyProcedure.ItemID))
 | |
| 			{
 | |
| 				itm.MyContent.Config = MyProcedure.MyConfig.ToString();
 | |
| 				itm.Save();
 | |
| 				// need to reset config to !dirty?
 | |
| 			}
 | |
| 
 | |
| 		}
 | |
| 		private void txbReviewDate_Enter(object sender, EventArgs e)
 | |
| 		{
 | |
| 			txbDate = txbReviewDate;
 | |
| 			grpDateSelector.Text = "Select Review Date";
 | |
| 			grpDateSelector.Visible = calDateSelector.Visible = true;
 | |
| 			//C2021-007 position the calendar to the current ReviewDate or if no ReviewDate, position to today's date
 | |
| 			DateTime initSelDate = (txbDate.Text != null && txbDate.Text.Length != 0) ? Convert.ToDateTime(txbDate.Text) : DateTime.Today;
 | |
| 			calDateSelector.DisplayMonth = calDateSelector.SelectedDate = initSelDate;
 | |
| 		}
 | |
| 
 | |
| 		private TextBox txbDate = null;
 | |
| 		private void calDateSelector_DateSelected(object sender, DateRangeEventArgs e)
 | |
| 		{
 | |
| 			if (txbDate != null)
 | |
| 				txbDate.Text = e.Start.ToShortDateString();
 | |
| 		}
 | |
| 
 | |
| 		string _NewRevForAllProcs = null;
 | |
| 		private void txbRevNum_Leave(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (_Initializing) return;
 | |
| 			// C2021-062 save the current rev number to be used when printing all procedures or merging
 | |
| 			if (cbxAssignRevToAllMergedPrcs.Checked && btnMergePDFs.Visible)
 | |
| 				_NewRevForAllProcs = txbRevNum.Text; // C2021-062 we will save the rev number as we print each procedure during the print merge or print all procedures
 | |
| 			else
 | |
| 				SaveRevNumToProcedureConfig(txbRevNum.Text);
 | |
| 		}
 | |
| 
 | |
| 		// C2021-062 used to save rev number information when all procedures are printed or merged
 | |
| 		private void SaveRevNumToProcedureConfig(string newrevnum)
 | |
| 		{
 | |
| 			// save the RevNum to the procedure's config.
 | |
| 			ProcedureConfig pc = MyProcedure.MyConfig as ProcedureConfig;
 | |
| 			if (pc == null) return;
 | |
| 			pc.Print_Rev = newrevnum;
 | |
| 			using (Item itm = Item.Get(MyProcedure.ItemID))
 | |
| 			{
 | |
| 				itm.MyContent.Config = MyProcedure.MyConfig.ToString();
 | |
| 				itm.Save();
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void expPrnSetting_ExpandedChanged(object sender, DevComponents.DotNetBar.ExpandedChangeEventArgs e)
 | |
| 		{
 | |
| 			if (expPrnSetting.Expanded)
 | |
| 			{
 | |
| 				this.Size = new Size(this.Size.Width + (expPrnSetting.Size.Width - expPrnSetting.TitlePanel.Size.Height), this.Size.Height);
 | |
| 				// B2018-137 set the visability of Generate Placekeeper
 | |
| 				swtbtnGeneratePlacekeeper.Visible = lblGeneratePlacekeeper.Visible = ((MyProcedure.ActiveFormat.PlantFormat.FormatData.PurchaseOptions & E_PurchaseOptions.AutoPlacekeeper) == E_PurchaseOptions.AutoPlacekeeper);
 | |
| 			}
 | |
| 			//else
 | |
| 			//	this.Size = new Size(this.Size.Width-(expPrnSetting.Size.Width-expPrnSetting.TitlePanel.Size.Height), this.Size.Height);
 | |
| 			//Refresh();
 | |
| 		}
 | |
| 
 | |
| 		private void expPrnSetting_ExpandedChanging(object sender, DevComponents.DotNetBar.ExpandedChangeEventArgs e)
 | |
| 	{
 | |
| 				if (expPrnSetting.Expanded)
 | |
| 				//this.Size = new Size(this.Size.Width+(expPrnSetting.Size.Width-expPrnSetting.TitlePanel.Size.Height), this.Size.Height);
 | |
| 			//else
 | |
| 				this.Size = new Size(this.Size.Width-(expPrnSetting.Size.Width-expPrnSetting.TitlePanel.Size.Height), this.Size.Height);
 | |
| 			//Refresh();
 | |
| 
 | |
| 		}
 | |
| 
 | |
| 		private void swtbtnPDFdtPrefixSuffix_ValueChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (swtbtnPDFdtPrefixSuffix.Value)
 | |
| 				swtbtnPDFLinks.Value = false;
 | |
| 			if (_AllProcedures) _DateTimePrefixSuffixPrintingAllProcedures = swtbtnPDFdtPrefixSuffix.Value; // C2018-033 add switch to use Prefix and Suffix on PDF file name
 | |
| 			BuildPDFFileName();
 | |
| 		}
 | |
| 
 | |
| 		private void swtbtnPDFLinks_ValueChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (swtbtnPDFLinks.Value)
 | |
| 				swtbtnPDFdtPrefixSuffix.Value = false;
 | |
| 			BuildPDFFileName();
 | |
| 			// C2024-013: When Create RO & Transition Hyperlinks in pdf is ON, disable the MergePdf
 | |
| 			//	button.  The Create RO & Transition Hyperlinks option looks for individual file names
 | |
| 			//	for procedures.
 | |
| 			btnMergePDFs.Enabled = !swtbtnPDFLinks.Value; 
 | |
| 		}
 | |
| 
 | |
| 		// C2019-004: Allow user to define duplex blank page text.  The text box for blank page text is always enabled for procedures with
 | |
| 		// supplemental information. For other types of procedures, the text box is enabled if duplex printing is turned on.
 | |
| 		private void swtbtnBlankPgsForDuplex_ValueChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value;
 | |
| 		}
 | |
| 
 | |
| 		// Merge the pdfs into one pdf file (C2019-012)
 | |
| 		private void btnMergePDFs_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			DateTime dtStart = DateTime.Now;
 | |
| 			_MergedPfd = new MergedPdf(PDFPath, _DocVersionInfo);
 | |
| 			PromsPrinter.MergedLandscapePages = null;		// B2019-152: MergedLandscapePages has data set when creating separate pdfs (DoCreatePDF)
 | |
| 			DoCreatePDF();		// create indivitual pdfs
 | |
| 			if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath;
 | |
| 			// C2021-063 pass in whether to generate Alarm Point List text when a merge is done
 | |
| 			if (!_MergedPfd.DoTheMerge(PromsPrinter.MergedLandscapePages,cbxAlmPtTxt.Checked)) return;		// merge them together.
 | |
| 			// if the property to show the file after printing is set (on the version dialog), display it.  Otherwise do a dialog to let user know it's done
 | |
| 			if (_DocVersionConfig.Print_MergedPdfsViewAfter)
 | |
| 			{
 | |
| 				if (_MergedPfd.MergedPdfs != null && _MergedPfd.MergedPdfs.Count > 0)
 | |
| 				{
 | |
| 					System.Diagnostics.Process sdp = System.Diagnostics.Process.Start(_MergedPfd.MergedFileName);
 | |
| 					if (sdp != null) // B2020-055 if the current .NET version does not recognize the program used to display the PDF, it will return a NULL (ex. Microsoft Edge)
 | |
| 						sdp.WaitForInputIdle();
 | |
| 				}
 | |
| 			}
 | |
| 			else if (VlnSettings.DebugMode)
 | |
| 			{
 | |
| 				FlexibleMessageBox.Show(string.Format("{0} Minutes to Print and Merge Procedures"
 | |
| 					, TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes),
 | |
| 					"Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | |
| 			}
 | |
| 			else // Production or Demo mode
 | |
| 			{
 | |
| 				FlexibleMessageBox.Show("Completed Successfully", "Print All and Merge Procedures", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | |
| 			}
 | |
| 			this.Close();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxAssignRevToAllMergedPrcs_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			txbRevNum.Enabled = cbxAssignRevToAllMergedPrcs.Checked;
 | |
| 			if (cbxAssignRevToAllMergedPrcs.Checked)
 | |
| 				_NewRevForAllProcs = txbRevNum.Text;
 | |
| 			else
 | |
| 				_NewRevForAllProcs = null;
 | |
| 		}
 | |
| 
 | |
| 
 | |
| 		//private void cbxDebug_CheckedChanged(object sender, EventArgs e)
 | |
| 		//{
 | |
| 		//  cbxCmpPRMSpfd.Visible = cbxDebug.Checked;
 | |
| 		//}
 | |
| 	}
 | |
| }
 |