From 268df16b6e10999967d6179358c6418fc114dd0d Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 8 Apr 2013 14:37:56 +0000 Subject: [PATCH] Modified vefn_GetMyChronology to include datetime parameter Modified getContentAuditsChronologyByItemID to include datetime parameter Modified vefn_ChronologyReport to include datetime parameter Modified getAnnotationAuditsChronologyByItemID to include datetime parameter Modified getContentAuditsSummaryByItemID to include datetime parameter --- PROMS/DataLoader/PROMStoCM.sql | 61 +++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/PROMS/DataLoader/PROMStoCM.sql b/PROMS/DataLoader/PROMStoCM.sql index 18dfe4a7..b0713187 100644 --- a/PROMS/DataLoader/PROMStoCM.sql +++ b/PROMS/DataLoader/PROMStoCM.sql @@ -2355,7 +2355,7 @@ GO Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE Copyright 2012 - Volian Enterprises, Inc. All rights reserved. *****************************************************************************/ -CREATE FUNCTION [dbo].[vefn_GetMyChronology](@ProcItemID int, @ItemID int, @IncludeDeletedChildren int) +CREATE FUNCTION [dbo].[vefn_GetMyChronology](@ProcItemID int, @ItemID int, @IncludeDeletedChildren int, @DTS datetime) RETURNS @Chrono TABLE ( [AuditID] bigint, @@ -2403,7 +2403,7 @@ select distinct [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config] ,(select dbo.vefn_GetStepTypeNameByItemIDandTypeID(t.itemid,r.type)) TypeName ,* from vefn_tblchilditems (@ProcItemID,@ItemID,@IncludeDeletedChildren) t - inner join vefn_chronologyreport(@ProcItemID) r + inner join vefn_chronologyreport(@ProcItemID,@DTS) r on t.icontentid = r.contentid -- where ActionDTS > procdts or dts > procdts ) ah @@ -2439,13 +2439,14 @@ CREATE PROCEDURE [dbo].[getContentAuditsChronologyByItemID] ( @ProcedureItemID int, @SelectedItemID int, - @IncludeDeletedChildren int + @IncludeDeletedChildren int, + @DTS datetime ) WITH EXECUTE AS OWNER AS begin - select * from vefn_GetMyChronology(@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) + select * from vefn_GetMyChronology(@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren,@DTS) -- select distinct [AuditID],[ContentID],[Number],[Text],[Type],[FormatID],[Config],[DTS],[UserID],[DeleteStatus],[ActionDTS],[ActionWhat],[ActionWhen],[Path],ItemID,TypeName,ordinalpath -- from -- ( @@ -2498,7 +2499,7 @@ select * from vefn_chronologyreport(2) where type > 0 order by contentid,auditid Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE Copyright 2012 - Volian Enterprises, Inc. All rights reserved. *****************************************************************************/ -CREATE function [dbo].[vefn_ChronologyReport](@ProcItemID int) +CREATE function [dbo].[vefn_ChronologyReport](@ProcItemID int, @DTS datetime) returns @Report table ( src int, @@ -2527,8 +2528,8 @@ declare @tmpTable table ) insert into @tmpTable select icontentid from vefn_tblchilditems(@ProcItemID,@ProcItemID,1) --added jcb 20111122 -declare @dts datetime -set @dts = (select dts from items where itemid = @ProcItemID ) +--declare @dts datetime +--set @dts = (select dts from items where itemid = @ProcItemID ) --set @dts = (SELECT .[dbo].[vefn_GetPreviousRevisionDTSByItemID] (@ProcItemID)) --end added jcb 20111122 insert into @Report @@ -2696,15 +2697,29 @@ getAnnotationAuditsChronologyByItemID 30,8505 Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE Copyright 2012 - Volian Enterprises, Inc. All rights reserved. *****************************************************************************/ -create procedure getAnnotationAuditsChronologyByItemID +create procedure [dbo].[getAnnotationAuditsChronologyByItemID] ( @ProcItemID int, - @ItemID int + @ItemID int, + @DTS datetime ) WITH EXECUTE AS OWNER AS begin - select +-- declare @dts datetime +-- set @dts = (select dts from items where itemid = @procitemid) + declare @tci table + ( + ItemID int, + IContentID int, + IDeleteStatus int, + ProcDTS datetime, + Path nvarchar(max), + OrdinalPath nvarchar(max) + ) + insert into @tci + select * from vefn_tblchilditems(@ProcItemID,@ItemID,0) + select case when lastauditid is null and dts > itemdts then 'Added' when deletestatus > 0 then 'Deleted' @@ -2717,13 +2732,13 @@ begin when lastauditid = deletedauditid then ActionDTS else dts end ActionWhen - ,* + ,* from ( - select + select cast(ident_current('annotationaudits') + 1 as bigint) auditid --- (select max(auditid) + 1 from annotationaudits) auditid --- 0 auditid + -- (select max(auditid) + 1 from annotationaudits) auditid + -- 0 auditid ,aa.annotationid ,aa.itemid ,aa.typeid @@ -2738,11 +2753,13 @@ begin ,(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 @tci tci on tci.itemid = ii.itemid where aa.deletestatus = 0 union - select + select aa.auditid ,aa.annotationid ,aa.itemid @@ -2758,11 +2775,16 @@ begin ,(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 @tci tci on tci.itemid = ii.itemid ) ah - where itemid in (select itemid from vefn_tblchilditems (@procitemid,@itemid,0)) - order by annotationid,auditid--actionwhen + where itemid in (select itemid from @tci) + 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 Trigger alter @@ -2826,7 +2848,8 @@ create PROCEDURE [dbo].[getContentAuditsSummaryByItemID] ( @ProcedureItemID int, @SelectedItemID int, - @IncludeDeletedChildren int + @IncludeDeletedChildren int, + @DTS datetime ) WITH EXECUTE AS OWNER @@ -2853,7 +2876,7 @@ TypeName nvarchar(max), ordinalpath nvarchar(max) ) insert into @Chrono -select * from vefn_GetMyChronology(@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren) +select * from vefn_GetMyChronology(@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren,@DTS) select * from @Chrono where AuditID is null OR AuditID in (select min(auditID) from @Chrono group by contentid UNION select max(auditID) from @Chrono group by contentid) order by OrdinalPath, contentid,auditid