/// <summary> /// Initializes de Artist Id Before making the requests /// </summary> private void InitArtistKey(Artist artist) { XmlHttpRequest xmlHttp = new XmlHttpRequest(); Dictionary <string, string> parameters = GetArtistInfoParameteres(artist.Name); XmlDocument xmlDoc = null; Task <string> strXmlStr = null; string externalArtistId = null; try { // does the http request strXmlStr = xmlHttp.DoGetRequestAsync(_performersDataBaseURL, parameters); // loads up de text into the XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strXmlStr.Result); // parses the XML Doc externalArtistId = ParseArtistXml(xmlDoc, artist); _artistKey = externalArtistId; } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <param name="artistName"></param> public Artist GetArtistByName(string strArtistName) { Artist resultArtist = null; XmlHttpRequest xmlHttp = new XmlHttpRequest(); Dictionary <string, string> parameters = GetArtistInfoParameteres(strArtistName.ToLower()); XmlDocument xmlDoc = null; Task <string> strXmlStr = null; try { // does the http request strXmlStr = xmlHttp.DoGetRequestAsync(_baseURL, parameters); // loads up de text into the XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strXmlStr.Result); // parses the XML Doc into the artist structure resultArtist = ParseArtistXml(xmlDoc); } catch (Exception ex) { throw ex; } return(resultArtist); }
/// <summary> /// Gets a location of an address from Google Maps /// </summary> /// <param name="strAddress"></param> /// <returns></returns> public Location GetLocation(string strAddress) { Location resultLocation = null; XmlHttpRequest xmlHttp = new XmlHttpRequest(); Dictionary <string, string> parameters = GetGeoLocationQueryParameteres(strAddress); Task <string> strJSONResponse = null; try { // does the http request strJSONResponse = xmlHttp.DoGetRequestAsync(_baseURL, parameters); GoogleGeoCodeResponse googleResponse = JsonConvert.DeserializeObject <GoogleGeoCodeResponse>(strJSONResponse.Result); if (googleResponse.status == "OK") { if (googleResponse.results.Length == 1) { resultLocation = new Location(); resultLocation.City = (googleResponse.GetAddressComponent("locality") != null ? googleResponse.GetAddressComponent("locality").long_name : ( googleResponse.GetAddressComponent("postal_town") != null ? googleResponse.GetAddressComponent("postal_town").long_name : null) ); resultLocation.Latitude = decimal.Parse(googleResponse.results[0].geometry.location.lat.Replace(".", ",")); resultLocation.Longitude = decimal.Parse(googleResponse.results[0].geometry.location.lng.Replace(".", ",")); resultLocation.Address1 = googleResponse.results[0].formatted_address; resultLocation.Country = googleResponse.GetAddressComponent("country").long_name; } } } catch (Exception ex) { throw ex; } return(resultLocation); }
/// <summary> /// Loads up the artists events /// </summary> /// <param name="artist"></param> /// <returns></returns> private List <Event> LoadEvents(Artist artist) { int currentPage = 1; int totalPages = 1; XmlHttpRequest xmlHttp = new XmlHttpRequest(); Dictionary <string, string> parameters = GetEventsInfoParameteres(artist.Name); XmlDocument xmlDoc = null; Task <string> strXmlStr = null; List <Event> eventList = new List <Event>(); try { while (currentPage <= totalPages) { // updates the page current parameter parameters["page_number"] = currentPage.ToString(); // does the http request strXmlStr = xmlHttp.DoGetRequestAsync(_eventsDataBaseURL, parameters); // loads up de text into the XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strXmlStr.Result); // parses the XML Doc totalPages = ParseEventsXml(xmlDoc, ref eventList); currentPage++; } } catch (Exception ex) { throw ex; } return(eventList); }
/// <summary> /// Loads the artist's albums from lastFM /// </summary> /// <param name="artistResult"></param> private void LoadAlbumInfo(Artist artist, Album album) { XmlHttpRequest xmlHttp = new XmlHttpRequest(); Dictionary <string, string> parameters = GetAlbumInfoParameteres(artist, album); XmlDocument xmlDoc = null; Task <string> strXmlStr = null; try { // does the http request strXmlStr = xmlHttp.DoGetRequestAsync(_baseURL, parameters); // loads up de text into the XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strXmlStr.Result); // parses the XML Doc into the artist structure ParseAlbumXml(artist, album, xmlDoc); } catch (Exception ex) { throw ex; } }