/// <summary> /// ProcessDatabaseBatch /// </summary> private void ProcessDatabaseBatch() { if (CompaniesProcessed.Count() > 0 && CompaniesProcessed.Count() % Convert.ToInt32(Configuration.Instance["BatchSizeDatabase"]) == 0 || CompaniesList.Count() == 0) { DataContext.Instance.SaveChanges(); LogCurrent.Add("OK! Current batch saved in database."); } }
/// <summary> /// ProcessNotResolved /// </summary> private void ProcessNotResolved() { if (!CompaniesProcessed.Any(s => s.ToUpper() == CurrentCompany.ToUpper())) { if (DataContext.Instance.NotResolved.Any(n => n.Company == CurrentCompany)) { LogCurrent.Add($"Company {CurrentCompany} exists already in database table NotResolved."); return; } DataContext.Instance.NotResolved.Add(new NotResolved { Company = CurrentCompany }); } CompaniesProcessed.Add(CurrentCompany); }
/// <summary> /// ProcessResolved /// </summary> /// <param name="contracts"></param> private void ProcessResolved(IList <Contract> contracts) { for (int i = 0; i < contracts.Count(); i++) { Contract contract = contracts[i]; if (!SymbolProcessed.Any(s => s.ToUpper() == contract.Symbol.ToUpper())) { if (DataContext.Instance.Contracts.Any(c => c.Symbol == contract.Symbol)) { LogCurrent.Add($"Symbol {contract.Symbol} exists already in database table Contracts. Adding record in table NotUnique."); DataContext.Instance.NotUnique.Add(new NotUnique { Symbol = contract.Symbol, Company = contract.Company }); continue; } DataContext.Instance.Contracts.Add(contract); SymbolProcessed.Add(contract.Symbol); } } CompaniesProcessed.Add(CurrentCompany); }