Beispiel #1
0
        private string[] GetPdfUrl(Data.PageSummaryView psv)
        {
            string[] returnStrings = new string[2];
            string   pdfLocation   = psv.PdfLocation;

            IFileAccessProvider fileAccess = new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true");

            try
            {
                bool fileExists = fileAccess.FileExists(pdfLocation);
                if (fileExists)
                {
                    returnStrings[0] =
                        fileAccess.GetFileSizeInMB(pdfLocation).ToString("0.") + " MB";
                    returnStrings[1] = psv.PdfAuthUrl;
                    return(returnStrings);
                }
            }
            catch (Exception ex)
            {
                DebugUtility.WriteErrorInfo(Response, Request, ex);
            }
            return(null);
        }
Beispiel #2
0
        public void PopulateControl(Data.PageSummaryView ps)
        {
            pageName = Request.ServerVariables["SCRIPT_NAME"];
            pageName = pageName.Substring(pageName.LastIndexOf("/") + 1, pageName.Length - pageName.LastIndexOf("/") - 1);

            if (pageName.ToLower() == "titlepage.aspx")
            {
                ddlItem.Attributes.Add("onchange", "location.href='/item/' + this.options[selectedIndex].value");
            }

            if (ps != null)
            {
                CustomGenericList <Data.Item> item = new BHLProvider().ItemSelectByTitleId(ps.TitleID);
                for (int i = 0; i < item.Count; i++)
                {
                    if (item[i].Volume == null || item[i].Volume == "")
                    {
                        item.RemoveAt(i);
                        i--;
                    }
                }

                ddlItem.DataSource     = item;
                ddlItem.DataTextField  = "DisplayedShortVolume";
                ddlItem.DataValueField = "ItemID";
                ddlItem.DataBind();
                if (ddlItem.Items.Count <= 1)
                {
                    ddlItem.Visible = false;
                }
                else
                {
                    ddlItem.Visible = true;
                }
            }

            if (ps != null)
            {
                ddlItem.SelectedValue = ps.ItemID.ToString();
                String displayTitle = ps.ShortTitle + " " + (ps.PartNumber ?? "") + " " + (ps.PartName ?? "");
                titleLiteral.Text = (displayTitle.Length <= 64) ? displayTitle : displayTitle.Substring(0, 64) + "...";

                linkBib.HRef    = "/bibliography/" + ps.TitleID.ToString();
                linkPDFGen.HRef = "/pdfgen/" + ps.ItemID.ToString();

                if (ps.DownloadUrl != String.Empty)
                {
                    linkPDF.HRef   = "http://www.archive.org/download/" + ps.BarCode + "/" + ps.BarCode + ".pdf";
                    linkPDF.Target = "_blank";

                    linkOCR.HRef    = "http://www.archive.org/download/" + ps.BarCode + "/" + ps.BarCode + "_djvu.txt";
                    linkImages.HRef = "http://www.archive.org/download/" + ps.BarCode + "/" + ps.BarCode + "_jp2.zip";
                    linkAll.HRef    = ps.DownloadUrl + ps.BarCode;
                }
                else
                {
                    string[] pdfUrl = GetPdfUrl(ps);
                    if (pdfUrl != null)
                    {
                        linkPDF.Attributes["onclick"] = "javascript:window.open('" + pdfUrl[1] + "','pdf', 'width=400,height=200,status=no,toolbar=no,menubar=no,resizeable=no');";
                        linkPDF.InnerText            += " (" + pdfUrl[0] + " PDF) ";
                    }
                    else
                    {
                        linkPDF.Visible = false;
                    }

                    linkOCR.Visible    = false;
                    linkImages.Visible = false;
                    linkAll.Visible    = false;
                }
            }
            else
            {
                linkAbout.Visible = false;
            }
        }
 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 "";
     }
 }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            main.SetPageType(Main.PageType.Content);
            ControlGenerator.AddScriptControl(Page.Master.Page.Header.Controls, "/Scripts/ResizeBrowseUtils.js");
            ControlGenerator.AddScriptControl(Page.Master.Page.Header.Controls, "/Scripts/jquery-1.2.6.min.js");
            ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload",
                                                              "ResizeContentPanel('browseContentPanel', 258);ResizeBrowseDivs();");
            ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onresize",
                                                              "ResizeContentPanel('browseContentPanel', 258);ResizeBrowseDivs();");

            Data.PageSummaryView              ps        = null;
            CustomGenericList <Data.Item>     items     = null;
            CustomGenericList <Data.Creator>  creators  = null;
            CustomGenericList <Data.TitleTag> titleTags = null;
            CustomGenericList <Data.Title_TitleIdentifier> titleIdentifiers  = null;
            CustomGenericList <Data.TitleAssociation>      titleAssociations = null;

            Data.Title title    = null;
            bool       showData = false;
            int        titleId  = 0;

            if (Request["titleid"] != null)
            {
                if (!int.TryParse(Request.QueryString["titleid"], out titleId))
                {
                    // Request seems to have included a MARCBibID instead of a TitleId
                    Data.PageSummaryView psBib = bhlProvider.PageTitleSummarySelectByBibID(Request.QueryString["titleid"].ToString());
                    if (psBib != null)
                    {
                        titleId = psBib.TitleID;
                    }
                }
                showData = true;
            }

            if (!showData && Request.QueryString["oclc"] != null)
            {
                // Get the title id associated with the OCLC identifier
                Data.Title_TitleIdentifier titleTitleId = bhlProvider.Title_TitleIdentifierSelectByIdentifierValue(Request.QueryString["oclc"].ToString());
                if (titleTitleId != null)
                {
                    titleId = titleTitleId.TitleID;
                }
                showData = true;
            }

            if (showData)
            {
                hidTitleID.Value = titleId.ToString();

                // Check to make sure this title hasn't been replaced.  If it has, redirect
                // to the appropriate titleid.
                title = bhlProvider.TitleSelect(titleId);
                if (title.RedirectTitleID != null)
                {
                    Response.Redirect("/bibliography/" + title.RedirectTitleID.ToString());
                    Response.End();
                }

                // Set the title for the COinS
                COinSControl1.TitleID = titleId;

                ps = bhlProvider.PageTitleSummarySelectByTitleId(titleId);
                if (ps == null)
                {
                    Response.Redirect("/TitleNotFound.aspx");
                    Response.End();
                }
                Barcode           = ps.BarCode;
                creators          = bhlProvider.CreatorSelectByTitleId(titleId);
                items             = bhlProvider.ItemSelectByTitleId(titleId);
                titleTags         = bhlProvider.TitleTagSelectTagTextByTitleId(titleId);
                titleIdentifiers  = bhlProvider.Title_TitleIdentifierSelectByTitleID(titleId);
                titleAssociations = bhlProvider.TitleAssociationSelectByTitleId(titleId, true);

                if (titleAssociations.Count == 0)
                {
                    associationsDiv.Visible = false;
                }
                else
                {
                    associationsDiv.Visible         = true;
                    associationsRepeater.DataSource = titleAssociations;
                    associationsRepeater.DataBind();
                }

                foreach (Data.Item item in items)
                {
                    // Populate empty volume descriptions with default text
                    if (item.Volume == String.Empty || item.Volume == null)
                    {
                        if (items.Count == 1)
                        {
                            item.Volume = "View Book";
                        }
                        if (items.Count > 1)
                        {
                            item.Volume = "(no volume description)";
                        }
                    }

                    // Make sure all Botanicus PDFs actually exist.  Remove the DownloadUrl for any that do not.
                    if (item.DownloadUrl != String.Empty && item.ItemSourceID == 2)
                    {
                        // This is kludgy... should find a better way to do this
                        String pdfLocation = item.DownloadUrl.Replace("http://www.botanicus.org/", "\\\\server\\").Replace('/', '\\');
                        if (new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").FileExists(pdfLocation))
                        {
                            item.DownloadUrl = ConfigurationManager.AppSettings["PdfAuthUrl"] != null?String.Format(ConfigurationManager.AppSettings["PdfAuthUrl"], item.BarCode) : String.Empty;
                        }
                        else
                        {
                            item.DownloadUrl = String.Empty;
                        }
                    }
                }

                // Look for an OCLC identifier (use the first one... might need to account for multiple at some point)
                bool oclcFound = false;
                foreach (Data.Title_TitleIdentifier titleIdentifier in titleIdentifiers)
                {
                    if (String.Compare(titleIdentifier.IdentifierName, "OCLC", StringComparison.CurrentCultureIgnoreCase) == 0)
                    {
                        localLibraryLink.NavigateUrl += "wcpa/oclc/";
                        if (titleIdentifier.IdentifierValue.ToLower().StartsWith("ocm"))
                        {
                            //strip the "ocm" from the beginning of the value.
                            localLibraryLink.NavigateUrl += titleIdentifier.IdentifierValue.Substring(3);
                        }
                        else
                        {
                            localLibraryLink.NavigateUrl += titleIdentifier.IdentifierValue;
                        }
                        oclcFound = true;
                        break;
                    }
                }

                if (!oclcFound)
                {
                    string truncatedTitle = "";
                    if (title.FullTitle.Length > 220)
                    {
                        truncatedTitle = title.FullTitle.Substring(0, 220);
                        truncatedTitle = truncatedTitle.Substring(0, truncatedTitle.LastIndexOf(" "));
                    }
                    else
                    {
                        truncatedTitle = title.FullTitle;
                    }
                    localLibraryLink.NavigateUrl += "search?q=" + truncatedTitle.Replace(" ", "+") + "&qt=owc_search";
                }

                Master.Page.Title = "Biodiversity Heritage Library: Information about '" + ps.FullTitle + "'";
                //descriptionLiteral.Text = title.TitleDescription;
                publicationInfoLiteral.Text = title.PublicationDetails;
                fullTitleLiteral.Text       = title.FullTitle + " " + (title.PartNumber ?? "") + " " + (title.PartName ?? "");
                if (title.CallNumber == null || title.CallNumber.Length == 0)
                {
                    callNumberPanel.Visible = false;
                }
                else
                {
                    callNumberLiteral.Text = title.CallNumber;
                }

                if (titleTags == null || titleTags.Count == 0)
                {
                    subjectPanel.Visible = false;
                }
                else
                {
                    int           k  = titleTags.Count - 1;
                    int           i  = 0;
                    StringBuilder sb = new StringBuilder();
                    foreach (Data.TitleTag titleTag in titleTags)
                    {
                        sb.Append("<a href='/subject/");
                        sb.Append(Server.UrlEncode(titleTag.TagText));
                        sb.Append("'>");
                        sb.Append(titleTag.TagText);
                        sb.Append("</a>");

                        if (i + 1 <= k)
                        {
                            sb.Append(", ");
                        }
                        i++;
                    }
                    subjectLiteral.Text = sb.ToString();
                }

                itemRepeater.DataSource = items;
                itemRepeater.DataBind();

                CustomGenericList <Data.Creator> authors           = new CustomGenericList <Data.Creator>();
                CustomGenericList <Data.Creator> additionalAuthors = new CustomGenericList <Data.Creator>();
                foreach (Data.Creator creator in creators)
                {
                    if (creator.CreatorRoleTypeForTitle >= 1 && creator.CreatorRoleTypeForTitle <= 3)
                    {
                        authors.Add(creator);
                    }
                    else
                    {
                        additionalAuthors.Add(creator);
                    }
                }
                authorsRepeater.DataSource = authors;
                authorsRepeater.DataBind();
                additionalAuthorsRepeater.DataSource = additionalAuthors;
                additionalAuthorsRepeater.DataBind();

                //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 );
                //    }
                //}

                if (Helper.IsAdmin(Request))
                {
                    editTitleLink.NavigateUrl = "/Admin/TitleEdit.aspx?id=" + titleId.ToString();
                }
                else
                {
                    editTitleLink.Visible = false;
                }

                // Get the full MARC details
                bool   marcFound = false;
                String filepath  = ps.MarcXmlLocation;
                bool   test      = (ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true");
                if (new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").FileExists(filepath))
                {
                    marcFound = true;
                }
                else
                {
                    // File not found in primary location, so look in alternate location (Botanicus files in alt location)
                    filepath = ps.MarcXmlAltLocation;
                    if (new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").FileExists(filepath))
                    {
                        marcFound = true;
                    }
                }

                if (marcFound)
                {
                    string marcXML = new BHLProvider().GetFileAccessProvider(ConfigurationManager.AppSettings["UseRemoteFileAccessProvider"] == "true").GetFileText(filepath);

                    XmlDocument  xml    = new XmlDocument();
                    StringReader reader = new StringReader(marcXML);
                    xml.Load(reader);

                    // Set up the XSL resolver that we'll use to extract the text from the xml
                    XmlUrlResolver resolver = new XmlUrlResolver();
                    resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    System.Xml.Xsl.XslTransform xslTransform = new System.Xml.Xsl.XslTransform();

                    // Format the MARC XML into a "readable" format
                    xslTransform.Load(Request.PhysicalApplicationPath + "xsl\\MARC21transformEnglish.xsl", resolver);
                    StringWriter output = new StringWriter();
                    xslTransform.Transform(xml, null, output, resolver);
                    litExpanded.Text = output.ToString();

                    // Format the MARC XML into a "flat" MARC format
                    xslTransform.Load(Request.PhysicalApplicationPath + "xsl\\MARC21transformMARC.xsl", resolver);
                    output = new StringWriter();
                    xslTransform.Transform(xml, null, output, resolver);
                    litMarc.Text = output.ToString();

                    viewcontrol.Visible = true;
                }
                else
                {
                    viewcontrolnomarc.Visible = true;
                }

                // Get the BibTex citations for this title
                try
                {
                    hypBibTex.NavigateUrl += title.TitleID.ToString();
                    litBibTeX.Text         = bhlProvider.TitleBibTeXGetCitationStringForTitleID(title.TitleID).Replace("\n", "<br>").Replace("\r", "<br>");
                }
                catch
                {
                    hypBibTex.Visible = false;
                    litBibTeX.Text    = "Error retrieving BibTex citations for this title.";
                }

                // Get the EndNote citation for this title
                try
                {
                    hypEndNote.NavigateUrl += title.TitleID.ToString();
                    litEndNote.Text         = bhlProvider.TitleEndNoteGetCitationStringForTitleID(title.TitleID,
                                                                                                  ConfigurationManager.AppSettings["ItemPageUrl"].ToString()).Replace("\n", "<br>").Replace("\r", "<br>");
                }
                catch
                {
                    hypEndNote.Visible = false;
                    litEndNote.Text    = "Error retrieving EndNote citations for this title.";
                }
            }
        }
 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 "";
 }