//Collect Daily Files from different SFTP sources and Copy to centralized location in PCI static void CollectSFTPFiles(LogHelper log) { AppDAL appDAL = new AppDAL(); WinSCPHelper scp = new WinSCPHelper(); // Get the list of items to process List <SFTPFileCollection> fileCollection = appDAL.GetSFTPAppSettings(); //Get SFTP Credentials from DB // Set up session options scp.WinSCPSession(fileCollection, log, toProcessFile); }
static void ProcessProduct(string cmeLink, int totalPages, int pageSize) { AppDAL appDal = new AppDAL(); Console.WriteLine("Processing Data..."); for (int i = 0; i < totalPages; i++) { string linkParam = "?page=" + i.ToString() + "&size=" + pageSize.ToString(); Console.WriteLine("Collecting Product information from source." + i.ToString() + " of " + totalPages.ToString()); var jsonProdTmp = new WebClient().DownloadString(cmeLink + linkParam); Console.WriteLine("Processing collected data to temp table..."); CMEProduct.ProductsMain prodobjTmp = JsonConvert.DeserializeObject <CMEProduct.ProductsMain>(jsonProdTmp); appDal.SetProductDataToSave(prodobjTmp); } }
static void DownloadCME_EODTrades(LogHelper log) { AppDAL appDAL = new AppDAL(); CME_EODTrades eodTrades = new CME_EODTrades(); log.Log("Downloading CME EOD Trade file.."); int downloaded = 0; WinSCPHelper scp = new WinSCPHelper(); // Get the list of items to process List <SFTPFileCollection> fileCollection = appDAL.GetSFTPAppSettingsByCode(sftpFileCode); //Get SFTP Credentials from DB //checked if file is already available in local folder - means already downloaded List <SFTPFileCollection> fileCollectionLeft = checkLocalFile(fileCollection, dateFilesToGet, log); if (fileCollectionLeft.Count <= 0) { log.Log("No files to be downloaded. Files might be already existing in local folder."); return; } string processTime = DateTime.Now.ToString(); Console.WriteLine("Start processing at {0}", processTime); log.Log("Starts - " + processTime); while (fileCollectionLeft.Count > 0) { // Set up session options fileCollectionLeft = scp.InitWinSCPSession(fileCollectionLeft, log, dateFilesToGet); if (fileCollectionLeft.Count > 0) { string mesg = "Still waiting for " + fileCollectionLeft.Count.ToString() + " file(s) from CME. Next file check will be at " + DateTime.Now.AddMilliseconds(300000) + " for the remaining files"; eodTrades.ExtractCME_Heartbit_Email(log, mesg); Console.WriteLine(mesg); Thread.Sleep(60000); //60 seconds Console.Clear(); } } }
public AppBL() { dal = new AppDAL(); }