Exemple #1
0
        /// <summary> Returns flag that indicates this citation section writer
        /// will be writing alues to the output stream </summary>
        /// <param name="Item"> Digital resource to analyze for data to write </param>
        /// <param name="ElementInfo"> Additional possible data about this citation element </param>
        public bool Has_Data_To_Write(CitationElement ElementInfo, BriefItemInfo Item)
        {
            // Look for a match in the item description
            BriefItem_DescriptiveTerm firstSpatial = Item.Get_Description("Hierarchical Spatial");

            return((firstSpatial != null) && (firstSpatial.Values.Count > 0));
        }
Exemple #2
0
        /// <summary> Returns flag that indicates this citation section writer
        /// will be writing alues to the output stream </summary>
        /// <param name="ElementInfo"> Additional possible data about this citation element </param>
        /// <param name="Item"> Digital resource to analyze for data to write </param>
        public bool Has_Data_To_Write(CitationElement ElementInfo, BriefItemInfo Item)
        {
            // Look for a match in the item description
            BriefItem_DescriptiveTerm firstCreator = Item.Get_Description("Creator");

            return((firstCreator != null) && (firstCreator.Values.Count > 0));
        }
Exemple #3
0
        /// <summary> Wites a section of citation from a provided digital resource </summary>
        /// <param name="ElementInfo"> Additional possible data about this citation element </param>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="Item"> Digital resource with all the data to write </param>
        /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param>
        /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param>
        /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance  </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer, Navigation_Object CurrentRequest)
        {
            BriefItem_DescriptiveTerm creatorList = Item.Get_Description("Creator");

            bool first_creator = true;

            string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Creators" : ElementInfo.DisplayTerm;

            Output.AppendLine("        <dt class=\"sbk_CivCREATOR_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>");
            Output.Append("        <dd class=\"sbk_CivCREATOR_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\" >");

            // Determine if ths standard itemprop was overriden
            string itemProp = (!String.IsNullOrWhiteSpace(ElementInfo.ItemProp)) ? ElementInfo.ItemProp : "creator";

            // Determine if the standard search code was overriden
            string searchCode = (!String.IsNullOrWhiteSpace(ElementInfo.SearchCode)) ? ElementInfo.SearchCode : "AU";

            foreach (BriefItem_DescTermValue thisValue in creatorList.Values)
            {
                // Was this the first?
                if (first_creator)
                {
                    first_creator = false;
                }
                else
                {
                    Output.AppendLine("<br />");
                }

                // It is possible a different search term is valid for this item, so check it
                string searchTerm = (!String.IsNullOrWhiteSpace(thisValue.SearchTerm)) ? thisValue.SearchTerm : thisValue.Value;

                Output.Append("<span itemprop=\"" + itemProp + "\">" + SearchLink.Replace("<%VALUE%>", search_link_from_value(searchTerm)).Replace("<%CODE%>", searchCode) + display_text_from_value(thisValue.Value) + SearchLinkEnd);

                if (!String.IsNullOrEmpty(thisValue.Authority))
                {
                    Output.Append(" ( " + display_text_from_value(thisValue.Authority) + " ) ");
                }

                if (!String.IsNullOrEmpty(thisValue.SubTerm))
                {
                    Output.Append(" ( <i>" + display_text_from_value(thisValue.SubTerm) + "</i> ) ");
                }


                Output.AppendLine("</span>");
            }

            Output.AppendLine("</dd>");
            Output.AppendLine();
        }
        /// <summary> Wites a section of citation from a provided digital resource </summary>
        /// <param name="ElementInfo"> Additional possible data about this citation element </param>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="Item"> Digital resource with all the data to write </param>
        /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param>
        /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param>
        /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance  </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer, Navigation_Object CurrentRequest)
        {
            // Set the default (since this always displays)
            string rights_statement = "All applicable rights reserved by the source institution and holding location.";
            string rights_image     = String.Empty;
            string uri = String.Empty;

            const string SEE_TEXT = "See License Deed";

            // Look for a match in the item description
            BriefItem_DescriptiveTerm rightsTerm = Item.Get_Description("Rights Management");

            if ((rightsTerm != null) && (rightsTerm.Values.Count > 0))
            {
                rights_statement = rightsTerm.Values[0].Value;

                if ((rightsTerm.Values[0].URIs != null) && (rightsTerm.Values[0].URIs.Count == 1))
                {
                    uri = rightsTerm.Values[0].URIs[0];

                    switch (uri)
                    {
                    case "http://creativecommons.org/licenses/by-nc-nd/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Nd_Img;
                        break;

                    case "http://creativecommons.org/licenses/by-nc-sa/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Sa_Img;
                        break;

                    case "http://creativecommons.org/licenses/by-nc/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Img;
                        break;

                    case "http://creativecommons.org/licenses/by-nd/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nd_Img;
                        break;

                    case "http://creativecommons.org/licenses/by-sa/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Sa_Img;
                        break;

                    case "http://creativecommons.org/licenses/by/3.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Img;
                        break;

                    case "http://creativecommons.org/publicdomain/zero/1.0/":
                        rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_Zero_Img;
                        break;
                    }
                }
            }

            string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Rights Management" : ElementInfo.DisplayTerm;

            Output.AppendLine("        <dt class=\"sbk_CivRIGHTS_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>");
            Output.Append("        <dd class=\"sbk_CivRIGHTS_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\"><span itemprop=\"rights\">");

            if ((rights_statement.IndexOf("http://") == 0) || (rights_statement.IndexOf("https://") == 0))
            {
                Output.Append("<a href=\"" + rights_statement + "\" target=\"RIGHTS\" >" + rights_statement + "</a>");
            }
            else
            {
                // Show the rights image?
                if (String.IsNullOrEmpty(rights_image))
                {
                    if (!String.IsNullOrEmpty(uri))
                    {
                        Output.Append(rights_statement + " ( <a href=\"" + uri + "\" alt=\"" + SEE_TEXT + "\" target=\"license\">link</a> )");
                    }
                    else
                    {
                        Output.Append(rights_statement);
                    }
                }
                else
                {
                    // Since the image is derived from the URI, there must be a URI here
                    Output.Append("<a href=\"" + uri + "\" alt=\"" + SEE_TEXT + "\" target=\"cc_license\"><img src=\"" + rights_image + "\" /></a> " + rights_statement);
                }
            }

            Output.AppendLine("</span></dd>");
            Output.AppendLine();
        }
Exemple #5
0
        /// <summary> Wites a section of citation from a provided digital resource </summary>
        /// <param name="ElementInfo"> Additional possible data about this citation element </param>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="Item"> Digital resource with all the data to write </param>
        /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param>
        /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param>
        /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance  </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer)
        {
            string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Spatial Coverage" : ElementInfo.DisplayTerm;

            Output.AppendLine("        <dt class=\"sbk_CivSPATIAL_COVERAGE_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>");
            Output.Append("        <dd class=\"sbk_CivSPATIAL_COVERAGE_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\">");

            int spatial_count = 1;

            while (true)
            {
                // Determine the term to use
                string term = "Hierarchical Spatial";
                if (spatial_count > 1)
                {
                    term = term + " (" + spatial_count + ")";
                }

                // Look for the match
                BriefItem_DescriptiveTerm thisSpatial = Item.Get_Description(term);

                // If no match, break out of this while loop
                if ((thisSpatial == null) || (thisSpatial.Values == null))
                {
                    break;
                }

                // Past the first complex spatial subject?
                if (spatial_count > 1)
                {
                    Output.AppendLine("<br />");
                }

                // Step through each subterm
                StringBuilder spatial_builder = new StringBuilder();
                foreach (BriefItem_DescTermValue thisValue in thisSpatial.Values)
                {
                    if (spatial_builder.Length > 0)
                    {
                        spatial_builder.Append(" -- ");
                    }

                    switch (thisValue.SubTerm)
                    {
                    case "Continent":
                    case "Province":
                    case "Region":
                    case "Territory":
                    case "City Section":
                    case "Island":
                    case "Area":
                        spatial_builder.Append(thisValue.Value);
                        break;

                    case "Country":
                        spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&amp;", "&").Replace("&", "").Replace("  ", " ")).Replace(",", "").Replace("&amp;", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CO") + thisValue.Value + SearchLinkEnd);
                        break;

                    case "State":
                        spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&amp;", "&").Replace("&", "").Replace("  ", " ")).Replace(",", "").Replace("&amp;", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "ST") + thisValue.Value + SearchLinkEnd);
                        break;

                    case "County":
                        spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&amp;", "&").Replace("&", "").Replace("  ", " ")).Replace(",", "").Replace("&amp;", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CT") + thisValue.Value + SearchLinkEnd);
                        break;

                    case "City":
                        spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&amp;", "&").Replace("&", "").Replace("  ", " ")).Replace(",", "").Replace("&amp;", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CI") + thisValue.Value + SearchLinkEnd);
                        break;
                    }
                }

                // Display this
                Output.Append("          " + spatial_builder);

                // Move to check the next spatial
                spatial_count++;
            }

            Output.AppendLine("</dd>");
            Output.AppendLine();
        }
        private static bool HTML_Send_Email(string Recepient_List, string CcList, string Comments, string User_Name, string SobekCM_Instance_Name, BriefItemInfo Item, string URL, int UserID)
        {
            try
            {
                StringBuilder messageBuilder = new StringBuilder();

                messageBuilder.AppendLine("<span style=\"font-family:Arial, Helvetica, sans-serif;\">");
                if (Comments.Length > 0)
                {
                    messageBuilder.AppendLine(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + " and included the following comments.<br /><br />\n");
                    messageBuilder.AppendLine(Comments.Replace("<", "(").Replace(">", ")").Replace("\"", "&quot;") + ".<br /><br />\n");
                }
                else
                {
                    messageBuilder.AppendLine(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + ".<br /><br />\n");
                }

                messageBuilder.AppendLine("<table cellspacing=\"0px\" cellpadding=\"0px\">\n");
                messageBuilder.AppendLine("<tr><td colspan=\"2\" style=\"background: black; color: white; font-family:Arial, Helvetica, sans-serif;\"><b>ITEM INFORMATION</b></td></tr>\n");

                // Include the thumbnail, if one exists
                if (String.IsNullOrEmpty(Item.Behaviors.Main_Thumbnail))
                {
                    messageBuilder.AppendLine("<tr>");
                }
                else
                {
                    messageBuilder.AppendLine("<tr valign=\"top\"><td><a href=\"" + URL + "\"><img src=\"" + Item.Web.Source_URL.Replace("\\", "/") + "/" + Item.Behaviors.Main_Thumbnail + "\" alt=\"BLOCKED THUMBNAIL IMAGE\" border=\"1px\" /></a></td>\n");
                }

                messageBuilder.AppendLine("<td>");
                messageBuilder.AppendLine("<table style=\"font-family:Arial, Helvetica, sans-serif; font-size:smaller;\">");



                // Step through the citation configuration here
                CitationSet citationSet = UI_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet("EMAIL");
                foreach (CitationFieldSet fieldsSet in citationSet.FieldSets)
                {
                    // Check to see if any of the values indicated in this field set exist
                    bool foundExistingData = false;
                    foreach (CitationElement thisField in fieldsSet.Elements)
                    {
                        // Look for a match in the item description
                        BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm);

                        // If no match, just continue
                        if ((briefTerm != null) && (briefTerm.Values.Count > 0))
                        {
                            foundExistingData = true;
                            break;
                        }
                    }

                    // If no data was found to put in this field set, skip it
                    if (!foundExistingData)
                    {
                        continue;
                    }

                    // Step through all the fields in this field set and write them
                    foreach (CitationElement thisField in fieldsSet.Elements)
                    {
                        // Look for a match in the item description
                        BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm);

                        // If no match, just continue
                        if ((briefTerm == null) || (briefTerm.Values.Count == 0))
                        {
                            continue;
                        }

                        // If they can all be listed one after the other do so now
                        if (!thisField.IndividualFields)
                        {
                            List <string> valueArray = new List <string>();
                            foreach (BriefItem_DescTermValue thisValue in briefTerm.Values)
                            {
                                if (String.IsNullOrEmpty(thisValue.Authority))
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value));
                                    }
                                    else
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )");
                                    }
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )");
                                    }
                                    else
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )");
                                    }
                                }
                            }

                            // Now, add this to the citation HTML
                            Add_Citation_HTML_Rows(thisField.DisplayTerm, valueArray, messageBuilder);
                        }
                        else
                        {
                            // In this case, each individual value gets its own citation html row
                            foreach (BriefItem_DescTermValue thisValue in briefTerm.Values)
                            {
                                // Determine the label
                                string label = thisField.DisplayTerm;
                                if (thisField.OverrideDisplayTerm == CitationElement_OverrideDispayTerm_Enum.subterm)
                                {
                                    if (!String.IsNullOrEmpty(thisValue.SubTerm))
                                    {
                                        label = thisValue.SubTerm;
                                    }
                                }

                                if (String.IsNullOrEmpty(thisValue.Authority))
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value)));
                                    }
                                    else
                                    {
                                        messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )"));
                                    }
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )"));
                                    }
                                    else
                                    {
                                        messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )"));
                                    }
                                }
                            }
                        }
                    }
                }

                messageBuilder.AppendLine("</table>");
                messageBuilder.AppendLine("</td></tr></table>");

                messageBuilder.AppendLine("</span>\n");

                string[] email_recepients = Recepient_List.Split(";,".ToCharArray());
                string   subject          = Item.Title.Replace("&quot;", "\"");
                if (Item.Title.Length > 40)
                {
                    subject = Item.Title.Substring(0, 35).Replace("&quot;", "\"") + "...";
                }

                int error_count = 0;
                foreach (string thisReceipient in email_recepients)
                {
                    EmailInfo newEmail = new EmailInfo
                    {
                        Body           = messageBuilder.ToString(),
                        isContactUs    = false,
                        isHTML         = true,
                        Subject        = subject,
                        RecipientsList = thisReceipient,
                        FromAddress    = SobekCM_Instance_Name + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">",
                        UserID         = UserID
                    };

                    if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay))
                    {
                        newEmail.FromAddress = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">";
                    }

                    if (CcList.Length > 0)
                    {
                        newEmail.RecipientsList = thisReceipient.Trim() + "," + CcList;
                    }

                    string error;
                    if (!Email_Helper.SendEmail(newEmail, out error))
                    {
                        error_count++;
                    }
                }
                return(error_count <= 0);
            }
            catch
            {
                return(false);
            }
        }
        private static bool Text_Send_Email(string Recepient_List, string CcList, string Comments, string User_Name, string SobekCM_Instance_Name, BriefItemInfo Item, string URL, int UserID)
        {
            try
            {
                StringBuilder messageBuilder = new StringBuilder();

                if (Comments.Length > 0)
                {
                    messageBuilder.Append(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + " and included the following comments:\n\n");
                    messageBuilder.Append("\"" + Comments + "\"\n\n");
                }
                else
                {
                    messageBuilder.Append(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + ".\n\n");
                }
                messageBuilder.Append("ITEM INFORMATION\n");
                messageBuilder.Append("------------------------------------------------------\n");


                // Step through the citation configuration here
                CitationSet citationSet = UI_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet("EMAIL");
                foreach (CitationFieldSet fieldsSet in citationSet.FieldSets)
                {
                    // Check to see if any of the values indicated in this field set exist
                    bool foundExistingData = false;
                    foreach (CitationElement thisField in fieldsSet.Elements)
                    {
                        // Look for a match in the item description
                        BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm);

                        // If no match, just continue
                        if ((briefTerm != null) && (briefTerm.Values.Count > 0))
                        {
                            foundExistingData = true;
                            break;
                        }
                    }

                    // If no data was found to put in this field set, skip it
                    if (!foundExistingData)
                    {
                        continue;
                    }

                    // Step through all the fields in this field set and write them
                    foreach (CitationElement thisField in fieldsSet.Elements)
                    {
                        // Look for a match in the item description
                        BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm);

                        // If no match, just continue
                        if ((briefTerm == null) || (briefTerm.Values.Count == 0))
                        {
                            continue;
                        }

                        // If they can all be listed one after the other do so now
                        if (!thisField.IndividualFields)
                        {
                            List <string> valueArray = new List <string>();
                            foreach (BriefItem_DescTermValue thisValue in briefTerm.Values)
                            {
                                if (String.IsNullOrEmpty(thisValue.Authority))
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value));
                                    }
                                    else
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )");
                                    }
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )");
                                    }
                                    else
                                    {
                                        valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )");
                                    }
                                }
                            }

                            // Now, add this to the citation HTML
                            Add_Citation_Text_Rows(thisField.DisplayTerm, valueArray, messageBuilder);
                        }
                        else
                        {
                            // In this case, each individual value gets its own citation html row
                            foreach (BriefItem_DescTermValue thisValue in briefTerm.Values)
                            {
                                // Determine the label
                                string label = thisField.DisplayTerm;
                                if (thisField.OverrideDisplayTerm == CitationElement_OverrideDispayTerm_Enum.subterm)
                                {
                                    if (!String.IsNullOrEmpty(thisValue.SubTerm))
                                    {
                                        label = thisValue.SubTerm;
                                    }
                                }

                                if (String.IsNullOrEmpty(thisValue.Authority))
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value)));
                                    }
                                    else
                                    {
                                        messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )"));
                                    }
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(thisValue.Language))
                                    {
                                        messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )"));
                                    }
                                    else
                                    {
                                        messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )"));
                                    }
                                }
                            }
                        }
                    }
                }


                string[] email_recepients = Recepient_List.Split(";,".ToCharArray());
                string   subject          = Item.Title.Replace("&quot;", "\"");
                if (Item.Title.Length > 40)
                {
                    subject = Item.Title.Substring(0, 35).Replace("&quot;", "\"") + "...";
                }

                int error_count = 0;
                foreach (string thisReceipient in email_recepients)
                {
                    EmailInfo newEmail = new EmailInfo
                    {
                        Body           = messageBuilder.ToString(),
                        isContactUs    = false,
                        isHTML         = false,
                        Subject        = subject,
                        RecipientsList = thisReceipient,
                        FromAddress    = SobekCM_Instance_Name + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">",
                        UserID         = UserID
                    };

                    if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay))
                    {
                        newEmail.FromAddress = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">";
                    }


                    if (CcList.Length > 0)
                    {
                        newEmail.RecipientsList = thisReceipient.Trim() + "," + CcList;
                    }

                    string error;
                    if (!Email_Helper.SendEmail(newEmail, out error))
                    {
                        error_count++;
                    }
                }
                return(error_count <= 0);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary> Write the item title bar to the item display html</summary>
        /// <param name="Output"> Stream to which to write </param>
        /// <param name="Prototyper"> Current item viewer prototyper </param>
        /// <param name="CurrentViewer"> Current item viewer which will be used to fill the primary part of the page </param>
        /// <param name="CurrentItem"> Current item which is being displayed </param>
        /// <param name="RequestSpecificValues"> Other, request specific values, such as the current mode, user, etc.. </param>
        /// <param name="Behaviors"> Behaviors for the current view and situation </param>
        public void Write_HTML(TextWriter Output, iItemViewerPrototyper Prototyper, iItemViewer CurrentViewer, BriefItemInfo CurrentItem, RequestCache RequestSpecificValues, List <HtmlSubwriter_Behaviors_Enum> Behaviors)
        {
            // The item viewer can choose to override the standard item titlebar
            if (!Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.Item_Subwriter_Suppress_Titlebar))
            {
                Output.WriteLine("<!-- Show the title and any other important item information -->");
                Output.WriteLine("<section id=\"sbkIsw_Titlebar\" role=\"banner\">");

                if (String.Compare(CurrentItem.VID, "00000", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    string grouptitle = "NO TITLE";
                    if ((CurrentItem.Behaviors != null) && (!String.IsNullOrWhiteSpace(CurrentItem.Behaviors.GroupTitle)))
                    {
                        grouptitle = CurrentItem.Behaviors.GroupTitle;
                    }
                    if (grouptitle.Length > 125)
                    {
                        Output.WriteLine("\t<h1 itemprop=\"name\"><abbr title=\"" + grouptitle + "\">" + grouptitle.Substring(0, 120) + "..</abbr></h1>");
                    }
                    else
                    {
                        Output.WriteLine("\t<h1 itemprop=\"name\">" + grouptitle + "</h1>");
                    }
                }
                else
                {
                    string final_title = CurrentItem.Title ?? "NO TITLE";

                    // Add the Title if there is one
                    if (final_title.Length > 0)
                    {
                        // Is this a newspaper?
                        bool newspaper = (String.Compare(CurrentItem.Behaviors.GroupType, "NEWSPAPER", StringComparison.OrdinalIgnoreCase) == 0);

                        // Does a custom setting override the default behavior to add a date?
                        if ((newspaper) && (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Include Date In Title")) && (UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Include Date In Title").ToUpper() == "NEVER"))
                        {
                            newspaper = false;
                        }

                        // Add the date if it should be added
                        if ((newspaper) && (!String.IsNullOrEmpty(CurrentItem.Web.Date)))
                        {
                            if (final_title.Length > 125)
                            {
                                Output.WriteLine("\t<h1 itemprop=\"name\"><abbr title=\"" + final_title + "\">" + final_title.Substring(0, 120) + "..</abbr> ( " + CurrentItem.Web.Date + " )</h1>");
                            }
                            else
                            {
                                Output.WriteLine("\t<h1 itemprop=\"name\">" + final_title + " ( " + CurrentItem.Web.Date + " )</h1>");
                            }
                        }
                        else
                        {
                            if (final_title.Length > 125)
                            {
                                Output.WriteLine("\t<h1 itemprop=\"name\"><abbr title=\"" + final_title + "\">" + final_title.Substring(0, 120) + "..</abbr></h1>");
                            }
                            else
                            {
                                Output.WriteLine("\t<h1 itemprop=\"name\">" + final_title + "</h1>");
                            }
                        }
                    }


                    // Add the link if there is one
                    // Links_BriefItemMapper
                    if ((CurrentItem.Web != null) && (!String.IsNullOrEmpty(CurrentItem.Web.Title_Box_Additional_Link)))
                    {
                        // Get the translated TYPE
                        string type = UI_ApplicationCache_Gateway.Translation.Get_Translation((CurrentItem.Web.Title_Box_Additional_Link_Type ?? "Related Link"), RequestSpecificValues.Current_Mode.Language);

                        // Add the link
                        Output.WriteLine("\t" + CurrentItem.Web.Title_Box_Additional_Link + " ( " + type + " )<br />");
                    }


                    // If there is an ACCESSION number and this is an ARTIFACT, include that at the top
                    BriefItem_DescriptiveTerm accessNumber = CurrentItem.Get_Description("Accession Number");
                    if ((accessNumber != null) && (accessNumber.Values != null) && (accessNumber.Values.Count > 0))
                    {
                        Output.WriteLine("\t" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Accession number", RequestSpecificValues.Current_Mode.Language) + " " + accessNumber.Values[0].Value + "<br />");
                    }
                }


                Output.WriteLine("</section>");
                Output.WriteLine();
            }
        }
Exemple #9
0
        public void Simple_Item_XML(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            // Must at least have one URL segment for the BibID
            if (UrlSegments.Count > 0)
            {
                Custom_Tracer tracer = new Custom_Tracer();

                try
                {
                    // Get the BibID and VID
                    string bibid = UrlSegments[0];
                    string vid   = (UrlSegments.Count > 1) ? UrlSegments[1] : "00001";

                    tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "Requested citation for " + bibid + ":" + vid);

                    // Get the brief item
                    tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "Build full brief item");
                    Tuple <BriefItemInfo, Items.SobekCM_Item_Error> returnTuple = GetBriefItem(bibid, vid, null, tracer);

                    // Was the item null?
                    if ((returnTuple == null) || (returnTuple.Item1 == null))
                    {
                        // If this was debug mode, then just write the tracer
                        if (IsDebug)
                        {
                            tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "NULL value returned from getBriefItem method");
                            Response.ContentType = "text/plain";
                            Response.Output.WriteLine("DEBUG MODE DETECTED");
                            Response.Output.WriteLine();

                            // Was an error received though?
                            if ((returnTuple != null) && (returnTuple.Item2 != null))
                            {
                                Items.SobekCM_Item_Error itemError = returnTuple.Item2;
                                switch (itemError.Type)
                                {
                                case Items.SobekCM_Item_Error_Type_Enum.Invalid_BibID:
                                    Response.Output.WriteLine("ERROR: Invalid BibID requested");
                                    break;

                                case Items.SobekCM_Item_Error_Type_Enum.Invalid_VID:
                                    Response.Output.WriteLine("ERROR: Invalid VID requested");
                                    Response.Output.WriteLine("First valid VID is " + itemError.FirstValidVid);
                                    break;

                                case Items.SobekCM_Item_Error_Type_Enum.System_Error:
                                    Response.Output.WriteLine("System ERROR detected while attempting to create the item");
                                    Response.Output.WriteLine(itemError.Message);
                                    break;
                                }

                                Response.Output.WriteLine();
                            }

                            Response.Output.WriteLine(tracer.Text_Trace);
                        }
                        return;
                    }

                    // Get the brief item info
                    BriefItemInfo returnValue = returnTuple.Item1;

                    // If this was debug mode, then just write the tracer
                    if (IsDebug)
                    {
                        Response.ContentType = "text/plain";
                        Response.Output.WriteLine("DEBUG MODE DETECTED");
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(tracer.Text_Trace);

                        return;
                    }

                    // If this is dark, do nothing
                    if (returnValue.Behaviors.Dark_Flag)
                    {
                        Response.ContentType = "text/plain";
                        Response.Output.WriteLine("Item is restricted");
                        Response.StatusCode = 403;
                        return;
                    }


                    // Create and write the basic item info
                    Response.Output.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>");
                    Response.Output.WriteLine("<item bibid=\"" + returnValue.BibID + "\" vid=\"" + returnValue.VID + "\">");
                    Response.Output.WriteLine("    <title>" + HttpUtility.HtmlEncode(returnValue.Title) + "</title>");
                    Response.Output.WriteLine("    <url_item>" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + returnValue.BibID + "/" + returnValue.VID + "/</url_item>");

                    // Add the thumbnail URL
                    if (!String.IsNullOrEmpty(returnValue.Behaviors.Main_Thumbnail))
                    {
                        try
                        {
                            Response.Output.WriteLine("    <url_thumbnail>" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL +
                                                      SobekFileSystem.AssociFilePath(returnValue.BibID, returnValue.VID).Replace("\\", "/") + returnValue.Behaviors.Main_Thumbnail.Trim() + "</url_thumbnail>");
                        }
                        catch (Exception ee)
                        {
                            Response.Output.WriteLine("ERROR WRITING THUMBNAIL");
                            Response.Output.WriteLine(ee.Message);
                            Response.Output.WriteLine(ee.StackTrace);
                        }
                    }

                    Response.Output.WriteLine("    <metadata>");

                    // Step through the citation configuration here
                    CitationSet citationSet = Engine_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet();
                    foreach (CitationFieldSet fieldsSet in citationSet.FieldSets)
                    {
                        // Step through all the fields in this field set and write them
                        foreach (CitationElement thisField in fieldsSet.Elements)
                        {
                            // Look for a match in the item description
                            BriefItem_DescriptiveTerm briefTerm = returnValue.Get_Description(thisField.MetadataTerm);

                            // If no match, just continue
                            if ((briefTerm == null) || (briefTerm.Values.Count == 0))
                            {
                                continue;
                            }

                            // Get the clean XML tag for this term
                            string cleaned_metadata_term = HttpUtility.HtmlEncode(thisField.DisplayTerm.Replace(" ", "_").Replace("/", "_").Replace("__", "_").Replace("__", "_"));

                            foreach (BriefItem_DescTermValue term in briefTerm.Values)
                            {
                                Response.Output.WriteLine("        <" + cleaned_metadata_term + ">" + HttpUtility.HtmlEncode(term.Value) + "</" + cleaned_metadata_term + ">");
                            }
                        }
                    }

                    Response.Output.WriteLine("    </metadata>");
                    Response.Output.WriteLine("</item>");
                }
                catch (Exception ee)
                {
                    if (IsDebug)
                    {
                        Response.ContentType = "text/plain";
                        Response.Output.WriteLine("EXCEPTION CAUGHT!");
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ee.Message);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ee.StackTrace);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(tracer.Text_Trace);
                        return;
                    }

                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("Error completing request");
                    Response.StatusCode = 500;
                }
            }
        }
        /// <summary> Map one or more data elements from the original METS-based object to the
        /// BriefItem object </summary>
        /// <param name="Original"> Original METS-based object </param>
        /// <param name="New"> New object to populate some data from the original </param>
        /// <returns> TRUE if successful, FALSE if an exception is encountered </returns>
        public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New)
        {
            if (Original.Bib_Info.Subjects_Count > 0)
            {
                int spatial_count = 1;
                foreach (Subject_Info thisSubject in Original.Bib_Info.Subjects)
                {
                    if (thisSubject.Class_Type == Subject_Info_Type.Hierarchical_Spatial)
                    {
                        // Determine the term to use
                        string term = "Hierarchical Spatial";
                        if (spatial_count > 1)
                        {
                            term = term + " (" + spatial_count + ")";
                        }

                        // Start to build this
                        BriefItem_DescriptiveTerm thisTerm = new BriefItem_DescriptiveTerm(term);

                        // Cast to the hierarchical geographic subject
                        Subject_Info_HierarchicalGeographic hieroSubj = (Subject_Info_HierarchicalGeographic)thisSubject;

                        // Now, step through and add each subterm
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Continent))
                        {
                            thisTerm.Add_Value(hieroSubj.Continent, "Continent");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Country))
                        {
                            thisTerm.Add_Value(hieroSubj.Country, "Country");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Province))
                        {
                            thisTerm.Add_Value(hieroSubj.Province, "Province");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Region))
                        {
                            thisTerm.Add_Value(hieroSubj.Region, "Region");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.State))
                        {
                            thisTerm.Add_Value(hieroSubj.State, "State");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Territory))
                        {
                            thisTerm.Add_Value(hieroSubj.Territory, "Territory");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.County))
                        {
                            thisTerm.Add_Value(hieroSubj.County, "County");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.City))
                        {
                            thisTerm.Add_Value(hieroSubj.City, "City");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.CitySection))
                        {
                            thisTerm.Add_Value(hieroSubj.CitySection, "City Section");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Island))
                        {
                            thisTerm.Add_Value(hieroSubj.Island, "Island");
                        }
                        if (!String.IsNullOrWhiteSpace(hieroSubj.Area))
                        {
                            thisTerm.Add_Value(hieroSubj.Area, "Area");
                        }

                        // Were some values found?
                        if ((thisTerm.Values != null) && (thisTerm.Values.Count > 0))
                        {
                            New.Add_Description(thisTerm);
                            spatial_count++;
                        }
                    }
                }
            }

            return(true);
        }