Example #1
0
        public List <NameSearchResult> NamesSearch()
        {
            List <NameSearchResult> retVal = new List <NameSearchResult>();

            HtmlNode table = doc.DocumentNode.SelectSingleNode($"//table[@class='{ID_NAMES_SEARCH}']");

            if (null != table)
            {
                HtmlNodeCollection rows = table.SelectNodes("tr");
                foreach (HtmlNode row in rows)
                {
                    HtmlNodeCollection cells = row.SelectNodes("td");
                    if (!String.IsNullOrWhiteSpace(cells[0].InnerText) &&
                        cells[0].InnerHtml.Contains("<strong>"))
                    {
                        continue;
                    }

                    NameSearchResult searchResult = new NameSearchResult();
                    if (cells.Count == 3)
                    {
                        int occurs = Int32.Parse(cells[1].InnerText);
                        searchResult.Occurs = occurs;
                        searchResult.Name   = cells[2].InnerText;
                        retVal.Add(searchResult);
                    }
                }
            }
            Log.Debug($"Search resulted in {retVal.Count} names");

            return(retVal);
        }
Example #2
0
        private NameSearchResult GetPageNameSearchResult(CustomGenericList <CustomDataRow> data)
        {
            NameSearchResult result = new NameSearchResult();

            result.QueryDate = DateTime.Now.ToString("dd MMM yyyy h:mmtt");

            //loop through the results and create a list of NameSearchTitle objects
            int lastTitleID = -1;
            int lastItemID  = -1;

            //List<NameSearchTitle> titleList = new List<NameSearchTitle>();
            foreach (CustomDataRow row in data)
            {
                int currentTitleID = (int)row["TitleID"].Value;
                if (currentTitleID != lastTitleID)
                {
                    NameSearchTitle title = new NameSearchTitle();
                    title.TitleID    = (int)row["TitleID"].Value;
                    title.ShortTitle = (string)row["ShortTitle"].Value;
                    title.SortTitle  = (string)row["SortTitle"].Value;
                    title.MarcBibID  = (string)row["MarcBibID"].Value;

                    result.Titles.Add(title);
                }
                NameSearchTitle currentTitle = result.Titles[result.Titles.Count - 1];

                int currentItemID = (int)row["ItemID"].Value;
                if (currentItemID != lastItemID)
                {
                    NameSearchItem item = new NameSearchItem();
                    item.ItemID       = (int)row["ItemID"].Value;
                    item.ItemSequence = (short)row["ItemSequence"].Value;
                    item.Volume       = (string)row["ItemVolume"].Value;

                    currentTitle.Items.Add(item);
                }

                NameSearchItem currentItem = currentTitle.Items[currentTitle.Items.Count - 1];
                NameSearchPage page        = new NameSearchPage();
                page.PageID         = (int)row["PageID"].Value;
                page.SequenceOrder  = (int)row["SequenceOrder"].Value;
                page.IndicatedPages = (string)row["IndicatedPages"].Value;
                currentTitle.TotalPageCount++;
                currentItem.Pages.Add(page);

                lastTitleID = currentTitleID;
                lastItemID  = currentItemID;
            }
            return(result);
        }
Example #3
0
        public NameSearchResult PageNameSearchForTitles(string name, string languageCode)
        {
            CustomGenericList <CustomDataRow> data = GetPageNameDalInstance().PageNameSearchForTitles(null, null,
                                                                                                      name, languageCode);

            NameSearchResult result = new NameSearchResult();

            result.QueryDate = DateTime.Now.ToString("dd MMM yyyy h:mmtt");

            //loop through the results and create a list of NameSearchTitle objects
            foreach (CustomDataRow row in data)
            {
                NameSearchTitle title = new NameSearchTitle();
                title.TitleID        = (int)row["TitleID"].Value;
                title.ShortTitle     = (string)row["ShortTitle"].Value + " " + (string)row["PartNumber"].Value + " " + (string)row["PartName"].Value;
                title.SortTitle      = (string)row["SortTitle"].Value;
                title.MarcBibID      = (string)row["MarcBibID"].Value;
                title.TotalPageCount = (int)row["TotalPageCount"].Value;
                result.Titles.Add(title);
            }
            return(result);
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type     = Request.QueryString["type"];
            string name     = Request.QueryString["name"];
            string pagetype = Request.QueryString["pagetype"];

            if (type != null && name != null && pagetype != null &&
                type.Length > 0 && name.Length > 0 && pagetype.Length > 0)
            {
                StringBuilder sb = new StringBuilder();
                BHLProvider   bp = new BHLProvider();

                NameSearchResult result   = bp.PageNameSearch(name, int.Parse(pagetype), "");
                string           sGenName = name;
                if (type.ToLower().Equals("bibtex"))
                {
                    sGenName += ".bibtex";
                }
                else if (type.ToLower().Equals("endnote"))
                {
                    sGenName += ".endnote";
                }

                foreach (NameSearchTitle title in result.Titles)
                {
                    foreach (NameSearchItem item in title.Items)
                    {
                        foreach (NameSearchPage page in item.Pages)
                        {
                            if (type.ToLower().Equals("bibtex"))
                            {
                                sb.Append("@Page{pageid:");
                                sb.Append(page.PageID.ToString());
                                sb.Append("\r\n");
                                sb.Append("\ttitle = \"");
                                sb.Append(title.ShortTitle);
                                sb.Append("\",\r\n");
                                sb.Append("\titem = \"");
                                sb.Append(item.Volume);
                                sb.Append("\",\r\n");
                                sb.Append("\tpage = \"");
                                if (page.IndicatedPages != null && page.IndicatedPages.Length > 0)
                                {
                                    sb.Append(page.IndicatedPages);
                                }
                                else
                                {
                                    sb.Append(page.SequenceOrder.ToString());
                                }
                                sb.Append("\",\r\n");
                                sb.Append("\turl = \"http://");
                                sb.Append(Request.ServerVariables["HTTP_HOST"]);
                                sb.Append("/page/");
                                sb.Append(page.PageID.ToString());
                                sb.Append("\",\r\n");
                                sb.Append("}");
                                sb.Append("\r\n");
                                sb.Append("\r\n");
                            }
                            else if (type.ToLower().Equals("endnote"))
                            {
                            }
                        }
                    }
                }


                Response.AddHeader("Content-disposition", "attachment; filename=" + sGenName);
                Response.ContentType = "application/octet-stream";
                Response.Write(sb.ToString());
                Response.End();
            }
        }