public void SplitBusinessDataByYears_MoreYears() { var inputBusinessItem = new BusinessDataItem { ICO = "123", Name = "Test company", LegalFormOfOwner = "s.r.o", CountryOfOwner = "Czech republic", OwnerCountrySign = "DOM", OwnerType = "FO", OwnerShare = "50", FromTime = DateTime.ParseExact("01.07.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture), ToTime = DateTime.ParseExact("30.09.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture), IsValid = "1", }; var dateProcessor = new DateProcessor(); var result = dateProcessor.SplitBusinessDataByYear(inputBusinessItem); Assert.AreEqual(7, result.Count); Assert.AreEqual(DateTime.ParseExact("01.07.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[0].FromTime); Assert.AreEqual(DateTime.ParseExact("31.12.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[0].ToTime); Assert.AreEqual(DateTime.ParseExact("01.01.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[6].FromTime); Assert.AreEqual(DateTime.ParseExact("30.09.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[6].ToTime); }
static void Main(string[] args) { var dataLoader = new CsvDataLoader(); var dateProcessor = new DateProcessor(); var dataAggregator = new DataAggregator(); var dataExporter = new CsvDataExporter(); var excelReader = new ExcelDataLoader(); var csvFinancialDataLoader = new CsvFinancialDataLoader(); var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); var result = dataLoader.LoadDataFromFile(desktopFolder + "/Diplomovka_ESF/transformed_10000.csv"); // var result = dataLoader.LoadDataFromFile(desktopFolder + "/Diplomovka_ESF/owners.csv"); List <BusinessDataItem> parsedBusinessData = new List <BusinessDataItem>(); result.ForEach(res => parsedBusinessData.AddRange(dateProcessor.SplitBusinessDataByYear(res))); var allLoadedIcos = parsedBusinessData.Select(businessData => businessData.ICO).Distinct().OrderBy(ico => ico).ToList(); var allIcosWithFinancialData = excelReader.LoadFinancialDataOfCompany(allLoadedIcos, desktopFolder + "/Data_DP/financial_data.xlsx"); Console.WriteLine($"AllLoadedIcos size {allLoadedIcos.Count} vs. icos with financialData size {allIcosWithFinancialData.Count}"); // var allIcosWithFinancialData = csvFinancialDataLoader.LoadFinancialDataOfCompany(allLoadedIcos, desktopFolder + "/Data_DP/financial_data_less_detail.csv"); // Console.WriteLine($"AllLoadedIcos size {allLoadedIcos.Count} vs. icos with financialData from csv size {allIcosWithFinancialData.Count}"); List <CompanyOutputData> ownersInfo = dataAggregator.AggregateDataByCompany(parsedBusinessData); dataExporter.ExportDataToCsv(ownersInfo); Console.WriteLine("Transformation finished"); }