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

View File

@ -535,7 +535,51 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
}
public static OwnerInfoList GetByVersionID(int versionID)
{
OwnerInfoList tmp = DataPortal.Fetch<OwnerInfoList>(new GetByVersionIDCriteria(versionID));
return tmp;
}
[Serializable()]
protected class GetByVersionIDCriteria
{
private int _VersionID;
public int VersionID { get { return _VersionID; } }
public GetByVersionIDCriteria(int versionID)
{
_VersionID = versionID;
}
}
private void DataPortal_Fetch(GetByVersionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getOwnersByVersionID";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new OwnerInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("OwberInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
public partial class OwnerInfo
{
public static OwnerInfo GetBySessionIDandVersionID(int sessionID, int versionID)

View File

@ -532,7 +532,7 @@ namespace Volian.Controls.Library
if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi) || ui.IsWriter(dvi))
{
OwnerInfoList.Reset();
oil = OwnerInfoList.Get();
oil = OwnerInfoList.GetByVersionID(dvi.VersionID);
cm.MenuItems.Add("Refresh Checked Out Procedures", new EventHandler(mi_Click));
cm.MenuItems.Add("New Procedure", new EventHandler(mi_Click));
if (dvi.MultiUnitCount > 1)
@ -572,7 +572,7 @@ namespace Volian.Controls.Library
else
{
OwnerInfoList.Reset();
oil = OwnerInfoList.Get();
oil = OwnerInfoList.GetByVersionID(dvi.VersionID);
cm.MenuItems.Add("Refresh Checked Out Procedures", new EventHandler(mi_Click));
if (dvi.MultiUnitCount > 1)
{