public object GenerateActivityAndPositionFilesForSilver(FileGenerationInputDto dto) { var trades = GetTransactions(tradesURL + "ALL"); var positions = GetTransactions(positionsURL); Task.WaitAll(new Task[] { trades, positions }); var tradeList = JsonConvert.DeserializeObject <Transaction[]>(trades.Result); var positionList = JsonConvert.DeserializeObject <Position[]>(positions.Result); var currentDir = System.AppDomain.CurrentDomain.BaseDirectory; System.IO.Directory.CreateDirectory(currentDir + Path.DirectorySeparatorChar + "SilverData"); DateTime businessDate = dto.businessDate.HasValue ? dto.businessDate.Value : DateTime.UtcNow; string convertedBusinessDate = businessDate.ToString("yyyy-MM-dd"); // filenames string activityFileName = convertedBusinessDate + "_activity"; string positionFileName = convertedBusinessDate + "_position"; var activityPath = currentDir + "SilverData" + Path.DirectorySeparatorChar + $"{activityFileName}.txt"; var positionPath = currentDir + "SilverData" + Path.DirectorySeparatorChar + $"{positionFileName}.txt"; if (System.IO.File.Exists(activityPath)) { string newFileName = currentDir + "SilverData" + Path.DirectorySeparatorChar + activityFileName + $"_{DateTime.UtcNow.Ticks}.txt"; System.IO.File.Move(activityPath, newFileName); } if (System.IO.File.Exists(positionPath)) { string newFileName = currentDir + "SilverData" + Path.DirectorySeparatorChar + positionFileName + $"_{DateTime.UtcNow.Ticks}.txt"; System.IO.File.Move(positionPath, newFileName); } //header and trailer var activityHeader = GetHeader("HDR", "SMGActivity", convertedBusinessDate); var activityTrailer = GetTrailer("TRL", "SMGActivity", convertedBusinessDate); var positionHeader = GetHeader("HDR", "SMGOpenLotPosition", convertedBusinessDate); var positionTrailer = GetTrailer("TRL", "SMGOpenLotPosition ", convertedBusinessDate); var activityResult = fileProcessor.ExportFile(tradeList, activityHeader, activityTrailer, activityPath, "Activity_json", "LpOrderId"); var positionResult = fileProcessor.ExportFile(positionList, positionHeader, positionTrailer, positionPath, "Position_json", "IntraDayPositionId"); var failedActivityList = MapFailedRecords(activityResult.Item1, businessDate, activityFileName); var failedPositionList = MapFailedRecords(positionResult.Item1, businessDate, positionFileName); List <FileInputDto> fileList = new List <FileInputDto>(); fileList.Add(new FileInputDto(activityPath, activityFileName, activityResult.Item2, "LightPoint", "Upload", failedActivityList, businessDate)); fileList.Add(new FileInputDto(positionPath, positionFileName, positionResult.Item2, "LightPoint", "Upload", failedPositionList, businessDate)); InsertActivityAndPositionFilesForSilver(fileList); return(Utils.Wrap(true)); }
public object GenerateActivityAndPositionFilesForSilver(FileGenerationInputDto dto) { return(controller.GenerateActivityAndPositionFilesForSilver(dto)); }