Fixed Stored Procedure getAnnotationAuditsChronologyByItemID
Fixed Approved Method to Update Content and Item at the same time Force History tab to be cleared when a procedure is deleted
This commit is contained in:
@@ -952,3 +952,99 @@ go
|
||||
IF (@@Error = 0) PRINT 'TableFunction [vefn_tblChildItems] Succeeded'
|
||||
ELSE PRINT 'TableFunction [vefn_tblChildItems] Error on Creation'
|
||||
go
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getAnnotationAuditsChronologyByItemID] Script Date: 04/02/2012 15:57:32 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getAnnotationAuditsChronologyByItemID] ******/
|
||||
/*
|
||||
getAnnotationAuditsChronologyByItemID 13,13
|
||||
getAnnotationAuditsChronologyByItemID 30,8570
|
||||
getAnnotationAuditsChronologyByItemID 30,8513
|
||||
getAnnotationAuditsChronologyByItemID 30,8505
|
||||
*/
|
||||
ALTER procedure [dbo].[getAnnotationAuditsChronologyByItemID]
|
||||
(
|
||||
@ProcItemID int,
|
||||
@ItemID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
declare @dts datetime
|
||||
set @dts = (select dts from items where itemid = @procitemid)
|
||||
select
|
||||
case
|
||||
when lastauditid is null and dts > itemdts then 'Added'
|
||||
when deletestatus > 0 then 'Deleted'
|
||||
when lastauditid = deletedauditid then 'Restored'
|
||||
else 'Changed'
|
||||
end ActionWhat
|
||||
,case
|
||||
when lastauditid is null and dts > itemdts then dts
|
||||
when deletestatus > 0 then ActionDTS
|
||||
when lastauditid = deletedauditid then ActionDTS
|
||||
else dts
|
||||
end ActionWhen
|
||||
,*
|
||||
from
|
||||
(
|
||||
select
|
||||
cast(ident_current('annotationaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from annotationaudits) auditid
|
||||
-- 0 auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,0 deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
,tci.ordinalpath
|
||||
from tblannotations aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
join vefn_tblchilditems(@procitemid,@itemid,0) tci on tci.itemid = ii.itemid
|
||||
where aa.deletestatus = 0
|
||||
union
|
||||
select
|
||||
aa.auditid
|
||||
,aa.annotationid
|
||||
,aa.itemid
|
||||
,aa.typeid
|
||||
,aa.rtftext
|
||||
,aa.searchtext
|
||||
,aa.config
|
||||
,aa.dts
|
||||
,aa.userid
|
||||
,aa.deletestatus
|
||||
,aa.ActionDTS
|
||||
,ii.contentid icontentid
|
||||
,(select min(dts) from tblitems where itemid = ii.itemid) ItemDTS
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid ) LastAuditID
|
||||
,(select max(auditid) from annotationaudits where annotationid = aa.annotationid and itemid = ii.itemid and aa.auditid > auditid and deletestatus > 0 and aa.dts = dts) DeletedAuditID
|
||||
,tci.ordinalpath
|
||||
from annotationaudits aa
|
||||
inner join items ii on aa.itemid = ii.itemid
|
||||
join vefn_tblchilditems(@procitemid,@itemid,0) tci on tci.itemid = ii.itemid
|
||||
) ah
|
||||
where itemid in (select itemid from vefn_tblchilditems (@procitemid,@itemid,0))
|
||||
and dts > @dts
|
||||
--(select dts from versions where versionid = (select max(versionid) from revisions rr inner join versions vv on rr.revisionid = vv.revisionid
|
||||
--inner join stages ss on vv.stageid = ss.stageid where itemid = @procitemid and ss.isapproved = 1))
|
||||
order by ordinalpath,annotationid,auditid--actionwhen
|
||||
end
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getAnnotationAuditsChronologyByItemID Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getAnnotationAuditsChronologyByItemID Error on Creation'
|
||||
GO
|
||||
|
Reference in New Issue
Block a user