Modified vesp_SessionBegin to delete inactive owner records and inactive session records for current user after 5 minutes of inactivity and for all other users after 15 minutes of inactivity during start of new session.

Added new stored procedure getOwnersByVersionID.
Added method to OwnerInfoList class named GetByVersionID
Utilized OwnerInfoList.GetByVersionID method
This commit is contained in:
Rich
2014-05-30 01:13:55 +00:00
parent 67638b51bd
commit 9e059a37f5
3 changed files with 108 additions and 5 deletions

View File

@@ -7676,9 +7676,11 @@ BEGIN TRY -- Try Block
--delete old closed sessions
DELETE FROM Sessions WHERE UserID = @UserID and DTSEnd is not null
--delete old owners from inactive sessions
DELETE FROM Owners WHERE SessionID in (SELECT SessionID FROM Sessions WHERE UserID = @UserID and DTSEnd is null and DTSActivity < DATEADD(minute, -15, getdate()))
DELETE FROM Owners WHERE SessionID in (SELECT SessionID FROM Sessions WHERE UserID = @UserID and DTSEnd is null and DTSActivity < DATEADD(minute, -5, getdate()))
DELETE FROM Owners WHERE SessionID in (SELECT SessionID FROM Sessions WHERE DTSEnd is null and DTSActivity < DATEADD(minute, -15, getdate()))
--delete inactive sessions where last activity is before 15 minutes ago
DELETE FROM Sessions WHERE UserID = @UserID and DTSEnd is null and DTSActivity < DATEADD(minute, -15, getdate())
DELETE FROM Sessions WHERE UserID = @UserID and DTSEnd is null and DTSActivity < DATEADD(minute, -5, getdate())
DELETE FROM Sessions WHERE DTSEnd is null and DTSActivity < DATEADD(minute, -15, getdate())
INSERT INTO [Sessions]([UserID],[MachineName],[ProcessID])
VALUES (@UserID, @MachineName, @ProcessID)
SELECT
@@ -8551,3 +8553,60 @@ GO
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListTables3 Succeeded'
ELSE PRINT 'Procedure Creation: vesp_ListTables3 Error on Creation'
GO
/****** Object: StoredProcedure [getOwnersByVersionID] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getOwnersByVersionID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getOwnersByVersionID];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getOwnersByVersionID]
(
@VersionID int
)
WITH EXECUTE AS OWNER
AS
SELECT
[OwnerID],
[SessionID],
[OwnerType],
[OwnerItemID],
[DTSStart],
oo.[LastChanged]
FROM [Owners] oo
JOIN vefn_GetVersionItems(@VersionID) vi ON oo.OwnerItemID = vi.ItemID
WHERE oo.OwnerType = 0
UNION
SELECT
[OwnerID],
[SessionID],
[OwnerType],
[OwnerItemID],
[DTSStart],
oo.[LastChanged]
FROM [Owners] oo
JOIN [Entries] ee on oo.OwnerItemID = ee.DocID
JOIN vefn_GetVersionItems(@VersionID) vi on ee.ContentID = vi.ContentID
WHERE oo.OwnerType = 1
UNION
SELECT
[OwnerID],
[SessionID],
[OwnerType],
[OwnerItemID],
[DTSStart],
oo.[LastChanged]
FROM [Owners] oo
WHERE oo.OwnerType = 2
AND oo.OwnerItemID = @VersionID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getOwnersByVersionID Succeeded'
ELSE PRINT 'Procedure Creation: getOwnersByVersionID Error on Creation'
GO