/// <summary> Gets the digital resource, mapped to a MARC record object, by BibID_VID </summary>
        /// <param name="BibID"> Bibliographic identifier (BibID) for the digital resource to retrieve </param>
        /// <param name="VID"> Volume identifier (VID) for the digital resource to retrieve </param>
        /// <param name="UseCache"> Flag indicates if the cache should be used to check for a built copy or store the final product </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Fully built MARC record, or NULL </returns>
        public MARC_Transfer_Record Get_Item_MARC_Record(string BibID, string VID, bool UseCache, Custom_Tracer Tracer)
        {
            // Add a beginning trace
            Tracer.Add_Trace("SobekEngineClient_ItemEndpoints.Get_Item_MARC_Record", "Get MARC record object by bibid/vid");

            // Look in the cache
            if ((Config.UseCache) && (UseCache))
            {
                MARC_Transfer_Record fromCache = CachedDataManager.Items.Retrieve_MARC_Record(BibID, VID, Tracer);
                if (fromCache != null)
                {
                    Tracer.Add_Trace("SobekEngineClient_ItemEndpoints.Get_Item_MARC_Record", "Found MARC record the local cache");
                    return(fromCache);
                }
            }
            // Get the endpoint
            MicroservicesClient_Endpoint endpoint = GetEndpointConfig("Items.GetItemMarcRecord", Tracer);

            // Format the URL
            string url = String.Format(endpoint.URL, BibID, VID);

            // Call out to the endpoint and deserialize the object
            MARC_Transfer_Record returnValue = Deserialize <MARC_Transfer_Record>(url, endpoint.Protocol, Tracer);

            // Add to the local cache
            if ((Config.UseCache) && (UseCache) && (returnValue != null))
            {
                Tracer.Add_Trace("SobekEngineClient_ItemEndpoints.Get_Item_MARC_Record", "Store MARC record in the local cache");
                CachedDataManager.Items.Store_MARC_Record(BibID, VID, returnValue, Tracer);
            }

            // Return the object
            return(returnValue);
        }
Exemplo n.º 2
0
        /// <summary> Store the MARC record object related to a digital resource on the cache   </summary>
        /// <param name="BibID"> Bibliographic Identifier for the digital resource to store </param>
        /// <param name="VID"> Volume Identifier for the digital resource to store </param>
        /// <param name="StoreObject"> EAD information for a digital Resource object to store for later retrieval </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        public void Store_MARC_Record(string BibID, string VID, MARC_Transfer_Record StoreObject, Custom_Tracer Tracer)
        {
            // If the cache is disabled, just return before even tracing
            if (settings.Disabled)
            {
                return;
            }

            // Determine the key
            string    key            = "ITEM_" + BibID + "_" + VID + "_MarcRecord";
            const int LENGTH_OF_TIME = 3;

            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager_ItemServices.Store_MARC_Record", "Adding object '" + key + "' to the local cache with expiration of " + LENGTH_OF_TIME + " minute");
            }

            HttpContext.Current.Cache.Insert(key, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(LENGTH_OF_TIME));
        }
        /// <summary> Returns the basic information about this digital resource in MARC HTML format </summary>
        /// <param name="Width"> Width statement to be included in the MARC21 table </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> HTML string with the MARC information for this digital resource </returns>
        public string MARC_String(string Width, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Citation_ItemViewer.MARC_String", "Configuring METS data into MARC format");
            }

            //// Build the value
            StringBuilder builder = new StringBuilder();

            // Add the edit item button, if the user can edit it
            if ((userCanEdit) && (BriefItem.Type != "BIBLEVEL"))
            {
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_Item_Metadata;
                CurrentRequest.My_Sobek_SubMode = "1";
                builder.AppendLine("<blockquote><button onclick=\"window.location.href='" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "';return false;\" id=\"sbkCiv_MarcEditButton\" class=\"roundbutton\"> EDIT THIS ITEM </button></blockquote>");
                CurrentRequest.Mode = Display_Mode_Enum.Item_Display;
            }
            else
            {
                builder.AppendLine("<br />");
            }

            // Get the MARC record
            MARC_Transfer_Record record = SobekEngineClient.Items.Get_Item_MARC_Record(BriefItem.BibID, BriefItem.VID, true, Tracer);

            builder.AppendLine(record.ToHTML(Width));

            builder.AppendLine("<br />");
            builder.AppendLine("<br />");
            builder.AppendLine("<div id=\"sbkCiv_MarcAutoGenerated\">The record above was auto-generated from the METS file.</div>");
            builder.AppendLine();
            builder.AppendLine("<br />");
            builder.AppendLine("<br />");
            builder.AppendLine("</div>");

            return(builder.ToString());
        }