コード例 #1
0
ファイル: Program.cs プロジェクト: hgirish/ftpdownload
        static void Main(string[] args)
        {
            var log = new LoggerConfiguration()
                .WriteTo.RollingFile("AppLog.txt")
                .WriteTo.ColoredConsole()
                .CreateLogger();
            Log.Logger = log;
           //ReadFoxproTable();
            //return;
             _dbHelper = new FoxproHelper();
            _list = new List<FileDetail>();
            //_list.Add(new FileDetail
            //{
            //    FileName = "Test.rtf",
            //    Records = 100,
            //    DownloadTime = DateTime.Now,
            //    FileDate = DateTime.Now,
            //    Folder = "Hands"
            //});
            //InsertRecord();
            //return;
            var siteurl = ConfigurationManager.AppSettings["ftpUrl"];
            var ftpUserName = ConfigurationManager.AppSettings["ftpUserName"];
            var ftpPassword = ConfigurationManager.AppSettings["ftpPassword"];
              Ftp ftp = new Ftp();
            //  Ftper ftper = new Ftper();
            // var files = ftper.Connect(siteurl, ftpUserName, ftpPassword);
            var files = ftp.Connect(siteurl, ftpUserName, ftpPassword);
            foreach (var ftpinfo in files)
            {
               // Console.WriteLine($"File Name: {ftpinfo.Filename}, File Type: {ftpinfo.FileType}");
                GetFtpFiles(ftpinfo, ftp, siteurl);
            }
            if (!_list.Any())
            {
                Console.WriteLine("No new files found!");
                return;
            }
            foreach (var detail in _list)
            {
                var fileName = detail.FileName;
                Console.WriteLine($"Inserting {fileName} into master ftp dbf");
                try
                {
                    if (_dbHelper.InsertFtpRecord(detail))
                    {
                        Console.WriteLine($"Inserted {fileName} into master ftp dbf successfully");
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
                Console.WriteLine($"Inserting {fileName} into master ftp sql");
                try
                {
                    if (_dbHelper.InsertSqlFtpRecord(detail))
                    {
                        Console.WriteLine($"Inserted {fileName} into master ftp sql successfully");
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
            }
            try
            {
                SendEmail();
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }

        }
コード例 #2
0
ファイル: Program.cs プロジェクト: hgirish/ftpdownload
        private static void ReadFoxproTable()
        {
            FoxproHelper dbHelper = new FoxproHelper();
            var table = dbHelper.GetYourData();
            foreach (DataColumn column in table.Columns)
            {
                Console.WriteLine(column.ColumnName);
            }
            foreach (DataRow r in table.Rows)
            {
                Console.WriteLine($"{r[0]}\t{r[1]}\t{r[2]}");
            }
            foreach (DataRow row in table.Rows)
            {
                foreach (var item in row.ItemArray)
                {
                    Console.Write("Value:" + item + "\t");
                }
            }

            return;
        }