From 6dff9463ad7a5bec3564ef893b31fdcb1df9c7ac Mon Sep 17 00:00:00 2001 From: Jake Date: Thu, 28 Jul 2022 10:03:07 +0000 Subject: [PATCH] B2022-083: Support Conditional RO Values (v2.1) [Part-2] --- PROMS/DataLoader/PROMSFixes.Sql | 906 ++++++++++- .../DlgPrintProcedure.cs | 1411 ++++++++++------- PROMS/VEPROMS User Interface/PROMSFixes.Sql | 906 ++++++++++- .../frmPDFStatusForm.Designer.cs | 12 +- .../frmPDFStatusForm.resx | 8 +- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 72 +- .../Config/ROFSTLookup.cs | 16 +- .../Extension/DocumentExt.cs | 122 +- PROMS/Volian.Controls.Library/DisplayRO.cs | 2 + PROMS/Volian.Print.Library/PromsPrinter.cs | 2 +- 10 files changed, 2722 insertions(+), 735 deletions(-) diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 4223b6f2..b80860e8 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -20041,15 +20041,909 @@ GO GO - - - /* ========================================================================================================== End: B2022-026 RO Memory reduction coding (Jakes Merge) [Version 2.0] ========================================================================================================== */ +/* +========================================================================================================== + Start: B2022-083: Support Conditional RO Values (v2.1) +========================================================================================================== +*/ + +/* + ---------------------------------------------------------------------------------- + Tables: + ---------------------------------------------------------------------------------- + [RofstExtension] [Created] + */ + + -- If RofstExtension table already exists then don't drop and recreate it + IF Not Exists(SELECT * FROM sys.objects Where name = 'RofstExtension' AND type in (N'U')) + Begin + + SET ANSI_NULLS ON + SET QUOTED_IDENTIFIER ON + + CREATE TABLE [dbo].[RofstExtension]( + [Offset] [int] NOT NULL, + [RoidExt] [varchar](4) NOT NULL, + [AccPageExt] [varchar](5) NOT NULL, + CONSTRAINT [PK_RofstExtension] PRIMARY KEY CLUSTERED + ( + [Offset] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + ) ON [PRIMARY] + + IF (@@Error = 0) PRINT 'Table Creation: [RofstExtension] Succeeded' + ELSE PRINT 'Table Creation: [RofstExtension] Error on Creation' + + IF (@@Error = 0) + Begin + + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (1,'0041','A'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (2,'0042','B'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (3,'0043','C'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (4,'0044','D'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (5,'0045','E'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (6,'0046','F'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (7,'0047','G'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (8,'0048','H'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (9,'0049','I'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (10,'004A','J'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (11,'004B','K'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (12,'004C','L'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (13,'004D','M'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (14,'004E','N'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (15,'004F','O'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (16,'0050','P'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (17,'0051','Q'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (18,'0052','R'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (19,'0053','S'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (20,'0054','T'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (21,'0055','U'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (22,'0056','V'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (23,'0057','W'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (24,'0058','X'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (25,'0059','Y'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (26,'005A','Z'); + + End + + End + Go + + + + /* + ---------------------------------------------------------------------------------- + Functions: + ---------------------------------------------------------------------------------- + [dbo].[vefn_RofstDataCleanUnitInfoTags] [Created] + [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] [Created] + [dbo].[vefn_RofstDataReplaceVars] [Modified] + */ + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataCleanUnitInfoTags] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataCleanUnitInfoTags' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 06/21/2022 + -- Description: Removes any legacy legacy unit info variables and fixes older applicability tags + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags](@Values VarChar(Max), @RemoveUnitInfoVars bit = 0) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + + Set @RetVal = dbo.vefn_Clean(@Values, 1, null); + + If (Len(@RetVal) > 0) + Begin + + -- Make Sure all tag/var instances are upper case & Remove any internal spaces + Set @RetVal = Replace(@RetVal, 'U-OTHER TEXT', 'U-OTHERTEXT'); + Set @RetVal = Replace(@RetVal, 'U-OTHER NUMBER', 'U-OTHERNUMBER'); + Set @RetVal = Replace(@RetVal, 'U-OTHER NAME', 'U-OTHERNAME'); + Set @RetVal = Replace(@RetVal, 'U-OTHER ID', 'U-OTHERID'); + Set @RetVal = Replace(@RetVal, '', ''); + + If (@RemoveUnitInfoVars > 0) + Begin + + -- Remove any Unit Info Variables + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + + End + + End + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Error on Creation' + GO + + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceLegacyTagsWithDefaults' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 06/21/2022 + -- Description: Replaces any legacy applicability tags with the default value + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + Declare @StartValIndex Int; + Declare @EndValIndex Int; + + Declare @TagName VarChar(Max); + Declare @LegacyTagNames VarChar(Max) = 'U-ID,U-NUMBER,U-NAME,U-TEXT,U-OTHERID,U-OTHERNUMBER,U-OTHERNAME,U-OTHERTEXT'; + + -- Make Sure all tag instances are upper case & Remove any internal spaces + Set @RetVal = dbo.vefn_RofstDataCleanUnitInfoTags(@Values, 0); + + + Declare LegacyTags_Cursor Cursor Fast_Forward For + Select '{' + x.ListValue + '{' as 'TagName' + From [dbo].[vefn_ParseStringListToTable](@LegacyTagNames, ',') x + + Open LegacyTags_Cursor + + Fetch Next From LegacyTags_Cursor Into @TagName + + While (@@FETCH_STATUS = 0) + Begin + + -- Get Start/End Index of Tag + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 2); + + Set @StartValIndex = PatIndex('%=%', @StartTagValue); + Set @EndValIndex = PatIndex('%}%', @StartTagValue); + + Set @DefaultValue = SubString(@StartTagValue, @StartValIndex + 1, (@EndValIndex - @StartValIndex) - 1); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + End -- While (@StartTagIndex > 0) + + + Fetch Next From LegacyTags_Cursor Into @TagName + End + + Close LegacyTags_Cursor; + Deallocate LegacyTags_Cursor; + + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Error on Creation' + GO + + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceVars' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataReplaceVars] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 3/25/2022 + -- Description: Replaces Any Variables and returns the rest of the value string + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + -- Replace Any Legacy Applicability Tags with the Default Value second + Select @RetVal = dbo.vefn_RofstDataReplaceLegacyTagsWithDefaults(@RetVal); + + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Error on Creation' + GO + + + + /* + ---------------------------------------------------------------------------------- + Views: + ---------------------------------------------------------------------------------- + [dbo].[vwRofstData_RofstExtensions] [Created] + [dbo].[vwRofstData_RofstValueTypes] [Created] + [dbo].[vwRofstData_RofstBaseRoids] [Created] + [dbo].[vwRofstData_RofstChildren] [Modified] + */ + + /****** Object: View [dbo].[vwRofstData_RofstExtensions] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstExtensions' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstExtensions] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2024 + Description: (RofstData) Master View for RofstExtensions + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstExtensions] + As + + Select re.Offset as 'Offset', + re.RoidExt as 'RoidExt', + re.AccPageExt as 'AccPageExt' + From RofstExtension re With (NoLock) + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstExtensions] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstExtensions] Error on Creation' + GO + + + + /****** Object: View [dbo].[vwRofstData_RofstValueTypes] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstValueTypes' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstValueTypes] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2022 + Description: (RofstData) Master View for Rofst Value Types + (0) Unknown (1) Single Line Text (2) Table (3) Multiple Line Text (4) X/Y Plot (8) Image + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstValueTypes] + As + + Select '0' as 'TypeID', 'Unknown' as 'TypeDescription' + + Union All + + Select '1' as 'TypeID', 'Single Line Text' as 'TypeDescription' -- Fixed Length Text + + Union All + + Select '2' as 'TypeID', 'Table' as 'TypeDescription' + + Union All + + Select '3' as 'TypeID', 'Multiple Line Text' as 'TypeDescription' + + Union All + + Select '4' as 'TypeID', 'X/Y Plot' as 'TypeDescription' + + Union All + + Select '8' as 'TypeID', 'Image' as 'TypeDescription' + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstValueTypes] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstValueTypes] Error on Creation' + GO + + + + /****** Object: View [dbo].[vwRofstData_RofstBaseRoids] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstBaseRoids' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstBaseRoids] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2024 + Description: (RofstData) Master View for Rofst Base Roid / AccPageID Values + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstBaseRoids] + As + + Select RofstID as 'RofstID', + Left(roid, 12) as 'BaseRoid', + Left(AccPageID, (Len(AccPageID)-2)) as 'BaseAccPageID' + From vwRofstData_RofstDefaultValues + Where AccPageID like '%.A'; + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Error on Creation' + GO + + + /****** Object: View [dbo].[vwRofstData_RofstChildren] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstChildren' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstChildren] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2024 + Description: (RofstData) Master View for RofstChildren (RoChild & Groups) + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstChildren] + As + + Select rc.RofstChildID as 'RofstChildID', + rd.RofstID as 'RofstID', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + rc.ID as 'ID', + rc.ParentID as 'ParentID', + rc.[type] as 'type', + IsNull(vt.TypeDescription, 'Unknown') as 'TypeDescription', + rc.title as 'title', + rc.roid as 'roid', + rc.appid as 'appid', + rc.[value] as 'value', + Case When (Not rc.[value] is null) Then rd.dbiAP + '-' + rc.appid Else null End as 'AccPageID' + From RofstChild rc With (NoLock) + inner join RofstDatabase rd With (NoLock) on rc.RofstID = rd.RofstID and rc.dbiID = rd.dbiID + left outer join vwRofstData_RofstValueTypes vt on vt.TypeID = rc.[type]; + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstChildren] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstChildren] Error on Creation' + GO + + + + /* + ---------------------------------------------------------------------------------- + Stored Procs: + ---------------------------------------------------------------------------------- + [dbo].[vesp_RofstDataGetChildByID] [Deleted] + [dbo].[vesp_RofstDataGetExtensions] [Created] + [dbo].[vesp_RofstChildInsert] [Modified] + [dbo].[vesp_RofstDataSearch] [Modified] + [dbo].[vesp_RofstDataGetChildByAccPageID] [Modified] + [dbo].[vesp_RofstDataGetChildByRoid] [Modified] + */ + + + /****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByID' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByID] + GO + + IF (@@Error = 0) PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Succeeded' + ELSE PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Error on Creation' + GO + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetExtensions] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetExtensions' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetExtensions] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2022 + Description: Gets the Ro Lookup Extensions + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetExtensions] + With Execute as Owner + As + Begin + + Select re.Offset, + re.RoidExt, + re.AccPageExt + From vwRofstData_RofstExtensions re + Order By re.Offset Asc; + + + Return; + End + + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Error on Creation' + GO + + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstChildInsert' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstChildInsert] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstChildInsert] + ( + @RofstID Int, + @ID Int, + @ParentID Int, + @dbiID Int, + @type Int, + @title VarChar(Max), + @roid VarChar(50), + @appid VarChar(Max) = null, + @value VarChar(Max) = null + ) + With Execute as Owner + As + Begin + + Declare @BaseAccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- Create Rofst Child/Group Record --> [Roid = (12) Digits] + Insert Into RofstChild (RofstID, ID, ParentID, dbiID, [type], title, roid, appid, [value]) + Values (@RofstID, @ID, @ParentID, @dbiID, @type, @title, @roid, @appid, @value); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @BaseAccPageID = dbo.vefn_RofstDataCleanUnitInfoTags(Concat(d.dbiAP, '-', @appid), 1) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value(s) (Children RoChild) --> [Roid = (16) Digits] + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select x.ListPosition as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, re.RoidExt) as 'roid', + Case When (Len(RTrim(LTrim(cv.DefaultValue))) > 0 ) Then dbo.vefn_RofstDataCleanUnitInfoTags(cv.DefaultValue, 0) Else '[TBD]' End as 'value', + Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID' + From ChildrenValues cv + inner join vwRofstData_RofstExtensions re on re.Offset = cv.OffsetIndex + Order By cv.OffsetIndex Asc + + + End -- (Len(@appid) > 0) + + + Return; + + End + Go + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstChildInsert] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstChildInsert] Error on Creation' + GO + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataSearch' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataSearch] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: RO Default Value Search + + @SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataSearch] + ( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1, -- Starts With + @OnlyRoid16 Bit = 1, -- Return Only Roid16 Records + @MaxNumOfRecords Int = null + ) + With Execute as Owner + As + Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + -- Create Temp Results Table + Create Table #SearchResults (roid VarChar(50) Not Null, [value] VarChar(Max), RowNum Int Not Null Primary Key); + + -- Select roids/values based on search criteria + Insert Into #SearchResults (roid, [value], RowNum) + Select rdv.roid, + rdv.[value], + Row_Number() Over (Order By rdv.[value] Asc, rdv.roid Asc) as 'RowNum' + From vwRofstData_RofstDefaultValues rdv + Where rdv.RofstID = @RofstID + And (@OnlyRoid16 = 0 Or Len(rdv.roid) = 16) + And ((@Value is null) + Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With + Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With + Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains + Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match + Order By rdv.[value] Asc, rdv.roid Asc + Option (Recompile); + + -- Return the specified number of results + Select sr.roid, sr.[value] + From #SearchResults sr + Where (@MaxNumOfRecords is null Or sr.RowNum <= @MaxNumOfRecords) + Order By sr.RowNum Asc; + + Return; + End + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataSearch] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataSearch] Error on Creation' + GO + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByAccPageID' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByAccPageID] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: Check if the AccPageID passed in has a specific Return Value Type Extension (.A, .B, .C, etc.) + If so, then strip off the return value specific extension to get the BaseAccPageID for the lookup. + Use the BaseAccPageID to lookup the BaseRoid, then use the Roid to lookup the Ro Child Object + + Note** Using the AccPageID to first lookup the roid, then using the roid to lookup the data is + significantly faster than directly looking up the data using the AccPageID because of the indexes + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID] + ( + @RofstID int, + @AccPageID VarChar(50) + ) + With Execute as Owner + As + Begin + + Declare @BaseAccPageID VarChar(Max); + Declare @Roid VarChar(Max); + + If (PatIndex('%.[A-Z]', @AccPageID) > 0) + Set @BaseAccPageID = Left(@AccPageID, Len(@AccPageID)-2); + Else + Set @BaseAccPageID = @AccPageID; + + -- First use the AccPageID to get the BaseRoid + Select @Roid = rb.BaseRoid + From vwRofstData_RofstBaseRoids rb + Where rb.RofstID = @RofstID + And rb.BaseAccPageID = @BaseAccPageID; + + -- Then use the Roid to lookup the Ro Child Object + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID + And rc.roid = @Roid; + + Return; + End + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Error on Creation' + GO + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByRoid' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByRoid] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: The data in the Rofst Children table currently only goes down to the (12) digit roid level. + To look up a specific return type value (16) digit roid for a RO object, you first have to + load the base RO object by its (12) digit roid in code, and then look for the specific + return value in the RO objects children collection because the values for any + multiple/variable return type formats can vary at runtime, based on your current selected + DocVersion and the Selected Slave (Unit) / OtherChild Override. + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetChildByRoid] + ( + @RofstID int, + @Roid VarChar(50) + ) + With Execute as Owner + As + Begin + + -- Only use the first (12) characters to lookup an RoChild by its roid + -- If its a (16) digit roid, then use its last (4) characters [roidExt ==> specific to a return type value] + -- to select the specified return value format type in the code once all of the children Ro Return types have + -- been loaded into memory in the code + + Set @Roid = Left(@Roid + '00000000', 12); + + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID + And rc.roid = @Roid; + + Return; + End + + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Error on Creation' + GO + + + + -- Delete All Existing Rofst Table Data + Delete From RofstHeader; + + +/* +========================================================================================================== + End: B2022-083: Support Conditional RO Values (v2.1) +========================================================================================================== +*/ ----------------------------------------------------------------------------- /* @@ -20073,7 +20967,7 @@ GO /***************************************************************************** Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE - Copyright 2021 - Volian Enterprises, Inc. All rights reserved. + Copyright 2022 - Volian Enterprises, Inc. All rights reserved. *****************************************************************************/ CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision] WITH EXECUTE AS OWNER @@ -20085,8 +20979,8 @@ BEGIN TRY -- Try Block DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '07/12/2022 11:15 AM' - set @RevDescription = 'ROFST Lookup / Memory Fixes (v2.0) - New procedures for Reduction of Memory Use' + set @RevDate = '07/27/2022 1:20 PM' + set @RevDescription = 'B2022-083: Support Conditional RO Values (v2.1)' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index 849f2cfe..4bc7cb99 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -16,16 +16,54 @@ namespace VEPROMS { public partial class DlgPrintProcedure : DevComponents.DotNetBar.Office2007Form { + #region Fields + + private string _Prefix = string.Empty; // RHM20150506 Multiline ItemID TextBox + private SessionInfo _MySessionInfo; + private bool _Automatic; + private Timer _MyTimer; + + private bool _AllProcedures; + private int _SelectedSlave = 0; + private ProcedureInfo _MyProcedure; + private DocVersionInfo _DocVersionInfo = null; + private DocVersionConfig _DocVersionConfig; + private ROFSTLookup _rofstLookup = null; + + private string _MultiunitPdfLocation = string.Empty; + private MergedPdf _MergedPfd = null; + private string _MergedPdfPath = null; + + private bool _Initializing = false; + + // C2018-033 Used to turn off using the date/time PDF file prefix and suffix when doing batch file automatic baseline print testing (frmVEPROMS.cs RunAutomatic()) + // This is needed so the automatic baselines can compare results from different runs of PROMS + private bool _AllowDateTimePrefixSuffix = true; + + 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 bool _CreateButtonClicked = false; // B2020-062 control the toggle of date/time prefix/suffix on pdf file name + + private string _UnitNumber; + private int _UnitIndex; + + private TextBox txbDate = null; + string _NewRevForAllProcs = null; + + #endregion + + #region Properties + public bool SaveLinks { - get - { - return swtbtnPDFLinks.Value; - } + get { return swtbtnPDFLinks.Value; } } + public int RemoveTrailingHardReturnsAndManualPageBreaks { - get + get { // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. // return values: 0=None; 1=Trailing; 2=ManualPgBrk; 3=Both. @@ -33,81 +71,50 @@ namespace VEPROMS if (!cbxRemoveManualPgBrk.Checked && !cbxRemoveTrailing.Checked) return 0; if (!cbxRemoveManualPgBrk.Checked && cbxRemoveTrailing.Checked) return 1; if (cbxRemoveManualPgBrk.Checked && !cbxRemoveTrailing.Checked) return 2; - return 3; + 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; } } - // 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 - { + 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 @@ -130,275 +137,371 @@ namespace VEPROMS return RevNum + "/" + RevDate; } } + public string ProcNum { get { return MyProcedure.DisplayNumber; } } + public string PDFPath { - get {// B2018-069 Revert to Temporary for Baseline testing + get + {// B2018-069 Revert to Temporary for Baseline testing if (PromsPrinter.BaselineTesting) return VlnSettings.TemporaryFolder; - return txbPDFLocation.Text; + 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; } } - 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; - cbxOverwritePDF2.Checked = true; - 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 ProcedureInfo MyProcedure + { + get { return _MyProcedure; } + set + { + _MyProcedure = value; + + // if procedure has supplemental information, the automatically 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 + } + } + + public int SelectedSlave + { + get { return _SelectedSlave; } + set + { + if (_SelectedSlave != value) + { + if (MyProcedure != null && MyProcedure. MyDocVersion != null && MyProcedure.MyDocVersion.DocVersionConfig != null) + { + MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = (value > 0) ? value : 0; + } + + _rofstLookup = null; + } + + lblMultiunitPdfLocation.Visible = (value > -1); + cbxMultiunitPdfLocation.Visible = (value > -1); + cbxMultiunitPdfLocation.SelectedIndex = 1; + + _SelectedSlave = value; + } + } + + public ROFSTLookup MyROFSTLookup + { + get + { + if (_rofstLookup == null) + { + var dvi = MyProcedure.MyDocVersion; + + // RofstLookup requires (RofstID, DocVersionInfo, selectedSlave) + if (dvi != null && dvi.DocVersionAssociations != null && dvi.DocVersionAssociations.Count > 0) + { + int rofstID = dvi.DocVersionAssociations[0].ROFstID; + string slaveOverride = (_SelectedSlave < 0) ? "0" : _SelectedSlave.ToString(); + + _rofstLookup = new ROFSTLookup(rofstID, dvi, slaveOverride); + } + } + + return _rofstLookup; + } + } + + #endregion + + #region Constructors + + public DlgPrintProcedure(DocVersionInfo dvi) + { + InitializeComponent(); + + _Automatic = false; + _AllProcedures = true; + + MyProcedure = dvi.Procedures[0].MyProcedure; + + var dvc = dvi.DocVersionConfig; + + _DocVersionInfo = dvi; + _DocVersionConfig = dvc; + SelectedSlave = dvc.SelectedSlave; + + swtbtnBlankPgsForDuplex.Value = dvc.Print_AddBlankPagesWhenUsingDuplexFoldouts; + tbBlankPage.Text = dvc.Print_DuplexBlankPageText; + tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value; + + 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; + } + + public DlgPrintProcedure(DocVersionInfo dvi, bool automatic) + { + InitializeComponent(); + + _Automatic = automatic; + _AllProcedures = true; + + MyProcedure = dvi.Procedures[0].MyProcedure; + + var dvc = dvi.DocVersionConfig; + + _DocVersionInfo = dvi; + _DocVersionConfig = dvc; + SelectedSlave = dvc.SelectedSlave; + + // 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 = dvc.Print_AddBlankPagesWhenUsingDuplexFoldouts; + tbBlankPage.Text = dvc.Print_DuplexBlankPageText; + tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value; + + + // 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(ProcedureInfo pi) { + // C2018-012 - Code Cleanup - redesigned the Print Dialog to include a sliding panel and replaced check boxes with ON/OFF switches InitializeComponent(); + + _Automatic = false; _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; + + var dvi = pi.MyDocVersion; + var dvc = dvi.DocVersionConfig; + + _DocVersionInfo = dvi; + _DocVersionConfig = dvc; + SelectedSlave = dvc.SelectedSlave; + + swtbtnBlankPgsForDuplex.Value = dvc.Print_AddBlankPagesWhenUsingDuplexFoldouts; + tbBlankPage.Text = dvc.Print_DuplexBlankPageText; + tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value; + 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; + + cbxOpenAfterCreate2.Checked = dvc.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; + + _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; + + var dvi = pi.MyDocVersion; + var dvc = dvi.DocVersionConfig; + + _DocVersionInfo = dvi; + _DocVersionConfig = dvc; + SelectedSlave = dvc.SelectedSlave; + + swtbtnBlankPgsForDuplex.Value = dvc.Print_AddBlankPagesWhenUsingDuplexFoldouts; + tbBlankPage.Text = dvc.Print_DuplexBlankPageText; + tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value; + 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; + + cbxOpenAfterCreate2.Checked = dvc.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; } - /// - /// RHM 20120925 Added so that the dialog would center over the PROMS window - /// - /// - 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(); + #endregion - // 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) + #region Public Methods + + 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)) { - swtbtnChgBar.Value = false; - cbxOvrrideDefChgBars.Checked = false; - expPrnSetting.Expanded = true; + 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; + } + + // 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 = string.Empty; + + 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"); + + // RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered. + ProfileTimer.Pop(profileDepth2); + + MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = this.SelectedSlave; + + // 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))//; //C2018-009 print PROMS version + { + frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value; + frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked; + + if (Automatic && cbxGenerateConActSum.Checked) + frmStatus.OnlyShowContinuousActionSummary = true; + + int profileDepth3 = ProfileTimer.Push(">>>> frmStatus"); + frmStatus.ShowDialog(); + + ProfileTimer.Pop(profileDepth3); + } + + MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0; + + 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"); + } } - 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 = VlnSettings.DebugMode; - } - - private void DlgPrintProcedure_Load(object sender, EventArgs e) - { - SetupForProcedure(); - _MyTimer = new Timer(); - _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; + 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 @@ -406,21 +509,24 @@ namespace VEPROMS // General 2 settings //txbPDFLocation.Text = _PDFPath; BuildPDFFileName(); + ProcedureConfig pc = _MyProcedure.MyConfig as ProcedureConfig; - if(SelectedSlave > 0) pc.SelectedSlave = 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. + + //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("\\"))) + || (_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash && RevNum.Contains("\\"))) { - int indx = RevNum.IndexOf(_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash ? '\\' : '/'); + 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. @@ -430,14 +536,16 @@ namespace VEPROMS itm.Save(); } } + // C2021-019: Override Watermark Text and Color from PSI string waterMarkTextOverride = pc.GetValue("PSI", "WATERMARKOVERRIDE"); - if (waterMarkTextOverride != null && waterMarkTextOverride != "") + if (!string.IsNullOrEmpty(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 @@ -458,11 +566,13 @@ namespace VEPROMS ReviewDate = null; cbxWaterMark.Visible = true; } + // B2019-044 use Enum without the "None" option for the print dialog cbxWaterMark.DataSource = EnumDetail.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")) @@ -473,7 +583,9 @@ namespace VEPROMS 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.Details(); //ppCmbxChgBarPos.DisplayMember = "Description"; @@ -488,13 +600,18 @@ namespace VEPROMS 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 @@ -505,183 +622,10 @@ namespace VEPROMS 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"; - } + #endregion - // 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; - } + #region Private Methods - 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"); @@ -689,6 +633,7 @@ namespace VEPROMS ProfileTimer.Reset(); int profileDepth = ProfileTimer.Push(">>>> CreatePdf"); StringBuilder sb = new StringBuilder(); + if (MySessionInfo != null) { foreach (ProcedureInfo myProc in _DocVersionInfo.Procedures) @@ -699,18 +644,22 @@ namespace VEPROMS 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(); @@ -718,18 +667,22 @@ namespace VEPROMS 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) + 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 + 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 = ""; + string waterMarkTextOverride = string.Empty; 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) @@ -737,15 +690,18 @@ namespace VEPROMS { 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 + 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; @@ -760,6 +716,7 @@ namespace VEPROMS 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), @@ -782,9 +739,10 @@ namespace VEPROMS { 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 + 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); @@ -819,7 +777,9 @@ namespace VEPROMS // Not master/slave else { + 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 @@ -857,17 +817,293 @@ namespace VEPROMS } } } + pbPDFsStatus.Visible = false; - if(!Automatic) + + 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 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; + + 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 = VlnSettings.DebugMode; + } + + 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; + cbxOverwritePDF2.Checked = true; + 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 visible the check box to assign rev number for all procedures being printed + // also make visible the Rev Num entry field. + txbRevNum.Enabled = oneProcedure; + cbxAssignRevToAllMergedPrcs.Visible = btnMergePDFs.Visible = !oneProcedure; + + // C2021-063 make the Generate Alarm Point List text checkbox visible in the format flag is set. + cbxAlmPtTxt.Visible = !oneProcedure && MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.ChkBoxToGeneratePointListText; + } + + // 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 = string.Empty; + + PDFDTPrefix dtPre = _DocVersionConfig.Print_PDFdtFilePrefix; + PDFDTSuffix dtSuf = _DocVersionConfig.Print_PDFdtFileSuffix; + + if (dtPre != PDFDTPrefix.None) PDFFilePrefix = string.Empty; // incase user entered prefix text but then selected a date/time (in working draft properties) + if (dtSuf != PDFDTSuffix.None) PDFFileSuffix = string.Empty; // 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 (string.IsNullOrEmpty(ProcNum)) + PDFFileName = this.UnitNumber; + else + PDFFileName = string.Format("{0}", _MyProcedure.PDFNumber); + + if (string.IsNullOrEmpty(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 + DocVersionConfig dvc = (_DocVersionConfig != null) ? _DocVersionConfig : MyProcedure.MyDocVersion.DocVersionConfig; + + string PDFFilePrefix = dvc.Print_PDFFilePrefix; + string PDFFileSuffix = dvc.Print_PDFFileSuffix; + + PDFDTPrefix dtPre = dvc.Print_PDFdtFilePrefix; + PDFDTSuffix dtSuf = dvc.Print_PDFdtFileSuffix; + + bool hasPrefixSuffix = _DateTimePrefixSuffixPrintingAllProcedures && (PDFFilePrefix.Length > 0 || PDFFileSuffix.Length > 0 || dtPre != PDFDTPrefix.None || dtSuf != PDFDTSuffix.None); + + // this will call BuildPDFFileName() thus MyProcedure must be set + swtbtnPDFdtPrefixSuffix.Value = hasPrefixSuffix; + swtbtnPDFdtPrefixSuffix.Enabled = hasPrefixSuffix; + } + + private void DlgPrintProcedure_Load(object sender, EventArgs e) + { + SetupForProcedure(); + + _MyTimer = new Timer(); + _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 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 void btnCreatePDF_Click(object sender, EventArgs e) + { + 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 void AddToMergeList(ProcedureInfo myProc, string locpdfname) { // if doing a merge and this procedure should be included, add it to _MergedPdf: @@ -876,20 +1112,63 @@ namespace VEPROMS // 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(); mpp.PageCount = PromsPrinter.ProcPageCount; + _MergedPfd.MergedPdfs.Add(mpp); } } + private void btnMergePDFs_Click(object sender, EventArgs e) + { + // Merge the pdfs into one pdf file (C2019-012) + DateTime dtStart = DateTime.Now; + _MergedPfd = new MergedPdf(PDFPath, _DocVersionInfo); + + // B2019-152: MergedLandscapePages has data set when creating separate pdfs (DoCreatePDF) + PromsPrinter.MergedLandscapePages = null; + + DoCreatePDF(); // create individual 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 string GetMultiunitPDFPath() { string newPDFPath = string.Empty; + if (_MultiunitPdfLocation == "None") newPDFPath = PDFPath; if (_MultiunitPdfLocation == "Unit Name") @@ -901,28 +1180,39 @@ namespace VEPROMS 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); + + // B2016-255 Non-P/C PC procedures need to remove that \0 that the code above adds + 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) @@ -930,86 +1220,7 @@ namespace VEPROMS 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; - } - // 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); - - // 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))//; //C2018-009 print PROMS version - { - frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value; - frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked; - if (Automatic && cbxGenerateConActSum.Checked) - frmStatus.OnlyShowContinuousActionSummary = true; - int profileDepth3 = ProfileTimer.Push(">>>> frmStatus"); - frmStatus.ShowDialog(); - ProfileTimer.Pop(profileDepth3); - } - MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0; - 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"); - } + Volian.Base.Library.BaselineMetaFile.Show(); // baseline } // Determine if any dialog selections for change bars have overridden the data @@ -1024,6 +1235,7 @@ namespace VEPROMS 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; @@ -1061,56 +1273,113 @@ namespace VEPROMS } return cbd; } - private void btnCreatePDF_Click(object sender, EventArgs e) + + private void btnCancel_Click(object sender, EventArgs e) { - DoCreatePDF(); + this.Close(); } - private void DoCreatePDF() + private void swtbtnChgBar_ValueChanged(object sender, EventArgs e) { - if (_AllProcedures) + // 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) { - this.Cursor = Cursors.WaitCursor; - DateTime dtStart = DateTime.Now; - _MultiunitPdfLocation = cbxMultiunitPdfLocation.SelectedItem.ToString(); - PromsPrinter.ClearTransPageNumProblems(); - CreatePDFs(); - PromsPrinter.ReportTransPageNumProblems(); - this.Cursor = Cursors.Default; - if (_MergedPfd == null) + switch (_DocVersionConfig.Print_ChangeBar) { - 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(); + 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; } } - else + } + + private void swtbtnWaterMark_ValueChanged(object sender, EventArgs e) + { + if (!swtbtnWaterMark.Value) // C2021-019: make both invisible { - // 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; + 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 bool _Initializing = 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; + } + } + } + + /// + /// RHM 20120925 Added so that the dialog would center over the PROMS window + /// + /// + 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 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 void btnPdfLocation_Click(object sender, EventArgs e) { DlgBrowseFolder.SelectedPath = PDFPath; DialogResult drslt = DlgBrowseFolder.ShowDialog(); + if (drslt == DialogResult.OK) { txbPDFLocation.Text = DlgBrowseFolder.SelectedPath; @@ -1131,6 +1400,7 @@ namespace VEPROMS ppTxbxChangeBarUserMsgOne.Enabled = enabled; ppTxbxChangeBarUserMsgTwo.Enabled = enabled; } + private void cbxOvrrideDefChgBars_CheckStateChanged(object sender, EventArgs e) { SetCustomControls(cbxOvrrideDefChgBars.Checked); @@ -1155,6 +1425,7 @@ namespace VEPROMS if (_Initializing) return; ppGpbxUserSpecTxt.Enabled = ppCmbxChgBarTxtType.SelectedIndex == (int)PrintChangeBarText.UserDef; } + private void txbRevDate_Enter(object sender, EventArgs e) { txbDate = txbRevDate; @@ -1184,7 +1455,6 @@ namespace VEPROMS itm.MyContent.Config = MyProcedure.MyConfig.ToString(); itm.Save(); } - } private void txbReviewDate_Leave(object sender, EventArgs e) @@ -1202,8 +1472,8 @@ namespace VEPROMS itm.Save(); // need to reset config to !dirty? } - } + private void txbReviewDate_Enter(object sender, EventArgs e) { txbDate = txbReviewDate; @@ -1214,14 +1484,12 @@ namespace VEPROMS 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; @@ -1260,20 +1528,22 @@ namespace VEPROMS } 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(); - + { + if (expPrnSetting.Expanded) + { + this.Size = new Size(this.Size.Width - (expPrnSetting.Size.Width - expPrnSetting.TitlePanel.Size.Height), this.Size.Height); + } } 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 + + // C2018-033 add switch to use Prefix and Suffix on PDF file name + if (_AllProcedures) + _DateTimePrefixSuffixPrintingAllProcedures = swtbtnPDFdtPrefixSuffix.Value; + BuildPDFFileName(); } @@ -1281,6 +1551,7 @@ namespace VEPROMS { if (swtbtnPDFLinks.Value) swtbtnPDFdtPrefixSuffix.Value = false; + BuildPDFFileName(); } @@ -1291,39 +1562,6 @@ namespace VEPROMS 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; @@ -1333,9 +1571,6 @@ namespace VEPROMS _NewRevForAllProcs = null; } - //private void cbxDebug_CheckedChanged(object sender, EventArgs e) - //{ - // cbxCmpPRMSpfd.Visible = cbxDebug.Checked; - //} + #endregion } } diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index 4223b6f2..b80860e8 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -20041,15 +20041,909 @@ GO GO - - - /* ========================================================================================================== End: B2022-026 RO Memory reduction coding (Jakes Merge) [Version 2.0] ========================================================================================================== */ +/* +========================================================================================================== + Start: B2022-083: Support Conditional RO Values (v2.1) +========================================================================================================== +*/ + +/* + ---------------------------------------------------------------------------------- + Tables: + ---------------------------------------------------------------------------------- + [RofstExtension] [Created] + */ + + -- If RofstExtension table already exists then don't drop and recreate it + IF Not Exists(SELECT * FROM sys.objects Where name = 'RofstExtension' AND type in (N'U')) + Begin + + SET ANSI_NULLS ON + SET QUOTED_IDENTIFIER ON + + CREATE TABLE [dbo].[RofstExtension]( + [Offset] [int] NOT NULL, + [RoidExt] [varchar](4) NOT NULL, + [AccPageExt] [varchar](5) NOT NULL, + CONSTRAINT [PK_RofstExtension] PRIMARY KEY CLUSTERED + ( + [Offset] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + ) ON [PRIMARY] + + IF (@@Error = 0) PRINT 'Table Creation: [RofstExtension] Succeeded' + ELSE PRINT 'Table Creation: [RofstExtension] Error on Creation' + + IF (@@Error = 0) + Begin + + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (1,'0041','A'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (2,'0042','B'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (3,'0043','C'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (4,'0044','D'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (5,'0045','E'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (6,'0046','F'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (7,'0047','G'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (8,'0048','H'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (9,'0049','I'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (10,'004A','J'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (11,'004B','K'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (12,'004C','L'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (13,'004D','M'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (14,'004E','N'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (15,'004F','O'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (16,'0050','P'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (17,'0051','Q'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (18,'0052','R'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (19,'0053','S'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (20,'0054','T'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (21,'0055','U'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (22,'0056','V'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (23,'0057','W'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (24,'0058','X'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (25,'0059','Y'); + Insert Into RofstExtension (Offset, RoidExt, AccPageExt) Values (26,'005A','Z'); + + End + + End + Go + + + + /* + ---------------------------------------------------------------------------------- + Functions: + ---------------------------------------------------------------------------------- + [dbo].[vefn_RofstDataCleanUnitInfoTags] [Created] + [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] [Created] + [dbo].[vefn_RofstDataReplaceVars] [Modified] + */ + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataCleanUnitInfoTags] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataCleanUnitInfoTags' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 06/21/2022 + -- Description: Removes any legacy legacy unit info variables and fixes older applicability tags + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataCleanUnitInfoTags](@Values VarChar(Max), @RemoveUnitInfoVars bit = 0) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + + Set @RetVal = dbo.vefn_Clean(@Values, 1, null); + + If (Len(@RetVal) > 0) + Begin + + -- Make Sure all tag/var instances are upper case & Remove any internal spaces + Set @RetVal = Replace(@RetVal, 'U-OTHER TEXT', 'U-OTHERTEXT'); + Set @RetVal = Replace(@RetVal, 'U-OTHER NUMBER', 'U-OTHERNUMBER'); + Set @RetVal = Replace(@RetVal, 'U-OTHER NAME', 'U-OTHERNAME'); + Set @RetVal = Replace(@RetVal, 'U-OTHER ID', 'U-OTHERID'); + Set @RetVal = Replace(@RetVal, '', ''); + + If (@RemoveUnitInfoVars > 0) + Begin + + -- Remove any Unit Info Variables + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + Set @RetVal = Replace(@RetVal, '', ''); + + End + + End + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataCleanUnitInfoTags] Error on Creation' + GO + + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceLegacyTagsWithDefaults' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 06/21/2022 + -- Description: Replaces any legacy applicability tags with the default value + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + Declare @StartValIndex Int; + Declare @EndValIndex Int; + + Declare @TagName VarChar(Max); + Declare @LegacyTagNames VarChar(Max) = 'U-ID,U-NUMBER,U-NAME,U-TEXT,U-OTHERID,U-OTHERNUMBER,U-OTHERNAME,U-OTHERTEXT'; + + -- Make Sure all tag instances are upper case & Remove any internal spaces + Set @RetVal = dbo.vefn_RofstDataCleanUnitInfoTags(@Values, 0); + + + Declare LegacyTags_Cursor Cursor Fast_Forward For + Select '{' + x.ListValue + '{' as 'TagName' + From [dbo].[vefn_ParseStringListToTable](@LegacyTagNames, ',') x + + Open LegacyTags_Cursor + + Fetch Next From LegacyTags_Cursor Into @TagName + + While (@@FETCH_STATUS = 0) + Begin + + -- Get Start/End Index of Tag + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 2); + + Set @StartValIndex = PatIndex('%=%', @StartTagValue); + Set @EndValIndex = PatIndex('%}%', @StartTagValue); + + Set @DefaultValue = SubString(@StartTagValue, @StartValIndex + 1, (@EndValIndex - @StartValIndex) - 1); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + End -- While (@StartTagIndex > 0) + + + Fetch Next From LegacyTags_Cursor Into @TagName + End + + Close LegacyTags_Cursor; + Deallocate LegacyTags_Cursor; + + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Error on Creation' + GO + + + /****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vefn_RofstDataReplaceVars' AND type in (N'FN')) + DROP FUNCTION [dbo].[vefn_RofstDataReplaceVars] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + -- ========================================================================================== + -- Author: Jake Ropar + -- Create Date: 3/25/2022 + -- Description: Replaces Any Variables and returns the rest of the value string + -- ========================================================================================== + + CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) + WITH EXECUTE AS OWNER + AS + BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + -- Replace Any Legacy Applicability Tags with the Default Value second + Select @RetVal = dbo.vefn_RofstDataReplaceLegacyTagsWithDefaults(@RetVal); + + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + + END + Go + + IF (@@Error = 0) PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Succeeded' + ELSE PRINT 'Function Creation: [vefn_RofstDataReplaceVars] Error on Creation' + GO + + + + /* + ---------------------------------------------------------------------------------- + Views: + ---------------------------------------------------------------------------------- + [dbo].[vwRofstData_RofstExtensions] [Created] + [dbo].[vwRofstData_RofstValueTypes] [Created] + [dbo].[vwRofstData_RofstBaseRoids] [Created] + [dbo].[vwRofstData_RofstChildren] [Modified] + */ + + /****** Object: View [dbo].[vwRofstData_RofstExtensions] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstExtensions' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstExtensions] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2024 + Description: (RofstData) Master View for RofstExtensions + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstExtensions] + As + + Select re.Offset as 'Offset', + re.RoidExt as 'RoidExt', + re.AccPageExt as 'AccPageExt' + From RofstExtension re With (NoLock) + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstExtensions] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstExtensions] Error on Creation' + GO + + + + /****** Object: View [dbo].[vwRofstData_RofstValueTypes] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstValueTypes' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstValueTypes] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2022 + Description: (RofstData) Master View for Rofst Value Types + (0) Unknown (1) Single Line Text (2) Table (3) Multiple Line Text (4) X/Y Plot (8) Image + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstValueTypes] + As + + Select '0' as 'TypeID', 'Unknown' as 'TypeDescription' + + Union All + + Select '1' as 'TypeID', 'Single Line Text' as 'TypeDescription' -- Fixed Length Text + + Union All + + Select '2' as 'TypeID', 'Table' as 'TypeDescription' + + Union All + + Select '3' as 'TypeID', 'Multiple Line Text' as 'TypeDescription' + + Union All + + Select '4' as 'TypeID', 'X/Y Plot' as 'TypeDescription' + + Union All + + Select '8' as 'TypeID', 'Image' as 'TypeDescription' + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstValueTypes] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstValueTypes] Error on Creation' + GO + + + + /****** Object: View [dbo].[vwRofstData_RofstBaseRoids] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstBaseRoids' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstBaseRoids] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2024 + Description: (RofstData) Master View for Rofst Base Roid / AccPageID Values + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstBaseRoids] + As + + Select RofstID as 'RofstID', + Left(roid, 12) as 'BaseRoid', + Left(AccPageID, (Len(AccPageID)-2)) as 'BaseAccPageID' + From vwRofstData_RofstDefaultValues + Where AccPageID like '%.A'; + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstBaseRoids] Error on Creation' + GO + + + /****** Object: View [dbo].[vwRofstData_RofstChildren] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vwRofstData_RofstChildren' AND type in (N'V')) + DROP VIEW [dbo].[vwRofstData_RofstChildren] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2024 + Description: (RofstData) Master View for RofstChildren (RoChild & Groups) + ========================================================================================================== + */ + Create View [dbo].[vwRofstData_RofstChildren] + As + + Select rc.RofstChildID as 'RofstChildID', + rd.RofstID as 'RofstID', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + rc.ID as 'ID', + rc.ParentID as 'ParentID', + rc.[type] as 'type', + IsNull(vt.TypeDescription, 'Unknown') as 'TypeDescription', + rc.title as 'title', + rc.roid as 'roid', + rc.appid as 'appid', + rc.[value] as 'value', + Case When (Not rc.[value] is null) Then rd.dbiAP + '-' + rc.appid Else null End as 'AccPageID' + From RofstChild rc With (NoLock) + inner join RofstDatabase rd With (NoLock) on rc.RofstID = rd.RofstID and rc.dbiID = rd.dbiID + left outer join vwRofstData_RofstValueTypes vt on vt.TypeID = rc.[type]; + + GO + + IF (@@Error = 0) PRINT 'View Creation: [vwRofstData_RofstChildren] Succeeded' + ELSE PRINT 'View Creation: [vwRofstData_RofstChildren] Error on Creation' + GO + + + + /* + ---------------------------------------------------------------------------------- + Stored Procs: + ---------------------------------------------------------------------------------- + [dbo].[vesp_RofstDataGetChildByID] [Deleted] + [dbo].[vesp_RofstDataGetExtensions] [Created] + [dbo].[vesp_RofstChildInsert] [Modified] + [dbo].[vesp_RofstDataSearch] [Modified] + [dbo].[vesp_RofstDataGetChildByAccPageID] [Modified] + [dbo].[vesp_RofstDataGetChildByRoid] [Modified] + */ + + + /****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByID' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByID] + GO + + IF (@@Error = 0) PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Succeeded' + ELSE PRINT 'Procedure Deletion: [vesp_RofstDataGetChildByID] Error on Creation' + GO + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetExtensions] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetExtensions' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetExtensions] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 06/21/2022 + Description: Gets the Ro Lookup Extensions + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetExtensions] + With Execute as Owner + As + Begin + + Select re.Offset, + re.RoidExt, + re.AccPageExt + From vwRofstData_RofstExtensions re + Order By re.Offset Asc; + + + Return; + End + + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetExtensions] Error on Creation' + GO + + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstChildInsert' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstChildInsert] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstChildInsert] + ( + @RofstID Int, + @ID Int, + @ParentID Int, + @dbiID Int, + @type Int, + @title VarChar(Max), + @roid VarChar(50), + @appid VarChar(Max) = null, + @value VarChar(Max) = null + ) + With Execute as Owner + As + Begin + + Declare @BaseAccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- Create Rofst Child/Group Record --> [Roid = (12) Digits] + Insert Into RofstChild (RofstID, ID, ParentID, dbiID, [type], title, roid, appid, [value]) + Values (@RofstID, @ID, @ParentID, @dbiID, @type, @title, @roid, @appid, @value); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @BaseAccPageID = dbo.vefn_RofstDataCleanUnitInfoTags(Concat(d.dbiAP, '-', @appid), 1) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value(s) (Children RoChild) --> [Roid = (16) Digits] + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select x.ListPosition as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, re.RoidExt) as 'roid', + Case When (Len(RTrim(LTrim(cv.DefaultValue))) > 0 ) Then dbo.vefn_RofstDataCleanUnitInfoTags(cv.DefaultValue, 0) Else '[TBD]' End as 'value', + Concat(@BaseAccPageID, '.', re.AccPageExt) as 'AccPageID' + From ChildrenValues cv + inner join vwRofstData_RofstExtensions re on re.Offset = cv.OffsetIndex + Order By cv.OffsetIndex Asc + + + End -- (Len(@appid) > 0) + + + Return; + + End + Go + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstChildInsert] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstChildInsert] Error on Creation' + GO + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataSearch' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataSearch] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: RO Default Value Search + + @SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataSearch] + ( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1, -- Starts With + @OnlyRoid16 Bit = 1, -- Return Only Roid16 Records + @MaxNumOfRecords Int = null + ) + With Execute as Owner + As + Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + -- Create Temp Results Table + Create Table #SearchResults (roid VarChar(50) Not Null, [value] VarChar(Max), RowNum Int Not Null Primary Key); + + -- Select roids/values based on search criteria + Insert Into #SearchResults (roid, [value], RowNum) + Select rdv.roid, + rdv.[value], + Row_Number() Over (Order By rdv.[value] Asc, rdv.roid Asc) as 'RowNum' + From vwRofstData_RofstDefaultValues rdv + Where rdv.RofstID = @RofstID + And (@OnlyRoid16 = 0 Or Len(rdv.roid) = 16) + And ((@Value is null) + Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With + Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With + Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains + Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match + Order By rdv.[value] Asc, rdv.roid Asc + Option (Recompile); + + -- Return the specified number of results + Select sr.roid, sr.[value] + From #SearchResults sr + Where (@MaxNumOfRecords is null Or sr.RowNum <= @MaxNumOfRecords) + Order By sr.RowNum Asc; + + Return; + End + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataSearch] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataSearch] Error on Creation' + GO + + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByAccPageID' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByAccPageID] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: Check if the AccPageID passed in has a specific Return Value Type Extension (.A, .B, .C, etc.) + If so, then strip off the return value specific extension to get the BaseAccPageID for the lookup. + Use the BaseAccPageID to lookup the BaseRoid, then use the Roid to lookup the Ro Child Object + + Note** Using the AccPageID to first lookup the roid, then using the roid to lookup the data is + significantly faster than directly looking up the data using the AccPageID because of the indexes + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID] + ( + @RofstID int, + @AccPageID VarChar(50) + ) + With Execute as Owner + As + Begin + + Declare @BaseAccPageID VarChar(Max); + Declare @Roid VarChar(Max); + + If (PatIndex('%.[A-Z]', @AccPageID) > 0) + Set @BaseAccPageID = Left(@AccPageID, Len(@AccPageID)-2); + Else + Set @BaseAccPageID = @AccPageID; + + -- First use the AccPageID to get the BaseRoid + Select @Roid = rb.BaseRoid + From vwRofstData_RofstBaseRoids rb + Where rb.RofstID = @RofstID + And rb.BaseAccPageID = @BaseAccPageID; + + -- Then use the Roid to lookup the Ro Child Object + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID + And rc.roid = @Roid; + + Return; + End + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Error on Creation' + GO + + + /****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] ***********************/ + If Exists(SELECT * FROM sys.objects Where name = 'vesp_RofstDataGetChildByRoid' AND type in (N'P')) + DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByRoid] + GO + + SET ANSI_NULLS ON + GO + SET QUOTED_IDENTIFIER ON + GO + + /***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. + *****************************************************************************/ + /* + ========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: The data in the Rofst Children table currently only goes down to the (12) digit roid level. + To look up a specific return type value (16) digit roid for a RO object, you first have to + load the base RO object by its (12) digit roid in code, and then look for the specific + return value in the RO objects children collection because the values for any + multiple/variable return type formats can vary at runtime, based on your current selected + DocVersion and the Selected Slave (Unit) / OtherChild Override. + ========================================================================================================== + */ + Create Procedure [dbo].[vesp_RofstDataGetChildByRoid] + ( + @RofstID int, + @Roid VarChar(50) + ) + With Execute as Owner + As + Begin + + -- Only use the first (12) characters to lookup an RoChild by its roid + -- If its a (16) digit roid, then use its last (4) characters [roidExt ==> specific to a return type value] + -- to select the specified return value format type in the code once all of the children Ro Return types have + -- been loaded into memory in the code + + Set @Roid = Left(@Roid + '00000000', 12); + + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID + And rc.roid = @Roid; + + Return; + End + + GO + + IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Succeeded' + ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByRoid] Error on Creation' + GO + + + + -- Delete All Existing Rofst Table Data + Delete From RofstHeader; + + +/* +========================================================================================================== + End: B2022-083: Support Conditional RO Values (v2.1) +========================================================================================================== +*/ ----------------------------------------------------------------------------- /* @@ -20073,7 +20967,7 @@ GO /***************************************************************************** Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE - Copyright 2021 - Volian Enterprises, Inc. All rights reserved. + Copyright 2022 - Volian Enterprises, Inc. All rights reserved. *****************************************************************************/ CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision] WITH EXECUTE AS OWNER @@ -20085,8 +20979,8 @@ BEGIN TRY -- Try Block DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '07/12/2022 11:15 AM' - set @RevDescription = 'ROFST Lookup / Memory Fixes (v2.0) - New procedures for Reduction of Memory Use' + set @RevDate = '07/27/2022 1:20 PM' + set @RevDescription = 'B2022-083: Support Conditional RO Values (v2.1)' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.Designer.cs b/PROMS/VEPROMS User Interface/frmPDFStatusForm.Designer.cs index 5e8f795f..96faa145 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.Designer.cs @@ -47,7 +47,7 @@ namespace VEPROMS this.lblStatus.Location = new System.Drawing.Point(9, 17); this.lblStatus.Margin = new System.Windows.Forms.Padding(2); this.lblStatus.Name = "lblStatus"; - this.lblStatus.Size = new System.Drawing.Size(228, 19); + this.lblStatus.Size = new System.Drawing.Size(542, 19); this.lblStatus.TabIndex = 0; this.lblStatus.Text = "Ready"; // @@ -60,7 +60,7 @@ namespace VEPROMS this.pb.Location = new System.Drawing.Point(9, 53); this.pb.Margin = new System.Windows.Forms.Padding(2); this.pb.Name = "pb"; - this.pb.Size = new System.Drawing.Size(541, 19); + this.pb.Size = new System.Drawing.Size(716, 19); this.pb.TabIndex = 1; this.pb.TextVisible = true; // @@ -72,7 +72,7 @@ namespace VEPROMS // this.btnOpenFolder.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnOpenFolder.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnOpenFolder.Location = new System.Drawing.Point(473, 23); + this.btnOpenFolder.Location = new System.Drawing.Point(643, 17); this.btnOpenFolder.Margin = new System.Windows.Forms.Padding(2); this.btnOpenFolder.Name = "btnOpenFolder"; this.btnOpenFolder.Size = new System.Drawing.Size(77, 19); @@ -86,7 +86,7 @@ namespace VEPROMS // this.btnOpenPDF.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnOpenPDF.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnOpenPDF.Location = new System.Drawing.Point(394, 23); + this.btnOpenPDF.Location = new System.Drawing.Point(564, 17); this.btnOpenPDF.Margin = new System.Windows.Forms.Padding(2); this.btnOpenPDF.Name = "btnOpenPDF"; this.btnOpenPDF.Size = new System.Drawing.Size(75, 19); @@ -100,7 +100,7 @@ namespace VEPROMS // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(453, 21); + this.btnCancel.Location = new System.Drawing.Point(623, 17); this.btnCancel.Margin = new System.Windows.Forms.Padding(2); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(77, 19); @@ -114,7 +114,7 @@ namespace VEPROMS // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(559, 84); + this.ClientSize = new System.Drawing.Size(736, 84); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnOpenPDF); this.Controls.Add(this.btnOpenFolder); diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.resx b/PROMS/VEPROMS User Interface/frmPDFStatusForm.resx index 05decc40..b8410e1a 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.resx +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.resx @@ -112,15 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + AAABAA4AMDAQAAEABABoBgAA5gAAACAgEAABAAQA6AIAAE4HAAAYGBAAAQAEAOgBAAA2CgAAEBAQAAEA diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index b733b6ae..b3e92463 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -105,20 +105,21 @@ namespace VEPROMS ProcedureInfo pi = args.Proc as ProcedureInfo; if (piThis != null && pi.ItemID != piThis.ItemID) pi = piThis; + if (pi == null) return; + //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit pi.MyDocVersion.DocVersionConfig.SelectedSlave = pi.ProcedureConfig.SelectedSlave; - if (pi == null) return; - DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi); //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit - prnDlg.SelectedSlave = pi.ProcedureConfig.SelectedSlave == 0 ? -1 : pi.ProcedureConfig.SelectedSlave; + prnDlg.SelectedSlave = (pi.ProcedureConfig.SelectedSlave == 0) ? -1 : pi.ProcedureConfig.SelectedSlave; prnDlg.MySessionInfo = MySessionInfo; prnDlg.Automatic = true; prnDlg.CreateContinuousActionSummary = true; prnDlg.OpenAfterCreate = (dr == System.Windows.Forms.DialogResult.Yes); prnDlg.Prefix = "CASTMP_"; // A temporary procedure PDF is created to grab page numbers + prnDlg.SetupForProcedure(); prnDlg.CreatePDF(); @@ -379,7 +380,6 @@ namespace VEPROMS } - void displaySearch1_SearchComplete(object sender, DisplaySearchEventArgs args) { ProgBarText = string.Format("{0} Seconds", args.HowLong.TotalSeconds); @@ -628,7 +628,7 @@ namespace VEPROMS else { int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, CheckOutType.Session); - //int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, (args.Index == 0) ? CheckOutType.Folder : CheckOutType.Session); + dlgExportImport dlg = new dlgExportImport(args.Index == 0 ? "Export" : "Import", fi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter dlg.ShowDialog(this); @@ -661,6 +661,7 @@ namespace VEPROMS } int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); + dlgExportImport dlg = new dlgExportImport("Import", dvi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter dlg.MyNewProcedure = null; dlg.ExternalTransitionItem = null; @@ -894,6 +895,7 @@ namespace VEPROMS } tc.SaveCurrentEditItem(); + string message = string.Empty; if (!MySessionInfo.CanCheckOutItem(dvi.VersionID, CheckOutType.DocVersion, ref message)) @@ -904,13 +906,15 @@ namespace VEPROMS int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); dvi.DocVersionConfig.SelectedSlave = args.UnitIndex; + dlgApproveProcedure dlg = new dlgApproveProcedure(dvi, true, this); dlg.MySessionInfo = MySessionInfo; dlg.ShowDialog(this); displayHistory.RefreshList(); - dvi.DocVersionConfig.SelectedSlave = 0; MySessionInfo.CheckInItem(ownerid); + + dvi.DocVersionConfig.SelectedSlave = 0; } void tv_ApproveAllProcedures(object sender, vlnTreeEventArgs args) @@ -924,11 +928,12 @@ namespace VEPROMS // C2020-036 display list of duplicate procedure numbers FlexibleMessageBox.Show("This procedure set has two or more procedures with the same procedure number.\n\n" + "Please make each procedure number unique before approving.\n\n" + - "Below is a list of the dupicate procedure numbers:\n\n" + dupProcList, "Approve All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Warning); + "Below is a list of the duplicate procedure numbers:\n\n" + dupProcList, "Approve All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tc.SaveCurrentEditItem(); + string message = string.Empty; if (!MySessionInfo.CanCheckOutItem(dvi.VersionID, CheckOutType.DocVersion, ref message)) @@ -939,13 +944,15 @@ namespace VEPROMS int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); dvi.DocVersionConfig.SelectedSlave = args.UnitIndex; + dlgApproveProcedure dlg = new dlgApproveProcedure(dvi, this);//Added frmVEPROMS Parameter dlg.MySessionInfo = MySessionInfo; dlg.ShowDialog(this); displayHistory.RefreshList(); - dvi.DocVersionConfig.SelectedSlave = 0; MySessionInfo.CheckInItem(ownerid); + + dvi.DocVersionConfig.SelectedSlave = 0; } void tv_RefreshCheckedOutProcedures(object sender, vlnTreeEventArgs args) @@ -1020,7 +1027,6 @@ namespace VEPROMS void tv_ApproveProcedure(object sender, vlnTreeEventArgs args) { ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; if (pi == null) return; // B2017-242 added check for duplicate procedure numbers in a procedure set? @@ -1033,6 +1039,7 @@ namespace VEPROMS } tc.SaveCurrentEditItem(pi); + string message = string.Empty; if (!MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref message)) @@ -1042,13 +1049,16 @@ namespace VEPROMS } int ownerid = MySessionInfo.CheckOutItem(pi.ItemID, 0); + pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; + dlgApproveProcedure dlg = new dlgApproveProcedure(pi, this);//Added frmVEPROMS Parameter dlg.MySessionInfo = MySessionInfo; dlg.ShowDialog(this); displayHistory.RefreshList(); - pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; MySessionInfo.CheckInItem(ownerid); + + pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; } void tv_PrintAllProcedures(object sender, vlnTreeEventArgs args) @@ -1058,23 +1068,28 @@ namespace VEPROMS tc.SaveCurrentEditItem(); + dvi.DocVersionConfig.SelectedSlave = args.UnitIndex; + DlgPrintProcedure prnDlg = new DlgPrintProcedure(dvi); - prnDlg.MySessionInfo = MySessionInfo; prnDlg.SelectedSlave = args.UnitIndex; + prnDlg.MySessionInfo = MySessionInfo; prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window + + dvi.DocVersionConfig.SelectedSlave = 0; } void tv_PrintProcedure(object sender, vlnTreeEventArgs args) { ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; if (pi == null) return; tc.SaveCurrentEditItem(pi); + pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; + DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi); - prnDlg.MySessionInfo = MySessionInfo; prnDlg.SelectedSlave = args.UnitIndex; + prnDlg.MySessionInfo = MySessionInfo; prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; @@ -1083,12 +1098,14 @@ namespace VEPROMS void tv_CreateContinuousActionSummary(object sender, vlnTreeEventArgs args) { DialogResult dr = System.Windows.Forms.DialogResult.Yes; + ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; if (pi == null) return; tc.SaveCurrentEditItem(pi); + pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; + DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi, true); prnDlg.MySessionInfo = MySessionInfo; prnDlg.SelectedSlave = args.UnitIndex; @@ -1096,7 +1113,6 @@ namespace VEPROMS prnDlg.CreateContinuousActionSummary = true; prnDlg.OpenAfterCreate = (dr == System.Windows.Forms.DialogResult.Yes); prnDlg.Prefix = "CASTMP_"; // prefix the temporary procedure PDF file that is generated (to grab page numbers) - prnDlg.SetupForProcedure(); prnDlg.CreatePDF(); @@ -1264,21 +1280,17 @@ namespace VEPROMS ProcedureInfo pi = args.Proc as ProcedureInfo; if (piThis != null && pi.ItemID != piThis.ItemID) pi = piThis; - //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit - pi.MyDocVersion.DocVersionConfig.SelectedSlave = pi.ProcedureConfig.SelectedSlave; - // Check if Procedure Info is null if (pi == null) return; - DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi); - //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit - prnDlg.SelectedSlave = pi.ProcedureConfig.SelectedSlave == 0 ? -1 : pi.ProcedureConfig.SelectedSlave; - prnDlg.MySessionInfo = MySessionInfo; + pi.MyDocVersion.DocVersionConfig.SelectedSlave = pi.ProcedureConfig.SelectedSlave; - // RHM 20120925 - Center dialog over PROMS window - prnDlg.ShowDialog(this); + DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi); + prnDlg.SelectedSlave = pi.ProcedureConfig.SelectedSlave == 0 ? -1 : pi.ProcedureConfig.SelectedSlave; //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit + prnDlg.MySessionInfo = MySessionInfo; + prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window //added by jcb 20130718 to support create pdf button when multi-unit and user selects a unit pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; @@ -2291,16 +2303,15 @@ namespace VEPROMS { ProcedureInfo proc = dicProcs[key]; - //Console.WriteLine("{0}", proc.ShortPath); DlgPrintProcedure prnDlg = new DlgPrintProcedure(proc, true); prnDlg.MySessionInfo = MySessionInfo; - - //prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window prnDlg.Prefix = proc.MyDocVersion.VersionID.ToString() + "_"; prnDlg.Automatic = true; prnDlg.OpenAfterCreate = (dr == System.Windows.Forms.DialogResult.Yes); prnDlg.SetupForProcedure(); prnDlg.CreatePDF(); + + //prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window } } @@ -2625,7 +2636,7 @@ namespace VEPROMS - Jess- Volian0 - John- Volian0 - Kathy- Volian0 - - Jake- Volian0 + - Jake- Volian0 - Jim- JCB2-HP - Rich- WINDOWS7-RHM - Rich - RICH-WINDOWS10 @@ -2699,6 +2710,7 @@ namespace VEPROMS void btnUserControlOfFormatsExport_Click(object sender, EventArgs e) { DocVersionInfo dvi = null; + dlgExportImport dlg = new dlgExportImport("Export Formats", dvi, this, (E_UCFImportOptions)0); dlg.MyNewProcedure = null; dlg.ExternalTransitionItem = null; @@ -2708,6 +2720,7 @@ namespace VEPROMS void btnUserControlOfFormatsImport_Click(object sender, EventArgs e) { DocVersionInfo dvi = null; + dlgExportImport dlg = new dlgExportImport("Import Formats", dvi, this, (E_UCFImportOptions)0); dlg.MyNewProcedure = null; dlg.ExternalTransitionItem = null; @@ -2879,14 +2892,13 @@ namespace VEPROMS foreach (string dvstr in dvstrs) { - if (dvstr != "") + if (dvstr != string.Empty) { DocVersionInfo dvi = DocVersionInfo.Get(int.Parse(dvstr)); if (dvi != null) { DlgPrintProcedure prnDlg = new DlgPrintProcedure(dvi, true); - if (dvi.MultiUnitCount == 0) prnDlg.SelectedSlave = -1; prnDlg.AllowDateTimePrefixSuffix = false; //C2018-033 don't append any selected date/time pdf file prefix or suffix (defined in working draft properties) prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index 35bb4bbe..aa25b768 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -353,11 +353,11 @@ namespace VEPROMS.CSLA.Library if (!string.IsNullOrEmpty(rc.roid) && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0) { // Check if AccPageID/Key has a return value specific extension. Try to find the RoChild record with the specific return value type, - // If not found then return the first/default return value type in the list of children + // If not found Or the specific extension value is (Null or Empty), then just return the first/default return value type in the list of children var accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault()); var roExt = Extensions.Where(x => x.AccPageExt.Equals(accPageExt)).SingleOrDefault(); - return (rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First(); + return (rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt && !string.IsNullOrEmpty(x.value)).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First(); } return rc; // If RoChild is not found, then a default (ROFSTLookup.rochild) object will be returned, but its ID will be -1 @@ -421,6 +421,7 @@ namespace VEPROMS.CSLA.Library } + public string GetRoValue(string roid) { return GetRoChild(roid).value; @@ -603,13 +604,11 @@ namespace VEPROMS.CSLA.Library public void LoadChildren(ref ROFSTLookup.rochild child) { // If Children is null then it hasn't been loaded yet - //if (child.children == null || child.children.Length <= 0) if (child.children == null) { if (!string.IsNullOrEmpty(child.appid)) child = GetRoChild12(child.roid, true); else - //child.children = GetRoChildrenByRoid(child.roid, true); child.children = GetRoChildrenByRoid(child.roid, false); } } @@ -617,9 +616,7 @@ namespace VEPROMS.CSLA.Library public void LoadChildren(ref ROFSTLookup.rodbi db) { // If Children is null then it hasn't been loaded yet - //if (child.children == null || child.children.Length <= 0) if (db.children == null) - //db.children = GetRoChildrenByID(db.ID, db.dbiID, true); db.children = GetRoChildrenByID(db.ID, db.dbiID, false); } @@ -1957,10 +1954,11 @@ namespace VEPROMS.CSLA.Library if (!string.IsNullOrEmpty(roid)) { + rc.roid = FormatRoidKey(roid).Substring(0, 12); + DocVersionConfig dvc = (_myDocVersionInfo != null) ? _myDocVersionInfo.DocVersionConfig : null; - - rc.roid = FormatRoidKey(roid).Substring(0, 12); - + if (dvc != null) dvc.SelectedSlave = this.SelectedSlave; + switch (rc.roid) { case "FFFF00000001": diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 13e3bb19..55ce15b0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -410,12 +410,14 @@ namespace VEPROMS.CSLA.Library public class DSOFile : IDisposable { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #region Fields private bool _IsDisposed; private DocumentInfo _MyDocument = null; private FileInfo _MyFile = null; private string _Extension = "DOC"; #endregion + #region Properties public DocumentInfo MyDocument { @@ -438,6 +440,7 @@ namespace VEPROMS.CSLA.Library set { _Extension = value; } } #endregion + #region Private Methods private void TryDelete() { @@ -757,7 +760,7 @@ namespace VEPROMS.CSLA.Library private static List _MissingDocs = new List(); private static bool _Automatic = false; - // [JAKE CODE]: Added an internal rochild dictionary cache specifically for printing + // B2022-083: Support Conditional RO Values --> Added an internal rochild dictionary cache specifically for printing // // As you loop through all of the specific RO AccPageKeys for the current MsWord Document Section, the code will first // check the internal rochild cache for the base (12) digit roid Key/Value, if it doesn't already exist, then load the @@ -825,11 +828,9 @@ namespace VEPROMS.CSLA.Library set { MSWordToPDF._FormForPlotGraphics = value; } } - /// - /// C2018-035 Don't use a MessageBox if in automatic (Baseline) testing mode. - /// public static bool Automatic { + // C2018-035 Don't use a MessageBox if in automatic (Baseline) testing mode. get { return MSWordToPDF._Automatic; } set { MSWordToPDF._Automatic = value; } } @@ -940,9 +941,11 @@ namespace VEPROMS.CSLA.Library DocStyle myDocStyle = sect.MyDocStyle; ProcedureInfo proc = sect.MyProcedure; DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo; + bool hasRos = false; ROFstInfo rofst = null; ROFSTLookup lookup = null; + string igPrefix = null; string spPrefix = null; bool convertCaretToDeltaSymbol = (sect.ActiveSection != null) ? sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta : false; // C2018-003 fixed use of getting the active section @@ -1321,6 +1324,8 @@ namespace VEPROMS.CSLA.Library } + lastStart = sel.Start; + sel = FindRO(); if (sel != null && !string.IsNullOrEmpty(sel.Text) && sel.Start == lastStart) @@ -1371,16 +1376,16 @@ namespace VEPROMS.CSLA.Library if (statusChange != null) statusChange(VolianStatusType.Complete, 0, string.Empty); if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("++EndTxt++"); - //GC.Collect(); //jsj 2-15-2016 - for memory garbage collection - + // [jpr 2022.07.26] - For memory optimization //GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; - //GC.Collect(); + + //jsj 2-15-2016 - for memory garbage collection + //GC.Collect(); return fileName; } } - private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, string spPrefix, string igPrefix, bool convertCaretToDeltaSymbol) { string accPageBase = string.Empty; @@ -1415,14 +1420,18 @@ namespace VEPROMS.CSLA.Library return roc; - // All ROs should have a specific accPageExt or the default (A/0041), except for the "Unit Information" ("FFFF") - roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First(); + // All ROs at this point should have a specific accPageExt or the default (A/0041) + roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt) && !string.IsNullOrEmpty(x.value)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First(); // Check the RoType roc.type = ((roc.type & 4) == 4 && roc.value.StartsWith("< 0) - //{ - // roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First(); - - // //roc = (roc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First(); - // // Convert.ToString(accPageKey.ToCharArray().LastOrDefault()) - //} - - //// All ROs should have a specific accPageExt, except for the "Unit Information" ("FFFF") - //// if (!string.IsNullOrEmpty(rc.roid) && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0) - //if (!string.IsNullOrEmpty(accPageExt)) - //{ - // if (roc.children != null && roc.children.Count() > 0) - // { - // roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First(); - // //roc = (roc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First(); - // // Convert.ToString(accPageKey.ToCharArray().LastOrDefault()) - // } - - // // Get specific RO return value by Extension, if not exists then return default ("0041") - // // var roExt = lookup.Extensions.Where(x => x.AccPageExt.Equals(accPageExt)).SingleOrDefault(); - //} - - - - // var accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault()); - - // Regex.IsMatch(accPageKey, @".*\.[A-Z]") - - // Get the RoChild object once and cache it for any future calls to the same Ro while printing - //ROFSTLookup.rochild roc = lookup.GetROChildByAccPageID(sel.Text, spPrefix, igPrefix); - - //if (!_roPrintCache.ContainsKey(accPageKey)) - // _roPrintCache.Add(accPageKey, roc); - - //// Check the RoType - //int roType = roType = ((roc.type & 4) == 4 && roc.value.StartsWith("< /// This closes the MS Word Application, but, delays for about 1 second. /// It appears that closing MSWord to quickly causes a: @@ -1781,16 +1729,6 @@ namespace VEPROMS.CSLA.Library #region Private Methods - //private static void WaitMS(int n) - //{ - // DateTime dtw = DateTime.Now.AddMilliseconds(n); - - // while (DateTime.Now < dtw) - // { - // System.Windows.Forms.Application.DoEvents(); - // } - //} - private static void CloseDocument() { int attempts = 0; @@ -1800,7 +1738,7 @@ namespace VEPROMS.CSLA.Library System.Windows.Forms.Application.DoEvents(); if (TryToClose(attempts)) return; - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(500); //WaitMS(1000); } } @@ -1829,13 +1767,13 @@ namespace VEPROMS.CSLA.Library private static void InsertROValue(LBSelection sel, string roValue, bool upRoIfPrevUpper, float indent, bool convertUnderline) { - if (roValue == null) + if (string.IsNullOrEmpty(roValue)) { string orgtext = sel.Text; sel.Text = string.Format("RO ({0}) Not Found", orgtext.Replace("<", string.Empty).Replace(">", string.Empty)); sel.Font.Color = LBWdColor.wdColorRed; } - else if (roValue != string.Empty) + else // RO has a value { if (upRoIfPrevUpper && sel.LastWasUpper) roValue = roValue.ToUpper(); @@ -2167,11 +2105,16 @@ namespace VEPROMS.CSLA.Library private class CloseWordApp : System.Windows.Forms.Timer { + #region Fields + // B2019-161 When tracking timing time this action private static VolianTimer _TimeActivity = new VolianTimer("DocumentExt.cs CloseWordApp_Tick", 1548); LBApplicationClass _MyApp; + #endregion + + #region Constructor public LBApplicationClass MyApp { @@ -2179,6 +2122,9 @@ namespace VEPROMS.CSLA.Library set { _MyApp = value; } } + #endregion + + #region Public Methods public CloseWordApp(LBApplicationClass myApp, int interval) { @@ -2188,6 +2134,10 @@ namespace VEPROMS.CSLA.Library Enabled = true; } + #endregion + + #region Private Methods + private void CloseWordApp_Tick(object sender, EventArgs e) { _TimeActivity.Open(); @@ -2205,6 +2155,8 @@ namespace VEPROMS.CSLA.Library Dispose(); _TimeActivity.Close(); } + + #endregion } #endregion diff --git a/PROMS/Volian.Controls.Library/DisplayRO.cs b/PROMS/Volian.Controls.Library/DisplayRO.cs index 2a4ee017..58242e14 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.cs +++ b/PROMS/Volian.Controls.Library/DisplayRO.cs @@ -715,6 +715,8 @@ namespace Volian.Controls.Library roc.appid = roc.children.First().appid; roc.roid = roc.children.First().roid; roc.value = roc.children.First().value; + + roc.children = new List().ToArray(); } } diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 5de7753d..c034ccc7 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -494,7 +494,7 @@ namespace Volian.Print.Library MSWordToPDF.DocReplace = DocReplace; MSWordFile = MSWordToPDF.GetDocPdf(section, PrintOverride.TextColor); MSWordToPDF.DocReplace = null; - GC.Collect(); // memory garbage collection + //GC.Collect(); // memory garbage collection OnStatusChanged("MSWord converted to PDF " + MSWordFile, PromsPrinterStatusType.MSWordToPDF); } return MSWordFile;