Support for Change Manager

This commit is contained in:
Rich 2011-03-18 14:17:02 +00:00
parent 3bb7779e63
commit bf0bae229e

View File

@ -1018,15 +1018,31 @@ AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @ChildID int, @ContentID int, @ParentContentID int, @LastChanged timestamp
, @newLastChanged timestamp, @Error int, @Rowcount int
, @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.DateEnd is not null
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 [tblParts_shadow] ([ContentID],[FromType],[ItemID],[DTS],[UserID],[DateEnd])
SELECT [ContentID],[FromType],[ItemID],[DTS],[UserID],[DateEnd] 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