private void FillListeConnectes() { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); CInfoSessionAsDynamicClass[] sessions = gestionnaire.GetInfosSessionsActives(); m_listeSessions = new List <CInfoSessionAsDynamicClass>(); foreach (CInfoSessionAsDynamicClass session in sessions) { if (!session.IsSystem || !m_chkHideSystem.Checked) { m_listeSessions.Add(session); } } m_wndListeSession.Remplir(m_listeSessions, false); foreach (ListViewItem item in m_wndListeSession.Items) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && info.Invalide) { item.BackColor = m_pictInvalide.BackColor; } if (info != null && info.IdSession == CTimosApp.SessionClient.IdSession) { item.BackColor = m_pictCurrent.BackColor; } if (info != null && info.DureeInactivité.Duree.Hours >= 4) { item.BackColor = m_pictInactif.BackColor; } } }
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 static IInfoUtilisateur[] GetUtilisateursConnecte() { IGestionnaireSessions gestionnaire = GestionnaireSessions; try { return(gestionnaire.GetUtilisateursConnectes()); } catch { } return(new IInfoUtilisateur[0]); }
/////////////////////////////////////////////// public static CSessionClient GetSessionForIdSession(int nIdSession) { CSessionClient session = (CSessionClient)m_tableSessionParId[nIdSession]; if (session != null) { return(session); } IGestionnaireSessions gestionnaire = GestionnaireSessions; session = gestionnaire.GetSessionClient(nIdSession); m_tableSessionParId[nIdSession] = session; return(session); }
/////////////////////////////////////////////// public static bool IsUserConnected(CDbKey keyUtilisateur) { IGestionnaireSessions gestionnaire = GestionnaireSessions; try { //TESTDBKEYOK return(gestionnaire.IsConnected(keyUtilisateur)); } catch { } return(false); }
/////////////////////////////////////////////// public CResultAErreur OpenSession(IAuthentificationSession authentification, string strDescriptionApplication, ETypeApplicationCliente typeApplication) { CResultAErreur result = CResultAErreur.True; IGestionnaireSessions gestionnaire = null; try { //Ne pas utiliser GestionnaireSessions car on a besoin du type de gestionnaire //Si l'appli utilise plusieurs gestionnaires de sessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(m_typeGestionnaireSessions); } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Error during the allowance of sessions manager|107")); return(result); } m_authentification = authentification; m_strDescription = strDescriptionApplication; m_typeApplication = typeApplication; try { result = gestionnaire.OpenSession(this); if (result) { m_tableSessionParId[IdSession] = this; m_tableSessionsLocales[IdSession] = true; if (AfterOpenSession != null) { AfterOpenSession(this); } if (m_nFirstSessionOuverte == -1) { m_nFirstSessionOuverte = IdSession; } GetDataThread(m_bUseSessionUtilisateurData).PushIdSession(IdSession); m_bIsOpen = true; } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Error while opening session|108")); return(result); } return(result); }
/// ////////////////////////////////////////// public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] valeursParametres) { CResultAErreur result = CResultAErreur.True; try { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); CInfoSessionAsDynamicClass[] infos = gestionnaire.GetInfosSessionsActives(); result.Data = infos; return(result); } catch { result.EmpileErreur(I.T("Error while retrieving active sessions|20056")); } return(result); }
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 { } } } }
private void FillListeConnectes() { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); int[] listeIdSessions = gestionnaire.GetListeIdSessionsConnectees(); string strNomGestionnaire = gestionnaire.GetType().ToString(); m_listView.Items.Clear(); foreach (int nId in listeIdSessions) { ListViewItem item = new ListViewItem(); item.Tag = nId; while (item.SubItems.Count < m_listView.Columns.Count) { item.SubItems.Add(""); } item.SubItems[colIdSession.Index].Text = nId.ToString(); IInfoSession session = gestionnaire.GetSessionClient(nId); try { session.GetInfoUtilisateur(); } catch { session = gestionnaire.GetSessionClientSurServeur(nId); item.BackColor = Color.Red; session = gestionnaire.GetSessionClientSurServeur(nId); } if (session == null) { item.BackColor = Color.Red; session = gestionnaire.GetSessionClientSurServeur(nId); item.SubItems[colNom.Index].Text = "#ERREUR ACCES"; } try { item.SubItems[colNom.Index].Text = session.GetInfoUtilisateur().NomUtilisateur; item.SubItems[colAppli.Index].Text = session.DescriptionApplicationCliente; item.SubItems[colType.Index].Text = session.TypeApplicationCliente.ToString(); DateTime dt = session.DateHeureConnexion; TimeSpan span = DateTime.Now - dt; string strChaine = ""; if (span.TotalDays > 1) { strChaine = ((int)span.TotalDays).ToString() + "j"; } if (span.TotalHours > 0) { strChaine += ((int)(span.TotalHours % 24)).ToString() + "h"; } strChaine += ((int)(span.TotalMinutes % 60)).ToString() + "m"; item.SubItems[colHeure.Index].Text = strChaine; string strKeyUtilisateur = ""; if (session.GetInfoUtilisateur().KeyUtilisateur != null) { strKeyUtilisateur = session.GetInfoUtilisateur().KeyUtilisateur.StringValue; item.SubItems[colIdUser.Index].Text = strKeyUtilisateur; CContexteDonnee ctx = new CContexteDonnee(session.IdSession, true, false); CDonneesActeurUtilisateur user = CUtilSession.GetUserForSession(ctx); if (user != null) { CListeObjetsDonnees lstEtapesPourActeur = user.Acteur.GetEtapeWorkflowsEnCours(); int nbTodo = lstEtapesPourActeur.Count; item.SubItems[colNbToDo.Index].Text = nbTodo.ToString(); } } } catch { if (nId == 0) { item.SubItems[colNom.Index].Text = "SERVEUR"; } else { item.BackColor = Color.Red; item.SubItems[colNom.Index].Text = "#ERREUR ACCES#"; } } if (nId == CSessionClient.GetSessionUnique().IdSession) { item.BackColor = Color.LightGreen; } m_listView.Items.Add(item); } }