Exemplo n.º 1
0
        private void Button_connexion_Click(object sender, RoutedEventArgs e)
        {
            bool   test     = false;
            string ip_ftp   = ServeurFTP.Get_IP_ftp();
            string user     = ServeurFTP.Get_user_ftp();
            string password = ServeurFTP.Get_password_ftp();

            if (ip_ftp == null)
            {
                label_etat.Foreground = Brushes.Red;
                label_etat.Content    = "Il est nécessaire d'appliquer les changements avant";
            }
            else
            {
                test = ServeurFTP.TestFTP(ip_ftp, user, password);

                if (test == true)
                {
                    label_etat.Foreground = Brushes.Green;
                    label_etat.Content    = "Connexion fonctionnelle";

                    this.mainWindow.label_etat_ftp.Content    = "Connecté au FTP sur :";
                    this.mainWindow.label_etat_ftp.Foreground = Brushes.Green;
                    this.mainWindow.label_ftp_infos.Content   = ServeurFTP.Get_IP_ftp() + ":" + ServeurFTP.Get_user_ftp();
                }
                else
                {
                    label_etat.Foreground = Brushes.Red;
                    label_etat.Content    = "La connexion a échoué";
                }
            }
        }
        public Signaler_anomalie()
        {
            InitializeComponent();

            /*  DirectoryInfo dir = new DirectoryInfo(@"../captures");
             * FileInfo[] fichiers = dir.GetFiles();
             * string[] fichiers_string = Directory.GetFiles(@"../captures", "*.jpg", SearchOption.AllDirectories);
             *
             * foreach (FileInfo fichier in fichiers)
             * {
             *    listBox_img_robot.Items.Add("Image: " + fichier.Name + "/ Date: " + fichier.CreationTime);
             *
             * }*/


            FtpClient client = new FtpClient(ServeurFTP.Get_IP_ftp());

            client.Credentials = new NetworkCredential(ServeurFTP.Get_user_ftp(), ServeurFTP.Get_password_ftp());
            client.Connect();

            foreach (FtpListItem item_capture_robot in client.GetListing("/capture_robot"))
            {
                // if this is a file
                if (item_capture_robot.Type == FtpFileSystemObjectType.File)
                {
                    listBox_img_robot.Items.Add("Image: " + item_capture_robot.Name + "/ Date: " + item_capture_robot.Modified);
                }
            }

            foreach (FtpListItem item_capture_thermique in client.GetListing("/capture_thermique"))
            {
                // if this is a file
                if (item_capture_thermique.Type == FtpFileSystemObjectType.File)
                {
                    listBox_img_thermique.Items.Add("Image: " + item_capture_thermique.Name + "/ Date: " + item_capture_thermique.Modified);
                }


                client.Disconnect();
            }
        }