private static void AddCalculatedColumns(DataTable table, Share share) { foreach(var calculation in share.Calculations) { table.Columns.Add(calculation.ToString(), typeof(Decimal)); } }
//todo explore parralelization here public int Import(string[] files) { var totalRecords = 0; engine.Reset(); foreach(var file in files) { var share = new Share( file.ToShareId(), file.ReadFile(), engine ); repo.Save(share); totalRecords += share.ProcessedQuotes.Count; } return totalRecords; }
private static DataTable AsDataTable(Share share) { var table = new DataTable(); AddQuoteColumns(table); AddCalculatedColumns(table, share); foreach (var pq in share.ProcessedQuotes) { DataRow row = table.NewRow(); AddQuoteRowData(share.Id, row, pq); AddCalculatedRowData(row, pq); table.Rows.Add(row); } return table; }
public void Save(Share share) { var data = AsDataTable(share); this.BulkInsertStock(data); }