Ejemplo n.º 1
0
        private byte[] DownloadCover(string coverUrl)
        {
            KnigoskopWebClient webClient = new KnigoskopWebClient();

            byte[] cover = webClient.DownloadImage(coverUrl);
            return(cover);
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 private byte[] DownloadCover(string coverUrl)
 {
     KnigoskopWebClient webClient = new KnigoskopWebClient();
     byte[] cover = webClient.DownloadImage(coverUrl);
     return cover;
 }