コード例 #1
0
ファイル: UpdateBookRecord.cs プロジェクト: avgx/knigoskop
        private byte[] DownloadCover(string coverUrl)
        {
            KnigoskopWebClient webClient = new KnigoskopWebClient();

            byte[] cover = webClient.DownloadImage(coverUrl);
            return(cover);
        }
コード例 #2
0
ファイル: GoogleBooks.cs プロジェクト: avgx/knigoskop
        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;
            }
        }
コード例 #3
0
ファイル: GoogleBooks.cs プロジェクト: avgx/knigoskop
        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;
            }
        }
コード例 #4
0
ファイル: UpdateBookRecord.cs プロジェクト: avgx/knigoskop
 private byte[] DownloadCover(string coverUrl)
 {
     KnigoskopWebClient webClient = new KnigoskopWebClient();
     byte[] cover = webClient.DownloadImage(coverUrl);
     return cover;
 }