예제 #1
0
 public void FindItem(ItemMasterRow item)
 {
     try
     {
         string hash = CitationTools.GetItemHash(item);
         if (currentSearchingItemHash != hash)
         {
             listSearchingItemFieldIndexes = new List<int>();
             foreach (TextCitationItem tci in rci.TextCitations)
             {
                 if (tci.HashList.Contains(hash))
                 {
                     int index = tci.HashList.IndexOf(hash);
                     listSearchingItemFieldIndexes.Add(tci.FieldIndexes[index]);
                 }
             }
             currentSearchingItemHash = hash;
             iCurrentSearchingItemCursor = 0;
         }
         if (listSearchingItemFieldIndexes.Count > iCurrentSearchingItemCursor)
         {
             editor.JumpToNextMatchingItem(listSearchingItemFieldIndexes[iCurrentSearchingItemCursor]);
             iCurrentSearchingItemCursor++;
         }
         else
         {
             MessageBox.Show(Lang.en_US.Alert_NoMoreMatching_Msg);
             iCurrentSearchingItemCursor = 0;
         }
     }
     catch(Exception ex)
     {
         log.WriteLine(LogType.Error, "DocumentFormatter::FindItem", ex.ToString());
     }
 }
예제 #2
0
        public Dictionary<string, object> GetResults(int iStart)
        {
            if (SearchQuery == string.Empty || SearchQuery.Length == 0)
                return null;

            Dictionary<string, object> Data = new Dictionary<string, object>();

            int iPageNumber = (int)Math.Floor((double)(iStart / Properties.Settings.Default.NUM_OF_SEARCH_RESULTS_PER_PAGE)) + 1;

            string strSPSearchURL = SCHOLARSPORTAL_SEARCHURL.Replace("{term}", HttpUtility.UrlEncode(SearchQuery));
            strSPSearchURL = strSPSearchURL.Replace("{page}", iPageNumber + "");
            strSPSearchURL = strSPSearchURL.Replace("{number}", "20");
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(strSPSearchURL);
                XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);
                nm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
                nm.AddNamespace("os", "http://a9.com/-/spec/opensearch/1.1/");
                nm.AddNamespace("sp", "http://scholarsportal.info/metadata");
                //Find Total Number
                List<ItemMasterRow> listItems = new List<ItemMasterRow>();
                XmlNode nodeTotalNumber = xmlDoc.SelectSingleNode("//os:totalResults", nm);
                if (nodeTotalNumber != null)
                {
                    Data["Count"] = nodeTotalNumber.InnerText;
                }

                XmlNodeList resultNodes = _FindResultNodes(xmlDoc, nm);
                if (resultNodes != null)
                {
                    foreach (XmlNode node in resultNodes)
                    {
                        ItemMasterRow item = new ItemMasterRow();
                        XmlDocument newXmlDoc = new XmlDocument();
                        newXmlDoc.LoadXml(node.OuterXml);
                        nm = new XmlNamespaceManager(newXmlDoc.NameTable);
                        nm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
                        nm.AddNamespace("os", "http://a9.com/-/spec/opensearch/1.1/");
                        nm.AddNamespace("sp", "http://scholarsportal.info/metadata");
                        if (_ProcessingNode(newXmlDoc, nm, ref item))
                        {
                            listItems.Add(item);
                        }
                    }
                }
                if (listItems.Count > 0)
                {
                    Data["ItemList"] = listItems;
                }
            }
            catch
            {
                Data["Count"] = "0";
            }

            return Data;
        }
예제 #3
0
파일: WorldCat.cs 프로젝트: ssc1223/piCite
        public Dictionary<string, object> GetResults(int iStart)
        {
            if (SearchQuery == string.Empty || SearchQuery.Length == 0)
                return null;

            Dictionary<string, object> Data = new Dictionary<string, object>();

            string strWCSearchURL = WORLDCAT_SEARCHURL.Replace("{term}", HttpUtility.UrlEncode(SearchQuery));
            strWCSearchURL = strWCSearchURL.Replace("{start}", iStart + "");
            strWCSearchURL = strWCSearchURL.Replace("{count}", NumberResultsPerPage + "");
            strWCSearchURL = strWCSearchURL.Replace("{key}", WORLDCAT_APIKEY);
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(strWCSearchURL);
                XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);
                nm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
                nm.AddNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/");
                //Find Total Number
                List<ItemMasterRow> listItems = new List<ItemMasterRow>();
                XmlNode nodeTotalNumber = xmlDoc.SelectSingleNode("//opensearch:totalResults", nm);
                if (nodeTotalNumber != null)
                {
                    Data["Count"] = nodeTotalNumber.InnerText;
                }

                XmlNodeList resultNodes = _FindResultNodes(xmlDoc, nm);
                if (resultNodes != null)
                {
                    foreach (XmlNode node in resultNodes)
                    {
                        ItemMasterRow item = new ItemMasterRow();
                        XmlDocument newXmlDoc = new XmlDocument();
                        newXmlDoc.LoadXml(node.OuterXml);
                        nm = new XmlNamespaceManager(newXmlDoc.NameTable);
                        nm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
                        nm.AddNamespace("opensearch", "http://a9.com/-/spec/opensearch/1.1/");
                        nm.AddNamespace("oclcterms", "http://purl.org/oclc/terms/");
                        if (_ProcessingNode(newXmlDoc, nm, ref item))
                        {
                            listItems.Add(item);
                        }
                    }
                }
                if (listItems.Count > 0)
                {
                    Data["ItemList"] = listItems;
                }
            }
            catch
            {
                Data["Count"] = "0";
            }

            return Data;
        }
예제 #4
0
 public ItemMasterRow AddItem(ref ItemMasterRow item, string url)
 {
     string hash = CitationTools.GetItemHash(item);
     int index = this.MasterHashList.IndexOf(hash);
     if (index > -1)
         return this.MasterRefList[index];
     else
     {
         this.MasterRefList.Add(item);
         this.MasterURLList.Add(url);
         this.MasterHashList.Add(hash);
         this.UserList[int.Parse(item.UserID)] = new User(int.Parse(item.UserID));
         return item;
     }
 }
예제 #5
0
파일: CiteULike.cs 프로젝트: ssc1223/piCite
        public Dictionary<string, object> GetResults(int iStart)
        {
            if (SearchQuery == string.Empty || SearchQuery.Length == 0)
                return null;

            Dictionary<string, object> Data = new Dictionary<string, object>();

            int iPageNumber = (int)Math.Floor((double)(iStart / int.Parse(CITEULIKE_NUMOFRESULTSPERPAGE))) + 1;
            string strSearchURL = CITEULIKE_SEARCHURL.Replace("{term}", HttpUtility.UrlEncode(SearchQuery));
            strSearchURL = strSearchURL.Replace("{page}", iPageNumber + "");
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(strSearchURL);
            XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);
            nm.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
            nm.AddNamespace("rss", "http://purl.org/rss/1.0/");
            nm.AddNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
            nm.AddNamespace("prism", "http://prismstandard.org/namespaces/1.2/basic/");
            nm.AddNamespace("dcterms", "http://purl.org/dc/terms/");
            nm.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            List<ItemMasterRow> listItems = new List<ItemMasterRow>();
            XmlNodeList resultNodes = _FindResultNodes(xmlDoc, nm);
            if (resultNodes != null)
            {
                for (int i = 0; i < resultNodes.Count; i++)
                {
                    XmlNode node = resultNodes[i];
                    ItemMasterRow item = new ItemMasterRow();
                    XmlDocument newXmlDoc = new XmlDocument();
                    newXmlDoc.LoadXml(node.OuterXml);
                    nm = new XmlNamespaceManager(newXmlDoc.NameTable);
                    nm.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                    nm.AddNamespace("rss", "http://purl.org/rss/1.0/");
                    nm.AddNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
                    nm.AddNamespace("prism", "http://prismstandard.org/namespaces/1.2/basic/");
                    nm.AddNamespace("dcterms", "http://purl.org/dc/terms/");
                    nm.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
                    if (_ProcessingNode(newXmlDoc, nm, ref item))
                    {
                        listItems.Add(item);
                    }
                }
            }
            if (listItems.Count > 0)
            {
                Data["ItemList"] = listItems;
            }
            return Data;
        }
예제 #6
0
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     string text = string.Empty;
     try
     {
         if (this.ItemTypeID == item.ItemTypeID)
         {
             for (int i = 0; i < this.Template.Count; i++)
             {
                 object field = Fields.GetType().GetField(this.Template[i]).GetValue(Fields);
                 text += field.GetType().GetMethod("Format").Invoke(field, new object[] { item, bInHtmlFormat });
             }
         }
     }
     catch(Exception ex)
     {
         this.log.WriteLine(LogType.Error, "CitationFormatter::Format", ex.ToString() + " ItemID: " + item.ItemID + " ItemTitle:" + item.Title);
     }
     return text;
 }
예제 #7
0
        public string Format(ItemMasterRow item, bool bInHtmlFormat)
        {
            string text = string.Empty;
            string itemtypes = item.ItemTypeID.ToString();
            if (item.ItemTypeID == Enums.ItemTypes.LectureNote)
                itemtypes = Enums.ItemTypes.Document.ToString();
            else if (item.ItemTypeID == Enums.ItemTypes.Video || item.ItemTypeID == Enums.ItemTypes.Audio)
                itemtypes = Enums.ItemTypes.WebPage.ToString();

            text = ItemTypes[itemtypes].Format(item, bInHtmlFormat);
            for (int i = 0; i < LineSpacing; i++)
            {
                if(bInHtmlFormat)
                    text += CitationTools.GetHtmlFormatString("", TextFormat.LineBreak);
                else
                    text += CitationTools.GetWordMLFormatString("", TextFormat.Paragraph);
            }
            if (bInHtmlFormat)
                text += CitationTools.GetHtmlFormatString("", TextFormat.LineBreak);
            return text;
        }
예제 #8
0
        public ItemMasterRow GetResult(string strBibTexURI)
        {
            ItemMasterRow item = new ItemMasterRow();
            if (strBibTexURI == string.Empty || strBibTexURI.Length == 0)
                return null;

            try
            {
                HttpWebRequest req = _PrepareBibTeXRequest(strBibTexURI);
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
                string strResp = sr.ReadToEnd();
                resp.Close();
                if (!_ProcessBibTexBlock(ref item, strResp))
                {
                    return null;
                }
            }
            catch {}
            return item;
        }
예제 #9
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     string text = CitationTools.FormateDate(item.PubDate, this, bInHtmlFormat);
     if(item.ItemTypeID == ItemTypes.Patent)
     {
         if (text.Length == 0)
             text = CitationTools.FormateDate(item.IssueDate, this, bInHtmlFormat);
         if (text.Length == 0)
             text = CitationTools.FormateDate(item.Date3, this, bInHtmlFormat);
     }
     return text;
 }
예제 #10
0
파일: Fields.cs 프로젝트: ssc1223/piCite
        public string Format(ItemMasterRow item, bool bInHtmlFormat)
        {
            if (Regex.Replace(item.Title, @"\s+", "").Length == 0)
                return string.Empty;
            string text = string.Empty;
            switch(this.Capitalization)
            {
                case Capitalization.AsIs:
                    text = item.Title;
                    break;
                case Capitalization.FirstIsCapital:
                    string[] terms = Regex.Split(item.Title.ToLower(), @"\s+");
                    string[] stopwords = {"a", "an", "and", "as", "at", "but", "by", "for", "from", "in", "into", "nor", "of", "on", "or", "over", "per", "the", "to", "upon", "vs.", "with", "gi"};
                    bool bTextBefore = false;
                    for (int i = 0; i < terms.Length; i++)
                    {
                        if(bTextBefore)
                            text += " ";
                        else
                            bTextBefore = true;

                        if (stopwords.Contains(terms[i]))
                            text += terms[i];
                        else
                            text += terms[i].Substring(0, 1).ToUpper() + terms[i].Substring(1);
                    }
                    if(text.Length > 0)
                        text = text.Substring(0, 1).ToUpper() + text.Substring(1);

                    break;
                case Capitalization.AllCapital:
                    text = item.Title.Substring(0, 1).ToUpper() + item.Title.Substring(1).ToLower();
                    break;
            }
            text = Regex.Replace(text, @"^\s+|\.*\s*$", "");
            text = CitationTools.ApplyStandardFormat(this, text, bInHtmlFormat);
            return text;
        }
예제 #11
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     string pages = item.Pages;
     bool bIsJournal = item.ItemTypeID == ItemTypes.JournalArticle;
     string text = string.Empty;
     if (Regex.Replace(item.Pages, @"\s+", "").Length == 0)
         return text;
     string[] pageTokens = Regex.Split(pages, @"\s*[" + Convert.ToChar(8211).ToString() + "|" + Convert.ToChar(45).ToString() + @"]\s*");
     string startpage = string.Empty;
     string endpage = string.Empty;
     if (pageTokens.Length > 0)
         startpage = Regex.Replace(pageTokens[0], @"^\s+|\s+$", "");
     if (pageTokens.Length > 1)
     {
         endpage = Regex.Replace(pageTokens[1], @"^\s+|\s+$", "");
         if (endpage.Length < startpage.Length)
             endpage = startpage.Substring(0, startpage.Length - endpage.Length) + endpage;
     }
     switch (this.PageFormat)
     {
         case PageNumberFormat.AsIs:
         default:
             text = pages;
             break;
         case PageNumberFormat.FirstPageOnly:
             text = startpage;
             break;
         case PageNumberFormat.LastPageOnly:
             text = endpage;
             break;
         case PageNumberFormat.Full:
             text = startpage;
             if (endpage.Length > 0)
                 text += "-" + endpage;
             break;
         case PageNumberFormat.AbbrLastPageOneDigit:
             for (int i = 0; i < startpage.Length && endpage.Length > 0; i++)
             {
                 if (startpage.Substring(i, 1) == endpage.Substring(0, 1))
                     endpage = endpage.Substring(1);
                 else
                     break;
             }
             text = startpage;
             if (endpage.Length > 0)
                 text += '-' + endpage;
             break;
         case PageNumberFormat.AbbrLastPageTwoDigits:
             for (int i = 0; i < startpage.Length && endpage.Length > 0; i++)
             {
                 if (startpage.Substring(i, 1) == endpage.Substring(0, 1) && endpage.Length > 2)
                     endpage = endpage.Substring(1);
                 else
                     break;
             }
             text = startpage;
             if (endpage.Length > 0)
                 text += '-' + endpage;
             break;
         case PageNumberFormat.FirstPageOnlyForJournals:
             text = startpage;
             if (!bIsJournal)
             {
                 if (endpage.Length > 0)
                     text += '-' + endpage;
             }
             break;
     }
     text = CitationTools.ApplyStandardFormat(this, text, bInHtmlFormat);
     return text;
 }
예제 #12
0
        public bool SetNotFound(ItemMasterRow item)
        {
            string hash = CitationTools.GetItemHash(item);
            int index = this.MasterHashList.IndexOf(hash);
            if(index > -1)
            {
                this.MasterRefList.RemoveAt(index);
                this.MasterURLList.RemoveAt(index);
                this.MasterHashList.RemoveAt(index);
                foreach (TextCitationItem tci in this.TextCitations)
                    tci.SetNotFound(item);
                return true;
            }

            return false;
        }
예제 #13
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     string link = string.Empty;
     if (item.ItemTypeID == ItemTypes.WebPage)
         link = item.Affiliation;
     else
         link = item.Links;
     if (Regex.Replace(link, @"\s+", "").Length == 0)
         return string.Empty;
     return CitationTools.ApplyStandardFormat(this, link, bInHtmlFormat);
 }
예제 #14
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     return CitationTools.FormateDate(item.IssueDate, this, bInHtmlFormat);
 }
예제 #15
0
        private ReferenceCitationItem getRCI()
        {
            ReferenceCitationItem rci = new ReferenceCitationItem();
            try
            {
                rci.DocType = "MSWORD";
                TextCitationItem currtci = null;
                WordHyperLink prevlink = null;
                int fieldDelCount = 0;
                List<int> listDeletedFields = new List<int>();
                List<int> listNullURL = new List<int>();
                int iLinkCount = editor.GetLinkCount();
                for (int i = 1; i <= iLinkCount; i++)
                {
                    try
                    {
                        WordHyperLink link = editor.GetLinkAt(i);
                        if (link == null || link.URL == null)
                        {
                            listNullURL.Add(i);
                            fieldDelCount++;
                            prevlink = null;
                            continue;
                        }
                        else if (Regex.Match(link.URL, @"pifolio\.com", RegexOptions.IgnoreCase).Success)//from wizfolio to pifolio
                        {
                            if (Regex.Match(link.URL, @"\?citation\=1&", RegexOptions.IgnoreCase).Success)
                            {
                                string strRangeText = string.Empty;
                                if (prevlink == null)
                                    strRangeText = " ";
                                else if (prevlink != null && prevlink.End != link.Start)
                                    strRangeText = editor.GetTextInRange(prevlink.End, link.Start);

                                if (rci.TextCitations.Count == 0 || strRangeText.Length > 0)
                                {
                                    currtci = new TextCitationItem(rci);
                                    rci.TextCitations.Add(currtci);
                                }
                                Dictionary<string, object> obj = CitationTools.ParseQueryString(link.URL);
                                ItemMasterRow item = new ItemMasterRow();
                                item.UserID = obj["UserID"] + "";
                                item.ItemID = int.Parse(obj["ItemID"] + "");
                                item.AccessCode = obj["AccessCode"] + "";
                                currtci.AddItem(item, link.URL, i - fieldDelCount, "");
                            }
                            else if (Regex.Match(link.URL, @"\?style\=1&", RegexOptions.IgnoreCase).Success)
                            {
                                if (rci.FieldIndex == -1)
                                {
                                    rci.URL = link.URL;
                                    rci.FieldIndex = i - fieldDelCount;
                                    Dictionary<string, object> obj = CitationTools.ParseQueryString(link.URL);
                                    rci.StyleInfo = new StyleInformation(int.Parse(obj["UserID"] + ""), obj["StyleName"] + "");
                                    if (rci.StyleInfo.UserID != -1)
                                        rci.UserList[rci.StyleInfo.UserID] = new User(rci.StyleInfo.UserID);
                                }
                                else
                                {
                                    listDeletedFields.Add(i);
                                    fieldDelCount++;
                                }
                            }
                            else
                            {
                                prevlink = null;
                                continue;
                            }
                            prevlink = link;
                        }
                        else
                        {
                            prevlink = null;
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        log.WriteLine(LogType.Error, "DocumentFormatter::getRCI", ex.ToString());
                    }
                }
                fieldDelCount = 0;
                for (int i = 0; i < listNullURL.Count; i++)
                {
                    editor.RemoveHyperLink(listNullURL[i] - fieldDelCount);
                    fieldDelCount++;
                }
                for (int i = 0; i < listDeletedFields.Count; i++)
                {
                    editor.RemoveCitation(listDeletedFields[i] - fieldDelCount);
                    fieldDelCount++;
                }
            }
            catch(Exception ex)
            {
                log.WriteLine(LogType.Error, "DocumentFormatter::getRCI", ex.ToString());
            }
            return rci;
        }
예제 #16
0
파일: PubMed.cs 프로젝트: ssc1223/piCite
        /// <summary>
        /// _s the fetch item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="strPMID">The STR PMID.</param>
        /// <returns></returns>
        private bool _ProcessingNode(XmlDocument xmlDoc, ref ItemMasterRow item)
        {
            Dictionary<string, string> Data = new Dictionary<string, string>();
            item.ItemTypeID = ItemTypes.JournalArticle;

            XmlNodeList authorsList = xmlDoc.SelectNodes("//Article/AuthorList/Author");
            int count = 0;
            foreach (XmlNode author in authorsList)
            {
                XmlNode lastname = author.SelectSingleNode("LastName");
                XmlNode firstname = author.SelectSingleNode("ForeName");
                if(lastname != null && firstname != null){
                    NameMasterRow nmr = new NameMasterRow();
                    nmr.NameTypeID = NameTypes.Author;
                    nmr.SequenceNo = count;
                    count++;
                    nmr.LastName = lastname.InnerText;
                    nmr.ForeName = firstname.InnerText;
                    item.Authors.Add(nmr);
                }
            }

            XmlNode node = xmlDoc.SelectSingleNode("//Article/Abstract/AbstractText");
            if(node != null)
                item.Abstract = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Affiliation");
            if (node != null)
                item.Affiliation = node.InnerText;

            node = xmlDoc.SelectSingleNode("//PMID");
            if (node != null)
                item.ID2 = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/ArticleTitle");
            if (node != null)
                item.Title = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Journal/ISSN");
            if (node != null)
                item.ID1 = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Journal//Volume");
            if (node != null)
                item.Volume = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Journal//Issue");
            if (node != null)
                item.Volume2 = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Journal//PubDate/Year");
            if (node != null)
            {
                item.PubDate = node.InnerText;
                item.PubYear = node.InnerText;
            }

            node = xmlDoc.SelectSingleNode("//Article/Journal/Title");
            if (node != null)
                item.Title2 = node.InnerText;

            node = xmlDoc.SelectSingleNode("//Article/Pagination/MedlinePgn");
            if (node != null)
                item.Pages = node.InnerText;

            node = xmlDoc.SelectSingleNode("//ArticleIdList/ArticleId[@IdType=doi]");
            if (node != null)
                item.DOI = node.InnerText;

            item.Links += "mainLink|" + PUBMED_LINK.Replace("{pmid}", item.ID2) + "|";
            item.Links += "relatedLinks|" + PUBMED_RELATEDLINK.Replace("{pmid}", item.ID2);

            return true;
        }
예제 #17
0
파일: CiteULike.cs 프로젝트: ssc1223/piCite
        /// <summary>
        /// _s the processing node.
        /// </summary>
        /// <param name="ProcessingNode">The processing node.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        private bool _ProcessingNode(XmlNode ProcessingNode, XmlNamespaceManager nm, ref ItemMasterRow item)
        {
            try
            {
                item.ItemTypeID = ItemTypes.JournalArticle;
                XmlNode node = ProcessingNode.SelectSingleNode("//rss:title", nm);
                if(node!=null)
                    item.Title = node.InnerText;

                node = ProcessingNode.SelectSingleNode("//rss:link", nm);
                if (node != null)
                    item.Links += "mainLink|" + node.InnerText + "|";

                node = ProcessingNode.SelectSingleNode("//rss:description", nm);
                if (node != null)
                {
                    string strContent = node.InnerText;
                    strContent = Regex.Replace(strContent, @"[\n|\t|\r]", "");
                    strContent = Regex.Replace(strContent, @"<i>.*?</i>", "");
                    strContent = Regex.Replace(strContent, @"<.*?>", "");
                    item.Abstract = strContent;
                }

                node = ProcessingNode.SelectSingleNode("//prism:publicationYear", nm);
                if (node != null)
                {
                    item.PubDate = node.InnerText;
                    item.PubYear = Regex.Match(item.PubDate, @"\d{4}").Value;
                }

                node = ProcessingNode.SelectSingleNode("//prism:publicationName", nm);
                if (node != null)
                    item.Title2 = node.InnerText;

                node = ProcessingNode.SelectSingleNode("//prism:volume", nm);
                if (node != null)
                    item.Volume = node.InnerText;

                node = ProcessingNode.SelectSingleNode("//prism:number", nm);
                if (node != null)
                    item.Volume2 = node.InnerText;

                node = ProcessingNode.SelectSingleNode("//dc:identifier", nm);
                if (node != null)
                {
                    string strContent = node.InnerText;
                    item.DOI = Regex.Replace(strContent, @"^doi:", "", RegexOptions.IgnoreCase);
                }
                int count = 0;
                foreach(XmlNode sNode in ProcessingNode.SelectNodes("//dc:creator", nm))
                {
                    NameMasterRow nmr = new NameMasterRow();
                    nmr.NameTypeID = NameTypes.Author;
                    nmr.SequenceNo = count;
                    count++;
                    string strContent = sNode.InnerText;
                    int index = strContent.LastIndexOf(" ");
                    nmr.LastName = strContent.Substring(index);
                    nmr.ForeName = strContent.Substring(0, index);
                    item.Authors.Add(nmr);
                }

                node = ProcessingNode.SelectSingleNode("//prism:publisher", nm);
                if(node!=null)
                {
                    NameMasterRow nmr = new NameMasterRow();
                    nmr.NameTypeID = NameTypes.Publisher;
                    nmr.LastName = node.InnerText;
                    nmr.ForeName = "";
                    item.Authors.Add(nmr);
                }

                return true;
            }
            catch
            { }

            return false;
        }
예제 #18
0
 /// <summary>
 /// Gets the item hash.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public static string GetItemHash(ItemMasterRow item)
 {
     return item.UserID + "_" + item.ItemID;
 }
예제 #19
0
        /// <summary>
        /// Formats the citation screen tip.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static string FormatCitationScreenTip(ItemMasterRow item)
        {
            string screentip = string.Empty;
            foreach (NameMasterRow name in item.Authors)
            {
                if (name.NameTypeID == NameTypes.Author)
                {
                    screentip += name.LastName;
                    break;
                }
            }
            if (item.PubYear.Length > 0 || item.PubDate.Length > 0 || item.IssueDate.Length > 0 || item.Date3.Length > 0)
            {
                string date = item.PubYear.Length > 0 ? item.PubYear : (item.PubDate.Length > 0 ? item.PubDate : (item.IssueDate.Length > 0 ? item.IssueDate : (item.Date3.Length > 0 ? item.Date3 : "")));
                screentip += date.Length > 0 ? ((screentip.Length > 0 ? ", " : "") + date) : "";
            }
            if (screentip.Length > 0)
                screentip = "(" + screentip + ")";

            if (item.Title.Length > 0)
                screentip = (item.Title.Length > Properties.Settings.Default.DEFAULT_SCREENTIP_TITLE_WORDLIMIT ? (item.Title.Substring(0, Properties.Settings.Default.DEFAULT_SCREENTIP_TITLE_WORDLIMIT) + "...") : item.Title) + "\r\n" + screentip;

            return screentip;
        }
예제 #20
0
 public ReferenceCitationItem CreateRCI()
 {
     ReferenceCitationItem currrci = new ReferenceCitationItem();
     currrci.OldFormatString = this.OldFormatString;
     currrci.FormatString = this.FormatString;
     currrci.FieldIndex = this.FieldIndex;
     currrci.DocType = this.DocType;
     currrci.URL = this.URL;
     currrci.StyleInfo = this.StyleInfo;
     if (Regex.Match(this.URL, @"\?style\=(.*?)$", RegexOptions.IgnoreCase).Success)
     {
         Dictionary<string, object> obj = CitationTools.ParseQueryString(this.URL);
         currrci.StyleInfo = new StyleInformation(int.Parse(obj["UserID"] + ""), obj["StyleName"]+"");
         if(currrci.StyleInfo.UserID != -1)
             currrci.UserList[currrci.StyleInfo.UserID] = new User(currrci.StyleInfo.UserID);
     }
     List<TextCitationItem> newtci = this.TextCitations;
     TextCitationItem currtci;
     for (int i = 0; i < newtci.Count; i++)
     {
         currtci = currrci.AddBlock();
         currtci.FormatString = newtci[i].FormatString;
         currtci.FieldIndexes = newtci[i].FieldIndexes;
         if(newtci[i].StartIndex != -1)
         {
             currtci.StartIndex = newtci[i].StartIndex;
         }
         for(int j=0; j<newtci[i].URLList.Count; j++)
         {
             Dictionary<string, object> obj = CitationTools.ParseQueryString(newtci[i].URLList[j]);
             ItemMasterRow item = new ItemMasterRow();
             item.UserID = obj["UserID"] + "";
             item.ItemID = int.Parse(obj["ItemID"] + "");
             item.AccessCode = obj["AccessCode"] + "";
             currtci.AddItem(item, newtci[i].URLList[j], newtci[i].FieldIndexes[j], newtci[i].FormatString[j]);
         }
     }
     return currrci;
 }
예제 #21
0
파일: PubMed.cs 프로젝트: ssc1223/piCite
        /// <summary>
        /// Gets the total.
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, object> GetResults(int iStart)
        {
            if (SearchQuery == string.Empty || SearchQuery.Length == 0)
                return null;

            Dictionary<string, object> Data = new Dictionary<string, object>();
            Int64 iTotal = 0;
            string strPubMedSearchURL = PUBMED_SEARCHURL.Replace("{term}", SearchQuery);
            strPubMedSearchURL = strPubMedSearchURL.Replace("{start}", iStart + "");
            strPubMedSearchURL = strPubMedSearchURL.Replace("{max}", Properties.Settings.Default.NUM_OF_SEARCH_RESULTS_PER_PAGE + "");
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(strPubMedSearchURL);
                XmlNodeList resultNodeList = xmlDoc.SelectNodes("/eSearchResult/Count");
                if (resultNodeList.Count > 0)
                {
                    iTotal = Int64.Parse(resultNodeList[0].InnerText);
                }
                Data["Count"] = iTotal;
                List<string> listPMID = new List<string>();
                if (iTotal > 0)
                {
                    XmlNodeList pubmedIDList = xmlDoc.SelectNodes("/eSearchResult/IdList/Id");
                    if (pubmedIDList.Count > 0)
                    {
                        foreach (XmlNode node in pubmedIDList)
                            listPMID.Add(node.InnerText);
                    }
                }
                JavaScriptSerializer sr = new JavaScriptSerializer();
                string pmids = String.Join(",", listPMID.ToArray());

                strPubMedSearchURL = PUBMED_FETCHURL.Replace("{pmid}", pmids);
                xmlDoc = new XmlDocument();
                xmlDoc.Load(strPubMedSearchURL);
                List<ItemMasterRow> listItems = new List<ItemMasterRow>();
                XmlNodeList resultNodes = _FindResultNodes(xmlDoc);
                if (resultNodes != null)
                {
                    foreach (XmlNode node in resultNodes)
                    {
                        ItemMasterRow item = new ItemMasterRow();
                        XmlDocument newXmlDoc = new XmlDocument();
                        newXmlDoc.LoadXml(node.OuterXml);
                        if (_ProcessingNode(newXmlDoc, ref item))
                        {
                            listItems.Add(item);
                        }
                    }
                }
                if (listItems.Count > 0)
                {
                    Data["ItemList"] = listItems;
                }

            }
            catch
            { }
            return Data;
        }
예제 #22
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public override string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     List<NameMasterRow> authors = item.Authors;
     string text = string.Empty;
     if (Tools.CitationTools.CountAuthor(authors, NameTypes.Author) > 0)
     {
         text = Tools.CitationTools.FormatAuthor(authors, this, NameTypes.Author, bInHtmlFormat);
     }
     return text;
 }
예제 #23
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     if (Regex.Replace(item.Volume2, @"\s+", "").Length == 0)
         return string.Empty;
     return CitationTools.ApplyStandardFormat(this, item.Volume2, bInHtmlFormat);
 }
예제 #24
0
 public bool GetItem(ref ItemMasterRow item, int itemID)
 {
     foreach (ItemMasterRow curritem in itemList)
     {
         if (curritem.ItemID == itemID)
         {
             item = curritem;
             return true;
         }
     }
     return false;
 }
예제 #25
0
파일: Fields.cs 프로젝트: ssc1223/piCite
        public string Format(ItemMasterRow item, bool bInHtmlFormat)
        {
            string text = string.Empty;
            text = item.Title2;
            if(NameFormat == JournalNameFormat.Abbreviation)
            {
                if (Regex.Replace(item.JournalAbbr, @"\s+", "").Length > 0)
                    text = item.JournalAbbr;
            }

            if (this.RemovePeriod)
                text.Replace(".", "");

            if(IsAPA && text.Length > 0)
            {
                string temp = string.Empty;
                // Capitalization each words
                string[] terms = Regex.Split(text.ToLower(), @"\s+");
                string[] stopwords = { "a", "an", "and", "as", "at", "but", "by", "for", "from", "in", "into", "nor", "of", "on", "or", "over", "per", "the", "to", "upon", "vs.", "with", "gi" };
                bool bTextBefore = false;
                for (int i = 0; i < terms.Length; i++)
                {
                    if (bTextBefore)
                        temp += " ";
                    else
                        bTextBefore = true;

                    if (stopwords.Contains(terms[i]))
                        temp += terms[i];
                    else
                        temp += terms[i].Substring(0, 1).ToUpper() + terms[i].Substring(1);
                }
                if (temp.Length > 0)
                    temp = temp.Substring(0, 1).ToUpper() + temp.Substring(1);

                text = temp;
            }

            text = CitationTools.ApplyStandardFormat(this, text, bInHtmlFormat);
            return text;
        }
예제 #26
0
 private void _ConvertBibTex2WizFolioItemType(ref ItemMasterRow item, string strBibTexItemType)
 {
     item.ItemTypeID = mappingBibTex2WizFolio.ContainsKey(strBibTexItemType) ? mappingBibTex2WizFolio[strBibTexItemType] : ItemTypes.JournalArticle;
 }
예제 #27
0
파일: Fields.cs 프로젝트: ssc1223/piCite
 public string Format(ItemMasterRow item, bool bInHtmlFormat)
 {
     return CitationTools.ApplyStandardFormat(this, item.SequenceNo + "", bInHtmlFormat);
 }
예제 #28
0
        private bool _ProcessBibTexBlock(ref ItemMasterRow item, string strBibTexBlock)
        {
            _InitializeBibTexParser();
            Dictionary<string, string> dataBibTex = new Dictionary<string, string>();
            try
            {

                if (_ParseBibTexBlock(ref dataBibTex, strBibTexBlock))
                {
                    item = new ItemMasterRow();

                    item.ItemTypeID = ItemTypes.JournalArticle;
                    if (dataBibTex.ContainsKey("ItemType"))
                        _ConvertBibTex2WizFolioItemType(ref item, dataBibTex["ItemType"].ToLower());

                    item.Title = dataBibTex.ContainsKey("Title") ? dataBibTex["Title"] : item.Title;
                    item.Title2 = dataBibTex.ContainsKey("Title2") ? dataBibTex["Title2"] : item.Title2;
                    item.Affiliation = dataBibTex.ContainsKey("Affiliation") ? dataBibTex["Affiliation"] : item.Affiliation;
                    item.Edition = dataBibTex.ContainsKey("Edition") ? dataBibTex["Edition"] : item.Edition;
                    item.Volume = dataBibTex.ContainsKey("Volume") ? dataBibTex["Volume"] : item.Volume;
                    item.Volume2 = dataBibTex.ContainsKey("Volume2") ? dataBibTex["Volume2"] : item.Volume2;
                    item.Abstract = dataBibTex.ContainsKey("Abstract") ? dataBibTex["Abstract"] : item.Abstract;
                    item.Notes = dataBibTex.ContainsKey("Notes") ? dataBibTex["Notes"] : item.Notes;
                    item.PubPlace = dataBibTex.ContainsKey("PubPlace") ? dataBibTex["PubPlace"] : item.PubPlace;
                    item.PubDate = dataBibTex.ContainsKey("PubDate") ? dataBibTex["PubDate"] : item.PubDate;
                    item.Pages = dataBibTex.ContainsKey("Pages") ? dataBibTex["Pages"] : item.Pages;
                    item.ID1 = dataBibTex.ContainsKey("ID1") ? dataBibTex["ID1"] : item.ID1;
                    item.Links = dataBibTex.ContainsKey("Links") ? ("Source|" + dataBibTex["Links"] + "|") : item.Links;
                    item.Keywords = dataBibTex.ContainsKey("Keywords") ? dataBibTex["Keywords"] : item.Keywords;
                    if (dataBibTex.ContainsKey("Authors"))
                    {
                        string[] Contributors = dataBibTex["Authors"].Split('|');
                        for (int i = 0; i < Contributors.Length - 1; i = i + 2)
                        {
                            NameMasterRow Contributor = new NameMasterRow();
                            Contributor.LastName = Contributors[i];
                            Contributor.ForeName = Contributors[i + 1];
                            Contributor.SequenceNo = i / 2;
                            item.Authors.Add(Contributor);
                        }
                    }
                    if (item.ItemTypeID == ItemTypes.BookWhole || item.ItemTypeID == ItemTypes.BookChapter)
                    {
                        if (dataBibTex.ContainsKey("Editors"))
                        {
                            string[] editors = dataBibTex["Editors"].Split('|');
                            for (int i = 0; i < editors.Length - 1; i = i + 2)
                            {
                                NameMasterRow editor = new NameMasterRow();
                                editor.NameTypeID = NameTypes.Editor;
                                editor.LastName = editors[i];
                                editor.ForeName = editors[i + 1];
                                editor.SequenceNo = i / 2;
                                item.Authors.Add(editor);
                            }
                        }
                    }
                    if (item.ItemTypeID == ItemTypes.BookWhole || item.ItemTypeID == ItemTypes.BookChapter || item.ItemTypeID == ItemTypes.Proceeding)
                    {
                        if (dataBibTex.ContainsKey("Publisher"))
                        {
                            NameMasterRow publisher = new NameMasterRow();
                            publisher.NameTypeID = NameTypes.Publisher;
                            publisher.LastName = dataBibTex["Publisher"];
                            publisher.ForeName = "";
                            item.Authors.Add(publisher);
                        }
                    }
                    item.Trim();
                }
            }
            catch
            {
                return false;
            }

            return true;
        }
예제 #29
0
 private string prepareFullText(ItemMasterRow item)
 {
     StringBuilder sb = new StringBuilder();
     int iFilterFields = Properties.Settings.Default.DEFAULT_FILTER_FIELDS;
     if ((iFilterFields & (int)FilterFields.Title) == (int)FilterFields.Title)
         sb.Append(item.Title + " ");
     if ((iFilterFields & (int)FilterFields.Title2) == (int)FilterFields.Title2)
         sb.Append(item.Title2 + " ");
     if ((iFilterFields & (int)FilterFields.Authors) == (int)FilterFields.Authors)
         sb.Append(item.Author + " ");
     if ((iFilterFields & (int)FilterFields.Abstract) == (int)FilterFields.Abstract)
         sb.Append(item.Abstract + " ");
     if ((iFilterFields & (int)FilterFields.Keywords) == (int)FilterFields.Keywords)
         sb.Append(item.Keywords + " ");
     if ((iFilterFields & (int)FilterFields.Notes) == (int)FilterFields.Notes)
         sb.Append(item.Notes + " ");
     if ((iFilterFields & (int)FilterFields.PubDate) == (int)FilterFields.PubDate)
     {
         sb.Append(item.PubDate + " ");
         if(item.ItemTypeID == ItemTypes.Patent)
             sb.Append(item.IssueDate + " " + item.Date3 + " ");
     }
     if ((iFilterFields & (int)FilterFields.Tags) == (int)FilterFields.Tags)
         sb.Append(item.Tags + " ");
     return sb.ToString();
 }
예제 #30
0
파일: WorldCat.cs 프로젝트: ssc1223/piCite
        private bool _ProcessingNode(XmlNode ProcessingNode, XmlNamespaceManager nm, ref ItemMasterRow item)
        {
            try
            {
                item.ItemTypeID = ItemTypes.BookWhole;
                XmlNode node = ProcessingNode.SelectSingleNode("//atom:title", nm);
                if (node != null)
                    item.Title = node.InnerText;

                node = ProcessingNode.SelectSingleNode("//atom:link", nm);
                if (node != null)
                    item.Links += "mainLink|" + node.Attributes["href"].Value + "|";

                node = ProcessingNode.SelectSingleNode("//atom:summary", nm);
                if (node != null)
                {
                    string strContent = node.InnerText;
                    item.Abstract = strContent;
                }

                node = ProcessingNode.SelectSingleNode("//oclcterms:recordIdentifier", nm);
                if (node != null)
                {
                    string id = node.InnerText;
                    string strItemDetailsURL = WORLDCAT_ITEMURL.Replace("{identifier}", id);
                    strItemDetailsURL = strItemDetailsURL.Replace("{key}", WORLDCAT_APIKEY);
                    XmlDocument xmlItemDoc = new XmlDocument();
                    xmlItemDoc.Load(strItemDetailsURL);
                    XmlNamespaceManager nmItem = new XmlNamespaceManager(xmlItemDoc.NameTable);
                    nmItem.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");

                    int count = 0;
                    foreach (XmlNode sNode in xmlItemDoc.SelectNodes("//dc:creator", nmItem))
                    {
                        string text = sNode.InnerText;
                        string[] split = Regex.Split(text, @"\s*\,\s*");
                        if(split.Length > 1)
                        {
                            NameMasterRow nmr = new NameMasterRow();
                            nmr.NameTypeID = NameTypes.Author;
                            nmr.SequenceNo = count;
                            count++;
                            nmr.LastName = Regex.Replace(split[0], @"^\s+|\s+$|\.\s*$", "");
                            nmr.ForeName = Regex.Replace(split[1], @"^\s+|\s+$|\.\s*$", "");
                            item.Authors.Add(nmr);
                        }
                    }
                    foreach (XmlNode sNode in xmlItemDoc.SelectNodes("//dc:contributor", nmItem))
                    {
                        string text = sNode.InnerText;
                        string[] split = Regex.Split(text, @"\s*\,\s*");
                        if (split.Length > 1)
                        {
                            NameMasterRow nmr = new NameMasterRow();
                            nmr.NameTypeID = NameTypes.Author;
                            nmr.SequenceNo = count;
                            count++;
                            nmr.LastName = Regex.Replace(split[0], @"^\s+|\s+$|\.\s*$", "");
                            nmr.ForeName = Regex.Replace(split[1], @"^\s+|\s+$|\.\s*$", "");
                            item.Authors.Add(nmr);
                        }
                    }
                    foreach (XmlNode sNode in xmlItemDoc.SelectNodes("//dc:publisher", nmItem))
                    {
                        NameMasterRow nmr = new NameMasterRow();
                        nmr.NameTypeID = NameTypes.Publisher;
                        nmr.SequenceNo = count;
                        count++;
                        nmr.LastName = Regex.Replace(sNode.InnerText, @"^\s+|\s+$|\.\s*$", "");
                        item.Authors.Add(nmr);
                    }

                    XmlNode tempNode = xmlItemDoc.SelectSingleNode("//dc:date", nmItem);
                    if(tempNode != null)
                    {
                        if (Regex.Match(tempNode.InnerText, @"\d{4}").Success)
                        {
                            item.PubYear = item.PubDate = Regex.Match(tempNode.InnerText, @"\d{4}").Value;
                        }
                    }

                    tempNode = xmlItemDoc.SelectSingleNode("//dc:format", nmItem);
                    if(tempNode != null)
                    {
                        if (Regex.Match(tempNode.InnerText, @"\d+\sp\.\s").Success)
                        {
                            string temp = Regex.Match(tempNode.InnerText, @"\d+\sp\.\s").Value;
                            item.Pages = Regex.Match(temp, @"\d+").Value;
                        }
                    }

                    //XmlNodeList listKeyNodes = xmlItemDoc.SelectNodes("//dc:subject", nmItem);
                    //foreach (XmlNode sNode in listKeyNodes)
                    //{
                    //    if (sNode.Attributes["xsi:type"].Value.Contains("LCSH"))
                    //        item.Keywords += sNode.InnerText + "|";
                    //}
                }

                return true;
            }
            catch
            { }

            return false;
        }