Exemplo n.º 1
0
        public Boolean get_Orders_from_FTP()
        {
            XmlFunction xmlf = new XmlFunction(); // classe xml
            FTPClient   ftp  = new FTPClient();   // classe ftp

            try
            {
                List <String> ls_files = ftp.EnumerateFile_FTP(); // creo la lista dei file da scaricare
                foreach (String f in ls_files)                    // scarico i files xml trovati e inserisco gli ordini
                {
                    /*------------------------------------------------------*/

                    Boolean res = ftp.Download_FTP(f);                                     // download da FTP
                    if (res)                                                               // se scaricato correttamente inserisco nella tabella ordersp
                    {
                        Boolean isPutInTable = xmlf.Deserialize_ORDERS(ServicePathIn + f); // deserializzo e inserisco e ritorna true o false
                        if (isPutInTable)
                        {
                            ftp.Delete_FTP(f);              // se ho inserito l'ordine in DB2 allora cancello il file dall'ftp
                        }
                    }

                    /*-------------------------------------------------------*/
                }

                return(true);
            }
            catch (Exception ex)
            {
                sendAlert("get_Orders_from_FTP<br><hr><br>" + ex.ToString());
                ev.WriteEventToMyLog(Source + "get_Orders_from_FTP", "ERRORE\n" + ex.ToString(), EventLogEntryType.Error, 99);
                return(false);
            }
        }
Exemplo n.º 2
0
        public Boolean put_OutBound_File_to_FTP()
        {
            XmlFunction xmlf = new XmlFunction();
            FTPClient   ftp  = new FTPClient(); // classe ftp

            try
            {
                try
                {
                    xmlf.read_CONORD0F();// legge  converte in xml e salva in folder Outbond
                }
                catch (Exception ex)
                {
                    ev.WriteEventToMyLog(Source + " Put CONORD0F", "ERRORE\n" + ex.ToString(), EventLogEntryType.Error, 99);
                }
                try
                {
                    xmlf.read_BOLLE00F();// legge  converte in xml e salva in folder Outbond
                }
                catch (Exception ex)
                {
                    ev.WriteEventToMyLog(Source + " Put BOLLE00F", "ERRORE\n" + ex.ToString(), EventLogEntryType.Error, 99);
                }

                DirectoryInfo Outbound = new DirectoryInfo(ServicePathOut);

                foreach (FileInfo f in Outbound.GetFiles("*.xml"))
                {
                    Boolean isUpladed = ftp.Upload_FTP(f.FullName);

                    if (isUpladed)
                    {
                        File.Move(f.FullName, BackupFolder + f.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                sendAlert("put_OutBound_File_to_FTP<br><hr><br>" + ex.ToString());
                ev.WriteEventToMyLog(Source + "put_OutBound_File_to_FTP", "ERRORE\n" + ex.ToString(), EventLogEntryType.Error, 99);
                return(false);
            }


            return(true);
        }