Пример #1
0
        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);
        }
Пример #2
0
        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
                    {
                    }
                }
            }
        }
Пример #3
0
        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);
            }
        }