From 74097dc316eed8994b73a721a1ff5844ae7ee0d7 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 4 Apr 2012 19:06:06 +0000 Subject: [PATCH] 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 --- PROMS/DataLoader/PROMSFixes.Sql | 96 +++++++++++++++++++ .../dlgApproveProcedure.cs | 8 +- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 2 +- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 5eedf0d9..72a360b7 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -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 diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index 75e7430b..388d01c3 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -960,7 +960,8 @@ namespace VEPROMS //make pdf with promsprinter and get byte stream string pdfTmp = string.Format(@"{0}.pdf", pi.DisplayNumber); string pdfPath = string.Format(@"{0}\{1}", VlnSettings.TemporaryFolder, pdfTmp); - UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS); + // Moved to end so that Item and Content are saved at the same time + //UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS); string waterMark = Stage.Get(RevStage).IsApproved > 0 ? null : Stage.Get(RevStage).Name; frmPDFStatusForm frm = new frmPDFStatusForm(pi, ap.RevNumber, ap.RevDate.ToString("MM/dd/yyyy"), waterMark, false, ViewPDF, true, VlnSettings.TemporaryFolder, new ChangeBarDefinition(), pdfTmp, location); frm.AllowAllWatermarks = true; @@ -974,7 +975,10 @@ namespace VEPROMS VEPROMS.CSLA.Library.Version version = VEPROMS.CSLA.Library.Version.MakeVersion(revision, Stage.Get(RevStage), buf, summaryBuf, DateTime.Now, VlnSettings.UserID); StageInfo si = StageInfo.Get(RevStage); if (si.IsApproved == 1) - UpdateProcedureDTS(pi, DateTime.Now); + UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, DateTime.Now); + else + UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS); + //UpdateProcedureDTS(pi, DateTime.Now); } return true; #region old code diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 2f5d79cf..04b2fafa 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -368,7 +368,7 @@ namespace VEPROMS } private bool tv_DeleteItemInfo(object sender, vlnTreeItemInfoEventArgs args) { - if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.ItemID == args.MyItemInfo.ItemID) + if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.MyProcedure.ItemID == args.MyItemInfo.ItemID) displayHistory.MyEditItem = null; return tc.DeleteRTBItem(args.MyItemInfo); //if (si == null) return false;