Compare commits

..

2 Commits

5 changed files with 660 additions and 196 deletions

View File

@@ -22229,14 +22229,14 @@ Go
/*
==========================================================================================================
Begin: C2024-004: KL - Update Copy Replace functionality, (remove ''copy of'')
==========================================================================================================
*/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[CopyItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ReplaceItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [CopyItemAndChildren]; DROP PROCEDURE [ReplaceItemAndChildren];
GO GO
/***************************************************************************** /*****************************************************************************
@@ -22246,11 +22246,22 @@ GO
/* /*
========================================================================================================== ==========================================================================================================
Author: Kevin Laskey Author: Kevin Laskey
Modified Date: 07/09/2024 Create Date: 07/15/2024
Description: Copy Item and its Children Description: B2024-041: "Copy of" is no longer being appended for paste before/after
========================================================================================================== ==========================================================================================================
*/ */
CREATE PROCEDURE [dbo].[CopyItemAndChildren]
/****** Object: StoredProcedure [dbo].[CopyItemAndChildren] Script Date: 7/15/2024 9:29:21 AM ******/
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.
*****************************************************************************/
CREATE PROCEDURE [dbo].[ReplaceItemAndChildren]
( (
@StartItemID INT, @StartItemID INT,
@DestFormatID INT, @DestFormatID INT,
@@ -22295,7 +22306,6 @@ INSERT INTO @Children SELECT ItemID,ItemID,ContentID,ContentID,FormatID,FormatID
-- <<< Copy Contents >>> -- <<< Copy Contents >>>
-- Create new content rows to match the existing rows. Set the type to the Current ContentID temporarily -- Create new content rows to match the existing rows. Set the type to the Current ContentID temporarily
-- so that the new content rows can be associated with the existing content rows. -- so that the new content rows can be associated with the existing content rows.
-- Rem 'Copy Of ' + before first [Number] for C2024-004 (KL)
INSERT INTO Contents INSERT INTO Contents
([Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID]) ([Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID])
select CASE when [ContentID] = @StartContentID and [Type]<20000 then [Number] else [Number] end, select CASE when [ContentID] = @StartContentID and [Type]<20000 then [Number] else [Number] end,
@@ -22623,18 +22633,620 @@ BEGIN CATCH -- Catch Block
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler EXEC vlnErrorHandler
END CATCH END CATCH
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[PasteItemReplace]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [PasteItemReplace];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2024 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
/*
==========================================================================================================
Author: Kevin Laskey
Create Date: 07/15/2024
Description: B2024-041: "Copy of" is no longer being appended for paste before/after
==========================================================================================================
*/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object: StoredProcedure [dbo].[PasteItemReplace] Script Date: 03/20/2012 16:02:54 ******/
/*
declare @NewItemID int
declare @dts datetime
set @newitemid = 0
set @dts = getdate()
exec PasteItemReplace 398,397,20014,@dts,'bodine',@NewItemID output
*/
-- ItemID is item to replace
-- StartItemID is item to copy
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[PasteItemReplace]
(
@ItemID int=null, @StartItemID 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 @ContentID AS INT
DECLARE @NextItemID AS INT
DECLARE @PreviousItemID AS INT
DECLARE @ExternalChildCount AS INT
DECLARE @ExternalCount AS INT
DECLARE @Path AS VARCHAR(MAX)
DECLARE @Children AS TABLE
(
ItemID INT PRIMARY KEY,
ContentID INT
)
if exists (select * from tblitems where itemid = @ItemID and DeleteStatus !=0)
BEGIN
RAISERROR ('###Cannot Paste Step###This current step has been deleted in another session',16,1)
RETURN
END
-- First check if the replaced item can be deleted, i.e. it doesn't have transitions
-- pointing to it or children.
DECLARE @ExternalTrans TABLE
(
[FromItemID] int,
[TransitionID] [int] NOT NULL,
[FromID] [int] NOT NULL,
[ToID] [int] NOT NULL,
[RangeID] [int] NOT NULL,
[Config] [nvarchar](max) NULL
)
SET NOCOUNT ON
DECLARE @DeleteID int
INSERT INTO DeleteLog (UserID) VALUES (@UserID)
SELECT @DeleteID = SCOPE_IDENTITY()
SELECT @ContentID = ContentID, @PreviousItemID = PreviousID FROM Items WHERE ItemID = @ItemID
SELECT @NextItemID = ItemID FROM Items WHERE PreviousID = @ItemID
--SELECT @ExternalCount = count(*) FROM vefn_FindExternalTransitions(@ItemID)
SELECT @ExternalChildCount = count(*) FROM vefn_FindExternalChildTransitions(@ItemID)
SET @Path = [dbo].[ve_GetShortPath](@ItemID)
--IF @ExternalCount > 0 AND @NextItemID is null
--BEGIN
-- RAISERROR ('###Cannot Delete Item###Step %d has External Transitions and has no next step - (%s)',16,1,@ItemID,@Path)
-- RETURN
--END
IF @ExternalChildCount > 0
BEGIN
RAISERROR ('###Cannot Delete Item###Step %d has External Transitions to it''s children - (%s)',16,1,@ItemID,@Path)
RETURN
END
-- Copy the item, 'NewItemID' represents the new item(s)
-- DestFormatID is the formatid for the destination parent's format
DECLARE @DestFormatID int
SET @DestFormatID = .dbo.vefn_GetInheritedFormat(@ItemID, 0)
EXECUTE ReplaceItemAndChildren @StartItemID, @DestFormatID, @UserID, @NewItemID OUTPUT
-- Adjust the next/previous to point to the new item
DECLARE @PreviousID int
SELECT @PreviousID = [PreviousID]
FROM [ITEMS] II
WHERE [ItemID]=@ItemID
UPDATE [ITEMS] SET [PreviousID]=@PreviousID where [ItemID]=@NewItemID
UPDATE [CONTENTS] SET [Type]=@Type
FROM [CONTENTS] CC JOIN [ITEMS] ii ON CC.[ContentID]=II.[ContentID]
WHERE [ItemID]=@NewItemID
UPDATE [ITEMS] SET [PreviousID]=@NewItemID where [PreviousID]=@ItemID
UPDATE [PARTS] SET [ItemID]=@NewItemID where [ItemID]=@ItemID
-- UPDATE DocVersion if this was a procedure
UPDATE DocVersions SET ItemID=@NewItemID where ItemID = @ItemID
-- If there were 'external transitions' that pointed to the original
-- top replaced step, adjust them to point to the new top.
INSERT INTO @ExternalTrans SELECT * FROM vefn_FindExternalTransitions(@ItemID)
OPTION (MAXRECURSION 10000)
IF (SELECT COUNT(*) from @ExternalTrans) > 0
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 TransitionID in(Select TransitionID from @ExternalTrans)
-- Update transitions that point to @ItemID to Point to @NextItemID
UPDATE TRANSITIONS
SET ToID = case when ToID = @ItemID then @NewItemID else ToID END,
RangeID = case when RangeID = @ItemID then @NewItemID else RangeID END
WHERE TransitionID in(Select TransitionID from @ExternalTrans)
DECLARE @typeID int -- AnnotationType
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' annotions for transtions that pointed to top step
-- and need to point to
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Verify Replaced Step Transition Destination',@UserID
FROM Items where ItemID in (SELECT FromItemID FROM @ExternalTrans)
END
-- Remove the old one
-- Get list of Children
INSERT INTO @Children SELECT * FROM vefn_ChildItems(@ItemID)
-- Delete Annotations for @ItemID and children
DELETE from Annotations where ItemID in(Select ItemID from @Children)
-- Delete Details associated with @ContentID and children
DELETE from Details where ContentID in(Select ContentID from @Children)
-- Delete Grids associated with @ContentID and children
DELETE from Grids where ContentID in(Select ContentID from @Children)
-- Delete Images associated with @ContentID and children
DELETE from Images where ContentID in(Select ContentID from @Children)
-- Delete Entries associated with @ContentID and children
DELETE from Entries where ContentID in(Select ContentID from @Children)
-- Delete ROUsages associated with @ContentID and children
DELETE from RoUsages where ContentID in(Select ContentID from @Children)
-- Delete ZTransitions records associated with @ContentID and children
DELETE FROM ZTransitions where TransitionID
in(SELECT TransitionID from Transitions where FromID in(SELECT ContentID FROM @Children) or FromID = @ContentID)
-- Delete Transitions associated with @ContentID and children
DELETE FROM Transitions where FromID in(SELECT ContentID FROM @Children) or FromID = @ContentID
-- Delete Parts associated with @ContentID and children
DELETE from Parts where ContentID in(Select ContentID from @Children)
-- Delete ZContents associated with @ContentID and children
DELETE from ZContents where ContentID in(Select ContentID from @Children)
-- Disconnect Items from Each Other
DELETE from Items where ItemID in(Select ItemID from @Children) and PreviousID Is Not Null
-- Disconnect Items to be deleted from each other
Update Items set PreviousID = null where ItemID in (Select ItemID from @Children) and PreviousID Is Not Null
-- Delete Item Records
DELETE from Items where ItemID in(Select ItemID from @Children)
-- DELETE Contents
DELETE from Contents where ContentID in(Select ContentID from @Children)
--delete from itemaudits where itemid = @newitemid
delete from itemaudits where itemid in (select itemid from vefn_ChildItems(@newitemid))
--delete from contentaudits where contentid = (select contentid from items where itemid = @newitemid)
delete from contentaudits where contentid in (select contentid from vefn_ChildItems(@newitemid))
DELETE from DeleteLog where DeleteID = @DeleteID
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
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[CopyItemAndChildren]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [CopyItemAndChildren];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2024 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
/*
==========================================================================================================
Author: Kevin Laskey
Create Date: 07/15/2024
Description: B2024-041: "Copy of" is no longer being appended for paste before/after
==========================================================================================================
*/
/****** Object: StoredProcedure [dbo].[CopyItemAndChildren] Script Date: 7/15/2024 10:01:59 AM ******/
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.
*****************************************************************************/
CREATE PROCEDURE [dbo].[CopyItemAndChildren]
(
@StartItemID INT,
@DestFormatID INT,
@UserID NVARCHAR(100),
@NewStartItemID int output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
--+-----------------------------------------------------------------+
--& BEGIN TRANSACTION to make these changes temporary &
--+-----------------------------------------------------------------+
BEGIN TRANSACTION
if exists (select * from tblitems where itemid = @StartItemID and DeleteStatus !=0)
BEGIN
RAISERROR ('###Cannot Paste Step###This step has been deleted',16,1)
RETURN
END
DECLARE @Children AS TABLE
(
ItemID INT PRIMARY KEY,
NewItemID INT,
ContentID INT,
NewContentID INT,
FormatID INT,
NewFormatID INT
)
DECLARE @NewDocuments AS TABLE
(
DocID INT PRIMARY KEY,
NewDocID INT
)
-- Locals
DECLARE @DTS DATETIME -- DTS of all New Items
DECLARE @StartContentID INT
Select @StartContentID = ContentID from Items where ItemID = @StartItemID
SET @DTS = GETDATE() -- Get the current Date and Time
-- Get a list of all of the Items to be copied based upon StartItemID and EndItemID
-- If the StartItemID = EndItemID then it is a single item and it's children
INSERT INTO @Children SELECT ItemID,ItemID,ContentID,ContentID,FormatID,FormatID FROM vefn_ChildItemsRange(@StartItemID,@StartItemID,null)
-- <<< Copy Contents >>>
-- Create new content rows to match the existing rows. Set the type to the Current ContentID temporarily
-- so that the new content rows can be associated with the existing content rows.
INSERT INTO Contents
([Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID])
select CASE when [ContentID] = @StartContentID and [Type]<20000 then 'Copy Of ' + [Number] else [Number] end,
[Text],[ContentID],[FormatID],[Config],@DTS,@UserID
from Contents where ContentID in(Select ContentID from @Children)
-- Update the @Children with the NewConentIDs
--print 'A ' + cast(datediff(s,@dts,getdate()) as varchar(100))
UPDATE NN set NN.NewContentID = CC.ContentID
From Contents CC
Join @Children NN on NN.ContentID = CC.Type AND CC.DTS = @DTS and CC.UserID = @UserID
-- Reset the Type column in the Contents table with the Type column from the original Records.
--print 'B ' + cast(datediff(s,@dts,getdate()) as varchar(100))
DECLARE @SourceType INT
Select @SourceType = Type from Contents where ContentID = @StartContentID
if @SourceType = 0
BEGIN
UPDATE CC set CC.Type = CC2.Type, CC.DTS = CC2.DTS, CC.UserID = CC2.UserID
From Contents CC
Join @Children NN on NN.NewContentID = CC.ContentID
Join Contents CC2 on NN.ContentID = CC2.ContentID
END
else
BEGIN
UPDATE CC set CC.Type = CC2.Type
From Contents CC
Join @Children NN on NN.NewContentID = CC.ContentID
Join Contents CC2 on NN.ContentID = CC2.ContentID
END
--print 'B1 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Contents are done
-- SELECT * From Contents where DTS = @DTS and UserID = @UserID
-- <<< Copy Grids >>>
INSERT INTO [Grids]([ContentID],[Data],[Config],[DTS],[UserID])
SELECT NN.[NewContentID],[Data],[Config],@DTS,@UserID
FROM [Grids] GG Join @Children NN on GG.ContentID = NN.ContentID
-- <<< Copy Images >>>
--print 'B2 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
INSERT INTO [Images]([ContentID],[ImageType],[FileName],[Data],[Config],[DTS],[UserID])
SELECT NN.[NewContentID],[ImageType],[FileName],[Data],[Config],@DTS,@UserID
FROM [Images] II Join @Children NN on II.ContentID = NN.ContentID
-- Create new item rows based upon the current item rows and the @Children table, with the NewContentIDs
--print 'B3 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
INSERT INTO [Items] ([PreviousID],[ContentID],[DTS],[UserID])
SELECT II.[PreviousID], -- Leave the PreviousID as is for now
NN.NewContentID, @DTS, @UserID
from @Children NN
join Items II on II.ContentID = NN.ContentID
-- Update the @Children with the NewItemIDs
--print 'B4 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
UPDATE NN set NN.NewItemID = II.ItemID
From Items II
Join @Children NN on NN.NewContentID = II.ContentID AND II.DTS = @DTS and II.UserID = @UserID
DECLARE @NewItemID int
SELECT @NewItemID = NewItemID
FROM @Children
WHERE ItemID = @StartItemID
--print 'B5 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
UPDATE NN SET NN.[NewFormatID] = CC.[FormatID]
FROM @Children NN
Join vefn_ChildItemsRange(@NewItemID,@NewItemID,@DestFormatID) CC
ON NN.NewItemID = CC.ItemID
-- The @Children table is now complete
--SELECT * From @Children
-- Update the PreviousID in the new Item rows, to the new ItemIDs based upon the old ItemIDs
--print 'B6 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
Update II Set II.[PreviousID] = NN.NewItemID
from Items II
Join @Children NN on NN.ItemID = II.PreviousID AND II.DTS = @DTS and II.UserID = @UserID
-- Get the new ItemIDs based upon the old ItemIDs
SELECT @NewStartItemID = NewItemID from @Children where ItemID = @StartItemID
--SELECT @NewEndItemID = NewItemID from @Children where ItemID = @EndItemID
-- Set the PreviousID for the starting Item to null temporarily.
-- This will be adjusted based upon where the step is inserted.
--print 'B7 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
Update Items Set PreviousID = null where ItemID = @NewStartItemID
if @SourceType = 0
BEGIN
UPDATE II SET II.DTS = II2.DTS, II.UserID = II2.UserID
From Items II
Join @Children NN on NN.NewItemID = II.ItemID
Join Items II2 on NN.ItemID = II2.ItemID
WHERE NN.ItemID = @StartItemID
END
--print 'C ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Items are done
--SELECT * From Items where DTS = @DTS and UserID = @UserID
-- <<< Copy Parts >>>
INSERT INTO [Parts] ([ContentID],[FromType],[ItemID],[DTS],[UserID])
Select NNF.NewContentID,[FromType],NNT.NewItemID, @DTS, @UserID from Parts PP
JOIN @Children NNF on PP.ContentID = NNF.ContentID
JOIN @Children NNT on PP.ItemID = NNT.ItemID
--print 'D ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Parts are done
-- SELECT * From Parts where DTS = @DTS and UserID = @UserID
-- <<< Copy Annotations >>>
INSERT INTO [Annotations] ([ItemID],[TypeID],[RtfText],[SearchText],[Config],[DTS],[UserID])
Select NewItemID, TypeID, RtfText, SearchText, Config, @DTS, @UserID
from Annotations AA Join @Children NN on AA.ItemID = NN.ItemID
--print 'E ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Annotations are done
-- SELECT * From Annotations where DTS = @DTS and UserID = @UserID
-- <<< Copy Documents and Entries>>>
-- logic to create Entries for Library Documents
INSERT INTO [Entries] ([ContentID],[DocID],[DTS],[UserID])
SELECT NN.[NewContentID],EE.[DocID],@DTS,@UserID
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
JOIN [Documents] DD on EE.[DocID] = DD.[DocID] and Isnull(LibTitle,'') <> ''
-- Logic to create new documents for any documents used that do not have libtitles
INSERT INTO [Documents] ([LibTitle],[DocContent],[DocAscii],[Config],[DTS],[UserID],[FileExtension])
OUTPUT CAST(INSERTED.[LibTitle] as INT),INSERTED.[DocID] INTO @NewDocuments
SELECT str(DD.[DocID]),[DocContent],[DocAscii],[Config],@DTS,@UserID,[FileExtension]
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
JOIN [Documents] DD on EE.[DocID] = DD.[DocID] and Isnull(LibTitle,'') = ''
UPDATE DD SET LibTitle = ''
FROM Documents DD JOIN @NewDocuments ND on DD.[DocID] = ND.[NewDocID]
where DTS = @DTS and UserID = @UserID
--print 'F ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Documents are Done
-- SELECT * From Documents where DTS = @DTS and UserID = @UserID
-- Logic to create entries for these newly created documents
INSERT INTO [Entries] ([ContentID],[DocID],[DTS],[UserID])
SELECT NN.[NewContentID],ND.[NewDocID],@DTS,@UserID
FROM [Entries] EE JOIN @Children NN on NN.ContentID = EE.ContentID
JOIN @NewDocuments ND on EE.[DocID] = ND.[DocID]
-- Logic to Create DROUsages for these newly created documents
INSERT INTO [DROUsages] ([DocID],[ROID],[Config],[DTS],[UserID],[RODbID])
SELECT ND.[NewDocID],[ROID],[Config],@DTS,@UserID,[RODbID]
FROM [DROUsages] RR
JOIN @NewDocuments ND on RR.[DocID] = ND.[DocID]
--print 'G ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Entries are done
-- SELECT * From Entries EE JOIN Documents DD on ee.DocID = DD.DocID where EE.DTS = @DTS and EE.UserID = @UserID
-- <<< Copy RoUsages >>>
INSERT INTO [RoUsages] ([ContentID],[ROID],[Config],[DTS],[UserID],[RODbID])
SELECT NN.[NewContentID],CAST([ROUsageID] as nvarchar(16)),[Config],@DTS,@UserID,[RODbID]
FROM [RoUsages] RR Join @Children NN on RR.ContentID = NN.ContentID
-- Update content records for newly copied records to use correct RO usage ids in the RO tags
DECLARE @RowsAffected int
SET @RowsAffected=1
WHILE @RowsAffected > 0
BEGIN
UPDATE CC SET [TEXT] = C2.NewText
FROM CONTENTS CC
JOIN (SELECT C1.ContentID, .dbo.vefn_FixROText(C1.Text, CAST([ROID] as int), [ROUsageID]) NewText
FROM CONTENTS C1
JOIN @Children NN on C1.ContentID = NN.NewContentID
JOIN RoUsages RO on NN.NewContentID = RO.ContentID where Len([ROID]) < 12) C2 ON CC.ContentID = C2.ContentID
WHERE [TEXT] <> C2.NewText
SET @RowsAffected = @@RowCount
END
-- Update grid records for newly copied records to use correct RO usage ids in the RO tags
SET @RowsAffected=1
WHILE @RowsAffected > 0
BEGIN
UPDATE GG SET [Data] = G2.NewData
FROM GRIDS GG
JOIN (SELECT G1.ContentID, .dbo.vefn_FixROData(G1.Data, CAST([ROID] as int), [ROUsageID]) NewData
FROM GRIDS G1
JOIN @Children NN on G1.ContentID = NN.NewContentID
JOIN RoUsages RO on NN.NewContentID = RO.ContentID where Len([ROID]) < 12) G2 ON GG.ContentID = G2.ContentID
WHERE Cast([Data] as nvarchar(max)) <> cast(G2.NewData as nvarchar(max))
SET @RowsAffected = @@RowCount
END
UPDATE RON SET [ROID] = ROO.[ROID]
FROM RoUsages RON
JOIN @Children NN on RON.ContentID = NN.NewContentID
JOIN RoUsages ROO on CAST(RON.ROID as int) = ROO.RoUsageID
where Len(RON.[ROID]) < 12
--print 'H ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- RoUsages are done
-- SELECT * From RoUsages where DTS = @DTS and UserID = @UserID
-- <<< Copy Transtions >>>
-- Note that the inserted record has the 'TranType' field set to old transitionid. This is done
-- so that the next step can replace the old transitionid with the new transitionid in the
-- content record's transition tokens. The TranType gets reset after the content records are
-- updated.
-- Also note that the 'toid/rangeid' may need converted to newly copied ids or may not. If it's
-- not a range, then it always is converted to new, if there is a new. If it's a range, both
-- the toid & the rangeid must be new in order for the conversion to be correct. You cannot
-- have part of the range pointing to the new and part of the range pointing to the original
-- locations.
INSERT INTO .[dbo].[Transitions] ([FromID],[ToID],[RangeID],[IsRange],[TranType],[Config],[DTS],[UserID])
SELECT NNF.[NewContentID],
-- if both toid & range are null, use the original toid & rangeid
CASE WHEN NNT.[NewItemID] is null or NNR.[NewItemID] is null THEN [ToID] ELSE NNT.[NewItemID] END,
CASE WHEN NNT.[NewItemID] is null or NNR.[NewItemID] is null THEN [RangeID] ELSE NNR.[NewItemID] END,
[IsRange],[TransitionID],[Config],@DTS,@UserID
FROM .[dbo].[Transitions] TT
JOIN @Children NNF on TT.[FromID] = NNF.[ContentID]
LEFT JOIN @Children NNT on TT.[ToID] = NNT.[ItemID]
LEFT JOIN @Children NNR on TT.[RangeID] = NNR.[ItemID]
--print 'H1 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- -- Update content records for newly copied records to use correct TransitionIDs in the Transition tags
SET @RowsAffected=1
WHILE @RowsAffected > 0
BEGIN
UPDATE CC SET [TEXT] = C2.NewText
FROM CONTENTS CC
JOIN (SELECT C1.ContentID, .dbo.vefn_FixTransitionTextForCopy(C1.Text, TRO.TransitionID, TRO.TranType, TRO.[ToID], TRO.[RangeID],TR.[TransitionID], TR.[ToID], TR.[RangeID], .dbo.vefn_GetNewTranType(NN.FormatID, NN.NewFormatID, TRO.TranType)) NewText
FROM CONTENTS C1
JOIN @Children NN on C1.ContentID = NN.NewContentID
JOIN Transitions TR on NN.NewContentID = TR.FromID
JOIN Transitions TRO on TR.TranType = TRO.TransitionID) C2 ON CC.ContentID = C2.ContentID
WHERE [TEXT] <> C2.NewText
SET @RowsAffected = @@RowCount
END
--print 'H2 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
--set nocount off
-- -- Update grid records for newly copied records to use correct TransitionIDs in the Transition tags
declare @grids table
(
contentid int primary key,
data xml
)
insert into @grids select gg.contentid,gg.data from GRIDS GG
where gg.contentid in (select nn.newcontentid from
@Children NN
JOIN Transitions TR on NN.NewContentID = TR.FromID
JOIN Transitions TRO on TR.TranType = TRO.TransitionID)
--print 'H2.1 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
--select * from @grids
SET @RowsAffected=1
WHILE @RowsAffected > 0
BEGIN
UPDATE GG SET [DATA] = G2.NewData
FROM @GRIDS GG
JOIN (SELECT G1.ContentID, .dbo.vefn_FixTransitionDataForCopy(G1.Data, TRO.TransitionID, TRO.TranType, TRO.[ToID], TRO.[RangeID],TR.[TransitionID], TR.[ToID], TR.[RangeID], .dbo.vefn_GetNewTranType(NN.FormatID, NN.NewFormatID, TRO.TranType)) NewData
FROM @GRIDS G1
JOIN @Children NN on G1.ContentID = NN.NewContentID
JOIN Transitions TR on NN.NewContentID = TR.FromID
JOIN Transitions TRO on TR.TranType = TRO.TransitionID) G2 ON GG.ContentID = G2.ContentID
WHERE Cast([DATA] as nvarchar(max)) <> CAST(G2.NewData as nvarchar(max))
SET @RowsAffected = @@RowCount
END
--print 'H2.2 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
update GG set data = g1.data from Grids gg join @grids g1 on gg.contentid = g1.contentid
--print 'H3 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
--set nocount on
-- 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 whose transition format changes
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT NN.NewItemID, @typeID,'Verify Transition Format',@UserID
FROM Transitions TR
JOIN @Children NN on TR.FromID = NN.NewContentID
JOIN Transitions TRO on TR.TranType = TRO.TransitionID
WHERE .dbo.vefn_CompareTranFormat(NN.FormatID, NN.NewFormatID, TRO.TranType) <> 0
--print 'H4 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
UPDATE TR SET TR.[TranType] = .dbo.vefn_GetNewTranType(NN.FormatID, NN.NewFormatID, TRO.TranType)
FROM Transitions TR
JOIN @Children NN on TR.FromID = NN.NewContentID
JOIN Transitions TRO on TR.TranType = TRO.TransitionID
--print 'H5 ' + cast(datediff(s,@dts,getdate()) as varchar(100))
-- Transitions are done
-- SELECT * From Transitions where DTS = @DTS and UserID = @UserID
--print 'Z ' + cast(datediff(s,@dts,getdate()) as varchar(100))
--foldouts fixing code
if exists (select * from contents where contentid in (select newcontentid from @children) and config like '%FloatingFoldout%')
begin
--insert into #mytemp
select cc.contentid,xsteps.value('@FloatingFoldout','int') oldfoldoutid,(select newitemid
from @children
where itemid = xsteps.value('@FloatingFoldout','int')) newfoldoutid,xconfig
into #mytemp
from (select *,cast(config as xml) xconfig from contents where contentid in (select newcontentid from @children)) cc
cross apply xconfig.nodes('Config/Step') tsteps(xsteps)
--build @cmd string
declare @cmd nvarchar(max)
declare cmds cursor for
select distinct 'update #mytemp set xconfig.modify(''replace value of (Config/Step/@FloatingFoldout)[1] with "'
+ cast(newfoldoutid as varchar(10))
+ '"'') where xconfig.value(''(Config/Step/@FloatingFoldout)[1]'',''int'') = '
+ cast(oldfoldoutid as varchar(10))
from #mytemp
--execute cursor over rows
open cmds
fetch next from cmds into @cmd
while @@fetch_status = 0
begin
exec sp_executesql @cmd
fetch next from cmds into @cmd
end
close cmds
deallocate cmds
--actually update contents
update cc set config = cast(xconfig as varchar(max)) from contents cc join #mytemp mt on cc.contentid = mt.contentid
--get rid of #mytemp
drop table #mytemp
end
--end foldouts fixing code
--section start
DECLARE @NewContentID int
Select @NewContentID = NewContentID from @Children where ItemID = @StartItemID
DECLARE @Config varchar(max)
DECLARE @XConfig xml
select @Config = config from contents where contentid = @NewContentID
select @XConfig = cast(@Config as xml)
if @Config like '%SectionStart%' begin
DECLARE @SectionStart int
select @SectionStart = xproc.value('@SectionStart','int') from @xconfig.nodes('Config/Procedure') tproc(xproc)
DECLARE @NewSectionStart int
select @NewSectionStart = newitemid from @children where itemid = @SectionStart
DECLARE @cmd2 nvarchar(max)
set @cmd2 = '
declare @XConfig xml;
set @XConfig = cast(''' + @Config + ''' as xml);
set @XConfig.modify(''replace value of (Config/Procedure/@SectionStart)[1] with "' + cast(@NewSectionStart as nvarchar(10)) + '"'');
update contents set config = cast(@XConfig as varchar(max)) where contentid = ' + cast(@NewContentID as nvarchar(10)) + ';'
exec sp_executesql @cmd2
end
--end section start
IF( @@TRANCOUNT > 0 ) COMMIT
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 Go
IF (@@Error = 0) PRINT 'Procedure Creation: [CopyItemAndChildren] Succeeded'
ELSE PRINT 'Procedure Creation: [CopyItemAndChildren] Error on Creation'
GO
/*
==========================================================================================================
End: C2024-004: KL - Update Copy Replace functionality, (remove ''copy of'')
==========================================================================================================
*/
@@ -22673,8 +23285,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255) DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255) DECLARE @RevDescription varchar(255)
set @RevDate = '07/09/2024 9:00 AM' set @RevDate = '07/16/2024 3:37 PM'
set @RevDescription = 'C2024-004: Update Copy Replace functionality' set @RevDescription = 'B2024-041: Updates to allow for proper replace vs paste above or below'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription

View File

@@ -1944,54 +1944,6 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region DataPortal #region DataPortal
private void DataPortal_Fetch(PastingPartEnhancedCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
Csla.ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@StartItemID", criteria.StartItemID); // copy children
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); //copy to
cm.Parameters.AddWithValue("@Type", criteria.Type);
cm.Parameters.AddWithValue("@DTS", criteria.DTS);
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
SqlParameter param_ItemID = new SqlParameter("@NewItemID", SqlDbType.Int);
param_ItemID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ItemID);
cm.CommandText = "PasteItemEnhancedReplace";
//cm.CommandText = "PasteItemReplace";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
//int newItemID = (int)cm.Parameters["@NewItemID"].Value;
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (Csla.ApplicationContext.ExecutionLocation == Csla.ApplicationContext.ExecutionLocations.Client)
Csla.ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (!ex.Message.Contains("This step has been deleted") && !ex.Message.Contains("This current step has been deleted in another session"))
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
}
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
private void DataPortal_Fetch(PastingPartCriteria criteria) private void DataPortal_Fetch(PastingPartCriteria criteria)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
@@ -2114,68 +2066,6 @@ namespace VEPROMS.CSLA.Library
} }
} }
#endregion #endregion
#region PastingPartEnhancedCriteria
[Serializable()]
public class PastingPartEnhancedCriteria
{
#region Properties
private int _StartItemID;
public int StartItemID
{
get { return _StartItemID; }
set { _StartItemID = value; }
}
private int _ItemID; // paste relative to this itemid
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private EAddpingPart _AddType;
public EAddpingPart AddType
{
get { return _AddType; }
set { _AddType = value; }
}
private int? _FromType = null;
public int? FromType
{
get { return _FromType; }
set { _FromType = value; }
}
private int? _Type = null;
public int? Type
{
get { return _Type; }
set { _Type = value; }
}
private DateTime _DTS;
public DateTime DTS
{
get { return _DTS; }
set { _DTS = value; }
}
private string _UserID;
public string UserID
{
get { return _UserID; }
set { _UserID = value; }
}
#endregion
#region Constructor
public PastingPartEnhancedCriteria(int startItemid, int itemID, EAddpingPart addType, int? type, int? fromType, DateTime dts, string userID)
{
_StartItemID = startItemid;
_ItemID = itemID;
_AddType = addType;
_Type = type;
_FromType = fromType;
_DTS = dts;
_UserID = userID;
}
#endregion
}
#endregion
#region PastingPartCriteria #region PastingPartCriteria
[Serializable()] [Serializable()]
public class PastingPartCriteria public class PastingPartCriteria
@@ -2466,17 +2356,6 @@ namespace VEPROMS.CSLA.Library
_MyPrevious = null; // Reset list so that the next line gets a new list _MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
} }
internal static ItemInfo CopyPasteReplaceEnhancedItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
{
ItemInfo tmp = null;
tmp = DataPortal.Fetch<StepInfo>(new ItemInfo.PastingPartEnhancedCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
if (tmp == null)
{
tmp = ItemInfo.Get(copyStartID);
}
AddToCache(tmp);
return tmp;
}
internal static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType) internal static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
{ {
ItemInfo tmp = null; ItemInfo tmp = null;
@@ -2624,18 +2503,10 @@ namespace VEPROMS.CSLA.Library
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace) public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace)
{ {
if (itemInfo.IsEnhancedStep)
{
// don't replace the step, just remove current children & add new children:
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Item");
}
bool tmp = false; bool tmp = false;
return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp); return PasteReplace(itemInfo, copyStartID, chgid, treeNodeReplace, ref tmp);
} }
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved // B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
// B2017-179 return a bool (firstTrans) if we could not replace the step but the user wants to position to the first transition that needs resolved
public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans) public static ItemInfo PasteReplace(ItemInfo itemInfo, int copyStartID, string chgid, TreeNode treeNodeReplace, ref bool firstTrans)
{ {
firstTrans = false; firstTrans = false;
@@ -2647,17 +2518,8 @@ namespace VEPROMS.CSLA.Library
ItemInfo newItemInfo = null; ItemInfo newItemInfo = null;
try try
{ {
// if this item is an enhanced item, do a pastereplace specific to it: newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
if (itemInfo.IsEnhancedStep) if (newItemInfo == null) return null;
{
newItemInfo = ItemInfo.CopyPasteReplaceEnhancedItemInfoFetch(copyStartID, itemInfo);
if (newItemInfo == null) return null;
}
else
{
newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
if (newItemInfo == null) return null;
}
} }
catch (Exception ex1) catch (Exception ex1)
{ {
@@ -2705,7 +2567,7 @@ namespace VEPROMS.CSLA.Library
//Create tree node for copied procedure when no other procedures exist in the folder //Create tree node for copied procedure when no other procedures exist in the folder
VETreeNode vtn = treeNodeReplace as VETreeNode; VETreeNode vtn = treeNodeReplace as VETreeNode;
DocVersionInfo dvi = vtn.VEObject as DocVersionInfo; DocVersionInfo dvi = vtn.VEObject as DocVersionInfo;
ItemInfo newProc = dvi.PasteChild(copyStartID); ItemInfo newProc = dvi.PasteChild(copyStartID);
VETreeNode tn1 = new VETreeNode(newProc); VETreeNode tn1 = new VETreeNode(newProc);
treeNodeReplace.Nodes.Add(tn1); // add tree node to end of list. treeNodeReplace.Nodes.Add(tn1); // add tree node to end of list.
@@ -2722,23 +2584,23 @@ namespace VEPROMS.CSLA.Library
firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved firstTrans = true; // B2017-179 set the firstTrans to true and return the itminfo of the first transition location that needs resolved
return iii; return iii;
} }
if (!HandleSqlExceptionOnCopy(ex)) if (!HandleSqlExceptionOnCopy(ex))
{ {
if (ex.Message.Contains("has External Transitions and has no next step") if (ex.Message.Contains("has External Transitions and has no next step")
|| ex.Message.Contains("has External Transitions to Procedure") || ex.Message.Contains("has External Transitions to Procedure")
|| ex.Message.Contains("has External Transitions to it's children") || ex.Message.Contains("has External Transitions to it's children")
|| ex.Message.Contains("This step has been deleted") || ex.Message.Contains("This step has been deleted")
) )
throw ex; throw ex;
FlexibleMessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); FlexibleMessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return itemInfo; return itemInfo;
} }
else else
return itemInfo; return itemInfo;
} }
} }
#endregion #endregion
private static bool HandleSqlExceptionOnCopy(Exception ex) private static bool HandleSqlExceptionOnCopy(Exception ex)
{ {
if (ex.Message.Contains("This step has been deleted")) if (ex.Message.Contains("This step has been deleted"))
{ {

View File

@@ -669,7 +669,7 @@ namespace Volian.Controls.Library
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString(); string key = "Item - " + proc.ItemID.ToString();
if (_MyDisplayTabItems.ContainsKey(key) && pasteType != ItemInfo.EAddpingPart.Replace) // If procedure page open use it unless replace if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{ {
DisplayTabItem pg = _MyDisplayTabItems[key]; DisplayTabItem pg = _MyDisplayTabItems[key];
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID) && if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID) &&
@@ -688,14 +688,14 @@ namespace Volian.Controls.Library
edtitm.PasteSiblingAfter(copyStartID); edtitm.PasteSiblingAfter(copyStartID);
break; break;
case ItemInfo.EAddpingPart.Replace: case ItemInfo.EAddpingPart.Replace:
EditItem ei = edtitm.PasteReplace(copyStartID); EditItem ei = edtitm.PasteReplace(copyStartID);
if (ei == null) if (ei == null)
{ {
CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab. CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted return false; //B2017-179 PasteReplace will return null if was aborted
} }
if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID) if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID)
{ {
edtitm.Dispose(); edtitm.Dispose();
@@ -708,12 +708,6 @@ namespace Volian.Controls.Library
return true; return true;
} }
} }
else if (_MyDisplayTabItems.ContainsKey(key) && pasteType == ItemInfo.EAddpingPart.Replace)
{
CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted
}
return false; return false;
} }

View File

@@ -1825,8 +1825,8 @@ namespace Volian.Controls.Library
EditItem newFocus = null; EditItem newFocus = null;
EditItem nextEditItem = MyNextEditItem; EditItem nextEditItem = MyNextEditItem;
EditItem prevEditItem = MyPreviousEditItem; EditItem prevEditItem = MyPreviousEditItem;
//if (MyStepPanel?.SelectedEditItem?.ActiveParent == null) return null; //Was causing an error// when active parent was null and the replaced proc was opened in the editor. if (MyStepPanel?.SelectedEditItem?.ActiveParent == null) return null; //Was causing an error when active parent was null and the replaced proc was opened in the editor.
EditItem parentEditItem = MyStepPanel?.SelectedEditItem?.ActiveParent; EditItem parentEditItem = ActiveParent;
StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig; StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;
int TopMostYBefore = TopMostEditItem.Top; int TopMostYBefore = TopMostEditItem.Top;
@@ -1936,7 +1936,7 @@ namespace Volian.Controls.Library
sia.IdentifyChildren(highlight); sia.IdentifyChildren(highlight);
} }
} }
if (MyBeforeEditItems != null && !MyItemInfo.IsEnhancedStep) if (MyBeforeEditItems != null)
{ {
foreach (EditItem sib in MyBeforeEditItems) foreach (EditItem sib in MyBeforeEditItems)
{ {

View File

@@ -1749,9 +1749,9 @@ namespace Volian.Controls.Library
EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments(); EnhancedDocuments eds = MyItemInfo.GetMyEnhancedDocuments();
// note in follow if statements, 'setting' == false when in enhanced document: // note in follow if statements, 'setting' == false when in enhanced document:
if (setting && MyItemInfo.IsStep && (eds == null || eds.Count == 0)) // this step is in enhanced, but not linked // B2018-112 and is allowed to edit if (setting && MyItemInfo.IsStep && (eds == null || eds.Count == 0)) // this step is in enhanced, but not linked // B2018-112 and is allowed to edit
allowDel = true; // allow delete if not linked allowDel = true; // allow delete if not linked
btnCpyStp.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi); // setting; btnCpyStp.Enabled = setting;
//B20170-158 Allow a Unlinked Step to be pasted before or after a linked step. //B20170-158 Allow a Unlinked Step to be pasted before or after a linked step.
StepTabPanel tmp = Parent as StepTabPanel; StepTabPanel tmp = Parent as StepTabPanel;
//B2020-058: crash on null reference //B2020-058: crash on null reference
if (tmp != null && tmp.MyDisplayTabControl != null && tmp.MyDisplayTabControl.MyCopyStep != null) if (tmp != null && tmp.MyDisplayTabControl != null && tmp.MyDisplayTabControl.MyCopyStep != null)
@@ -1761,10 +1761,6 @@ namespace Volian.Controls.Library
{ {
if (MyItemInfo.IsEnhancedStep) btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; if (MyItemInfo.IsEnhancedStep) btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
} }
else if (tmp.MyDisplayTabControl.MyCopyStep.IsEnhancedStep && tmp.MyDisplayTabControl.MyCopyStep.MyDocVersion.VersionID == MyItemInfo.MyDocVersion.VersionID)
{
btnPasteBefore.Enabled = btnPasteAfter.Enabled = MyUserInfo.IsAllowedToEdit(Mydvi);
}
} }
else else
btnStepPaste.Enabled = setting; btnStepPaste.Enabled = setting;