private async Task <(int[], List <InvoiceFull>, List <RootRecord>, List <Invoice>, List <Receipt>, List <BankTransaction>)> Prepare(int[] years) { var store = new FileSystemKVStore(Tools.GetOutputFolder()); var invoiceStore = new SBCScan.InvoiceStore(store); var files = await invoiceStore.GetKeysParsed(); var invoices = (await Task.WhenAll(files.Where(o => years.Contains(o.RegisteredDate.Year)).Select(async o => await invoiceStore.Get(o)).ToList())).ToList(); var sieFolder = Tools.GetOutputFolder("SIE"); var sieFiles = new DirectoryInfo(sieFolder).GetFiles($"output_*.se").Select(o => o.Name).Where(o => years.Any(p => o.Contains(p.ToString()))); var sie = await SBCExtensions.ReadSIEFiles(sieFiles.Select(file => Tools.GetOutputFolder("SIE", file))); var dir = Tools.GetOutputFolder("sbc_html"); var sbcInvoices = new InvoiceSource().ReadAll(dir).Where(o => years.Contains(o.RegisteredDate.Year)).ToList(); var sbcReceipts = new ReceiptsSource().ReadAll(dir).Where(o => years.Contains(o.Date.Year)).ToList(); var sbcTransactions = new BankTransactionSource().ReadAll(dir).Where(o => years.Contains(o.CurrencyDate.Year)).ToList(); return(years, invoices, sie.ToList(), sbcInvoices, sbcReceipts, sbcTransactions); }
public async Task MyTestMethod() { var store = new FileSystemKVStore(Tools.GetOutputFolder()); var invoiceStore = new SBCScan.InvoiceStore(store); var alreadyScraped = await invoiceStore.GetKeysParsed(); var errors = new Dictionary <InvoiceFull.FilenameFormat, Exception>(); foreach (var item in alreadyScraped) { try { await invoiceStore.Get(item); } catch (Exception ex) { errors.Add(item, ex); } } Assert.IsFalse(errors.Any()); }