/////////////////////////////////////////////// public void RemoveSousSession(ISessionClientSurServeur sousSession) { if (m_listeSousSessions.Contains(sousSession)) { m_listeSousSessions.Remove(sousSession); } }
/////////////////////////////////////////////// public void RegisterSousSession(ISessionClientSurServeur sousSession) { if (!m_listeSousSessions.Contains(sousSession)) { m_listeSousSessions.Add(sousSession); } }
public bool CloseSession() { CSessionClient session = CSessionClient.GetSessionForIdSession(IdSession); if (session != null) { try { session.CloseSession(); return(true); } catch { try { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); ISessionClientSurServeur sessionSurServeur = gestionnaire.GetSessionClientSurServeur(IdSession); sessionSurServeur.CloseSession(); return(true); } catch (Exception) { return(false); } } } return(false); }
/////////////////////////////////////////////// public virtual void CloseSession() { if (!m_bIsOpen) { return; } DateTime dt = DateTime.Now; if (BeforeClosingSession != null) { BeforeClosingSession(this); } TimeSpan sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 1-" + sp.TotalMilliseconds); CGestionnaireObjetsAttachesASession.OnCloseSession(IdSession); sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 2-" + sp.TotalMilliseconds); if (OnCloseSession != null) { OnCloseSession(this, new EventArgs()); } sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 3-" + sp.TotalMilliseconds); m_tableSessionParId.Remove(IdSession); sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 4-" + sp.TotalMilliseconds); m_tableSessionsLocales.Remove(IdSession); sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 5-" + sp.TotalMilliseconds); if (m_sessionSurServeur != null) { m_sessionSurServeur.CloseSession(); } sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 6-" + sp.TotalMilliseconds); m_sessionSurServeur = null; if (m_cacheInfosUtilisateur != null) { m_cacheInfosUtilisateur.Dispose(); } sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 7-" + sp.TotalMilliseconds); m_cacheInfosUtilisateur = null; //Nettoie les recepteurs de notification m_tableRecepteursParType.Clear(); GetDataThread(m_bUseSessionUtilisateurData).PopIdSession(); sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 8-" + sp.TotalMilliseconds); m_bIsOpen = false; m_sponsor.Unregister(m_sessionSurServeur); sp = DateTime.Now - dt; //Console.WriteLine("Closing " + m_nIdSession + " : 9-" + sp.TotalMilliseconds); m_sessionSurServeur = null; }
/////////////////////////////////////////////// public ISessionClientSurServeur GetSessionPrincipale() { CAuthentificationSessionSousSession auth = m_authentification as CAuthentificationSessionSousSession; if (auth != null) { ISessionClientSurServeur session = CGestionnaireSessions.GetSessionClientSurServeurStatic(auth.IdSessionPrincipale); if (session != null) { return(session.GetSessionPrincipale()); } } return(this); }
/////////////////////////////////////////////// public void CloseSession() { string strMessage = I.T("Closing session @1|110", IdSession.ToString()); try { strMessage += " " + GetInfoUtilisateur().NomUtilisateur; } catch { } CAuthentificationSessionSousSession authSousSession = m_authentification as CAuthentificationSessionSousSession; if (authSousSession != null) { ISessionClientSurServeur sessionPrinc = CGestionnaireSessions.GetSessionClientSurServeurStatic(authSousSession.IdSessionPrincipale); if (sessionPrinc != null) { sessionPrinc.RemoveSousSession(this); } } C2iEventLog.WriteInfo(strMessage, NiveauBavardage.VraiPiplette); int nIdSession = IdSession; DateTime dt = DateTime.Now; MyCloseSession(); TimeSpan sp = DateTime.Now - dt; Console.WriteLine("SessionServeur closing " + nIdSession + " / 1 : " + sp.TotalMilliseconds); CGestionnaireObjetsAttachesASession.OnCloseSession(IdSession); sp = DateTime.Now - dt; Console.WriteLine("SessionServeur closing " + nIdSession + " / 2 : " + sp.TotalMilliseconds); CGestionnaireSessions.CloseSession(this); sp = DateTime.Now - dt; Console.WriteLine("SessionServeur closing " + nIdSession + " / 3 : " + sp.TotalMilliseconds); CGestionnaireObjetsAttachesASession.OnCloseSession(IdSession); //Si jamais le close sessino a réaloué des éléments sp = DateTime.Now - dt; Console.WriteLine("SessionServeur closing " + nIdSession + " / 4 : " + sp.TotalMilliseconds); m_sponsor.Unregister(m_sessionSurClient); sp = DateTime.Now - dt; Console.WriteLine("SessionServeur closing " + nIdSession + " / 5 : " + sp.TotalMilliseconds); m_sessionSurClient = null; }
/// /////////////////////////////////////////////////// public CResultAErreur ReconnecteSession(CSessionClient sessionSurClient) { CResultAErreur result = CResultAErreur.True; ISessionClientSurServeur sessionSurServeur = GetSessionClientSurServeur(sessionSurClient.IdSession); if (sessionSurServeur != null) { sessionSurClient.SessionSurServeur = sessionSurServeur; return(result); } result = CanOpenSession(sessionSurClient); if (result) { sessionSurServeur = GetNewSessionSurServeur(sessionSurClient, result.Data); result.Data = null; if (sessionSurServeur == null) { result.EmpileErreur(I.T("Server session allocation impossible|105")); } else { sessionSurClient.SessionSurServeur = sessionSurServeur; lock (typeof(CLockerListeSessions)) { m_listeSessions[sessionSurClient.IdSession] = sessionSurServeur; } string strMessage = I.T("Session Reconnection n°|111") + sessionSurClient.IdSession + "\r\n" + I.T("Type|107") + sessionSurClient.TypeApplicationCliente.ToString(); strMessage += I.T("\r\n|108") + sessionSurServeur.DescriptionApplicationCliente; try { strMessage += I.T("\r\n|108") + sessionSurClient.GetInfoUtilisateur().NomUtilisateur; } catch { } C2iEventLog.WriteInfo(strMessage, NiveauBavardage.VraiPiplette); CDonneeNotificationConnection donnee = new CDonneeNotificationConnection(sessionSurClient.IdSession, true); CEnvoyeurNotification.EnvoieNotifications(new IDonneeNotification[] { donnee }); } } return(result); }
/////////////////////////////////////////////// public CSessionClientSurServeur(CSessionClient sessionSurClient) { m_sessionSurClient = sessionSurClient; IdSession = sessionSurClient.IdSession; m_dateHeureConnexion = sessionSurClient.DateHeureConnexion; m_dateHeureDerniereActivite = DateTime.Now; m_sponsor.Register(m_sessionSurClient); m_strDescription = sessionSurClient.DescriptionApplicationCliente; m_typeApplication = sessionSurClient.TypeApplicationCliente; m_authentification = sessionSurClient.Authentification; CAuthentificationSessionSousSession autSousSession = m_authentification as CAuthentificationSessionSousSession; if (autSousSession != null) { ISessionClientSurServeur sessionPrincipale = CGestionnaireSessions.GetSessionClientSurServeurStatic(autSousSession.IdSessionPrincipale); if (sessionPrincipale != null) { sessionPrincipale.RegisterSousSession(this); } } }
private void m_lnkFermer_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (m_wndListeSession.CheckedItems.Count == 0) { MessageBox.Show(I.T("Check sessions to close first !|20519")); return; } if (MessageBox.Show( I.T("You will send a stop message to @1 sessions. Please confirm this action|20515", m_wndListeSession.CheckedItems.Count.ToString()), I.T("Confirmation|20516"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } ArrayList lstThreads = new ArrayList(); m_listeServicesToLaunch.Clear(); m_listeThreadsEnAttente.Clear(); ThreadStart funcStart = new ThreadStart(AskForClose); StringBuilder bl = new StringBuilder(); int nNbSessionsSysteme = 0; foreach (ListViewItem item in m_wndListeSession.CheckedItems) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && info.IsSystem) { nNbSessionsSysteme++; bl.Append(info.IdSession); bl.Append(','); } } string strMessage = ""; if (nNbSessionsSysteme > 0) { bl.Remove(bl.Length - 1, 1); if (nNbSessionsSysteme > 1) { strMessage = I.T("Sessions @1 are system sessions and will not be close|20517", bl.ToString()); } else { strMessage = I.T("@1 session is a system session and will not be closed|20518", bl.ToString()); } MessageBox.Show(strMessage); } IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); foreach (ListViewItem item in m_wndListeSession.CheckedItems) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && !info.IsSystem) { int nIdSession = info.IdSession; CSessionClient session = CSessionClient.GetSessionForIdSession(nIdSession); try { if (!info.Invalide) { CServiceSurClientFermerApplication service = (CServiceSurClientFermerApplication)session.GetServiceSurClient(CServiceSurClientFermerApplication.c_idService); if (service != null) { lock (m_listeServicesToLaunch) { m_listeServicesToLaunch.Add(service); } Thread th = new Thread(funcStart); th.Start(); } } else { ISessionClientSurServeur sessionSurServeur = gestionnaire.GetSessionClientSurServeur(info.IdSession); sessionSurServeur.CloseSession(); } } catch { } } } }