From 4540344b0b0396d095c2930c165915e515e78755 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 14 Sep 2015 13:29:19 +0000 Subject: [PATCH] Added logic to remove Session records associated with previously closed processes. --- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index d2c7fb7a..8f2b251f 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -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"); } + /// + /// 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. + /// + 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))