C2022-004 Logic to print a Unit Designator Watermark

C2022-004 added Unit Designator Watermark option
C2022-004 added format xml structure for Unit Designator Watermark and a flag to use it on Approval PDFs
This commit is contained in:
John Jenko 2022-02-23 21:01:33 +00:00
parent 4e2b669199
commit b1a39f4a21
4 changed files with 149 additions and 23 deletions

View File

@ -462,8 +462,16 @@ namespace VEPROMS
cbxWaterMark.DataSource = EnumDetail<PrintDlgWatermarkList>.Details();
cbxWaterMark.ValueMember = "EValue";
PrintWatermark pw = _DocVersionConfig.Print_Watermark; // MyProcedure.ProcedureConfig.Print_Watermark;
if (!pw.ToString().ToUpper().Equals("NONE")) //B2019-044 check setting from folder level
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
@ -696,6 +704,7 @@ namespace VEPROMS
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();
@ -709,6 +718,7 @@ namespace VEPROMS
{
string locpdfname = null; // get pdf file name for later merge code
MyProcedure = myProc;
frmPDFStatusForm.SetUnitWatermark(MyProcedure, ref waterMarkText, ref watermarkColor); //C2022-004 Unit Designator watermark
// C2021-019: Override Watermark Text, 'waterMarkText' will have whatever watermark text should be printed
ProcedureConfig procConfig = MyProcedure.MyConfig as ProcedureConfig;
string waterMarkTextOverride = "";
@ -746,7 +756,7 @@ namespace VEPROMS
// 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))//;//C2018-009 print PROMS version
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor))//;//C2018-009 print PROMS version
{
frmStatus.CloseWhenDone = true;
Application.DoEvents();
@ -783,7 +793,7 @@ namespace VEPROMS
// 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)) // ;//C2018-009 print PROMS version
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor)) // ;//C2018-009 print PROMS version
{
frmStatus.CloseWhenDone = true;
Application.DoEvents();
@ -819,7 +829,7 @@ namespace VEPROMS
// 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)) // ;//C2018-009 print PROMS version
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();
@ -843,7 +853,6 @@ namespace VEPROMS
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:
@ -940,6 +949,8 @@ namespace VEPROMS
// 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
@ -964,7 +975,7 @@ namespace VEPROMS
// 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))//; //C2018-009 print PROMS version
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, false, tbBlankPage.Text, _MergedPfd, watermarkColor))//; //C2018-009 print PROMS version
{
frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value;
frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked;

View File

@ -82,7 +82,7 @@ namespace VEPROMS
get { return _DidAll; }
set { _DidAll = value; }
}
public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd, string pdfFile, Point newLocation, bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, int removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer, bool didAll, string blankPageText, MergedPdf mergedPdf)
public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd, string pdfFile, Point newLocation, bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, int removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer, bool didAll, string blankPageText, MergedPdf mergedPdf, string watermarkColor)
{
// B2021-088 moved this if/else from CreatePDF() so that the Approval logic will have access to this logic
ProcedureInfo MyProcedure = myItem as ProcedureInfo;
@ -103,13 +103,44 @@ namespace VEPROMS
// if the version number of PROMS is 1.0, then we are running a Demo version.
// When running a Demo version, force a "Sample" watermark when printing.
// B2020-022 append a ".pdf" extension if the file name does on have one.
MyPromsPrinter = new PromsPrinter(myItem, rev, (VlnSettings.ReleaseMode.Equals("DEMO")) ? "Sample" : watermark, debugOutput, origPgBrk, pdfPath + @"\Compare", false, overWrite, cbd, (pdfFile.ToUpper().EndsWith(".PDF"))?pdfFile:pdfFile+".pdf", insertBlankPages, allOrAuto,Prefix,saveLinks,removeTrailingHardReturnsAndManualPageBreaks, blankPageText, DidAll, mergedPdf);
MyPromsPrinter = new PromsPrinter(myItem, rev, (VlnSettings.ReleaseMode.Equals("DEMO")) ? "Sample" : watermark, debugOutput, origPgBrk, pdfPath + @"\Compare", false, overWrite, cbd, (pdfFile.ToUpper().EndsWith(".PDF"))?pdfFile:pdfFile+".pdf", insertBlankPages, allOrAuto,Prefix,saveLinks,removeTrailingHardReturnsAndManualPageBreaks, blankPageText, DidAll, mergedPdf, watermarkColor);
MyPromsPrinter.PromsVersion = (showPROMSVer) ? AboutVEPROMS.PROMSVersion : ""; //C2018-009 print PROMS version
PDFPath = pdfPath;
this.Text = "Creating PDF of " + myItem.DisplayNumber;
_NewLocation = newLocation;
DialogResult = DialogResult.OK;
}
public static void SetUnitWatermark(ProcedureInfo procInfo, ref string waterMarkText, ref string watermarkColor)
{
// C2022-004 BNPP Unit Specific Watermark
// Check if the user selected the "Unit Designator" watermark.
// If the procedure number starts with any of the ProcNumPrefix values (set in the format file) then
// set the Watermark Override text and color variables with the values from the format
if (waterMarkText.ToUpper().Equals("UNIT DESIGNATOR") && procInfo.ActiveFormat.PlantFormat.FormatData.UnitWatermarkList != null)
{
foreach (UnitWatermark uw in procInfo.ActiveFormat.PlantFormat.FormatData.UnitWatermarkList)
{
if (procInfo.DisplayNumber.StartsWith(uw.ProcNumPrefix) || uw.ProcNumPrefix.ToUpper() == "DEFAULT")
{
waterMarkText = uw.WMText;
watermarkColor = uw.WMColor;
break;
}
}
// Check if the watermark is the defined Parent/Child applicability token (field)
// if procedure does not use parent/child, then make the watermark text blank (empty string)
if (waterMarkText.ToUpper() == "[U-TEXT]")
{
string utxt = (procInfo.MyDocVersion.MultiUnitCount > 1) ? procInfo.MyDocVersion.DocVersionConfig.Unit_Text : "";
waterMarkText = (utxt == null) ? "" : utxt;
}
else if (waterMarkText.ToUpper() == "[U-NUMBER]")
{
string uNum = (procInfo.MyDocVersion.MultiUnitCount > 1) ? procInfo.MyDocVersion.DocVersionConfig.Unit_Number : "";
waterMarkText = (uNum == null) ? "" : uNum;
}
}
}
// used when the approved function creates an export file with unlinked ROs and Transitons. Word sections that have RO tokens are saved with the RO Vaules in DocReplace
// DocReplace is passed on to the Export functions.
private Dictionary<int, byte[]> _DocReplace;

View File

@ -8,20 +8,26 @@ namespace VEPROMS.CSLA.Library
{
//class ConfigEnum
//{
//C2022-004 Added option for Unit Specific Watermark
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintWatermark : int
{
None = 0, Reference, Draft, Master, Sample,
[Description("Information Only")]
InformationOnly
InformationOnly,
[Description("Unit Designator")]
UnitDesignator
}
// B2019-044 use Enum without the "None" option for the print dialog
//C2022-004 Added option for Unit Designator Watermark
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintDlgWatermarkList : int
{
Reference, Draft, Master, Sample,
[Description("Information Only")]
InformationOnly
InformationOnly,
[Description("Unit Designator")]
UnitDesignator
}
// Change Bar Use from 16-bit code:
// No Default

View File

@ -540,6 +540,16 @@ namespace VEPROMS.CSLA.Library
}
set { _ShadingOptionList = value; }
}
// C2022-004 Unit Watermarks defined in the format file - used by Barakah
private UnitWatermarkList _UnitWatermarkList;
public UnitWatermarkList UnitWatermarkList
{
get
{
return (_UnitWatermarkList == null) ? _UnitWatermarkList = new UnitWatermarkList(SelectNodes("UnitWatermarkData/UnitWatermark")) : _UnitWatermarkList;
}
set { _UnitWatermarkList = value; }
}
private SymbolList _SymbolList;
public SymbolList SymbolList
{
@ -978,6 +988,65 @@ namespace VEPROMS.CSLA.Library
public ShadingOptionList(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region UnitWatermarks
// C2022-004 Watermark information based on the beginning of the the procedure number
/* Example XML in BNPP Single Column format file (base format has only the default setting):
<UnitWatermarkData>
<UnitWatermark ProcNumPrefix = "000-" WMText = "0" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "001-" WMText = "1" WMColor="[A=255, R=184, G=209, B=255]"/> <!-- Blue-->
<UnitWatermark ProcNumPrefix = "002-" WMText = "2" WMColor="[A=255, R=255, G=196, B=171]"/> <!-- Organge-->
<UnitWatermark ProcNumPrefix = "003-" WMText = "3" WMColor="[A=255, R=255, G=252, B=147]"/> <!-- Yellow -->
<UnitWatermark ProcNumPrefix = "004-" WMText = "4" WMColor="[A=255, R=164, G=181, B=120]"/> <!-- Green-->
<UnitWatermark ProcNumPrefix = "1N2-" WMText = "A" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "3N4-" WMText = "B" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "1T4-" WMText = "T" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "1-" WMText = "A" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "2-" WMText = "A" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "3-" WMText = "B" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "4-" WMText = "B" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey-->
<UnitWatermark ProcNumPrefix = "9-" WMText = "[U-Text]" WMColor="[A=255, R=150, G=150, B=150]"/> <!-- Grey--> <!-- this uses the <U-Text> Applicability setting -->
<UnitWatermark ProcNumPrefix = "default" WMText = "[U-Number]" WMColor="Blue"/> <!-- this uses the <U-Number> Applicability setting -->
</UnitWatermarkData>
**/
[TypeConverter(typeof(ExpandableObjectConverter))]
public class UnitWatermark : vlnFormatItem
{
public UnitWatermark(XmlNode xmlNode) : base(xmlNode) { }
public UnitWatermark() : base() { }
[Category("Strings")]
private LazyLoad<string> _ProcNumPrefix;
public string ProcNumPrefix // based on the what the procedure number starts with, usually a resolved unit toke (ex: <U-Number>)
{
get
{
return LazyLoad(ref _ProcNumPrefix, "@ProcNumPrefix");
}
}
[Category("Strings")]
private LazyLoad<string> _WMText;
public string WMText
{
get
{
return LazyLoad(ref _WMText, "@WMText");
}
}
[Category("Strings")]
private LazyLoad<string> _WMColor;
public string WMColor
{
get
{
return LazyLoad(ref _WMColor, "@WMColor");
}
}
}
[TypeConverter(typeof(vlnListConverter<UnitWatermarkList, UnitWatermark>))]
public class UnitWatermarkList : vlnFormatList<UnitWatermark>
{
public UnitWatermarkList(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region Symbols
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Symbol : vlnFormatItem
@ -1336,6 +1405,15 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _ChkBoxToGeneratePointListText, "@ChkBoxToGeneratePointListText");
}
}
// C2022-004 When a procedure is approved, force the watermark of the unit number (defined in the format file under UnitWatermarkData)
private LazyLoad<bool> _UseUnitWatermarkOnApproved;
public bool UseUnitWatermarkOnApproved
{
get
{
return LazyLoad(ref _UseUnitWatermarkOnApproved, "@UseUnitWatermarkOnApproved");
}
}
}
#endregion
#region VersionIdText