Beispiel #1
0
        public bool Add(Journal model)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@ISSN", SqlDbType.NVarChar,32),
                    new SqlParameter("@EISSN", SqlDbType.NVarChar,32),
                    new SqlParameter("@Publisher", SqlDbType.NVarChar,1024),
                    new SqlParameter("@Subject", SqlDbType.NVarChar,1024),
                    new SqlParameter("@JournalLanguage", SqlDbType.NVarChar,128),
                    new SqlParameter("@StartYear", SqlDbType.NVarChar,32),
                    new SqlParameter("@PublicationFee", SqlDbType.NVarChar,32),
                    new SqlParameter("@CategoryWebsiteID", SqlDbType.Int,4),
                    new SqlParameter("@JournalName", SqlDbType.NVarChar, 1024)
                                        };
            parameters[0].Value = model.ISSN;
            parameters[1].Value = model.EISSN;
            parameters[2].Value = model.Publisher;
            parameters[3].Value = model.Subject;
            parameters[4].Value = model.JournalLanguage;
            parameters[5].Value = model.StartYear;
            parameters[6].Value = model.PublicationFee;
            parameters[7].Value = model.CategoryWebsiteID;
            parameters[8].Value = model.JournalName;

            StringBuilder sb = new StringBuilder();
            sb.Append(SQL_INSERT_JOURNAL);
            bool result =new DBHelperSQL().ExecuteNonQuery(sb, parameters, MethodInfo.GetCurrentMethod().Name);
            return result;
        }
Beispiel #2
0
 public bool Add(Journal model)
 {
     return journalDAL.Add(model);
 }
Beispiel #3
0
        /// <summary>
        /// 从下载到本地的期刊页面中读取所有需要的信息
        /// </summary>
        /// <param name="directoryPath">下面下载后所在路径</param>
        /// <param name="webUrl">页面网址(决定了所在的本地文件夹)</param>
        /// <returns>信息列表</returns>
        private List<Journal> ExtractJournals(string directoryPath, string[] webUrl)
        {
            JournalBLL journalBLL = new JournalBLL();
            List<Journal> jnlInfoList = new List<Journal>();
            try
            {
                if (Tools.FileExsits(webUrl[0]) == false)
                    return null;
                string text = Tools.ReadFile(webUrl[0]);

                int curPos = 0;
                string journalFlag = "<div class=\"data\">";
                while (curPos < text.Length)
                {
                    curPos = text.IndexOf(journalFlag, curPos);
                    if (curPos == -1)
                        break;

                    Journal jnlInfo = new Journal();
                    jnlInfo.JournalName = Tools.DeleteStringInParent(Tools.StringExtractor(text, "<b>", "</b>", curPos), '<', '>').Trim();
                    jnlInfo.JournalName = Tools.DeleteBeginAndEndIllegalChar(jnlInfo.JournalName);
                    //ISSN and EISSN
                    curPos = text.IndexOf("<div style=\"color: #585858\">", curPos);
                    string temp = Tools.StringExtractor(text, "</strong>:", "<br>", curPos);
                    IList<string> ISSNAndEISSN = Tools.GetISSNAndEISSN(Tools.DeleteBeginAndEndIllegalChar(temp));
                    if (ISSNAndEISSN.Count == 2)
                    {
                        jnlInfo.ISSN = ISSNAndEISSN[0];
                        jnlInfo.EISSN = ISSNAndEISSN[1];
                    }
                    else if (ISSNAndEISSN.Count == 1)
                    {
                        jnlInfo.ISSN = ISSNAndEISSN[0];
                    }
                    //publisher
                    curPos = text.IndexOf("<br>", curPos);
                    jnlInfo.Publisher = Tools.DeleteBeginAndEndIllegalChar(Tools.StringExtractor(text, "</strong>:", "<br>", curPos));
                    //subject
                    curPos = text.IndexOf("<br><strong>Subject</strong>", curPos);
                    int nextPos = text.IndexOf("<br><b>Country</b>", curPos);
                    string subjectStr = "";
                    while (curPos < nextPos)
                    {
                        string temp2 = Tools.DeleteBeginAndEndIllegalChar(Tools.StringExtractor(text, "\">", "</a>", curPos));
                        if (text.IndexOf(temp2) > nextPos)
                            break;
                        else
                            subjectStr += temp2 + ",";
                        curPos = text.IndexOf("\">", curPos) + 2;
                    }
                    if (subjectStr.Length != 0)
                        subjectStr = subjectStr.Substring(0, subjectStr.Length - 1);
                    jnlInfo.Subject = subjectStr;
                    curPos = nextPos;
                    //country
                    //language
                    curPos = text.IndexOf("<b>Language</b>", curPos);
                    jnlInfo.JournalLanguage = Tools.DeleteBeginAndEndIllegalChar(Tools.StringExtractor(text, "</b>:", "</br>", curPos));
                    //start year
                    curPos = text.IndexOf("<b>Start year</b>", curPos);
                    jnlInfo.StartYear = Tools.DeleteBeginAndEndIllegalChar(Tools.StringExtractor(text, "</b>", "</b>", curPos));
                    //fee
                    curPos = text.IndexOf("<b>Publication fee</b>", curPos);
                    jnlInfo.PublicationFee = Tools.DeleteBeginAndEndIllegalChar(Tools.StringExtractor(text, "\">", "</span>", curPos));

                    jnlInfoList.Add(jnlInfo);
                }

            }
            catch (Exception ex)
            {
                textBoxDisplay.AppendText(ex.ToString() + newLine);
            }
            return jnlInfoList;
        }