/// <summary> Builds a title-level digital resource object for the given BibID </summary> /// <param name="BibID"> Bibliographic identifier for the digital resource to build </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <param name="Item_Group_Object"> [OUT] Fully built item group object </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> /// <remarks> This method relies heavily upon the <see cref="SobekCM_METS_Based_ItemBuilder"/> class to actually /// read the METS files and build the items. </remarks> public static void Get_Item_Group(string BibID, Custom_Tracer Tracer, out SobekCM_Items_In_Title Items_In_Title, out SobekCM_Item Item_Group_Object) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Item_Factory.Get_Item_Group", "Build this item group"); } // Get the METS based item builder SobekCM_METS_Based_ItemBuilder builder = new SobekCM_METS_Based_ItemBuilder(); // Allow the builder to build the item builder.Build_Item_Group(BibID, Tracer, out Items_In_Title, out Item_Group_Object); }
/// <summary> Builds a title-level digital resource object for the given BibID </summary> /// <param name="BibID"> Bibliographic identifier for the digital resource to build </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <param name="Item_Group_Object"> [OUT] Fully built item group object </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> /// <remarks> This method relies heavily upon the <see cref="SobekCM_METS_Based_ItemBuilder"/> class to actually /// read the METS files and build the items. </remarks> public static void Get_Item_Group(string BibID, Custom_Tracer Tracer, out SobekCM_Items_In_Title Items_In_Title, out SobekCM_Item Item_Group_Object) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Item_Factory.Get_Item_Group", "Build this item group"); } // Get the METS based item builder SobekCM_METS_Based_ItemBuilder builder = new SobekCM_METS_Based_ItemBuilder(); // Allow the builder to build the item builder.Build_Item_Group(BibID, Tracer, out Items_In_Title, out Item_Group_Object ); }
/// <summary> Stores the list of items for a single bibid to the cache or caching server </summary> /// <param name="BibID"> Bibliographic identifier for the list of items </param> /// <param name="StoreObject"> List of items within the single title </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> public static void Store_Items_In_Title( string BibID , SobekCM_Items_In_Title StoreObject, Custom_Tracer Tracer) { // If the cache is disabled, just return before even tracing if (Disabled) return; if (Tracer != null) { Tracer.Add_Trace("Cached_Data_Manager.Store_Items_In_Title", ""); } // Store this on the local cache, if not there and storing on the cache server failed string key = "ITEMLIST_" + BibID; if (HttpContext.Current.Cache[key] == null) { if (Tracer != null) { Tracer.Add_Trace("Cached_Data_Manager.Store_Items_In_Title", "Adding object '" + key + "' to the local cache with expiration of 1 minutes"); } HttpContext.Current.Cache.Insert(key, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1)); } }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Item_List"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Search_History"> List of recent searches performed against this digital library </param> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Checked_Items"> List of all items which are currently checked out for single fair use and the IP address currently viewing the item</param> /// <param name="IP_Restrictions"> Any possible restriction on item access by IP ranges </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of static web content pages </param> /// <param name="Items_In_Title"> List of items within the current title ( used for the Item Group display )</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Html_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, SobekCM_Skin_Object HTML_Skin, User_Object Current_User, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, Statistics_Dates Stats_Date_Range, Recent_Searches Search_History, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<Thematic_Heading> Thematic_Headings, Public_User_Folder Public_Folder, Dictionary<string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, Checked_Out_Items_List Checked_Items, IP_Restriction_Ranges IP_Restrictions, Portal_List URL_Portals, SobekCM_SiteMap Site_Map, SobekCM_Items_In_Title Items_In_Title, HTML_Based_Content Static_Web_Content, Custom_Tracer Tracer ) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // Save parameters htmlSkin = HTML_Skin; translator = Translator; codeManager = Code_Manager; itemList = Item_List; statsDateRange = Stats_Date_Range; searchHistory = Search_History; currentUser = Current_User; iconList = Icon_Dictionary; thematicHeadings = Thematic_Headings; publicFolder = Public_Folder; aggregationAliases = Aggregation_Aliases; webSkins = Web_Skin_Collection; checkedItems = Checked_Items; ipRestrictionInfo = IP_Restrictions; urlPortals = URL_Portals; siteMap = Site_Map; itemsInTitle = Items_In_Title; // Set some defaults // Handle basic events which may be fired by the internal header if (HttpContext.Current.Request.Form["internal_header_action"] != null) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to hide or show the header? if ((internalHeaderAction == "hide") || (internalHeaderAction == "show")) { // Pull the current visibility from the session bool shown = !((HttpContext.Current.Session["internal_header"] != null) && (HttpContext.Current.Session["internal_header"].ToString() == "hidden")); if ((internalHeaderAction == "hide") && (shown)) { HttpContext.Current.Session["internal_header"] = "hidden"; currentMode.Redirect(); return; } if ((internalHeaderAction == "show") && (!shown)) { HttpContext.Current.Session["internal_header"] = "shown"; currentMode.Redirect(); return; } } } try { // Create the html sub writer now switch (Current_Mode.Mode) { case Display_Mode_Enum.Internal: subwriter = new Internal_HtmlSubwriter(iconList, currentUser, codeManager); break; case Display_Mode_Enum.Statistics: subwriter = new Statistics_HtmlSubwriter(searchHistory, codeManager, statsDateRange); break; case Display_Mode_Enum.Preferences: subwriter = new Preferences_HtmlSubwriter(currentMode); break; case Display_Mode_Enum.Error: subwriter = new Error_HtmlSubwriter(false); // Send the email now if (currentMode.Caught_Exception != null) { if (currentMode.Error_Message.Length == 0) currentMode.Error_Message = "Unknown exception caught"; Email_Information(currentMode.Error_Message, currentMode.Caught_Exception, Tracer, false); } break; case Display_Mode_Enum.Legacy_URL: subwriter = new LegacyUrl_HtmlSubwriter(); break; case Display_Mode_Enum.Item_Print: subwriter = new Print_Item_HtmlSubwriter(currentItem, codeManager, translator, currentMode); break; case Display_Mode_Enum.Contact: StringBuilder builder = new StringBuilder(); builder.Append("\n\nSUBMISSION INFORMATION\n"); builder.Append("\tDate:\t\t\t\t" + DateTime.Now.ToString() + "\n"); string lastMode = String.Empty; try { if (HttpContext.Current.Session["Last_Mode"] != null) lastMode = HttpContext.Current.Session["Last_Mode"].ToString(); builder.Append("\tIP Address:\t\t\t" + HttpContext.Current.Request.UserHostAddress + "\n"); builder.Append("\tHost Name:\t\t\t" + HttpContext.Current.Request.UserHostName + "\n"); builder.Append("\tBrowser:\t\t\t" + HttpContext.Current.Request.Browser.Browser + "\n"); builder.Append("\tBrowser Platform:\t\t" + HttpContext.Current.Request.Browser.Platform + "\n"); builder.Append("\tBrowser Version:\t\t" + HttpContext.Current.Request.Browser.Version + "\n"); builder.Append("\tBrowser Language:\t\t"); bool first = true; string[] languages = HttpContext.Current.Request.UserLanguages; if (languages != null) foreach (string thisLanguage in languages) { if (first) { builder.Append(thisLanguage); first = false; } else { builder.Append(", " + thisLanguage); } } builder.Append("\n\nHISTORY\n"); if (HttpContext.Current.Session["LastSearch"] != null) builder.Append("\tLast Search:\t\t" + HttpContext.Current.Session["LastSearch"] + "\n"); if (HttpContext.Current.Session["LastResults"] != null) builder.Append("\tLast Results:\t\t" + HttpContext.Current.Session["LastResults"] + "\n"); if (HttpContext.Current.Session["Last_Mode"] != null) builder.Append("\tLast Mode:\t\t\t" + HttpContext.Current.Session["Last_Mode"] + "\n"); builder.Append("\tURL:\t\t\t\t" + HttpContext.Current.Items["Original_URL"]); } catch { } subwriter = new Contact_HtmlSubwriter(lastMode, builder.ToString(), currentMode, hierarchyObject); break; case Display_Mode_Enum.Contact_Sent: subwriter = new Contact_HtmlSubwriter(String.Empty, String.Empty, currentMode, hierarchyObject); break; case Display_Mode_Enum.Simple_HTML_CMS: subwriter = new Web_Content_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, htmlBasedContent, siteMap); break; case Display_Mode_Enum.My_Sobek: subwriter = new MySobek_HtmlSubwriter(results_statistics, paged_results, codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, currentItem, currentUser, iconList, statsDateRange, webSkins, Tracer); break; case Display_Mode_Enum.Administrative: subwriter = new Admin_HtmlSubwriter(codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, aggregationAliases, webSkins, currentUser, ipRestrictionInfo, iconList, urlPortals, thematicHeadings, Tracer); break; case Display_Mode_Enum.Results: subwriter = new Search_Results_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser); break; case Display_Mode_Enum.Public_Folder: subwriter = new Public_Folder_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser, publicFolder); break; case Display_Mode_Enum.Search: case Display_Mode_Enum.Aggregation: subwriter = new Aggregation_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, translator, thisBrowseObject, results_statistics, paged_results, codeManager, itemList, thematicHeadings, currentUser, htmlBasedContent, Tracer); break; case Display_Mode_Enum.Item_Display: if ((!currentMode.Invalid_Item) && (currentItem != null)) { bool show_toc = false; if (HttpContext.Current.Session["Show TOC"] != null) { Boolean.TryParse(HttpContext.Current.Session["Show TOC"].ToString(), out show_toc); } // Check that this item is not checked out by another user bool itemCheckedOutByOtherUser = false; if (currentItem.Behaviors.CheckOut_Required) { if (!checkedItems.Check_Out(currentItem.Web.ItemID, HttpContext.Current.Request.UserHostAddress)) { itemCheckedOutByOtherUser = true; } } // Check to see if this is IP restricted string restriction_message = String.Empty; if (currentItem.Behaviors.IP_Restriction_Membership > 0) { if (HttpContext.Current != null) { int user_mask = (int)HttpContext.Current.Session["IP_Range_Membership"]; int comparison = currentItem.Behaviors.IP_Restriction_Membership & user_mask; if (comparison == 0) { int restriction = currentItem.Behaviors.IP_Restriction_Membership; int restriction_counter = 0; while (restriction % 2 != 1) { restriction = restriction >> 1; restriction_counter++; } restriction_message = ipRestrictionInfo[restriction_counter].Item_Restricted_Statement; } } } // Create the item viewer writer subwriter = new Item_HtmlSubwriter(currentItem, currentPage, currentUser, codeManager, translator, show_toc, (SobekCM_Library_Settings.JP2ServerUrl.Length > 0), currentMode, hierarchyObject, restriction_message, itemsInTitle, Tracer); ((Item_HtmlSubwriter)subwriter).Item_Checked_Out_By_Other_User = itemCheckedOutByOtherUser; } else { // Create the invalid item html subwrite and write the HTML subwriter = new Error_HtmlSubwriter(true); } break; } } catch (Exception ee) { // Send to the dashboard if ((HttpContext.Current.Request.UserHostAddress == "127.0.0.1") || (HttpContext.Current.Request.UserHostAddress == HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]) || (HttpContext.Current.Request.Url.ToString().IndexOf("localhost") >= 0)) { Tracer.Add_Trace("Html_MainWriter.Constructor", "Exception caught!", Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.Message, Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.StackTrace, Custom_Trace_Type_Enum.Error); // Wrap this into the SobekCM Exception SobekCM_Traced_Exception newException = new SobekCM_Traced_Exception("Exception caught while building the mode-specific HTML Subwriter", ee, Tracer); // Save this to the session state, and then forward to the dashboard HttpContext.Current.Session["Last_Exception"] = newException; HttpContext.Current.Response.Redirect("dashboard.aspx", false); Current_Mode.Request_Completed = true; return; } else { subwriter = new Error_HtmlSubwriter(false); } } if (subwriter != null) { subwriter.Mode = currentMode; subwriter.Skin = htmlSkin; subwriter.Current_Aggregation = hierarchyObject; } }
/// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Items_In_Title"> List of items within this title </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Group_Add_Volume_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary<string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, SobekCM_Items_In_Title Items_In_Title, Language_Support_Info Translator, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; itemsInTitle = Items_In_Title; base.Translator = Translator; skins = HTML_Skin_Collection; // Set some defaults ipRestrict = -1; title = String.Empty; date = String.Empty; level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level1Order = -1; level2Order = -1; level3Order = -1; hierarchyCopiedFromDate = false; message = String.Empty; trackingBox = String.Empty; bornDigital = false; materialRecdDate = null; materialRecdNotes = String.Empty; dispositionAdvice = -1; dispositionAdviceNotes = String.Empty; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // Determine the default template code string template_code = "addvolume"; if (!user.Include_Tracking_In_Standard_Forms) template_code = "addvolume_notracking"; // Load this template template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["action"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } else if (hidden_request.IndexOf("save") == 0 ) { // Get the VID that used as a source for this string vid = HttpContext.Current.Request.Form["base_volume"]; if (string.IsNullOrEmpty(vid)) { message = "<span style=\"color: red\"><strong>No base volume selected!</strong></span>"; } else { try { // Get a new instance of this item SobekCM_Item saveItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, vid, Icon_Table, null, Tracer); // Clear some values for this item saveItem.VID = String.Empty; saveItem.Divisions.Clear(); saveItem.Behaviors.Serial_Info.Clear(); saveItem.Bib_Info.Series_Part_Info.Clear(); saveItem.Behaviors.Clear_Ticklers(); saveItem.Tracking.Internal_Comments = String.Empty; saveItem.Bib_Info.Location.PURL = String.Empty; saveItem.Behaviors.Main_Thumbnail = String.Empty; saveItem.METS_Header.Create_Date = DateTime.Now; saveItem.METS_Header.Modify_Date = saveItem.METS_Header.Create_Date; saveItem.METS_Header.Creator_Software = "SobekCM Web - Online add a volume (derived from VID " + vid + ")"; saveItem.METS_Header.Clear_Creator_Individual_Notes(); saveItem.METS_Header.Creator_Individual = user.Full_Name; saveItem.Bib_Info.Location.Other_URL = String.Empty; saveItem.Bib_Info.Location.Other_URL_Display_Label = String.Empty; saveItem.Bib_Info.Location.Other_URL_Note = String.Empty; // Save the template changes to this item template.Save_To_Bib(saveItem, user, 1); // Save this item and copy over complete_item_submission(saveItem, Tracer); // Clear the volume list Cached_Data_Manager.Remove_Items_In_Title(saveItem.BibID, Tracer); // Forward differently depending on request switch (hidden_request) { case "save_edit": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; case "save_again": // No redirect, but save values date = saveItem.Bib_Info.Origin_Info.Date_Issued; ipRestrict = saveItem.Behaviors.IP_Restriction_Membership; trackingBox = saveItem.Tracking.Tracking_Box; bornDigital = saveItem.Tracking.Born_Digital; dispositionAdvice = saveItem.Tracking.Disposition_Advice; dispositionAdviceNotes = saveItem.Tracking.Disposition_Advice_Notes; materialRecdDate = saveItem.Tracking.Material_Received_Date; materialRecdNotes = saveItem.Tracking.Material_Received_Notes; if (!hierarchyCopiedFromDate) { if (saveItem.Behaviors.Serial_Info.Count > 0) { level1 = saveItem.Behaviors.Serial_Info[0].Display; level1Order = saveItem.Behaviors.Serial_Info[0].Order; } if (saveItem.Behaviors.Serial_Info.Count > 1) { level2 = saveItem.Behaviors.Serial_Info[1].Display; level2Order = saveItem.Behaviors.Serial_Info[1].Order; } if (saveItem.Behaviors.Serial_Info.Count > 2) { level3 = saveItem.Behaviors.Serial_Info[2].Display; level3Order = saveItem.Behaviors.Serial_Info[2].Order; } } message = message + "<span style=\"color: blue\"><strong>Saved new volume ( " + saveItem.BibID + " : " + saveItem.VID + ")</strong></span>"; break; case "save_addfiles": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; default: currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; } } catch ( Exception ee ) { message = message + "<br /><span style=\"color: red\"><strong>EXCEPTION CAUGHT!<br /><br />" + ee.Message + "<br /><br />" + ee.StackTrace.Replace("\n","<br />") + "</strong></span>"; } } } }
/// <summary> Get a digital resource for display or for editing </summary> /// <param name="Collection_Code"> Collection code to which this item must belong </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Base_URL"> Base URL for all the digital resource files for items to display </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Current_User"> Currently logged on user information (used when editing an item)</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Current_Item"> [OUT] Built single digital resource ready for displaying or editing </param> /// <param name="Current_Page"> [OUT] Build current page for display </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> This attempts to pull the objects from the cache. If unsuccessful, it builds the objects from the /// database and hands off to the <see cref="Cached_Data_Manager" /> to store in the cache. If the item must be /// built from scratch, the <see cref="Items.SobekCM_Item_Factory"/> class is utilized. </remarks> public bool Get_Item(string Collection_Code, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, string Base_URL, Dictionary<string, Wordmark_Icon> Icon_Table, Custom_Tracer Tracer, User_Object Current_User, out SobekCM_Item Current_Item, out Page_TreeNode Current_Page, out SobekCM_Items_In_Title Items_In_Title) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Item", String.Empty); } // Initially assign nulls Current_Item = null; Current_Page = null; Items_In_Title = null; // Check for legacy reference by itemid if ((Current_Mode.BibID.Length == 0) && (Current_Mode.ItemID_DEPRECATED > 0)) { DataRow thisRowInfo = SobekCM_Database.Lookup_Item_By_ItemID(Current_Mode.ItemID_DEPRECATED, Tracer); if (thisRowInfo == null) { Current_Mode.Invalid_Item = true; return false; } Current_Mode.Mode = Display_Mode_Enum.Legacy_URL; Current_Mode.Error_Message = Current_Mode.Base_URL + thisRowInfo["BibID"] + "/" + thisRowInfo["VID"]; return false; } // Must at least have a bib id of the proper length if (Current_Mode.BibID.Length < 10) { Current_Mode.Invalid_Item = true; return false; } // Get the title object for this bool item_group_display = false; Multiple_Volume_Item dbTitle = All_Items_Lookup.Title_By_Bib(Current_Mode.BibID); if (dbTitle == null) { Current_Mode.Invalid_Item = true; return false; } // Try to get the very basic information about this item, to determine if the // bib / vid combination is valid Single_Item selected_item = null; // Certain mySobek modes only need the item group if (( Current_Mode.Mode == Display_Mode_Enum.My_Sobek ) && (( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Edit_Group_Behaviors ) || ( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy ) || ( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Group_Add_Volume ) || ( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Group_AutoFill_Volumes ) || ( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Group_Mass_Update_Items ))) { item_group_display = true; } // If this is not a mode that is only item group display, try to pull the item if (!item_group_display) { if ((Current_Mode.VID.Length > 0) && (Current_Mode.VID != "00000")) { selected_item = All_Items_Lookup.Item_By_Bib_VID(Current_Mode.BibID, Current_Mode.VID, Tracer); } else { if ((dbTitle.Item_Count == 1) && (Current_Mode.VID != "00000")) { selected_item = All_Items_Lookup.Item_By_Bib_Only(Current_Mode.BibID); } else { item_group_display = true; } } } // If no valid item and not a valid item group display either, return if ((selected_item == null) && (!item_group_display)) { Current_Mode.Invalid_Item = true; return false; } // If this is for a single item, return that if (selected_item != null) { // Make sure the VID is set Current_Mode.VID = selected_item.VID; // Try to get this from the cache if ((Current_Mode.Mode == Display_Mode_Enum.My_Sobek) && ( Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Edit_Item_Metadata ) && (Current_User != null)) Current_Item = Cached_Data_Manager.Retrieve_Digital_Resource_Object(Current_User.UserID, Current_Mode.BibID, Current_Mode.VID, Tracer); else Current_Item = Cached_Data_Manager.Retrieve_Digital_Resource_Object( Current_Mode.BibID, Current_Mode.VID, Tracer); // If not pulled from the cache, then we will have to build the item if (Current_Item == null) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Item", "Build the item"); } Current_Item = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, Current_Mode.VID, Icon_Table, Tracer); if (Current_Item != null) { if ((Current_Mode.Mode == Display_Mode_Enum.My_Sobek) && (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Edit_Item_Metadata) && (Current_User != null)) { string note_to_add = "Online edit by " + Current_User.Full_Name + " ( " + DateTime.Now.ToShortDateString() + " )"; Current_Item.METS_Header.Add_Creator_Individual_Notes( note_to_add ); Cached_Data_Manager.Store_Digital_Resource_Object(Current_User.UserID, Current_Mode.BibID, Current_Mode.VID, Current_Item, Tracer); } else Cached_Data_Manager.Store_Digital_Resource_Object(Current_Mode.BibID, Current_Mode.VID, Current_Item, Tracer); } } else { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Item", "Item found in the cache"); } } // If an item was requested and none was found, go to the current home if ((Current_Item == null)) { if (Tracer != null && !Tracer.Enabled) { Current_Mode.Mode = Display_Mode_Enum.Aggregation_Home; return false; } return false; } // Get the page to display (printing has its own specification of page(s) to display) if (Current_Mode.Mode != Display_Mode_Enum.Item_Print) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Item", "Get the current page"); } Current_Page = SobekCM_Item_Factory.Get_Current_Page(Current_Item, Current_Mode.Page, Tracer); } } else if (item_group_display) { // Try to get this from the cache Current_Item = Cached_Data_Manager.Retrieve_Digital_Resource_Object(Current_Mode.BibID, Tracer); // Have to build this item group information then if (Current_Item == null) { string bibID = Current_Mode.BibID; SobekCM_Item_Factory.Get_Item_Group(bibID, Tracer, out Items_In_Title, out Current_Item ); if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Item", "TEST LOG ENTRY"); } if (Current_Item == null) { Exception ee = SobekCM_Database.Last_Exception; if (Tracer != null) Tracer.Add_Trace("SobekCM_Assistant.Get_Item", ee != null ? ee.Message : "NO DATABASE EXCEPTION", Custom_Trace_Type_Enum.Error); Current_Mode.Invalid_Item = true; return false; } // Put this back on the cache Current_Item.METS_Header.RecordStatus_Enum = METS_Record_Status.BIB_LEVEL; Cached_Data_Manager.Store_Digital_Resource_Object(bibID, Current_Item, Tracer); Cached_Data_Manager.Store_Items_In_Title(bibID, Items_In_Title, Tracer); } } return true; }
/// <summary> Get a digital resource for display or for editing </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Base_URL"> Base URL for all the digital resource files for items to display </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Current_User"> Currently logged on user information (used when editing an item)</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Current_Item"> [OUT] Built single digital resource ready for displaying or editing </param> /// <param name="Current_Page"> [OUT] Build current page for display </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> This attempts to pull the objects from the cache. If unsuccessful, it builds the objects from the /// database and hands off to the <see cref="Cached_Data_Manager" /> to store in the cache. If the item must be /// built from scratch, the <see cref="Items.SobekCM_Item_Factory"/> class is utilized. </remarks> public bool Get_Item(SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, string Base_URL, Dictionary<string, Wordmark_Icon> Icon_Table, User_Object Current_User, Custom_Tracer Tracer, out SobekCM_Item Current_Item, out Page_TreeNode Current_Page, out SobekCM_Items_In_Title Items_In_Title ) { return Get_Item(String.Empty, Current_Mode, All_Items_Lookup, Base_URL, Icon_Table, Tracer, Current_User, out Current_Item, out Current_Page, out Items_In_Title); }
/// <summary> Constructor for a new instance of the Edit_Item_Group_Form class </summary> /// <param name="Group_Info"> List of all the items within this item group </param> /// <param name="BibID"> BibID of the current item being displayed </param> public Edit_Serial_Hierarchy_Form(string BibID, SobekCM_Items_In_Title Group_Info) { groupInfo = Group_Info; bibid = BibID; // Get references to each column itemIdColumn = groupInfo.Item_Table.Columns["ItemID"]; titleColumn = groupInfo.Item_Table.Columns["Title"]; level1TextColumn = groupInfo.Item_Table.Columns["Level1_Text"]; level1IndexColumn = groupInfo.Item_Table.Columns["Level1_Index"]; level2TextColumn = groupInfo.Item_Table.Columns["Level2_Text"]; level2IndexColumn = groupInfo.Item_Table.Columns["Level2_Index"]; level3TextColumn = groupInfo.Item_Table.Columns["Level3_Text"]; level3IndexColumn = groupInfo.Item_Table.Columns["Level3_Index"]; vidColumn = groupInfo.Item_Table.Columns["VID"]; if (!groupInfo.Item_Table.Columns.Contains("sort1")) { groupInfo.Item_Table.Columns.Add("sort1", Type.GetType("System.Int32")); groupInfo.Item_Table.Columns.Add("sort2", Type.GetType("System.Int32")); groupInfo.Item_Table.Columns.Add("sort3", Type.GetType("System.Int32")); groupInfo.Item_Table.Columns.Add("changed", Type.GetType("System.Boolean")); } foreach ( DataRow thisRow in groupInfo.Item_Table.Rows) { thisRow["sort1"] = thisRow[ level1IndexColumn ]; thisRow["sort2"] = thisRow[ level2IndexColumn]; thisRow["sort3"] = thisRow[ level3IndexColumn]; thisRow["changed"] = false; } view = new DataView(groupInfo.Item_Table) {Sort = "sort1 ASC, sort2 ASC, sort3 ASC"}; InitializeComponent(); isXp = true; if (!Windows_Appearance_Checker.is_XP_Theme) { isXp = false; checkBox1.FlatStyle = FlatStyle.Flat; checkBox1.BackColor = Color.White; } BackColor = Color.FromArgb(240, 240, 240); headerPanel.BackColor = Color.FromArgb(25, 68, 141); Text = "Edit Item Group Information ( " + BibID + " )"; rows = new List<Serial_Hierarchy_Row>(); oddRow = true; locationY = 0; index = 0; if (groupInfo.Item_Table.Rows.Count < ROWS_PER_PAGE) { nextButton.Button_Enabled = false; prevButton.Button_Enabled = false; foreach (object t in groupInfo.Item_Table.Rows) { add_row(); } } else { prevButton.Button_Enabled = false; for (int i = 0; i < ROWS_PER_PAGE; i++) { add_row(); } } show_serial_hierarchy(); // Set the size correctly Size = SMaRT_UserSettings.Edit_Hierarchy_Form_Size; int screen_width = Screen.PrimaryScreen.WorkingArea.Width; int screen_height = Screen.PrimaryScreen.WorkingArea.Height; if ((Width > screen_width) || (Height > screen_height) || ( SMaRT_UserSettings.Edit_Hierarchy_Form_Maximized )) WindowState = FormWindowState.Maximized; }
/// <summary> Constructor for a new instance of the Item_HtmlSubwriter class </summary> /// <param name="Current_Item">Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="Current_User"> Currently logged on user for determining rights over this item </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="ShowToc"> Flag indicates whether to show the table of contents open for this item </param> /// <param name="Show_Zoomable"> Flag indicates if the zoomable server is available </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Collection"> Current item aggregation this item is being displayed from (if there is one) </param> /// <param name="Item_Restricted_Message"> Message to be shown because this item is restriced from the current user by IP address </param> /// <param name="Items_In_Title"> List of items within a title (for item group display in particular) </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Item_HtmlSubwriter(SobekCM_Item Current_Item, Page_TreeNode Current_Page, User_Object Current_User, Aggregation_Code_Manager Code_Manager, Language_Support_Info Translator, bool ShowToc, bool Show_Zoomable, SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Collection, string Item_Restricted_Message, SobekCM_Items_In_Title Items_In_Title, Custom_Tracer Tracer ) { Mode = Current_Mode; currentUser = Current_User; currentItem = Current_Item; currentPage = Current_Page; itemsInTitle = Items_In_Title; translations = Translator; showToc = ShowToc; showZoomable = Show_Zoomable; Current_Aggregation = Current_Collection; itemCheckedOutByOtherUser = false; userCanEditItem = false; searchResultsCount = 0; // Determine if this item is an EAD isEadTypeItem = (currentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY) != null); // Determine if this item is actually restricted itemRestrictedFromUserByIp = Item_Restricted_Message.Length > 0; // Determine if this user can edit this item if (currentUser != null) { userCanEditItem = currentUser.Can_Edit_This_Item(currentItem); } // If this item is restricted by IP than alot of the upcoming code is unnecessary if (( currentUser != null ) && ((!itemRestrictedFromUserByIp) || ( userCanEditItem ) || ( currentUser.Is_Internal_User ))) { #region Region suppressed currently - was for adding feature to a map image? //// Searching for EAD/EAC type items is different from others //if (!isEadTypeItem) //{ // // If there is a coordinate search, and polygons, do that // // GEt the geospatial metadata module // GeoSpatial_Information geoInfo = currentItem.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; // if ((geoInfo != null) && (geoInfo.hasData)) // { // if ((currentMode.Coordinates.Length > 0) && (geoInfo.Polygon_Count > 1)) // { // // Determine the coordinates in this search // string[] splitter = currentMode.Coordinates.Split(",".ToCharArray()); // if (((splitter.Length > 1) && (splitter.Length < 4)) || ((splitter.Length == 4) && (splitter[2].Length == 0) && (splitter[3].Length == 0))) // { // Double.TryParse(splitter[0], out providedMaxLat); // Double.TryParse(splitter[1], out providedMaxLong); // providedMinLat = providedMaxLat; // providedMinLong = providedMaxLong; // } // else if (splitter.Length >= 4) // { // Double.TryParse(splitter[0], out providedMaxLat); // Double.TryParse(splitter[1], out providedMaxLong); // Double.TryParse(splitter[2], out providedMinLat); // Double.TryParse(splitter[3], out providedMinLong); // } // // Now, if there is length, determine the count of results // searchResultsString = new List<string>(); // if (searchResultsString.Count > 0) // { // searchResultsCount = searchResultsString.Count; // // Also, look to see where the current point lies in the matching, current polygon // if ((providedMaxLong == providedMinLong) && (providedMaxLat == providedMinLat)) // { // foreach (Coordinate_Polygon itemPolygon in geoInfo.Polygons) // { // // Is this the current page? // if (itemPolygon.Page_Sequence == currentMode.Page) // { // if (itemPolygon.is_In_Bounding_Box(providedMaxLat, providedMaxLong)) // { // searchMatchOnThisPage = true; // ReadOnlyCollection<Coordinate_Point> boundingBox = itemPolygon.Bounding_Box; // featureYRatioLocation = Math.Abs(((providedMaxLat - boundingBox[0].Latitude)/(boundingBox[0].Latitude - boundingBox[1].Latitude))); // featureXRatioLocation = Math.Abs(((providedMaxLong - boundingBox[0].Longitude)/(boundingBox[0].Longitude - boundingBox[1].Longitude))); // } // } // } // } // } // } // } //} #endregion // Is this a postback? if (currentMode.isPostBack) { // Handle any actions from standard user action (i.e., email, add to bookshelf, etc.. ) if (HttpContext.Current.Request.Form["item_action"] != null) { string action = HttpContext.Current.Request.Form["item_action"].ToLower().Trim(); if (action == "email") { string address = HttpContext.Current.Request.Form["email_address"].Replace(";", ",").Trim(); string comments = HttpContext.Current.Request.Form["email_comments"].Trim(); string format = HttpContext.Current.Request.Form["email_format"].Trim().ToUpper(); if (address.Length > 0) { // Determine the email format bool is_html_format = format != "TEXT"; // CC: the user, unless they are already on the list string cc_list = currentUser.Email; if (address.ToUpper().IndexOf(currentUser.Email.ToUpper()) >= 0) cc_list = String.Empty; // Send the email HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", !Item_Email_Helper.Send_Email(address, cc_list, comments, currentUser.Full_Name,currentMode.SobekCM_Instance_Abbreviation,currentItem,is_html_format,HttpContext.Current.Items["Original_URL"].ToString(), currentUser.UserID) ? "Error encountered while sending email" : "Your email has been sent"); HttpContext.Current.Response.Redirect( HttpContext.Current.Items["Original_URL"].ToString(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } } if (action == "add_item") { string usernotes = HttpContext.Current.Request.Form["add_notes"].Trim(); string foldername = HttpContext.Current.Request.Form["add_bookshelf"].Trim(); bool open_bookshelf = HttpContext.Current.Request.Form["open_bookshelf"] != null; if (SobekCM_Database.Add_Item_To_User_Folder(currentUser.UserID, foldername, currentItem.BibID, currentItem.VID, 0, usernotes, Tracer)) { currentUser.Add_Bookshelf_Item(currentItem.BibID, currentItem.VID); // Ensure this user folder is not sitting in the cache Cached_Data_Manager.Remove_User_Folder_Browse(currentUser.UserID, foldername, Tracer); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Item was saved to your bookshelf."); if (open_bookshelf) { HttpContext.Current.Session.Add("ON_LOAD_WINDOW", "?m=lmfl" + foldername.Replace("\"", "%22").Replace("'", "%27").Replace("=", "%3D").Replace("&", "%26") + "&vp=1"); } } else { HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "ERROR encountered while trying to save to your bookshelf."); } HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } if (action == "remove") { if (SobekCM_Database.Delete_Item_From_User_Folders(currentUser.UserID, currentItem.BibID, currentItem.VID, Tracer)) { currentUser.Remove_From_Bookshelves(currentItem.BibID, currentItem.VID); Cached_Data_Manager.Remove_All_User_Folder_Browses(currentUser.UserID, Tracer); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Item was removed from your bookshelves."); } else { HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "ERROR encountered while trying to remove item from your bookshelves."); } HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } if (action.IndexOf("add_tag") == 0) { int tagid = -1; if (action.Replace("add_tag", "").Length > 0) { tagid = Convert.ToInt32(action.Replace("add_tag_", "")); } string description = HttpContext.Current.Request.Form["add_tag"].Trim(); int new_tagid = SobekCM_Database.Add_Description_Tag(currentUser.UserID, tagid, currentItem.Web.ItemID, description, Tracer); if (new_tagid > 0) { currentItem.Behaviors.Add_User_Tag(currentUser.UserID, currentUser.Full_Name, description, DateTime.Now, new_tagid); currentUser.Has_Descriptive_Tags = true; } HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } if (action.IndexOf("delete_tag") == 0) { if (action.Replace("delete_tag", "").Length > 0) { int tagid = Convert.ToInt32(action.Replace("delete_tag_", "")); if (currentItem.Behaviors.Delete_User_Tag(tagid, currentUser.UserID)) { SobekCM_Database.Delete_Description_Tag(tagid, Tracer); } } HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } } } // Handle any request from the internal header for the item if ((HttpContext.Current != null) && (HttpContext.Current.Request.Form["internal_header_action"] != null) && ( currentUser != null )) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to save the item comments? if (internalHeaderAction == "save_comments") { string new_comments = HttpContext.Current.Request.Form["intheader_internal_notes"].Trim(); if ( Resource_Object.Database.SobekCM_Database.Save_Item_Internal_Comments( currentItem.Web.ItemID, new_comments)) currentItem.Tracking.Internal_Comments = new_comments; } // Is this to change accessibility? if ((internalHeaderAction == "public") || (internalHeaderAction == "private") || (internalHeaderAction == "restricted")) { int current_mask = currentItem.Behaviors.IP_Restriction_Membership; switch (internalHeaderAction) { case "public": currentItem.Behaviors.IP_Restriction_Membership = 0; break; case "private": currentItem.Behaviors.IP_Restriction_Membership = -1; break; case "restricted": currentItem.Behaviors.IP_Restriction_Membership = 1; break; } // Is this new visibility different than the old one? if (currentItem.Behaviors.IP_Restriction_Membership != current_mask) { // Save this to the database if (Resource_Object.Database.SobekCM_Database.Set_IP_Restriction_Mask(currentItem.Web.ItemID, currentItem.Behaviors.IP_Restriction_Membership, currentUser.UserName, String.Empty)) { // Update the cached item Cached_Data_Manager.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, Tracer); Cached_Data_Manager.Store_Digital_Resource_Object(currentItem.BibID, currentItem.VID, currentItem, Tracer); // Update the web.config Resource_Web_Config_Writer.Update_Web_Config(currentItem.Source_Directory, currentItem.Behaviors.Dark_Flag, (short) current_mask, currentItem.Behaviors.Main_Thumbnail); } } } } } // Set the code for bib level mets to show the volume tree by default if ((currentItem.METS_Header.RecordStatus_Enum == METS_Record_Status.BIB_LEVEL) && (currentMode.ViewerCode.Length == 0)) { currentMode.ViewerCode = "allvolumes1"; } // If there is a file name included, look for the sequence of that file if (currentMode.Page_By_FileName.Length > 0) { int page_sequence = currentItem.Divisions.Physical_Tree.Page_Sequence_By_FileName(currentMode.Page_By_FileName); if (page_sequence > 0) { currentMode.ViewerCode = page_sequence.ToString(); currentMode.Page = (ushort) page_sequence; } } // Get the valid viewer code Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Getting the appropriate item viewer"); if ((currentMode.ViewerCode.Length == 0) && (currentMode.Coordinates.Length > 0)) { currentMode.ViewerCode = "map"; } currentMode.ViewerCode = currentItem.Web.Get_Valid_Viewer_Code(currentMode.ViewerCode, currentMode.Page); View_Object viewObject = currentItem.Web.Get_Viewer(currentMode.ViewerCode); PageViewer = ItemViewer_Factory.Get_Viewer(viewObject, currentItem.Bib_Info.SobekCM_Type_String.ToUpper(), currentItem, currentUser, currentMode); // If this was in fact restricted by IP address, restrict now if (itemRestrictedFromUserByIp) { if ((PageViewer.ItemViewer_Type != ItemViewer_Type_Enum.Citation) && (PageViewer.ItemViewer_Type != ItemViewer_Type_Enum.MultiVolume) && (PageViewer.ItemViewer_Type != ItemViewer_Type_Enum.Related_Images)) { PageViewer = new Restricted_ItemViewer(Item_Restricted_Message); currentMode.ViewerCode = "res"; } } // If execution should end, do it now if (currentMode.Request_Completed) return; Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Created " + PageViewer.GetType().ToString().Replace("SobekCM.Library.ItemViewer.Viewers.", "")); // Assign the rest of the information, if a page viewer was created if (PageViewer != null) { PageViewer.CurrentItem = currentItem; PageViewer.CurrentMode = currentMode; PageViewer.Translator = Translator; PageViewer.CurrentUser = currentUser; // Special code if this is the citation viewer Citation_ItemViewer viewer = PageViewer as Citation_ItemViewer; if (viewer != null) { viewer.Code_Manager = Code_Manager; viewer.Item_Restricted = itemRestrictedFromUserByIp; } // Special code if this is the multi-volumes viewer var itemViewer = PageViewer as MultiVolumes_ItemViewer; if (itemViewer != null) { if (itemsInTitle == null) { // Look in the cache first itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); // If still null, try to pull from the database if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); //// Add the related titles, if there are some //if ((currentGroup.Tables.Count > 3) && (currentGroup.Tables[3].Rows.Count > 0)) //{ // foreach (DataRow thisRow in currentGroup.Tables[3].Rows) // { // string relationship = thisRow["Relationship"].ToString(); // string title = thisRow["GroupTitle"].ToString(); // string bibid = thisRow["BibID"].ToString(); // string link_and_title = "<a href=\"" + currentMode.Base_URL + bibid + "<%URL_OPTS%>\">" + title + "</a>"; // currentItem.Behaviors.All_Related_Titles.Add(new SobekCM.Resource_Object.Behaviors.Related_Titles(relationship, link_and_title)); // } //} // Store in cache if retrieved if (itemsInTitle != null) { Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } } } itemViewer.Item_List = itemsInTitle; } // Finally, perform any necessary work before display PageViewer.Perform_PreDisplay_Work(Tracer); // Get the list of any special behaviors behaviors = PageViewer.ItemViewer_Behaviors; } else { behaviors = new List<HtmlSubwriter_Behaviors_Enum>(); } // ALways suppress the banner behaviors.Add(HtmlSubwriter_Behaviors_Enum.Suppress_Banner); //if ((searchMatchOnThisPage) && ((PageViewer.ItemViewer_Type == ItemViewer_Type_Enum.JPEG) || (PageViewer.ItemViewer_Type == ItemViewer_Type_Enum.JPEG2000))) //{ // if (PageViewer.ItemViewer_Type == ItemViewer_Type_Enum.JPEG2000) // { // Aware_JP2_ItemViewer jp2_viewer = (Aware_JP2_ItemViewer) PageViewer; // jp2_viewer.Add_Feature("Red", "DrawEllipse", ((int) (featureXRatioLocation*jp2_viewer.Width)), ((int) (featureYRatioLocation*jp2_viewer.Height)), 800, 800); // } //} }
/// <summary> Gets the list of all items within this item group, indicated by BibID, including additional information for the SMaRT tracking application </summary> /// <param name="BibID"> Bibliographic identifier for the title of interest </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns> Strongly typed dataset with information about the title (item group), including volumes, icons, and skins</returns> /// <remarks> This calls the 'Tracking_Get_Multiple_Volumes' stored procedure <br /><br /> /// This is very similar to the <see cref="SobekCM_Database.Get_Multiple_Volumes" /> method, except it returns more information, since /// the tracking application does not have basic information about each item/title in its cache, unlike the /// web server application, which does cache this information. </remarks> public static SobekCM_Items_In_Title Tracking_Multiple_Volumes(string BibID, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Database.Tracking_Multiple_Volumes", "List of volumes for " + BibID + " pulled from database"); } try { // Create the connection SqlConnection connect = new SqlConnection(connectionString); // Create the command SqlCommand executeCommand = new SqlCommand("Tracking_Get_Multiple_Volumes", connect) {CommandType = CommandType.StoredProcedure}; executeCommand.Parameters.AddWithValue("@bibid", BibID); // Create the adapter SqlDataAdapter adapter = new SqlDataAdapter(executeCommand); // Get the datatable DataSet valueSet = new DataSet(); adapter.Fill(valueSet); // If there was either no match, or more than one, return null if ((valueSet.Tables.Count == 0) || (valueSet.Tables[0] == null) || (valueSet.Tables[0].Rows.Count == 0)) { return null; } // Create the object SobekCM_Items_In_Title returnValue = new SobekCM_Items_In_Title(valueSet.Tables[0]); // Return the fully built object return returnValue; } catch (Exception ee) { lastException = ee; return null; } }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Item_List"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Search_History"> List of recent searches performed against this digital library </param> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Checked_Items"> List of all items which are currently checked out for single fair use and the IP address currently viewing the item</param> /// <param name="IP_Restrictions"> Any possible restriction on item access by IP ranges </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of static web content pages </param> /// <param name="Items_In_Title"> List of items within the current title ( used for the Item Group display )</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> public Html_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, SobekCM_Skin_Object HTML_Skin, User_Object Current_User, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, Statistics_Dates Stats_Date_Range, Recent_Searches Search_History, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<Thematic_Heading> Thematic_Headings, Public_User_Folder Public_Folder, Dictionary<string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, Checked_Out_Items_List Checked_Items, IP_Restriction_Ranges IP_Restrictions, Portal_List URL_Portals, SobekCM_SiteMap Site_Map, SobekCM_Items_In_Title Items_In_Title, HTML_Based_Content Static_Web_Content ) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // Save parameters htmlSkin = HTML_Skin; translator = Translator; codeManager = Code_Manager; itemList = Item_List; statsDateRange = Stats_Date_Range; searchHistory = Search_History; currentUser = Current_User; iconList = Icon_Dictionary; thematicHeadings = Thematic_Headings; publicFolder = Public_Folder; aggregationAliases = Aggregation_Aliases; webSkins = Web_Skin_Collection; checkedItems = Checked_Items; ipRestrictionInfo = IP_Restrictions; urlPortals = URL_Portals; siteMap = Site_Map; itemsInTitle = Items_In_Title; // Set some defaults finishPageInAddFinalHtmlMethod = false; // Handle basic events which may be fired by the internal header if (HttpContext.Current.Request.Form["internal_header_action"] != null) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to hide or show the header? if ((internalHeaderAction == "hide") || (internalHeaderAction == "show")) { // Pull the current visibility from the session bool shown = true; if ((HttpContext.Current.Session["internal_header"] != null) && (HttpContext.Current.Session["internal_header"].ToString() == "hidden")) { shown = false; } if ((internalHeaderAction == "hide") && (shown)) { HttpContext.Current.Session["internal_header"] = "hidden"; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), true); } if ((internalHeaderAction == "show") && (!shown)) { HttpContext.Current.Session["internal_header"] = "shown"; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), true); } } } }
/// <summary> Constructor for a new instance of the MySobek_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public MySobek_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, User_Object Current_User, Dictionary<string, Wordmark_Icon> Icon_Table, Statistics_Dates Stats_Date_Range, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer ) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.My_Sobek_Type) { case My_Sobek_Type_Enum.Home: mySobekViewer = new Home_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.New_Item: mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Folder_Management: mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Saved_Searches: mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Preferences: mySobekViewer = new Preferences_MySobekViewer(user, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Logon: mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer); break; case My_Sobek_Type_Enum.New_Password: mySobekViewer = new NewPassword_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Delete_Item: mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, currentItem, All_Items_Lookup, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Behaviors: mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Metadata: mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.File_Management: mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Behaviors: mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy: mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user); break; case My_Sobek_Type_Enum.Item_Tracking: mySobekViewer = new Track_Item_MySobekViewer(user, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Group_Add_Volume: // Pull the list of items tied to this group SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Store in cache if retrieved Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Group_AutoFill_Volumes: mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Mass_Update_Items: mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Page_Images_Management: mySobekViewer = new Page_Image_Upload_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer ); break; case My_Sobek_Type_Enum.User_Tags: mySobekViewer = new User_Tags_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.User_Usage_Stats: mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer); break; } // Pass in the navigation and translator information mySobekViewer.CurrentMode = Current_Mode; mySobekViewer.Translator = translator; }
/// <summary> Builds an item group object, from a METS file </summary> /// <param name="BibID"> Bibliographic identifier for the item group to retrieve </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <param name="Item_Group_Object"> [OUT] Fully built item group object </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> public void Build_Item_Group(string BibID, Custom_Tracer Tracer, out SobekCM_Items_In_Title Items_In_Title, out SobekCM_Item Item_Group_Object ) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Item_Group", "Create the requested item group"); } // Set to NULL by default Item_Group_Object = null; Items_In_Title = null; // Get the basic information about this item DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(BibID, Tracer); // If this is NULL then there was an error if (itemDetails == null) return; // Get the location for the METS file from the returned value DataRow mainItemRow = itemDetails.Tables[0].Rows[0]; string metsLocation = mainItemRow["File_Location"].ToString(); // Get the response object for this METS file string metsFile = metsLocation.Replace("\\", "/") + "/" + BibID + ".xml"; if (metsFile.IndexOf("http:") < 0) { metsFile = SobekCM_Library_Settings.Image_Server_Network + metsFile; } // Try to read this METS file bool pulledFromMETSFile = true; Item_Group_Object = Build_Item_From_METS(metsFile, BibID + ".xml", Tracer); // If this failed, just create an item from scratch if (Item_Group_Object == null) { Item_Group_Object = new SobekCM_Item(); Item_Group_Object.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Serial; Item_Group_Object.BibID = BibID; pulledFromMETSFile = false; } // Set some default and add the management view Item_Group_Object.METS_Header.RecordStatus_Enum = METS_Record_Status.BIB_LEVEL; Item_Group_Object.Behaviors.Add_View(View_Enum.MANAGE); // Pull values from the database Item_Group_Object.Behaviors.GroupTitle = String.Empty; Item_Group_Object.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString()); Item_Group_Object.Behaviors.Text_Searchable = false; Item_Group_Object.Web.File_Root = String.Empty; Item_Group_Object.Web.Image_Root = SobekCM_Library_Settings.Image_URL; Item_Group_Object.Web.Siblings = 2; Item_Group_Object.Web.Static_PageCount = 0; Item_Group_Object.Web.Static_Division_Count = 0; Item_Group_Object.Web.AssocFilePath = "/" + BibID.Substring(0, 2) + "/" + BibID[2] + BibID[6] + "/" + BibID[4] + BibID[8] + "/" + BibID[3] + BibID[7] + "/" + BibID[5] + BibID[9] + "/"; Item_Group_Object.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]); // Add the full citation view and google map if pulled from the METS file if (pulledFromMETSFile) { // GEt the geospatial metadata module GeoSpatial_Information geoInfo = Item_Group_Object.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo != null) && (geoInfo.hasData)) { // In addition, if there is a latitude or longitude listed, add the Google Maps if ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0)) { Item_Group_Object.Behaviors.Insert_View(0, View_Enum.GOOGLE_MAP); } } Item_Group_Object.Behaviors.Insert_View(0, View_Enum.CITATION); } // If this has more than 1 sibling (this count includes itself), add the multi-volumes viewer Item_Group_Object.Behaviors.Insert_View(0, View_Enum.ALL_VOLUMES, String.Empty, Item_Group_Object.Bib_Info.SobekCM_Type_String); // Pull the data from the database Item_Group_Object.Behaviors.GroupType = mainItemRow["Type"].ToString(); Item_Group_Object.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString(); Item_Group_Object.Web.File_Root = mainItemRow["File_Location"].ToString(); // Create the list of items in this title Items_In_Title = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Add the database information to the icons now Item_Group_Object.Behaviors.Clear_Wordmarks(); foreach (DataRow thisIconRow in itemDetails.Tables[2].Rows) { Wordmark_Info newIcon = new Wordmark_Info(); if ( thisIconRow["Link"].ToString().Length == 0) { newIcon.Title = thisIconRow["Icon_Name"].ToString(); newIcon.Link = thisIconRow["Link"].ToString(); newIcon.HTML = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&","&") + "\" title=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" alt=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" />"; } else { newIcon.Title = thisIconRow["Icon_Name"].ToString(); newIcon.Link = thisIconRow["Link"].ToString(); newIcon.HTML = "<a href=\"" + newIcon.Link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&", "&").Replace("\"", """) + "\" title=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" alt=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" /></a>"; } Item_Group_Object.Behaviors.Add_Wordmark(newIcon); } // Add the web skin codes to this bib-level item as well Item_Group_Object.Behaviors.Clear_Web_Skins(); foreach (DataRow thisRow in itemDetails.Tables[3].Rows) { Item_Group_Object.Behaviors.Add_Web_Skin(thisRow[0].ToString().ToUpper()); } // Set the aggregations in the package to the aggregation links from the database if (itemDetails.Tables.Count == 6) { Item_Group_Object.Behaviors.Clear_Aggregations(); foreach (DataRow thisRow in itemDetails.Tables[4].Rows) { Item_Group_Object.Behaviors.Add_Aggregation(thisRow[0].ToString()); } // Add the related titles, if there are some foreach (DataRow thisRow in itemDetails.Tables[5].Rows) { string relationship = thisRow["Relationship"].ToString(); string title = thisRow["GroupTitle"].ToString(); string bibid = thisRow["BibID"].ToString(); string link_and_title = "<a href=\"<%BASEURL%>" + bibid + "<%URL_OPTS%>\">" + title + "</a>"; Item_Group_Object.Web.All_Related_Titles.Add(new Related_Titles(relationship, link_and_title)); } } }
/// <summary> Builds an item group object, from a METS file </summary> /// <param name="BibID"> Bibliographic identifier for the item group to retrieve </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <param name="Item_Group_Object"> [OUT] Fully built item group object </param> /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param> public void Build_Item_Group(string BibID, Custom_Tracer Tracer, out SobekCM_Items_In_Title Items_In_Title, out SobekCM_Item Item_Group_Object) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Item_Group", "Create the requested item group"); } // Set to NULL by default Item_Group_Object = null; Items_In_Title = null; // Get the basic information about this item DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(BibID, Tracer); // If this is NULL then there was an error if (itemDetails == null) { return; } // Get the location for the METS file from the returned value DataRow mainItemRow = itemDetails.Tables[0].Rows[0]; string metsLocation = mainItemRow["File_Location"].ToString(); // Get the response object for this METS file string metsFile = metsLocation.Replace("\\", "/") + "/" + BibID + ".xml"; if (metsFile.IndexOf("http:") < 0) { metsFile = SobekCM_Library_Settings.Image_Server_Network + metsFile; } // Try to read this METS file bool pulledFromMETSFile = true; Item_Group_Object = Build_Item_From_METS(metsFile, BibID + ".xml", Tracer); // If this failed, just create an item from scratch if (Item_Group_Object == null) { Item_Group_Object = new SobekCM_Item(); Item_Group_Object.METS_Header.RecordStatus_Enum = METS_Record_Status.BIB_LEVEL; Item_Group_Object.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Serial; Item_Group_Object.BibID = BibID; pulledFromMETSFile = false; } // Pull values from the database Item_Group_Object.Behaviors.GroupTitle = String.Empty; Item_Group_Object.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString()); Item_Group_Object.Behaviors.Text_Searchable = false; Item_Group_Object.Web.File_Root = String.Empty; Item_Group_Object.Web.Image_Root = SobekCM_Library_Settings.Image_URL; Item_Group_Object.Web.Siblings = 2; Item_Group_Object.Web.Static_PageCount = 0; Item_Group_Object.Web.Static_Division_Count = 0; Item_Group_Object.Web.AssocFilePath = "/" + BibID.Substring(0, 2) + "/" + BibID[2] + BibID[6] + "/" + BibID[4] + BibID[8] + "/" + BibID[3] + BibID[7] + "/" + BibID[5] + BibID[9] + "/"; Item_Group_Object.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]); // Add the full citation view and google map if pulled from the METS file if (pulledFromMETSFile) { // GEt the geospatial metadata module GeoSpatial_Information geoInfo = Item_Group_Object.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if ((geoInfo != null) && (geoInfo.hasData)) { // In addition, if there is a latitude or longitude listed, add the Google Maps if ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0)) { Item_Group_Object.Behaviors.Insert_View(0, View_Enum.GOOGLE_MAP); } } Item_Group_Object.Behaviors.Insert_View(0, View_Enum.CITATION); } // If this has more than 1 sibling (this count includes itself), add the multi-volumes viewer Item_Group_Object.Behaviors.Default_View = Item_Group_Object.Behaviors.Insert_View(0, View_Enum.ALL_VOLUMES, String.Empty, Item_Group_Object.Bib_Info.SobekCM_Type_String); // Pull the data from the database Item_Group_Object.Behaviors.GroupType = mainItemRow["Type"].ToString(); Item_Group_Object.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString(); Item_Group_Object.Web.File_Root = mainItemRow["File_Location"].ToString(); // Create the list of items in this title Items_In_Title = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Add the database information to the icons now Item_Group_Object.Behaviors.Clear_Wordmarks(); foreach (DataRow thisIconRow in itemDetails.Tables[2].Rows) { Wordmark_Info newIcon = new Wordmark_Info(); if (thisIconRow["Link"].ToString().Length == 0) { newIcon.Title = thisIconRow["Icon_Name"].ToString(); newIcon.Link = thisIconRow["Link"].ToString(); newIcon.HTML = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&", "&") + "\" title=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" alt=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" />"; } else { newIcon.Title = thisIconRow["Icon_Name"].ToString(); newIcon.Link = thisIconRow["Link"].ToString(); newIcon.HTML = "<a href=\"" + newIcon.Link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&", "&").Replace("\"", """) + "\" title=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" alt=\"" + newIcon.Title.Replace("&", "&").Replace("\"", """) + "\" /></a>"; } Item_Group_Object.Behaviors.Add_Wordmark(newIcon); } // Add the web skin codes to this bib-level item as well Item_Group_Object.Behaviors.Clear_Web_Skins(); foreach (DataRow thisRow in itemDetails.Tables[3].Rows) { Item_Group_Object.Behaviors.Add_Web_Skin(thisRow[0].ToString().ToUpper()); } // Set the aggregations in the package to the aggregation links from the database if (itemDetails.Tables.Count == 6) { Item_Group_Object.Behaviors.Clear_Aggregations(); foreach (DataRow thisRow in itemDetails.Tables[4].Rows) { Item_Group_Object.Behaviors.Add_Aggregation(thisRow[0].ToString()); } // Add the related titles, if there are some foreach (DataRow thisRow in itemDetails.Tables[5].Rows) { string relationship = thisRow["Relationship"].ToString(); string title = thisRow["GroupTitle"].ToString(); string bibid = thisRow["BibID"].ToString(); string link_and_title = "<a href=\"<%BASEURL%>" + bibid + "<%URL_OPTS%>\">" + title + "</a>"; Item_Group_Object.Web.All_Related_Titles.Add(new Related_Titles(relationship, link_and_title)); } } }