/// <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; }
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; }
/// <summary> /// Return Author name in desired format /// </summary> /// <param name="name">NameMasterRow authorname</param> /// <param name="format">AuthorFormat format</param> /// <returns></returns> public static string FormatName(NameMasterRow name, AuthorFormat format) { string formatname = string.Empty; string[] temp = Regex.Split(name.ForeName, @"[\s|-]+"); name.Initials = string.Empty; for (int i = 0; i < temp.Length; i++) { if(Regex.Replace(temp[i], @"\s+", "").Length > 0) name.Initials += temp[i].Substring(0, 1) + "|"; } name.Initials = name.Initials.ToUpper(); switch(format) { //William Jefferson Clinton case AuthorFormat.FullNameFirstNameFirst: formatname = name.ForeName; if (formatname.Length > 0) formatname += " " + name.LastName; else formatname = name.LastName; break; //W. J. Clinton case AuthorFormat.InitialWithDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", ". "); if (formatname.Length > 0) formatname += name.LastName; else formatname = name.LastName; break; //W.J. Clinton case AuthorFormat.InitialWithDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", "."); if (formatname.Length > 0) formatname += " " + name.LastName; else formatname = name.LastName; break; //W J Clinton case AuthorFormat.InitialWithoutDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", " "); if (formatname.Length > 0) formatname += name.LastName; else formatname = name.LastName; break; //WJ Clinton case AuthorFormat.InitialWithoutDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", "") + " " + name.LastName; else formatname = name.LastName; break; //Clinton, William Jefferson case AuthorFormat.FullNameLastNameFirstWithComma: formatname = name.LastName; if (name.ForeName.Length > 0) formatname += ", " + name.ForeName; break; //Clinton, W. J. case AuthorFormat.InitialLastNameFirstWithCommaWithDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", ". "); if (formatname.Length > 0) formatname = name.LastName + ", " + Regex.Replace(formatname, @"^\s+|\s+$", ""); else formatname = name.LastName; break; //Clinton, W.J. case AuthorFormat.InitialLastNameFirstWithCommaWithDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", "."); if (formatname.Length > 0) formatname = name.LastName + ", " + formatname; else formatname = name.LastName; break; //Clinton, W J case AuthorFormat.InitialLastNameFirstWithCommaWithoutDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", " "); if (formatname.Length > 0) formatname = name.LastName + ", " + Regex.Replace(formatname, @"^\s+|\s+$", ""); else formatname = name.LastName; break; //Clinton, WJ case AuthorFormat.InitialLastNameFirstWithCommaWithoutDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = name.LastName + ", " + Regex.Replace(formatname, @"\|", ""); else formatname = name.LastName; break; //Clinton case AuthorFormat.LastNameOnly: formatname = name.LastName; break; //Clinton W. J. case AuthorFormat.InitialLastNameFirstWithoutCommaWithDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", ". "); if (formatname.Length > 0) formatname = name.LastName + " " + Regex.Replace(formatname, @"^\s+|\s+$", ""); else formatname = name.LastName; break; //Clinton W.J. case AuthorFormat.InitialLastNameFirstWithoutCommaWithDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", "."); if (formatname.Length > 0) formatname = name.LastName + " " + formatname; else formatname = name.LastName; break; //Clinton W J case AuthorFormat.InitialLastNameFirstWithoutCommaWithoutDot: formatname = name.Initials; if (formatname.Length > 0) formatname = Regex.Replace(formatname, @"\|", " "); if (formatname.Length > 0) formatname = name.LastName + " " + Regex.Replace(formatname, @"^\s+|\s+$", ""); else formatname = name.LastName; break; //Clinton WJ case AuthorFormat.InitialLastNameFirstWithoutCommaWithoutDotWithoutSpace: formatname = name.Initials; if (formatname.Length > 0) formatname = name.LastName + " " + Regex.Replace(formatname, @"\|", ""); else formatname = name.LastName; break; //William J. Clinton case AuthorFormat.FirstNameFirstMidNameInitialWithDot: formatname = name.ForeName + " "; if(name.Initials.Length > 0) { formatname += name.Initials.Substring(0, 1).ToUpper(); } if (formatname.Length > 0) formatname += ". "; formatname += name.LastName; break; //Clinton,W. J. case AuthorFormat.InitialLastNameFirstWithCommaWithDotWithoutSpaceAfterComma: formatname = name.Initials; if (formatname.Length > 0) formatname += Regex.Replace(formatname, @"\|", ". "); if (formatname.Length > 0) formatname = name.LastName + "," + Regex.Replace(formatname, @"^\s+|\s+$", ""); else formatname = name.LastName; break; //Clinton,W.J. case AuthorFormat.InitialLastNameFirstWithCommaWithDotWithoutAnySpace: formatname = name.Initials; if (formatname.Length > 0) formatname += Regex.Replace(formatname, @"\|", "."); if (formatname.Length > 0) formatname = name.LastName + "," + formatname; else formatname = name.LastName; break; } return formatname; }
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; }
/// <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; }
/// <summary> /// _s the processing node. /// </summary> /// <param name="ProcessingNode">The processing node.</param> /// <param name="nm">The nm.</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("//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 + "|"; nm.AddNamespace("atom", "http://scholarsportal.info/metadata"); node = ProcessingNode.SelectSingleNode("//atom:article/atom:publication-date", nm); if (node != null) { item.PubDate = node.InnerText; item.PubYear = Regex.Match(item.PubDate, @"\d{4}").Value; } node = ProcessingNode.SelectSingleNode("//atom:journal/atom:title", nm); if (node != null) item.Title2 = node.InnerText; node = ProcessingNode.SelectSingleNode("//atom:journal/atom:volume", nm); if (node != null) item.Volume = node.InnerText; node = ProcessingNode.SelectSingleNode("//atom:journal/atom:issue", nm); if (node != null) item.Volume2 = node.InnerText; node = ProcessingNode.SelectSingleNode("//atom:pages", nm); if (node != null) { XmlNode fpageNode = node.SelectSingleNode("atom:fpage", nm); XmlNode lpageNode = node.SelectSingleNode("atom:lpage", nm); if (fpageNode != null && lpageNode != null) { item.Pages = fpageNode.InnerText + "-" + lpageNode.InnerText; } } node = ProcessingNode.SelectSingleNode("//atom:journal/atom:issn-ppub", nm); if (node != null) { item.ID1 = node.InnerText; } int count = 0; foreach (XmlNode sNode in ProcessingNode.SelectNodes("//atom:article/atom:authors/atom:author", nm)) { XmlNode givenNameNode = sNode.SelectSingleNode("atom:givenname", nm); XmlNode surNameNode = sNode.SelectSingleNode("atom:surname", nm); if (givenNameNode != null && surNameNode != null) { NameMasterRow nmr = new NameMasterRow(); nmr.NameTypeID = NameTypes.Author; nmr.SequenceNo = count; count++; nmr.LastName = surNameNode.InnerText; nmr.ForeName = givenNameNode.InnerText; item.Authors.Add(nmr); } } node = ProcessingNode.SelectSingleNode("//atom:journal/atom:publisher", nm); if (node != null) { NameMasterRow nmr = new NameMasterRow(); nmr.NameTypeID = NameTypes.Publisher; nmr.LastName = node.InnerText; nmr.ForeName = ""; item.Authors.Add(nmr); } node = ProcessingNode.SelectSingleNode("//atom:article/atom:abstract", nm); if (node != null) { string strContent = node.InnerText; item.Abstract = strContent; } XmlNodeList nodesKeyword = ProcessingNode.SelectNodes("//atom:article/atom:keywords/atom:keyword", nm); foreach (XmlNode keyword in nodesKeyword) { item.Keywords += keyword.InnerText + "|"; } return true; } catch { } return false; }
public static List<NameMasterRow> ConvertWithoutNameID(DataView dv) { List<NameMasterRow> NameList = new List<NameMasterRow>(); string[] strColumns = TableColumns; if (dv.Count > 0) { for (int i = 0; i < strColumns.Length; i++) { if (strColumns[i] == NameMasterColumns.NameID.ToString()) continue; if (!dv.Table.Columns.Contains(strColumns[i])) return NameList; } } for (int i = 0; i < dv.Count; i++) { NameMasterRow nmr = new NameMasterRow(); nmr.NameID = int.MinValue; nmr.DisplayName = dv[i][NameMasterColumns.DisplayName.ToString()] + ""; nmr.ForeName = dv[i][NameMasterColumns.ForeName.ToString()] + ""; nmr.Initials = dv[i][NameMasterColumns.Initials.ToString()] + ""; nmr.LastName = dv[i][NameMasterColumns.LastName.ToString()] + ""; nmr.NameTypeID = (NameTypes)int.Parse(dv[i][NameMasterColumns.NameTypeID.ToString()] + ""); NameList.Add(nmr); } return NameList; }