public void TestSaveTickers() { TickerBLL bll = new TickerBLL(this.s3_bucket_name, this.tempTickerFolder); List <TickerEntity> tickerList = new List <TickerEntity>(); tickerList.Add(new TickerEntity { T = "CLL", P = 20081201, O = (float)66.01, H = (float)77.01, L = (float)999.0, C = (float)12.1, V = 123124 }); tickerList.Add(new TickerEntity { T = "CLL", P = 20071201, O = (float)111111.01, H = (float)11111.01, L = (float)111.0, C = (float)111.1, V = 123124 }); tickerList.Add(new TickerEntity { T = "CLL", P = 20091212, O = (float)33.01, H = (float)199.01, L = (float)13.0, C = (float)13.1, V = 2346 }); tickerList.Add(new TickerEntity { T = "CLL", P = 20081202, O = (float)33.01, H = (float)99.01, L = (float)13.0, C = (float)13.1, V = 2346 }); bll.SaveTickersToS3("CLL", tickerList, true).Wait(); }
public async Task ProcessSourceFile(S3Object fileInfo) { LambdaLogger.Log($"About to download file, {fileInfo.Key}\n"); String resultFileName = await this.DownloadFileAsync(fileInfo.BucketName, fileInfo.Key, this.Temp_Folder + "originSourceFiles/"); string dailyTargetFolder = this.Temp_Folder + $"originExtractedFiles/{fileInfo.Key}/"; LambdaLogger.Log($"Download file, {fileInfo.Key}, about to extract to {dailyTargetFolder}.\n"); List <String> dailyFileList = this.ExtractIntoDayData(resultFileName, dailyTargetFolder); LambdaLogger.Log($"Extracted files done. items {dailyFileList.Count} \n"); foreach (string path in dailyFileList) { this.AddDailyFileIntoStockDict(path); } TickerBLL bll = new TickerBLL(this.S3_Bucket_Name, this.Temp_Folder); // save tickers into S3 foreach (KeyValuePair <string, List <TickerEntity> > tickerGroup in this.stockDict) { await bll.SaveTickersToS3(tickerGroup.Key, tickerGroup.Value, true); LambdaLogger.Log($"Save to S3 for {tickerGroup.Key} with items {tickerGroup.Value.Count} \n"); } // move file to archive S3Service service = new S3Service(); string archiveKey = fileInfo.Key.Replace("source", "archive"); await service.CopyObject(this.S3_Bucket_Name, fileInfo.Key, this.S3_Bucket_Name, archiveKey); await service.DeleteObject(this.S3_Bucket_Name, fileInfo.Key); // about to clean things File.Delete(resultFileName); FileHelper.ClearDirectory(this.Temp_Folder + $"originExtractedFiles/", true); this.stockDict = new Dictionary <string, List <TickerEntity> >(); LambdaLogger.Log("Temp folder cleared"); }