public void GetFtpReleases()
        {
            //Konfig FTP Folder parsen
            //var ftpConfig = FtpConfiguration.Value;
            string[] sArray = FtpConfiguration.Value.Folders.Split(';');


            log.Info("Task: Lade FTP Konfig");
            Rebex.Licensing.Key = "==AOptXWwcjeC/mE+S0K60UcnUhOW7heBDBmgjFhBdpuvU==";
            try
            {
                using (var client = new Rebex.Net.Ftp())
                {
                    client.Settings.SslAcceptAllCertificates = true;
                    // connect and log in
                    client.Connect(FtpConfiguration.Value.Host, FtpConfiguration.Value.Port);
                    //if ssl true
                    if (FtpConfiguration.Value.Ssl == true)
                    {
                        client.Secure();
                    }
                    //FTP Login
                    log.Info("Task: FTP Login");
                    client.Login(FtpConfiguration.Value.Username, FtpConfiguration.Value.Passwort);
                    //FTP Root Login
                    client.ChangeDirectory("/");

                    //FTP Ordner durchsuchen
                    log.Info("Task: FTP Ordner durchsuchen");
                    foreach (string s in sArray)
                    {
                        string[] dataItems = client.GetNameList(s);

                        foreach (string a in dataItems)
                        {
                            string relname  = a.Substring(a.LastIndexOf("/") + 1);
                            string relgroup = a.Substring(a.LastIndexOf("-") + 1);

                            FtpRelease _ftpRelease = _db.FtpRelease.Where(r => r.FtpReleasename == relname).FirstOrDefault();

                            if (_ftpRelease == null)
                            {
                                _db.Add(new FtpRelease {
                                    FtpReleasename = relname, FtpReleaseGroup = relgroup, FtpFolder = a
                                });
                                _db.SaveChanges();
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                log.Info("Task: Fehler" + ex);
            }
        }
Esempio n. 2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------//

        public static void FTP_DeleteFiles()
        {
            // FTP
            Rebex.Net.Ftp ftp = alfaFtp.Get();

            // File Names
            string[] p_FileList = ftp.GetNameList();

            // Create List
            List <alfaItem> p_ItemList = new List <alfaItem>();

            foreach (string p_File in p_FileList)
            {
                // DeleteFile
                ftp.DeleteFile(p_File);
            }
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------//

        public static List <alfaItem> Step02_FTP_GetFileNames()
        {
            // Break
            if (!alfaSAM.IsRunning)
            {
                throw new Exception(alfaSAM.BreakMessage);
            }

            // Start
            DateTime p_Start = DateTime.Now;

            // Log
            alfaLog.Add("(FTP) Server = " + alfaSAM.m_FtpAdd1 + alfaSAM.m_FtpPath);
            alfaLog.Add("(FTP) Getting FileNames ... [ Start ]");

            // FTP
            Rebex.Net.Ftp ftp = alfaFtp.Get();

            // File Names
            string[] p_FileList = ftp.GetNameList();

            // Create List
            List <alfaItem> p_ItemList = new List <alfaItem>();

            // Index
            int p_Index = 0;

            foreach (string p_File in p_FileList)
            {
                // Inc Index
                p_Index = p_Index + 1;

                // FileName
                string p_FileName = string.Format("[{0:000}]  {1}  ( {2} Bytes )", p_Index, p_File, ftp.GetFileLength(p_File));

                // Add to List
                p_ItemList.Add(new alfaItem(p_FileName, p_File));
            }

            // Log
            alfaLog.Add("(FTP) Getting FileNames ...", alfaDate.GetSec(p_Start));

            // Return
            return(p_ItemList);
        }