public static JurisdictionCollection GetJurisdictions() { JurisdictionCollection collection = new JurisdictionCollection(); JurisdictionList list = GetJurisdictionList(); int total = list.Data.Count; for (var i = 0; i < total; i++) { var data = list.Data[i]; string jurisdictionURL = JurisdictionsBaseURL + "/" + data.Id; int percent = (int)Math.Round(i * ((decimal)100 / total)); // ConsoleEx.WriteProgress("Getting Jurisdictions", "Jurisdictions", data.Title, percent); string jurisdictionJson = InvokeWebRequest(jurisdictionURL); var jurisdiction = JurisdictionsSerializer.Deserialize(jurisdictionJson); collection.Add(jurisdiction); } Console.WriteLine(); return(collection); }
private static void ProcessJurisdictions() { // Console.WriteLine("Getting jurisdictions..."); JurisdictionCollection collection = Requester.GetJurisdictions(); // Console.WriteLine("Importing jurisdictions..."); JurisdictionDBImporter.Import(collection); int standardSetsCount = collection.SelectMany(j => j.Data.StandardSets).Count(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(); Console.WriteLine("Complete!"); Console.WriteLine("Import task was successful. {0} jurisdictions and {1} standard sets imported.", collection.Count, standardSetsCount); Console.ResetColor(); }
public static void Import(JurisdictionCollection collection) { int total = collection.Count; for (var i = 0; i < total; i++) { var jurisdiction = collection[i]; int percent = (int)Math.Round(i * ((decimal)100 / total)); ConsoleEx.WriteProgress("Importing Jurisdictions", $"Jurisdiction {i} of {total}", jurisdiction.Data.Title, percent); Guid jurisdictionsKey = Guid.NewGuid(); ImportJurisdictionData(jurisdiction.Data, jurisdictionsKey); ImportStandardSets(jurisdiction.Data.StandardSets, jurisdictionsKey); } }
public static string SerializeCollection(JurisdictionCollection collection) { return(JsonConvert.SerializeObject(collection, Formatting.Indented)); }