public static void GetAllPersons() { var humans = new List <Human>(); var errors = new List <Tuple <int, Exception> >(); var responseBody = File.ReadAllText(WdqResponse); var wdqRequestor = new WdqRequestor(); Console.WriteLine("Getting human instance references."); var wdqResult = wdqRequestor.ResultFromString(responseBody); Console.WriteLine("Found {0} human instances.", wdqResult.items.Length); var humanFactory = new HumanFactory(); foreach (var id in wdqResult.items) { try { if (humans.Count % 10 == 0) { Console.Write("\r{0}/{1} completed.", humans.Count, wdqResult.items.Count()); } var human = humanFactory.FromEntityId(id); humans.Add(human); } catch (Exception ex) { var t = new Tuple <int, Exception>(id, ex); errors.Add(t); } } Console.WriteLine(); Console.WriteLine("{0} humans found.", humans.Count); Console.WriteLine("Writing reports."); var livingSb = new StringBuilder(); livingSb.AppendFormat("Name\tDoB\tAge\tLink"); livingSb.AppendLine(); var living = humans.Where(h => h.DateOfBirth != null && h.DateOfDeath == null).OrderByDescending(h => h.Age()); foreach (var l in living) { livingSb.AppendFormat("{0}\t{1}\t{2}\t{3}", l.Label, l.DateOfBirth, l.Age(), l.WikiLink); livingSb.AppendLine(); } File.WriteAllText("Living.txt", livingSb.ToString()); Console.WriteLine("Reports finished."); }
public static void GetPersons( [ClArgs("id")] string[] ids ) { var humanFactory = new HumanFactory(); foreach (var id in ids) { int intId; if (int.TryParse(id, out intId)) { var human = humanFactory.FromEntityId(intId); Console.WriteLine("{0}:", intId); Console.WriteLine("{0}", human); } else { Console.WriteLine("{0} is not an integer.", id); } } }