C2019-045: Fix length of procedure number for CCR to work

C2019-045: For enhanced procedures, allow modification of number & title
This commit is contained in:
Kathy Ruffing 2019-12-13 11:51:15 +00:00
parent 5109fbbddb
commit beed3319ca
7 changed files with 618 additions and 31 deletions

View File

@ -15228,6 +15228,263 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsNew
ELSE PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsNew Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemChild]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemChild];
GO
CREATE PROCEDURE [dbo].[addItemChild]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@FromType int=null, @Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @ChildID int, @ContentID int, @ParentContentID int, @LastChanged timestamp
, @newLastChanged timestamp, @Error int, @Rowcount int, @ChildDeleted int
SELECT @ChildID = pp.[ItemID],@ParentContentID = ii.ContentID, @LastChanged = pp.LastChanged
FROM [ITEMS] ii
LEFT JOIN [PARTS] pp on pp.ContentID=ii.ContentID and pp.FromType=@FromType
WHERE ii.[ItemID]=@ItemID
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[tblParts]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
BEGIN
SELECT @ChildDeleted = pp.[ItemID],@ParentContentID = ii.ContentID, @LastChanged = pp.LastChanged
FROM [ITEMS] ii
LEFT JOIN [tblPARTS] pp on pp.ContentID=ii.ContentID and pp.FromType=@FromType
WHERE ii.[ItemID]=@ItemID and pp.DeleteStatus > 0
END
EXECUTE AddContent @Number, @Text, @Type, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem null, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
IF @ChildID is null -- No existing child - Add Parts record
BEGIN
IF @ChildDeleted is not null
BEGIN
-- INSERT INTO [PartAudits] ([ContentID],[FromType],[ItemID],[DTS],[UserID],[DeleteStatus])
-- SELECT [ContentID],[FromType],[ItemID],[DTS],[UserID],[DeleteStatus] FROM [tblParts]
-- WHERE ItemID = @ChildDeleted
DELETE FROM [tblParts] WHERE ItemID = @ChildDeleted
END
EXECUTE AddPart @ParentContentID, @FromType, @newItemID, @DTS, @UserID, @newLastChanged output
END
ELSE -- Update existing Parts record
BEGIN
EXECUTE UpdatePart @ParentContentID, @FromType, @newItemID, @DTS, @UserID, @LastChanged, @newLastChanged output
UPDATE [Items] SET [PreviousID]=@newItemID WHERE [ItemID]=@ChildID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,TT.TransitionID,TT.TranType,TT.ToID,TT.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN Transitions TT ON TT.FromID = CC.ContentID
WHERE TT.ToID = @ChildID OR TT.RangeID = @ChildID
-- Update transitions that pointed to @ItemID to point to @newItemID
Update TRANSITIONS
Set ToID = CASE ToID WHEN @ChildID THEN @newItemID ELSE ToID END,
RangeID = CASE RangeID WHEN @ChildID THEN @newItemID ELSE RangeID END
WHERE ToID = @ChildID OR RangeID = @ChildID
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
-- I don't expect to see any transitions that point to @ChildID. They should have changed in
-- the update above to point to @newItemID. This is here for consistency with the other insert
-- stored procedures
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@ChildID,@newItemID) OR RangeID IN(@ChildID,@newItemID))
-- Transition Text gets updated in ItemInsertExt.cs
END
IF( @@TRANCOUNT > 0 ) COMMIT
PRINT 'Child Added ' + ltrim(str(@newItemID))
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemChild Succeeded'
ELSE PRINT 'Procedure Creation: addItemChild Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemSiblingAfter]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemSiblingAfter];
GO
CREATE PROCEDURE [dbo].[addItemSiblingAfter]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @NextID int, @ContentID int, @newLastChanged timestamp, @NewType int
SELECT @NewType=ISNULL(@Type,[Type])
FROM [ITEMS] II JOIN [CONTENTS] CC ON II.[ContentID]=CC.[ContentID]
WHERE [ItemID]=@ItemID
SELECT @NextID = [ItemID]
FROM [ITEMS]
WHERE [PreviousID]=@ItemID
EXECUTE AddContent @Number, @Text, @NewType, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem @ItemID, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
UPDATE [ITEMS] SET [PreviousID]=@newItemID, [DTS]=@DTS, [UserID]=@UserID where [ItemID]=@NextID -- Should be UpdateItem
-- Get a list of Transitions which need to change children of @ItemID that point to @NextID
DECLARE @NextStepTransitions TABLE
(
[TransitionID] int PRIMARY KEY,
[FromID] [int],
[ToID] [int],
[RangeID] [int],
[TranType] [int],
[Config] [nvarchar](max)
)
Insert into @NextStepTransitions select * from vefn_NextStepTransitions(@NextID,@ItemID)
IF (SELECT COUNT(*) from @NextStepTransitions) > 0 -- Next Step Transitions
BEGIN
-- Update all transitions in the list to point to @newItemID
Update TT
Set TT.ToID = CASE TT.ToID WHEN @NextID THEN @newItemID ELSE TT.ToID END,
TT.RangeID = CASE TT.RangeID WHEN @NextID THEN @newItemID ELSE TT.RangeID END
From TRANSITIONS TT
JOIN @NextStepTransitions NS ON NS.TransitionID = TT.TransitionID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,NS.TransitionID,NS.TranType,NS.ToID,NS.RangeID,@NextID,@newItemID)
From CONTENTS CC
JOIN @NextStepTransitions NS ON NS.FromID = CC.ContentID
END
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Next Step Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@newItemID) OR RangeID IN(@newItemID))
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@NextID) OR RangeID IN(@NextID))
-- Transition Text gets updated in ItemInsertExt.cs
IF( @@TRANCOUNT > 0 ) COMMIT
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemSiblingAfter Succeeded'
ELSE PRINT 'Procedure Creation: addItemSiblingAfter Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemSiblingBefore]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemSiblingBefore];
GO
CREATE PROCEDURE [dbo].[addItemSiblingBefore]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @PreviousID int, @ContentID int, @newLastChanged timestamp, @NewType int
SELECT @PreviousID = [PreviousID], @NewType=ISNULL(@Type,[Type])
FROM [ITEMS] II
JOIN [CONTENTS] CC ON CC.[ContentID]=II.[CONTENTID]
WHERE [ItemID]=@ItemID
EXECUTE AddContent @Number, @Text, @NewType, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem @PreviousID, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
UPDATE [ITEMS] SET [PreviousID]=@newItemID where [ItemID]=@ItemID -- Should be UpdateItem
UPDATE [PARTS] SET [ItemID]=@newItemID where [ItemID]=@ItemID -- Should be UpdatePart
IF @PreviousID is null -- The step is replacing the first step
BEGIN
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,TT.TransitionID,TT.TranType,TT.ToID,TT.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN Transitions TT ON TT.FromID = CC.ContentID
WHERE TT.ToID = @ItemID OR TT.RangeID = @ItemID
-- Update transitions that pointed to @ItemID to point to @newItemID
Update TRANSITIONS
Set ToID = CASE ToID WHEN @ItemID THEN @newItemID ELSE ToID END,
RangeID = CASE RangeID WHEN @ItemID THEN @newItemID ELSE RangeID END
WHERE ToID = @ItemID OR RangeID = @ItemID
END
ELSE -- Check for Transitions that point to the Next Step
BEGIN
-- Get a list of Transitions which need to change children of @ItemID that point to @NextID
DECLARE @NextStepTransitions TABLE
(
[TransitionID] int PRIMARY KEY,
[FromID] [int],
[ToID] [int],
[RangeID] [int],
[TranType] [int],
[Config] [nvarchar](max)
)
Insert into @NextStepTransitions select * from vefn_NextStepTransitions(@ItemID,@PreviousID)
IF (SELECT COUNT(*) from @NextStepTransitions) > 0 -- Next Step Transitions
BEGIN
-- Update all transitions in the list to point to @newItemID
Update TT
Set TT.ToID = CASE TT.ToID WHEN @ItemID THEN @newItemID ELSE TT.ToID END,
TT.RangeID = CASE TT.RangeID WHEN @ItemID THEN @newItemID ELSE TT.RangeID END
From TRANSITIONS TT
JOIN @NextStepTransitions NS ON NS.TransitionID = TT.TransitionID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,NS.TransitionID,NS.TranType,NS.ToID,NS.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN @NextStepTransitions NS ON NS.FromID = CC.ContentID
END
END
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@ItemID,@newItemID) OR RangeID IN(@ItemID,@newItemID))
-- Transition Text gets updated in ItemInsertExt.cs
IF( @@TRANCOUNT > 0 ) COMMIT
PRINT 'Sibling Added Before ' + ltrim(str(@newItemID))
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemSiblingBefore Succeeded'
ELSE PRINT 'Procedure Creation: addItemSiblingBefore Error on Creation'
GO
-----------------------------------------------------------------------------
/*
@ -15243,7 +15500,7 @@ GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2017 - Volian Enterprises, Inc. All rights reserved.
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision]
WITH EXECUTE AS OWNER
@ -15254,8 +15511,8 @@ BEGIN TRY -- Try Block
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '12/11/2019 02:32 PM'
set @RevDescription = 'Text Search Duplicate Primary Key Fix'
set @RevDate = '12/13/2019 7:00 AM'
set @RevDescription = 'Procedure number length when adding procedures'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT

View File

@ -15228,6 +15228,263 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsNew
ELSE PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsNew Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemChild]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemChild];
GO
CREATE PROCEDURE [dbo].[addItemChild]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@FromType int=null, @Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @ChildID int, @ContentID int, @ParentContentID int, @LastChanged timestamp
, @newLastChanged timestamp, @Error int, @Rowcount int, @ChildDeleted int
SELECT @ChildID = pp.[ItemID],@ParentContentID = ii.ContentID, @LastChanged = pp.LastChanged
FROM [ITEMS] ii
LEFT JOIN [PARTS] pp on pp.ContentID=ii.ContentID and pp.FromType=@FromType
WHERE ii.[ItemID]=@ItemID
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[tblParts]') AND OBJECTPROPERTY(id,N'IsTable') = 1)
BEGIN
SELECT @ChildDeleted = pp.[ItemID],@ParentContentID = ii.ContentID, @LastChanged = pp.LastChanged
FROM [ITEMS] ii
LEFT JOIN [tblPARTS] pp on pp.ContentID=ii.ContentID and pp.FromType=@FromType
WHERE ii.[ItemID]=@ItemID and pp.DeleteStatus > 0
END
EXECUTE AddContent @Number, @Text, @Type, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem null, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
IF @ChildID is null -- No existing child - Add Parts record
BEGIN
IF @ChildDeleted is not null
BEGIN
-- INSERT INTO [PartAudits] ([ContentID],[FromType],[ItemID],[DTS],[UserID],[DeleteStatus])
-- SELECT [ContentID],[FromType],[ItemID],[DTS],[UserID],[DeleteStatus] FROM [tblParts]
-- WHERE ItemID = @ChildDeleted
DELETE FROM [tblParts] WHERE ItemID = @ChildDeleted
END
EXECUTE AddPart @ParentContentID, @FromType, @newItemID, @DTS, @UserID, @newLastChanged output
END
ELSE -- Update existing Parts record
BEGIN
EXECUTE UpdatePart @ParentContentID, @FromType, @newItemID, @DTS, @UserID, @LastChanged, @newLastChanged output
UPDATE [Items] SET [PreviousID]=@newItemID WHERE [ItemID]=@ChildID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,TT.TransitionID,TT.TranType,TT.ToID,TT.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN Transitions TT ON TT.FromID = CC.ContentID
WHERE TT.ToID = @ChildID OR TT.RangeID = @ChildID
-- Update transitions that pointed to @ItemID to point to @newItemID
Update TRANSITIONS
Set ToID = CASE ToID WHEN @ChildID THEN @newItemID ELSE ToID END,
RangeID = CASE RangeID WHEN @ChildID THEN @newItemID ELSE RangeID END
WHERE ToID = @ChildID OR RangeID = @ChildID
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
-- I don't expect to see any transitions that point to @ChildID. They should have changed in
-- the update above to point to @newItemID. This is here for consistency with the other insert
-- stored procedures
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@ChildID,@newItemID) OR RangeID IN(@ChildID,@newItemID))
-- Transition Text gets updated in ItemInsertExt.cs
END
IF( @@TRANCOUNT > 0 ) COMMIT
PRINT 'Child Added ' + ltrim(str(@newItemID))
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemChild Succeeded'
ELSE PRINT 'Procedure Creation: addItemChild Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemSiblingAfter]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemSiblingAfter];
GO
CREATE PROCEDURE [dbo].[addItemSiblingAfter]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @NextID int, @ContentID int, @newLastChanged timestamp, @NewType int
SELECT @NewType=ISNULL(@Type,[Type])
FROM [ITEMS] II JOIN [CONTENTS] CC ON II.[ContentID]=CC.[ContentID]
WHERE [ItemID]=@ItemID
SELECT @NextID = [ItemID]
FROM [ITEMS]
WHERE [PreviousID]=@ItemID
EXECUTE AddContent @Number, @Text, @NewType, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem @ItemID, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
UPDATE [ITEMS] SET [PreviousID]=@newItemID, [DTS]=@DTS, [UserID]=@UserID where [ItemID]=@NextID -- Should be UpdateItem
-- Get a list of Transitions which need to change children of @ItemID that point to @NextID
DECLARE @NextStepTransitions TABLE
(
[TransitionID] int PRIMARY KEY,
[FromID] [int],
[ToID] [int],
[RangeID] [int],
[TranType] [int],
[Config] [nvarchar](max)
)
Insert into @NextStepTransitions select * from vefn_NextStepTransitions(@NextID,@ItemID)
IF (SELECT COUNT(*) from @NextStepTransitions) > 0 -- Next Step Transitions
BEGIN
-- Update all transitions in the list to point to @newItemID
Update TT
Set TT.ToID = CASE TT.ToID WHEN @NextID THEN @newItemID ELSE TT.ToID END,
TT.RangeID = CASE TT.RangeID WHEN @NextID THEN @newItemID ELSE TT.RangeID END
From TRANSITIONS TT
JOIN @NextStepTransitions NS ON NS.TransitionID = TT.TransitionID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,NS.TransitionID,NS.TranType,NS.ToID,NS.RangeID,@NextID,@newItemID)
From CONTENTS CC
JOIN @NextStepTransitions NS ON NS.FromID = CC.ContentID
END
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Next Step Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@newItemID) OR RangeID IN(@newItemID))
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@NextID) OR RangeID IN(@NextID))
-- Transition Text gets updated in ItemInsertExt.cs
IF( @@TRANCOUNT > 0 ) COMMIT
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemSiblingAfter Succeeded'
ELSE PRINT 'Procedure Creation: addItemSiblingAfter Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addItemSiblingBefore]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addItemSiblingBefore];
GO
CREATE PROCEDURE [dbo].[addItemSiblingBefore]
(
@ItemID int=null, @Number nvarchar(256)=null, @Text nvarchar(MAX)=null, @FormatID int=null, @Config nvarchar(MAX)=null,
@Type int=null, @DTS datetime, @UserID nvarchar(100), @newItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @PreviousID int, @ContentID int, @newLastChanged timestamp, @NewType int
SELECT @PreviousID = [PreviousID], @NewType=ISNULL(@Type,[Type])
FROM [ITEMS] II
JOIN [CONTENTS] CC ON CC.[ContentID]=II.[CONTENTID]
WHERE [ItemID]=@ItemID
EXECUTE AddContent @Number, @Text, @NewType, @FormatID, @Config, @DTS, @UserID, @ContentID output, @newLastChanged output
EXECUTE AddItem @PreviousID, @ContentID, @DTS, @UserID , @newItemID output, @newLastChanged output
UPDATE [ITEMS] SET [PreviousID]=@newItemID where [ItemID]=@ItemID -- Should be UpdateItem
UPDATE [PARTS] SET [ItemID]=@newItemID where [ItemID]=@ItemID -- Should be UpdatePart
IF @PreviousID is null -- The step is replacing the first step
BEGIN
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,TT.TransitionID,TT.TranType,TT.ToID,TT.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN Transitions TT ON TT.FromID = CC.ContentID
WHERE TT.ToID = @ItemID OR TT.RangeID = @ItemID
-- Update transitions that pointed to @ItemID to point to @newItemID
Update TRANSITIONS
Set ToID = CASE ToID WHEN @ItemID THEN @newItemID ELSE ToID END,
RangeID = CASE RangeID WHEN @ItemID THEN @newItemID ELSE RangeID END
WHERE ToID = @ItemID OR RangeID = @ItemID
END
ELSE -- Check for Transitions that point to the Next Step
BEGIN
-- Get a list of Transitions which need to change children of @ItemID that point to @NextID
DECLARE @NextStepTransitions TABLE
(
[TransitionID] int PRIMARY KEY,
[FromID] [int],
[ToID] [int],
[RangeID] [int],
[TranType] [int],
[Config] [nvarchar](max)
)
Insert into @NextStepTransitions select * from vefn_NextStepTransitions(@ItemID,@PreviousID)
IF (SELECT COUNT(*) from @NextStepTransitions) > 0 -- Next Step Transitions
BEGIN
-- Update all transitions in the list to point to @newItemID
Update TT
Set TT.ToID = CASE TT.ToID WHEN @ItemID THEN @newItemID ELSE TT.ToID END,
TT.RangeID = CASE TT.RangeID WHEN @ItemID THEN @newItemID ELSE TT.RangeID END
From TRANSITIONS TT
JOIN @NextStepTransitions NS ON NS.TransitionID = TT.TransitionID
-- Update content records for the transitions
Update CC
Set Text = DBO.vefn_FixTransitionText(Text,NS.TransitionID,NS.TranType,NS.ToID,NS.RangeID,@ItemID,@newItemID)
From CONTENTS CC
JOIN @NextStepTransitions NS ON NS.FromID = CC.ContentID
END
END
-- Add 'Verification Required' AnnotationType
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
IF(@typeID IS NULL)
BEGIN
INSERT INTO [AnnotationTypes] ([Name],[UserID]) VALUES ('Verification Required','Volian')
SELECT @typeID = SCOPE_IDENTITY()
END
-- Add "Verification Required" Annotation for each Transition that points to @newItemID or @NextID
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Transition Destination',@UserID
FROM Items where CONTENTID in (SELECT FromID FROM TRANSITIONS
where ToID IN(@ItemID,@newItemID) OR RangeID IN(@ItemID,@newItemID))
-- Transition Text gets updated in ItemInsertExt.cs
IF( @@TRANCOUNT > 0 ) COMMIT
PRINT 'Sibling Added Before ' + ltrim(str(@newItemID))
EXECUTE GetItem @newItemID
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addItemSiblingBefore Succeeded'
ELSE PRINT 'Procedure Creation: addItemSiblingBefore Error on Creation'
GO
-----------------------------------------------------------------------------
/*
@ -15243,7 +15500,7 @@ GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2017 - Volian Enterprises, Inc. All rights reserved.
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision]
WITH EXECUTE AS OWNER
@ -15254,8 +15511,8 @@ BEGIN TRY -- Try Block
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '12/11/2019 02:32 PM'
set @RevDescription = 'Text Search Duplicate Primary Key Fix'
set @RevDate = '12/13/2019 7:00 AM'
set @RevDescription = 'Procedure number length when adding procedures'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT

View File

@ -2253,5 +2253,30 @@ OnPropertyChanged("Default_BkColor");
}
//end added by jcb to fix master issue byron/braidwood
#endregion
#region Enhanced
// C2019-045: For enhanced procedures, allow modifications of number & text.
[Category("Enhanced Settings")]
[Browsable(false)]
[DisplayName("AllowMods")]
[RefreshProperties(RefreshProperties.All)]
[Description("Allow Modifications of Number and Text")]
public bool Enhanced_AllowMods
{
get
{
string s = _Xp["Enhanced", "allowmods"];
if (s == string.Empty) return false; // empty is false
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
_Xp["Enhanced", "allowmods"] = value.ToString();
OnPropertyChanged("Enhanced_AllowMods");
}
}
}
#endregion
}
}

View File

@ -363,6 +363,16 @@ namespace VEPROMS.CSLA.Library
return _EnhType;
}
}
public bool EnhAllowMod()
{
// C2019-045: For enhanced procedures, allow modifications of number & text. This method checks whether the
// user selected to allow for modifications, i.e. the value in the docversion config, 'Enhanced_AllowMods' is true.
// Note that the flag is set on the enhanced doc versions, not the source, so that each enhanced can have its own setting.
if (!IsProcedure) return false;
if (MyDocVersion.DocVersionConfig.Enhanced_AllowMods) return true;
return false;
}
public bool InList(params int[] IDs)
{
foreach (int id in IDs)
@ -7148,14 +7158,18 @@ namespace VEPROMS.CSLA.Library
// the text in the enhanced item based on the displaytext of the source item.
foreach (ItemInfo ii in iil)
{
EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
// C2019-045: if allowing mods for procedure num/text we don't want to update the enhanced text so only do if not allowing mods:
if (!ii.EnhAllowMod())
{
ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID);
using (Item enhItem = Item.Get(ii.ItemID))
EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
{
enhItem.MyContent.Text = srcItem.DisplayTextKeepSpecialChars;
enhItem.Save();
ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID);
using (Item enhItem = Item.Get(ii.ItemID))
{
enhItem.MyContent.Text = srcItem.DisplayTextKeepSpecialChars;
enhItem.Save();
}
}
}
}

View File

@ -1615,6 +1615,18 @@ namespace VEPROMS.CSLA.Library
// look through pervious first:
ItemInfo iiCur = this.MyPrevious;
EAddpingPart addtype = EAddpingPart.After;
// C2019-045: For enhanced procedures, allow modifications of number & text. When a procedure is inserted, if allowing updates, the number/text doesn't
// get set to the existing source because this was done automatically in the contentinfo code that sets the enhanced text to the source and this code
// isn't run if modifications are allowed. Thus, use the number/text here for this case. If the changes in this method aren't made the number is emtpy
// and the procedure text (title) is 'New Procedure'
string pnum = null;
string ptext = null;
if (IsProcedure)
{
pnum = MyContent.Number;
ptext = MyContent.Text;
}
while (iiCur != null && newEnh == null)
{
foreach (EnhancedDocument edSource in iiCur.GetMyEnhancedDocuments())
@ -1626,15 +1638,20 @@ namespace VEPROMS.CSLA.Library
// B2017-272 did not need the if-check to set the enhanced type (commented it out)
//if (iiCur.MyContent.Type == MyContent.Type) // B2017-134 the enhanced section was being created with the wrong document type creating new enhanced section from EOP (bryon data)
enhType = (int)exEnh.MyContent.Type;
if (exEnh.IsStep)
{
// B2018-115: use the correct step type for the add.
// if coming from a HLS, note or caution, the enhanced type should be the base hls/note/caution type (from GetEnhancedTypeForAdd)
enhType = GetEnhancedTypeForAdd();
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, enhType, edSource.Type, this.ItemID);
}
else
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, enhType, edSource.Type, this.ItemID);
if (exEnh.IsStep)
{
// B2018-115: use the correct step type for the add.
// if coming from a HLS, note or caution, the enhanced type should be the base hls/note/caution type (from GetEnhancedTypeForAdd)
enhType = GetEnhancedTypeForAdd();
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, enhType, edSource.Type, this.ItemID);
}
else
{
if (!IsProcedure || !exEnh.MyDocVersion.DocVersionConfig.Enhanced_AllowMods)
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, enhType, edSource.Type, this.ItemID);
else
newEnh = exEnh.InsertEnhancedItems(ptext, pnum, addtype, enhType, edSource.Type, this.ItemID);
}
}
}
iiCur = iiCur.MyPrevious;
@ -1662,7 +1679,12 @@ namespace VEPROMS.CSLA.Library
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, enhType, edSource.Type, this.ItemID);
}
else
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, enhType, edSource.Type, this.ItemID);
{
if (!IsProcedure || !exEnh.MyDocVersion.DocVersionConfig.Enhanced_AllowMods)
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, enhType, edSource.Type, this.ItemID);
else
newEnh = exEnh.InsertEnhancedItems(ptext, pnum, addtype, enhType, edSource.Type, this.ItemID);
}
}
}
iiNxt = iiNxt.GetNextItem();
@ -1683,7 +1705,11 @@ namespace VEPROMS.CSLA.Library
{
// get the enhaced docversioninfo:
DocVersionInfo enhDVInfo = DocVersionInfo.Get(ded.VersionID);
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] :null, MyContent.Number, "New Procedure", 0))
string epnum = MyContent.Number;
string eptext = "New Procedure";
if (enhDVInfo.DocVersionConfig.Enhanced_AllowMods)
eptext = MyContent.Text;
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] :null, MyContent.Number, eptext, 0))
{
newEnh = ItemInfo.Get(newenhProcedure.ItemID);
string scng = null;

View File

@ -629,14 +629,19 @@ namespace VEPROMS.CSLA.Library
if (tmp.LocalEntry != null && tmpInfo.MyEntry != null && tmp.MyEntry.MyDocument.DocID != tmpInfo.MyEntry.MyDocument.DocID)
EntryInfo.Refresh(tmp.MyEntry);
}
// Update Enhanced Document Text
StepConfig sc = new StepConfig(tmp.Config);
foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
// Update Enhanced Document Text
StepConfig sc = new StepConfig(tmp.Config);
foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
{
// Without this 'if' infinite loop. Only update text if in source and updating to point to enhanced.
if (ed.Type != 0)
{
// Without this 'if' infinite loop. Only update text if in source and updating to point to enhanced.
if (ed.Type != 0)
ItemInfo ii = ItemInfo.Get(ed.ItemID);
// C2019-045: For enhanced procedures, allow modification of number & text. A setting on the docversion (set from Properties dialog) defines whether text
// can be modified if it is an enhanced item. If it can be modified, don't do the automatic update if the 'source' text is changed.
bool doEnhancedMods = ii.EnhAllowMod();
if (!doEnhancedMods)
{
ItemInfo ii = ItemInfo.Get(ed.ItemID);
DisplayText dt = new DisplayText(ii, ii.MyContent.Text, false);
string str = ItemInfo.Get(tmp.ContentItems[0].ItemID).DisplayTextKeepSpecialChars;
dt.Save(str);
@ -650,6 +655,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
}
}
protected virtual void RefreshFields(Content tmp)
{

View File

@ -1080,9 +1080,11 @@ namespace Volian.Controls.Library
ItemInfoList iil = pi.FindEnhancedProcedureTextDifferences();
if (iil != null)
{
if (FlexibleMessageBox.Show(this, "Text differences were found between this enhanced procedure and its source procedure. Do you want to refresh the text in this procedure?", "Confirm Text Refresh", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
// C2019-045: See if this is a procedure & modifications are allowed, if that case, don't prompt:
bool doMsg = true;
if (iil.Count == 1 && iil[0].EnhAllowMod()) doMsg = false;
if (doMsg && FlexibleMessageBox.Show(this, "Text differences were found between this enhanced procedure and its source procedure. Do you want to refresh the text in this procedure?", "Confirm Text Refresh", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
pi.EnhancedProcedureRefreshTextDifferences(iil);
}
}