Added logic to remove Session records associated with previously closed processes.

This commit is contained in:
Rich 2015-09-14 13:29:19 +00:00
parent 97ae5f3f1c
commit 4540344b0b

View File

@ -1095,6 +1095,7 @@ namespace VEPROMS
tmrCloseTabItems.Interval = 100;
tmrCloseTabItems.Tick += new EventHandler(tmrCloseTabItems_Tick);
tmrCloseTabItems.Enabled = true;
CloseSessionsNoLongerActive();
MySessionInfo = SessionInfo.BeginSession(Environment.MachineName, System.Diagnostics.Process.GetCurrentProcess().Id);
this.LastContentChange = MySessionInfo.LastContentChange;
_MyLog.WarnFormat("Original last content change {0}", this.LastContentChange);
@ -1202,6 +1203,28 @@ namespace VEPROMS
// RHM20150506 Multiline ItemID TextBox
this.txtSearch.Text = Volian.Base.Library.VlnSettings.GetCommand("ItemIDs", "").Replace(",","\r\n");
}
/// <summary>
/// This looks for sessions associated with the current PC and user which are no longer active and removes them.
/// This will in-turn close any related procedure owner records and allow the user to re-open a previously open procedure.
/// </summary>
private void CloseSessionsNoLongerActive()
{
SessionInfoList sil = SessionInfoList.Get();
foreach(SessionInfo si in sil)
{
if (si.DTSEnd == null && si.MachineName == Environment.MachineName && si.UserID == Volian.Base.Library.VlnSettings.UserID)
{
try
{
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(si.ProcessID);
}
catch(Exception ex)// Process not found
{
Session.Delete(si.SessionID);// Remove Session record associated with a closed process
}
}
}
}
//public bool IsEnhancedDocumentOpen(ItemInfo ii)
//{
// if (tc.dicEnhancedDocuments.ContainsKey(ii.MyProcedure))