示例#1
0
 private void verificationStatutResa()
 {
     if (Parametres.debug == "all")
     {
         MainForm.writeLog("frm_Temps.cs->verificationStatutResa");
     }
     /// vérification du statut. Si le poste a été libéré depuis la console, status_resa est différent de zéro
     if (resa.statut != 0)
     {
         if (Parametres.debug == "all")
         {
             MainForm.writeLog("frm_Temps.cs->timer_Tick : déconnexion forcée depuis la console");
         }
         msgBox_deconnexion = new frm_MsgBox();
         msgBox_deconnexion.Show("Déconnexion forcée depuis la console !", "Avertissement", 10000);
         // deconnexion forcée
         this.Close();
     }
 }
示例#2
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (Parametres.debug == "all")
            {
                MainForm.writeLog("frm_Temps.cs->timer_Tick : 1s");
            }

            String affichage_restant, affichage_utilise;
            System.TimeSpan diffRestant, diffUtilise;

            DateTime heureDeconnexion = heureConnexion.AddMinutes(resa.duree);

            diffRestant = heureDeconnexion - DateTime.Now;
            diffUtilise = DateTime.Now - heureConnexion;


            if (utilisateur.tempsRestant() == 1440)  // le temps affecté est de 24h00, donc infini dans la pratique
            {
                affichage_restant = "";
                lbl_text_restant.Text = "";
            }
            else
            {
                if (diffRestant.Ticks >= DateTime.MinValue.Ticks)
                {
                    affichage_restant = new DateTime(diffRestant.Ticks).ToString("HH:mm:ss");
                }
                else
                {
                    affichage_restant = "00:00:00";
                }
            }

            affichage_utilise = new DateTime(diffUtilise.Ticks).ToString("HH:mm:ss");

            affichageChronos(affichage_restant, affichage_utilise);

            /*if (Parametres.debug == "all")
            {
                MainForm.writeLog("frm_Temps.cs->timer_Tick : " + lbl_temps_restant.Text);
            }*/

            // si la déconnexion automatique est activée
            if (configLogiciel.deconnexionAuto)
            {
                if ((Math.Floor(diffRestant.TotalMinutes)) == 2 && diffRestant.Seconds == 0)
                {
                    if (Parametres.debug == "all")
                    {
                        MainForm.writeLog("frm_Temps.cs->timer_Tick : déconnexion programmée dans 2 minutes.");
                    }

                    msgBox_deconnexion = new frm_MsgBox();
                    msgBox_deconnexion.Show("Déconnexion automatique dans 2 minutes ! Pensez à sauvegarder vos documents !", "Avertissement", 119000);
                    msgBox_deconnexion.TopMost = true;
                    lbl_temps_restant.ForeColor = System.Drawing.Color.Red;
                }
                if ((Math.Floor(diffRestant.TotalMinutes)) < 0)
                {

                    if (Parametres.debug == "all")
                    {
                        MainForm.writeLog("frm_Temps.cs->timer_Tick : message de déconnexion");
                    }

                    if (msgBox_deconnexion != null) { 
                        if (msgBox_deconnexion.IsDisposed)
                        {
                            msgBox_deconnexion = new frm_MsgBox();
                        }
                    }
                    msgBox_deconnexion.Show("Déconnexion automatique !! Au revoir !", "Avertissement", 10000);

                }
                if (diffRestant.TotalMinutes < -0.16) // environ 10 secondes
                {
                    if (!msgBox_deconnexion.IsDisposed)
                        msgBox_deconnexion.Close();
                    if (Parametres.debug == "all")
                    {
                        MainForm.writeLog("frm_Temps.cs->timer_Tick : déconnexion réelle");
                    }
                    this.Close();
                }
            }

            verificationStatutResa();
        }