示例#1
0
 public static BookDataBase GetInstance()
 {
     if (instance == null)
     {
         instance = new BookDataBase();
     }
     return(instance);
 }
示例#2
0
 public static BookDataBase GetInstance()
 {
     if (instance == null)
     {
         instance = new BookDataBase();
     }
     return instance;
 }
示例#3
0
        public static bool GetDownloadUrl(this BookInfo book, DependencyObject dispatcher = null)
        {
            if (book.ReadBookUrl == null || book.ReadBookUrl == "")
            {
                GetReadBookUrl(book);
            }
            string source = null;

            if (book.IsReadAll)
            {
                source = HttpWebResponseUtility.GetHtmlByWebBrowser(book.ReadBookUrl, dispatcher);
            }
            else
            {
                source = HttpWebResponseUtility.GetHtmlByHttpWebRequest(book.ReadBookUrl);
            }

            string regexStr = "did = \"(.*?)\"[\\s\\S]*?PdgPath = \"(.*?)\"[\\s\\S]*?var str = \"(.*?)\"";
            Match  m        = Regex.Match(source, regexStr);

            if (!m.Success)
            {
                throw new Exception("获取STR时出现错误!");
            }
            book.did     = m.Groups[1].Value;
            book.PdgPath = m.Groups[2].Value;
            String str = m.Groups[3].Value;

            if (!book.IsReadAll)
            {
                book.DownloadUrlTemp = String.Format(unreadableDownloadUrl, str, "{0}");
                string pid = null;
                try
                {
                    pid = BookDataBase.GetInstance().GetBookPID(book.DXID);
                }
                catch
                {
                    return(false);
                }
                string regex = @"img\d*/(.*?)/";
                m = Regex.Match(str, regex);
                if (pid != null && m.Success)
                {
                    book.DownloadUrl = book.DownloadUrlTemp.Replace(m.Groups[1].Value, pid);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                book.DownloadUrlTemp = String.Format(readableDownloadUrl, str, "{0}");
                book.DownloadUrl     = book.DownloadUrlTemp;
            }
            return(true);
        }
示例#4
0
        public static void GetDownloadUrlByStr(this BookInfo book, String str)
        {
            string regex = @"img\d*/(.*?)/";
            Match  m     = Regex.Match(book.DownloadUrlTemp, regex);
            String pid   = BookDataBase.GetInstance().GetPIDByStr(str);

            if (pid != null && m.Success)
            {
                book.DownloadUrl = book.DownloadUrlTemp.Replace(m.Groups[1].Value, pid);
            }
        }
示例#5
0
 private void refreshDB_Click(object sender, RoutedEventArgs e)
 {
     BookDataBase.GetInstance().addNewItem(this.ssid.Text, this.str.Text);
 }