/// <summary> /// Get cartridge list by a part of the name. /// </summary> /// <param name="name">Part of the name</param> public void BeginGetByName(string name) { if (!checkConnection()) { throw new InvalidOperationException("Invalid connection to the API."); } Live.SearchCartridgesRequest search = new Live.SearchCartridgesRequest() { PageNumber = 1, ResultsPerPage = 50, SearchArguments = new Live.CartridgeSearchArguments() { CartridgeName = name.Trim(), OrderSearchBy = Live.CartridgeSearchArguments.OrderBy.Distance } }; beginGetCartridges(search); }
/// <summary> /// Get cartridge list with only play anywhere cartridges. Sort list by date. /// </summary> public void BeginGetByPlayAnywhere() { if (!checkConnection()) { throw new InvalidOperationException("Invalid connection to the API."); } Live.SearchCartridgesRequest search = new Live.SearchCartridgesRequest() { PageNumber = 1, ResultsPerPage = 50, SearchArguments = new Live.CartridgeSearchArguments() { OrderSearchBy = Live.CartridgeSearchArguments.OrderBy.PublishDate, IsPlayAnywhere = true } }; beginGetCartridges(search); }
/// <summary> /// Get cartridge list by a coordinate and a radius. /// </summary> /// <param name="lat">Latitude</param> /// <param name="lon">Longitude</param> /// <param name="radius">Radius in km</param> public void BeginGetByCoords(double lat, double lon, double radius) { if (!checkConnection()) { throw new InvalidOperationException("Invalid connection to the API."); } Live.SearchCartridgesRequest search = new Live.SearchCartridgesRequest() { PageNumber = 1, ResultsPerPage = 50, SearchArguments = new Live.CartridgeSearchArguments() { Latitude = lat, Longitude = lon, SearchRadiusInKm = radius } }; beginGetCartridges(search); }
/// <summary> /// Search cartridges via web client. /// </summary> /// <param name="search">Search parameters</param> private void beginGetCartridges(Live.SearchCartridgesRequest search) { // Starts the asynchronous search operation. // The result happens in the event handler onSearchCartridgesCompleted. if (!String.IsNullOrEmpty(userToken)) { search.UserToken = userToken; } string result = callAPI("SearchCartridges", search); Live.SearchCartridgesResponse resp = JsonConvert.DeserializeObject <Live.SearchCartridgesResponse>(result); status = resp.Status.StatusCode; if (status == 0) { if (resp.Cartridges != null) { // Delete old ones Clear(); // Get new ones foreach (Live.CartridgeSearchResult res in resp.Cartridges) { Cartridge cart = new Cartridge(); cart.Name = res.Name; cart.AuthorName = res.AuthorName; cart.AuthorCompany = res.AuthorCompany; cart.DateAdded = res.DateAdded; cart.DateLastPlayed = res.DateLastPlayed; cart.DateLastUpdated = res.DateLastUpdated; cart.CompletionTime = res.CompletionTime; cart.ActivityType = res.ActivityType; cart.CountryID = res.CountryID; cart.StateID = res.StateID; cart.IsArchived = res.IsArchived; cart.IsDisabled = res.IsDisabled; cart.IsOpenSource = res.IsOpenSource; cart.IsPlayAnywhere = res.IsPlayAnywhere; cart.IconFileURL = res.IconFileURL; cart.PosterFileURL = res.PosterFileURL; cart.StartingLocationLatitude = res.Latitude; cart.StartingLocationLongitude = res.Longitude; cart.LinkedGeocacheNames = res.LinkedGeocacheNames; cart.LinkedGeocacheGCs = res.LinkedGeocacheGCs; cart.LinkedGeocacheGUIDs = res.LinkedGeocacheGuids; cart.LongDescription = res.LongDescription; cart.ShortDescription = res.ShortDescription; cart.NumberOfCompletions = res.NumberOfCompletions; cart.NumberOfUsersWatching = res.NumberOfUsersWatching; cart.UniqueDownloads = res.UniqueDownloads; cart.Complete = res.UserHasCompleted; cart.UserHasPartiallyPlayed = res.UserHasPartiallyPlayed; cart.WGCode = res.WGCode; Add(cart); } } } else { statusMessage = resp.Status.StatusMessage; } }