/// <summary> /// Manages our Database function call and gets back the Data as they return us /// And converts it to an array which we return /// </summary> /// <returns>A Dictionary Array which we can read through</returns> public Dictionary <string, object>[] GetData(DateTime date) { ManageDB test = new ManageDB(); IEnumerable <Dictionary <string, object> > results = test.LoadDB(date); /// <remarks> /// Allows us to read the data /// We convert the dara into an array so it is not in an interface and we are able /// to read the data that our query returned /// </remarks> Dictionary <string, object>[] results_arr = results.ToArray(); return(results_arr); }
/// <summary> /// Assisted by code from https://dev.socrata.com/foundry/data.cityofnewyork.us/fhrw-4uyv /// queried DB - https://data.cityofnewyork.us /// API KEY - PVGjhHLj8Svy7Ryz0uJgW9IBh /// loadDB connects to the database, sends the query and then returns the data /// </summary> /// <returns>Returns the da taset of the query to main</returns> public IEnumerable <Dictionary <string, object> > LoadDB() { /// <remarks> /// This requires the SODA library /// It can be installed from NuGet in Visual studio using /// Install-Package CSM.SodaDotNet /// </remarks>> SODA.SodaClient client = new SodaClient("https://data.cityofnewyork.us", "PVGjhHLj8Svy7Ryz0uJgW9IBh"); /// <remarks> /// The documentation on the web is outdated. /// The .NET library has been updated to no longer allow generic typing. /// You must use either Dictionary(String,Object) - use <> but not allowed in XML comments /// OR a user-defined json serializable class - their documentation does not explain how to do this /// well enough, however so we are sticking with the Generic Collection specified /// </remarks>> SODA.Resource <Dictionary <string, object> > dataset = client.GetResource <Dictionary <string, object> >("fhrw-4uyv"); /// <summary> /// instantiate our object and get our query from GetQueryDate() /// </summary> ManageDB test = new ManageDB(); SODA.SoqlQuery soql = test.GetQueryDate(); /// <summary> /// Query sends our query to our pre-defined location and returns an IEnumerable which we assign to results /// results now contains the results of our query /// </summary> IEnumerable <Dictionary <string, object> > results = dataset.Query <Dictionary <string, object> >(soql); /// <summary> /// Testing to make sure that our query returned results /// Will be changed to throw an error instead of printing a value /// </summary> int SizeOfList; test.TestIEnum(ref results, out SizeOfList); Console.WriteLine(SizeOfList); return(results); }