Exemplo n.º 1
0
 public static void DownloadFtpFiles(CPRDirectExtractDataProvider prov)
 {
     if (prov.HasFtpSource)
     {
         Admin.LogFormattedSuccess("Listing FTP contents at <{0}> ", prov.FtpAddress);
         var ftpFiles = prov.ListFtpContents();
         Admin.LogFormattedSuccess("Found <{0}> files at FTP <{1}> ", ftpFiles.Count(), prov.FtpAddress);
         foreach (var ftpFile in ftpFiles)
         {
             try
             {
                 string name = ftpFile;
                 Admin.LogFormattedSuccess("Downloading FTP file <{0}>", name);
                 var len = prov.GetLength(name);
                 prov.DownloadFile(name, len);
                 Admin.LogFormattedSuccess("Deleting FTP file <{0}> ", ftpFile);
                 prov.DeleteFile(name);
             }
             catch (Exception ex)
             {
                 Admin.LogException(ex);
             }
         }
     }
 }
Exemplo n.º 2
0
        public static void ExtractLocalFiles(CPRDirectExtractDataProvider prov)
        {
            var files = Directory.GetFiles(prov.ExtractsFolder);

            Admin.LogFormattedSuccess("Found <{0}> files", files.Length);

            foreach (var file in files)
            {
                try
                {
                    Admin.LogFormattedSuccess("Reading file <{0}> ", file);
                    ExtractManager.ImportFileInSteps(file, CprBroker.Config.Properties.Settings.Default.CprDirectExtractImportBatchSize);
                    Admin.LogFormattedSuccess("Importing file <{0}> succeeded", file);

                    MoveToProcessed(prov.ExtractsFolder, file);
                    Admin.LogFormattedSuccess("File <{0}> moved to \\Processed folder", file);
                }
                catch (Exception ex)
                {
                    Admin.LogException(ex);
                }
            }
        }