public int pullXMLbyIDSaveToDBAndTweetAboutIt(string apiKey) { try { var API = new APIAccessor_boardgamegeek_BoardGame(); var BC = new RawGamesAccessor(); var twit = new TwitterApiAccessor("iNbJLSc1T9fvufuWbFV3V6Xni", "JFjvyyhz56ZvZR1IkGjNSXNBThUT31OUrn43LXMQkCdNyy2CpK", "749359779592613888-wWPrZIls1xVFprjqRunSpKEr5GgaXDp", "rRHz1DhGR9kJ8DwwMjGuMj3uWn9z0t1IIp3YAYDlL4FKm"); var xml = API.getBoardGame(apiKey.ToString()); var newGame = new RawGame(); newGame.APIID = apiKey; newGame.TheBlob = xml; BC.UpdateOrCreate(newGame); twit.SendTweet("Someone posted information about Game ID: " + newGame.APIID + " from BGG - " + DateTime.Now.ToString("yyyyMMdd-hhmmss")); return(100); } catch (Exception e) { return(499); } }
public string searchAndSaveAllReferences(string searchCriteria) { try { var API = new APIAccessor_boardgamegeek_BoardGame(); var BC = new RawGamesAccessor(); var xml = API.search(searchCriteria); if (xml.Contains("<body>")) { return("TimeOut"); } //todo - log the search var obj = xml.ParseXML <BoardChitless.Shared.DataContracts.BoardGameGeekSearch.items>(); foreach (BoardChitless.Shared.DataContracts.BoardGameGeekSearch.itemsItem i in obj.item) { var g = new RawGame(); g.APIID = i.id.ToString(); g.Name = i.name.value.ToString(); try { g.YearPublished = i.yearpublished.value; if (i.typeField == "boardgameexpansion") { g.isAlsoExpansion = 1; } } catch { //let it be null } g.RecordType = i.typeField; g.addedBy = "console-search-" + searchCriteria; g.dateAdded = DateTime.UtcNow; //newGame.TheBlob = xml; if (i.name.type == "primary") { BC.UpdateOrCreate(g); } } return("Done"); } catch { return("Error"); } }
public string pullXMLbyIDAndSaveToDatabase(string apiKey) { try { var API = new APIAccessor_boardgamegeek_BoardGame(); var BC = new RawGamesAccessor(); var xml = API.getBoardGame(apiKey.ToString()); var newGame = new RawGame(); newGame.APIID = apiKey; newGame.TheBlob = xml; BC.UpdateOrCreate(newGame); return("Done!"); } catch { return("Error"); } }