private void ProcessRecords(List <OuiLookup> Items) { var added = 0; var existing = 0; foreach (var item in Items) { try { Console.SetCursorPosition(0, 2); var result = NetworkContext.Merge(item); Console.Write($"Records Added: {added:N0}"); added++; } catch (LiteDB.LiteException ex) { if (ex.Message.StartsWith("Cannot insert duplicate key in unique index '_id'.")) { Console.SetCursorPosition(0, 3); Console.WriteLine($"Existing Record: {existing:N0}"); existing++; } else { Console.WriteLine(ex.Message); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { var totalProcessed = Convert.ToDecimal(added + existing); var pct = Math.Round((totalProcessed / Items.Count) * 100, 2); Console.SetCursorPosition(0, 4); Console.Write($"Percent Processed: {totalProcessed:N0}/{Items.Count:N0} \t\t {pct:N} %"); } } }