private byte[] DownloadCover(string coverUrl) { KnigoskopWebClient webClient = new KnigoskopWebClient(); byte[] cover = webClient.DownloadImage(coverUrl); return(cover); }
private GoogleBookJsonResponse GetBooksDataFromGoogle(string bookName, string author, int iterator) { string queryString = baseGoogleBooksUrl + " \"" + bookName + "\" " + author; KnigoskopWebClient webClient = new KnigoskopWebClient(); try { string jsonGoogleBooksResponse = webClient.DownloadData(queryString); GoogleBookJsonResponse bookItem = GetGoogleBookItem(jsonGoogleBooksResponse); return(bookItem); } catch (WebException ex) { if (ex.Message.Contains("(403)")) { string currentTime = Convert.ToString(DateTime.Now); Console.WriteLine(currentTime + " " + ex.Message); Thread.Sleep((iterator + 1) * 5000); if (iterator <= 10) { iterator++; return(GetBooksDataFromGoogle(bookName, author, iterator)); } else { throw ex; } } else { throw ex; } } catch (Exception ex) { throw ex; } }
private GoogleBookJsonResponse GetBooksDataFromGoogle(string bookName, string author, int iterator) { string queryString = baseGoogleBooksUrl + " \"" + bookName + "\" " + author; KnigoskopWebClient webClient = new KnigoskopWebClient(); try { string jsonGoogleBooksResponse = webClient.DownloadData(queryString); GoogleBookJsonResponse bookItem = GetGoogleBookItem(jsonGoogleBooksResponse); return bookItem; } catch (WebException ex) { if (ex.Message.Contains("(403)")) { string currentTime = Convert.ToString(DateTime.Now); Console.WriteLine(currentTime+" "+ex.Message); Thread.Sleep((iterator + 1) * 5000); if (iterator <= 10) { iterator++; return GetBooksDataFromGoogle(bookName, author, iterator); } else { throw ex; } } else { throw ex; } } catch (Exception ex) { throw ex; } }
private byte[] DownloadCover(string coverUrl) { KnigoskopWebClient webClient = new KnigoskopWebClient(); byte[] cover = webClient.DownloadImage(coverUrl); return cover; }