Ejemplo n.º 1
0
        /// <summary>
        /// 将期刊信息保存到数据库
        /// </summary>
        private void ProcessForButtonSavetoDatabase()
        {
            //if (journalList == null) return;
            CategoryWebsiteBLL categoryWebsiteBLL = new CategoryWebsiteBLL();
            IList<CategoryWebsite> categoryWebsiteList = categoryWebsiteBLL.GetAllCategoryWebsites();
            foreach(CategoryWebsite cate in categoryWebsiteList)
            {
                webUrl[0] = cate.Website;
                int count = cate.WebsiteCount;
                int id = cate.CategoryWebsiteID;
                int num = count / 10;
                if (count % 10 > 0)
                    num++;
                string folderName = Tools.GetFolderName(webUrl[0]);
                string filePath = directoryPath + folderName;
                for(int i = 0; i < num; i++)
                {
                    webUrl[0] = filePath + (i + 1) + ".html";
                    journalList = ExtractJournals(directoryPath, webUrl);
                    JournalBLL journalBusiness = new JournalBLL();
                    foreach (Journal jnlInfo in journalList)
                    {
                        try
                        {
                            jnlInfo.CategoryWebsiteID = id;
                            journalBusiness.Add(jnlInfo);
                        }
                        catch (Exception ex_for1)
                        {
                            continue;
                            textBoxDisplay.AppendText(ex_for1.ToString() + newLine);
                        }
                        textBoxDisplay.AppendText(twoLine);
                    }
                    textBoxDisplay.AppendText(twoLine + "All Journals are saved!" + twoLine);
                    buttonSaveToDatabase.Text = "Conserve To Database";
                }
            }

            //paperBusiness.RemoveDuplicate();
            //authorBusiness.RemoveDuplicate();
            buttonSaveToDatabase.Enabled = true;
            buttonDownloadJournal.Enabled = true;
            buttonSettings.Enabled = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 下载页面
        /// </summary>
        /// TODO 需要从新指定路径webUrl
        private void ProcessForButtonDownloadJournal()
        {
            CategoryWebsiteBLL categoryWebsiteBLL = new CategoryWebsiteBLL();
            IList<CategoryWebsite> categoryWebsiteList = categoryWebsiteBLL.GetAllCategoryWebsites();
            foreach (CategoryWebsite cate in categoryWebsiteList)
            {
                webUrl[0] = cate.Website;
                if (DownloadJournalList(directoryPath, webUrl, cate.WebsiteCount) == true)
                {
                    textBoxDisplay.AppendText(webUrl[0] + " Downloaded!" + newLine + newLine);
                }
                else
                {
                    textBoxDisplay.AppendText(webUrl[0] + " is already existed!" + newLine);

                }
            }

            textBoxDisplay.AppendText("All Pages Downloaded!" + newLine + newLine);

            buttonSaveToDatabase.Enabled = true;
            //journalList = ExtractJournals(directoryPath, webUrl);
            buttonDownloadJournal.Enabled = true;
            buttonSaveToDatabase.Enabled = true;
            buttonSettings.Enabled = false;
            buttonDownloadJournal.Text = "Download Journal List";
        }