Exemple #1
0
        private void m_lnkFermer_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CResultAErreur result = CResultAErreur.True;

            if (MessageBox.Show("Fermer toutes les sessions sélectionnées ?", "Confirmation",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            ArrayList lstThreads = new ArrayList();

            m_listeServicesToLaunch.Clear();
            m_listeThreadsEnAttente.Clear();
            ThreadStart funcStart = new ThreadStart(AskForClose);

            foreach (ListViewItem item in m_listView.CheckedItems)
            {
                int            nIdSession = (int)item.Tag;
                CSessionClient session    = CSessionClient.GetSessionForIdSession(nIdSession);
                try
                {
                    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();
                    }
                }
                catch (Exception ex1)
                {
                    result.EmpileErreur(ex1.Message);
                    try
                    {
                        if (session != null)
                        {
                            session.CloseSession();
                        }
                    }
                    catch (Exception ex2)
                    {
                        result.EmpileErreur(ex2.Message);
                    }
                }
            }
            if (!result)
            {
                MessageBox.Show(result.MessageErreur);
            }
        }
Exemple #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
                    {
                    }
                }
            }
        }