Esempio n. 1
0
        protected void detailGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("showPageLinkButton"))
            {
                int             rowNum    = int.Parse(e.CommandArgument.ToString());
                int             pageId    = (int)detailGridView.DataKeys[rowNum].Value;
                PageSummaryView ps        = bp.PageSummarySelectByPageId(pageId);
                string          viewerUrl = new BHLProvider().GetPageUrl(ps);

                pageFrame.Attributes.Add("src", viewerUrl);

                // Reset previous row
                if (ViewState["RowNum"] != null)
                {
                    int oldRowNum = int.Parse(ViewState["RowNum"].ToString());
                    if ((oldRowNum - 1) / 2 == oldRowNum / 2)
                    {
                        detailGridView.Rows[oldRowNum].BackColor = System.Drawing.Color.FromArgb(255, 255, 215);
                    }
                    else
                    {
                        detailGridView.Rows[oldRowNum].BackColor = System.Drawing.Color.White;
                    }
                }

                // Shade viewed row
                detailGridView.Rows[rowNum].BackColor = System.Drawing.Color.FromArgb(228, 226, 213);
                ViewState["RowNum"] = rowNum;
            }
        }
Esempio n. 2
0
 private string GetTextUrl(PageSummaryView psv)
 {
     try
     {
         if (new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").FileExists(psv.OcrTextLocation))
         {
             return("/Text.aspx?PageId=" + psv.PageID);
         }
         else
         {
             return("");
         }
     }
     catch
     {
         if (DebugUtility.IsDebugMode(this.Context.Request))
         {
             return("error");
         }
         else
         {
             return("");
         }
     }
 }
Esempio n. 3
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            PageSummaryView ps = (PageSummaryView)Session["Page" + pageIdTextBox.Text];
            CustomGenericList <PageName> pageNames = (CustomGenericList <PageName>)Session["PageNames" + pageIdTextBox.Text];

            if (validate(pageNames))
            {
                BHLProvider bp = new BHLProvider();
                try
                {
                    foreach (PageName pageName in pageNames)
                    {
                        if (pageName.IsNew && pageName.Active)
                        {
                            PageName existingPageName =
                                bp.PageNameSelectByPageIDAndNameFound(ps.PageID, pageName.NameFound);

                            if (existingPageName == null)
                            {
                                pageName.PageID = ps.PageID;
                                pageName.Source = "User Reported";
                                pageName.Active = true;
                                // Get confirmed value and namebankid from uBio
                                FindItItem uBioResult = ubioLookup(pageName.NameFound);
                                if (uBioResult != null)
                                {
                                    pageName.NameConfirmed = TypeHelper.NullIfEmpty(uBioResult.Name);
                                    pageName.NameBankID    = TypeHelper.NullIfZero(uBioResult.NamebankID);
                                }
                            }
                        }
                        else
                        {
                            if (pageName.Active)
                            {
                                FindItItem uBioResult = ubioLookup(pageName.NameFound);
                                if (uBioResult != null && uBioResult.NamebankID >= 0)
                                {
                                    pageName.NameConfirmed = TypeHelper.NullIfEmpty(uBioResult.Name);
                                    pageName.NameBankID    = TypeHelper.NullIfZero(uBioResult.NamebankID);
                                }
                            }
                        }
                    }

                    bp.PageNameSaveList(pageNames);
                }
                catch (Exception ex)
                {
                    Session["Exception"] = ex;
                    Response.Redirect("/Error.aspx");
                }
            }
            else
            {
                return;
            }

            Response.Redirect("/Admin/Dashboard.aspx");
        }
Esempio n. 4
0
 public static PageSummaryModel Map(this PageSummaryView source)
 => new PageSummaryModel
 {
     Status     = source.Status.ToEnum(EditingStatus.Available),
     Count      = source.Count,
     Percentage = source.Percentage
 };
Esempio n. 5
0
        protected void addPageNameButton_Click(object sender, EventArgs e)
        {
            PageSummaryView ps = (PageSummaryView)Session["Page" + pageIdTextBox.Text];
            PageName        pn = new PageName();

            pn.PageID = ps.PageID;
            CustomGenericList <PageName> pageNames = (CustomGenericList <PageName>)Session["PageNames" + pageIdTextBox.Text];

            pageNames.Add(pn);
            pageNameList.EditIndex = pageNames.Count - 1;
            bindPageNameData(false);
        }
Esempio n. 6
0
 private string GetOcrText(PageSummaryView ps)
 {
     try
     {
         return(new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").GetFileText(ps.OcrTextLocation));
     }
     catch (Exception ex)
     {
         return(DebugUtility.GetErrorInfo(this.Context.Request, ex));
     }
     return("");
 }
Esempio n. 7
0
        private void search(int id)
        {
            BHLProvider bp = new BHLProvider();

            PageSummaryView ps = bp.PageSummarySelectByPageId(id);

            Session["Page" + pageIdTextBox.Text] = ps;

            CustomGenericList <PageName> pageNameList = bp.PageNameSelectByPageID(ps.PageID);

            Session["PageNames" + pageIdTextBox.Text] = pageNameList;

            fillUI();
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            String pageIDString = context.Request.QueryString["PageID"] as String;

            if (pageIDString == null)
            {
                return;
            }

            String heightString = context.Request.QueryString["h"] as String;
            String widthString  = context.Request.QueryString["w"] as String;
            int    height;
            int    width;

            if (!Int32.TryParse(heightString, out height))
            {
                height = 300;
            }
            if (!Int32.TryParse(widthString, out width))
            {
                width = 200;
            }

            int pageID;

            if (Int32.TryParse(pageIDString, out pageID))
            {
                BHLProvider     provider = new BHLProvider();
                PageSummaryView ps       = provider.PageSummarySelectByPageId(pageID);
                String          imageUrl = String.Empty;

                if (ps.ExternalURL == null)
                {
                    String cat  = (ps.WebVirtualDirectory == String.Empty) ? "Researchimages" : ps.WebVirtualDirectory;
                    String item = ps.MARCBibID + "/" + ps.BarCode + "/jp2/" + ps.FileNamePrefix + ".jp2";
                    imageUrl = String.Format("http://images.mobot.org/ImageWeb/GetImage.aspx?cat={0}&item={1}&wid=" + width.ToString() + "&hei= " + height.ToString() + "&rgn=0,0,1,1&method=scale", cat, item);
                }
                else
                {
                    imageUrl = ps.ExternalURL;
                }

                System.Net.WebClient client = new System.Net.WebClient();
                context.Response.ContentType = "image/jpeg";
                context.Response.BinaryWrite(client.DownloadData(imageUrl));
            }
        }
Esempio n. 9
0
        private void fillUI()
        {
            PageSummaryView ps = (PageSummaryView)Session["Page" + pageIdTextBox.Text];

            pageIdLabel.Text          = ps.PageID.ToString();
            titleLink.NavigateUrl     = "/Admin/TitleEdit.aspx?id=" + ps.TitleID.ToString();
            titleLink.Text            = ps.ShortTitle + " (" + ps.TitleID.ToString() + ")";
            itemLink.NavigateUrl      = "/Admin/ItemEdit.aspx?id=" + ps.ItemID.ToString();
            itemLink.Text             = (ps.Volume == "") ? "(click to edit volume)" : ps.Volume;
            descriptionLabel.Text     = ps.PageDescription;
            addPageNameButton.Enabled = true;
            saveButton.Enabled        = true;

            pageNameList.DataSource = (CustomGenericList <PageName>)Session["PageNames" + pageIdTextBox.Text];
            pageNameList.DataBind();

            string viewerUrl = new BHLProvider().GetPageUrl(ps);

            pageFrame.Attributes.Add("src", viewerUrl);
        }
Esempio n. 10
0
        /// <summary>
        /// Build the image viewer path to a specific page image.  Depending on
        /// various attributes of the page, different parameters will be passed
        /// to the image viewer.
        /// </summary>
        /// <param name="psv">Object containing the page attributes</param>
        /// <returns>The completed image viewer path</returns>
        public String GetPageUrl(PageSummaryView psv)
        {
            String cat            = String.Empty;
            String client         = String.Empty;
            String image          = String.Empty;
            String imageUrl       = String.Empty;
            String imageDetailUrl = String.Empty;

            if (psv.ExternalURL != null && psv.ExternalURL.Length > 0)
            {
                imageUrl       = psv.ExternalURL;
                imageDetailUrl = psv.AltExternalURL;
            }
            else if (psv.RareBooks)
            {
                if (psv.Illustration)
                {
                    cat    = psv.WebVirtualDirectory;
                    client = psv.MARCBibID + "/" + psv.BarCode;
                    image  = psv.FileNamePrefix + ".jp2";
                }
                else
                {
                    imageUrl = String.Format("http://www.botanicus.org/{0}/{1}/{2}/fullsize/{3}.jpg", psv.WebVirtualDirectory, psv.MARCBibID, psv.BarCode, psv.FileNamePrefix);
                }
            }
            else
            {
                cat    = psv.WebVirtualDirectory;
                client = psv.MARCBibID + "/" + psv.BarCode + "/jp2";
                image  = psv.FileNamePrefix + ".jp2";
            }

            if (ConfigurationManager.AppSettings["UseIAViewer"] == "true")
            {
                // TODO: This branch only for testing OpenLibrary GnuBook viewer!
                int  numPages  = 0;
                int  pageIndex = 0;
                Item item      = this.ItemSelectByBarCode(psv.BarCode);
                if (item != null)
                {
                    numPages = this.PageSelectCountByItemID(item.ItemID);
                }

                if (psv.ExternalURL != null)
                {
                    // IA items
                    pageIndex = Convert.ToInt32(imageUrl.Substring(imageUrl.Length - 8).Substring(0, 4));
                }
                else
                {
                    // Botanicus items
                    if (psv.FileNamePrefix != String.Empty)
                    {
                        pageIndex = (int)psv.SequenceOrder;                                      // Convert.ToInt32(psv.FileNamePrefix.Substring(psv.FileNamePrefix.Length - 4));
                    }
                }
                return(String.Format("/OLBookReader/Viewer/index.html?pgs={0}&item={1}&alt={2}#page/{3}",
                                     numPages.ToString(),
                                     item.ItemID.ToString(),
                                     HttpUtility.UrlEncode(String.Format(psv.ImageServerUrlFormat,
                                                                         HttpUtility.UrlEncode(cat),
                                                                         HttpUtility.UrlEncode(client),
                                                                         HttpUtility.UrlEncode(image),
                                                                         HttpUtility.UrlEncode(imageUrl),
                                                                         HttpUtility.UrlEncode(imageDetailUrl))),
                                     pageIndex));
            }
            else
            {
                return(String.Format(psv.ImageServerUrlFormat,
                                     HttpUtility.UrlEncode(cat),
                                     HttpUtility.UrlEncode(client),
                                     HttpUtility.UrlEncode(image),
                                     HttpUtility.UrlEncode(imageUrl),
                                     HttpUtility.UrlEncode(imageDetailUrl)));
            }
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Master.Page.Header.Controls.Add( ControlGenerator.GetScriptControl( "/Scripts/Ubio.js" ) );
            Master.Page.Header.Controls.Add(ControlGenerator.GetScriptControl("/Scripts/BotanicusDropInViewerUtils.js"));
            //Master.Page.Header.Controls.Add( ControlGenerator.GetScriptControl( "/Scripts/Highlighter.js" ) );

            pageListContentPanel.SetTableID("pageListTable");
            namesListContentPanel.SetTableID("nameListTable");
            //ControlGenerator.AddScriptControl(Page.Master.Page.Header.Controls, "/Scripts/ResizeContentPanelUtils.js");
            ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload",
                                                              "SetContentPanelWidth('pageListTable', 250);SetContentPanelWidth('nameListTable', 250);");
            ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onresize", "resizeViewerHeight(157);");

            main.SetPageType(Main.PageType.TitleViewer);
            main.HideOverflow();

            if (!Page.IsPostBack)
            {
                PageSummaryView ps = null;

                if ((Request["BibId"] != null) &&
                    ((Request["volume"] != null) || (Request["issue"] != null) || (Request["year"] != null) ||
                     (Request["startpage"] != null)) &&
                    Request["resolved"] == null)
                {
                    Response.Redirect("PageResolve.aspx?" + Request.ServerVariables["QUERY_STRING"]);
                }

                if (ps == null)
                {
                    if (Request.QueryString["pageid"] != null)
                    {
                        int pageid;
                        if (int.TryParse(Request.QueryString["pageid"], out pageid))
                        {
                            ps = bhlProvider.PageSummarySelectByPageId(pageid);
                        }
                    }
                    else if (Request.QueryString["titleid"] != null)
                    {
                        int titleid;
                        if (int.TryParse(Request.QueryString["titleid"], out titleid))
                        {
                            // Check to make sure this title hasn't been replaced.  If it has, redirect
                            // to the appropriate titleid.
                            Title title = bhlProvider.TitleSelect(titleid);
                            if (title.RedirectTitleID != null)
                            {
                                Response.Redirect("/title/" + title.RedirectTitleID.ToString());
                                Response.End();
                            }

                            ps = bhlProvider.PageTitleSummarySelectByTitleId(titleid);
                        }
                    }
                    else if (Request.QueryString["itemid"] != null)
                    {
                        int itemid;
                        if (int.TryParse(Request.QueryString["itemid"], out itemid))
                        {
                            ps = bhlProvider.PageSummarySelectByItemId(itemid);
                        }
                    }
                    else if (Request["BibId"] != null)
                    {
                        ps = bhlProvider.PageTitleSummarySelectByBibID(Request["bibID"].ToString());
                    }
                    else if (Request["Barcode"] != null)
                    {
                        ps = bhlProvider.PageSummarySelectByBarcode(Request["Barcode"].ToString());
                    }
                    else if (Request["Prefix"] != null)
                    {
                        ps = bhlProvider.PageSummarySelectByPrefix(Request["Prefix"].ToString());
                    }
                }

                if (ps != null)
                {
                    hidItemID.Value = ps.ItemID.ToString();
                    ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload",
                                                                      "changePage(" + ps.SequenceOrder + ");resizeViewerHeight(157);");
                }
                else
                {
                    // if our PageSummaryView is still null, then redirect because we couldn't find the requested title.
                    Response.Redirect("/TitleNotFound.aspx");
                    Response.End();
                }

                if (ps != null)
                {
                    Master.Page.Title = "Biodiversity Heritage Library: " + ps.ShortTitle;

                    // Set the item for the COinS
                    COinSControl1.ItemID = ps.ItemID;

                    CustomGenericList <MOBOT.BHL.DataObjects.Page> pages = bhlProvider.PageMetadataSelectByItemID(ps.ItemID);

                    pageListBox.DataTextField  = "WebDisplay";
                    pageListBox.DataValueField = "PageID";
                    pageListBox.DataSource     = pages;
                    pageListBox.DataBind();

                    int totalPageCount = bhlProvider.PageSelectCountByItemID(ps.ItemID);
                    hidSequenceMax.Value = totalPageCount.ToString();

                    hidPageID.Value    = ps.PageID.ToString();
                    pageLink.InnerText = "/page/" + ps.PageID.ToString();
                    titleVolumeSelectionControl.PopulateControl(ps);

                    Data.Institution institution = bhlProvider.InstitutionSelectByItemID(ps.ItemID);
                    if (institution != null)
                    {
                        if (institution.InstitutionUrl != null && institution.InstitutionUrl.Trim().Length > 0)
                        {
                            HyperLink link = new HyperLink();
                            link.Text        = institution.InstitutionName;
                            link.NavigateUrl = institution.InstitutionUrl;
                            link.Target      = "_blank";
                            attributionPlaceHolder.Controls.Add(link);
                        }
                        else
                        {
                            Literal literal = new Literal();
                            literal.Text = institution.InstitutionName;
                            attributionPlaceHolder.Controls.Add(literal);
                        }
                        string attributionDivAttributesString = "";
                        if (BrowserUtility.IsBrowserIE6OrBelow(Request))
                        {
                            attributionDivAttributesString = ConfigurationManager.AppSettings["attributionDivPropertiesIE6"];
                        }
                        else
                        {
                            attributionDivAttributesString = ConfigurationManager.AppSettings["attributionDivPropertiesDefault"];
                        }

                        string[] attributionDivAttributeParts = attributionDivAttributesString.Split('|');
                        attributionDiv.Style.Add("position", attributionDivAttributeParts[0]);
                        attributionDiv.Style.Add("bottom", attributionDivAttributeParts[1]);
                    }
                }
            }
        }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                browseContentPanel.SetTableID("browseContentPanel");
                Master.Page.Header.Controls.Add(ControlGenerator.GetScriptControl("/Scripts/ResizeBrowseUtils.js"));
                ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload",
                                                                  "ResizeBrowseDivs();ResizeContentPanel('browseContentPanel', 258);");
                ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onresize",
                                                                  "ResizeBrowseDivs();ResizeContentPanel('browseContentPanel', 258);");

                main.SetPageType(Main.PageType.Content);
            }

            if ((Request.QueryString["titleid"] != null ||
                 Request.QueryString["pid"] != null || Request.QueryString["title"] != null ||
                 Request.QueryString["stitle"] != null) &&
                ((Request.QueryString["volume"] != null) || (Request.QueryString["issue"] != null) ||
                 (Request.QueryString["year"] != null) || (Request.QueryString["startpage"] != null) ||
                 (Request.QueryString["spage"] != null) || (Request.QueryString["date"] != null)))
            {
                string volume    = "";
                string issue     = "";
                string year      = "";
                string startpage = "";

                if (Request.QueryString["volume"] != null)
                {
                    volume = Request.QueryString["volume"].ToString();
                }
                if (Request.QueryString["issue"] != null)
                {
                    issue = Request.QueryString["issue"].ToString();
                }
                if (Request.QueryString["year"] != null)
                {
                    year = Request.QueryString["year"].ToString();
                }
                if (Request.QueryString["startpage"] != null)
                {
                    startpage = Request.QueryString["startpage"].ToString();
                }
                if (Request.QueryString["spage"] != null)
                {
                    startpage = Request.QueryString["spage"].ToString();
                }
                if (Request.QueryString["date"] != null)
                {
                    year = Request.QueryString["date"].ToString();
                }

                //see if this is a valid date value...if so, only use the year portion
                DateTime date;
                if (DateTime.TryParse(year, out date))
                {
                    year = date.Year.ToString();
                }

                if (volume.Trim().Length == 0)
                {
                    volumeLiteral.Text = "not supplied";
                }
                else
                {
                    volumeLiteral.Text = volume;
                }

                if (issue.Trim().Length == 0)
                {
                    issueLiteral.Text = "not supplied";
                }
                else
                {
                    issueLiteral.Text = issue;
                }

                if (year.Trim().Length == 0)
                {
                    yearLiteral.Text = "not supplied";
                }
                else
                {
                    yearLiteral.Text = year;
                }

                if (startpage.Trim().Length == 0)
                {
                    startPageLiteral.Text = "not supplied";
                }
                else
                {
                    startPageLiteral.Text = startpage;
                }

                int    titleId      = 0;
                string fullTitle    = "";
                string abbreviation = "";

                if (Request.QueryString["titleid"] != null)
                {
                    int.TryParse(Request.QueryString["titleid"], out titleId);
                }

                if (Request.QueryString["pid"] != null)
                {
                    int.TryParse(Request.QueryString["pid"], out titleId);
                }

                if (Request.QueryString["title"] != null)
                {
                    fullTitle = Request.QueryString["title"];
                }
                if (Request.QueryString["stitle"] != null)
                {
                    abbreviation = Request.QueryString["stitle"];
                }

                MOBOT.BHL.DataObjects.Title title = null;
                if (titleId > 0)
                {
                    title = bhlProvider.TitleSelectAuto(titleId);
                }
                else if (fullTitle != null && fullTitle.Trim().Length > 0)
                {
                    CustomGenericList <MOBOT.BHL.DataObjects.Title> titleList = bhlProvider.TitleSelectByFullTitle(fullTitle);
                    if (titleList.Count == 1)
                    {
                        titleId = titleList[0].TitleID;
                    }
                }
                else if (abbreviation != null && abbreviation.Trim().Length > 0)
                {
                    CustomGenericList <MOBOT.BHL.DataObjects.Title> titleList = bhlProvider.TitleSelectByAbbreviation(abbreviation);
                    if (titleList.Count == 1)
                    {
                        titleId = titleList[0].TitleID;
                    }
                }

                PageSummaryView ps = null;

                if (titleId > 0)
                {
                    ps = bhlProvider.PageTitleSummarySelectByTitleId(titleId);
                }

                if (ps == null)
                {
                    resultMessageLiteral.Text = "We're sorry, but we were not able to map your request to a particular title.";
                }
                else
                {
                    titleLiteral.Text         = ps.FullTitle;
                    resultMessageLiteral.Text = "Title found...move on to the next step...";
                    CustomGenericList <CustomDataRow> list = bhlProvider.PageResolve(ps.TitleID, volume, issue, year, startpage);
                    if (!UniqueItemFound(list))
                    {
                        // Couldn't narrow down to a single item/volume, therefore, redirect to the bibliography page and let them choose
                        // from there
                        resultMessageLiteral.Text = "We're sorry, but we were unable to resolve the page you requested to a unique " +
                                                    "item. Please visit the <a href=\"/bibliography/" + ps.TitleID.ToString() + "\">bibliography</a> page for " +
                                                    "this title to browse for the requested page.";
                    }
                    else if (list.Count > 1 || !IsResultAnExactMatch(list[0]))
                    {
                        // Multiple results so show the results and let the user pick
                        resultMessageLiteral.Text = "We're sorry, but we were not able to find an exact match based on the above " +
                                                    "criteria. However, we did find options that are close. Please select one of the pages below or visit the " +
                                                    "<a href=\"/bibliography/" + ps.TitleID.ToString() + "\">bibliography</a> page for this title to browse " +
                                                    "for the requested page.<br />";

                        // Kind of kludgy, but since we don't have a typed object to work with, we can't bind to a repeater.
                        foreach (CustomDataRow row in list)
                        {
                            string singleResut = "<br /><a href=\"page/" + row["PageID"].Value.ToString() + "\">";
                            if (row["Year"].Value != null)
                            {
                                singleResut += "Year: " + row["Year"].Value.ToString() + "; ";
                            }

                            if (row["Issue"].Value != null)
                            {
                                singleResut += "Issue: " + row["Issue"].Value.ToString() + "; ";
                            }

                            if (row["Volume"].Value != null)
                            {
                                singleResut += "Volume: " + row["Volume"].Value.ToString() + "; ";
                            }

                            if (row["PagePrefix"].Value != null && row["PageNumber"].Value != null)
                            {
                                singleResut += "Start Page: " + row["PagePrefix"].Value.ToString() + " " +
                                               row["PageNumber"].Value.ToString() + "; ";
                            }

                            singleResut += "(ID: " + row["PageID"].Value.ToString() + ")</a><br />";

                            similarResultsLiteral.Text += singleResut;
                        }
                    }
                    else
                    {
                        // Narrowed it down to one potential page. If all criteria matches exactly, redirect to title page.
                        // Otherwise display the single result and acknowledge that it is not an exact match
                        Response.Redirect("/page/" + list[0]["PageID"].Value.ToString());
                    }
                }
            }
            else
            {
                resultMessageLiteral.Text = "We're sorry, but we were not able to map your request to a particular title.";
            }
        }