/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Admin_HtmlSubwriter( RequestCache RequestSpecificValues )
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting RequestSpecificValues.Current_User object back from the session");

            // All Admin pages require a RequestSpecificValues.Current_User being logged on
            if (RequestSpecificValues.Current_User == null)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;
                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user is not an admin, and admin was selected, reroute this
            if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.Aggregation_Single))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Get the appropriate admin viewer from the factory
            adminViewer = AdminViewer_Factory.Get_AdminViewer(RequestSpecificValues);
        }
        /// <summary> Constructor for a new instance of the Saved_Searches_MySobekViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Saved_Searches_MySobekViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Saved_Searches_MySobekViewer.Constructor", String.Empty);

            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Pull the standard values
                NameValueCollection form = HttpContext.Current.Request.Form;

                string item_action = form["item_action"].ToUpper().Trim();
                string folder_id = form["folder_id"].Trim();

                if (item_action == "REMOVE")
                {
                    int folder_id_int;
                    if (Int32.TryParse(folder_id, out folder_id_int))
                        SobekCM_Database.Delete_User_Search(folder_id_int, RequestSpecificValues.Tracer);
                }

                HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString(), false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                RequestSpecificValues.Current_Mode.Request_Completed = true;
            }
        }
        /// <summary> Constructor for a new instance of the Advanced_Search_YearRange_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Advanced_Search_YearRange_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Compute the redirect stem to use
            string fields = RequestSpecificValues.Current_Mode.Search_Fields;
            string searchCollections = RequestSpecificValues.Current_Mode.SubAggregation;
            Display_Mode_Enum lastMode = RequestSpecificValues.Current_Mode.Mode;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            RequestSpecificValues.Current_Mode.SubAggregation = String.Empty;

            string searchString = RequestSpecificValues.Current_Mode.Search_String;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string redirectStem = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            // Get the browse all url, if enabled
            string browse_url = String.Empty;
            if (ViewBag.Hierarchy_Object.Can_Browse_Items)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
                browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            }

            RequestSpecificValues.Current_Mode.Search_String = searchString;
            RequestSpecificValues.Current_Mode.Search_Fields = fields;
            RequestSpecificValues.Current_Mode.SubAggregation = searchCollections;
            RequestSpecificValues.Current_Mode.Mode = lastMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;

            Search_Script_Action = "advanced_search_years_sobekcm('" + redirectStem + "','" + browse_url + "')";
        }
        /// <summary> Constructor for a new instance of the Advanced_Search_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Advanced_Search_AggregationViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Compute the redirect stem to use
            string fields = RequestSpecificValues.Current_Mode.Search_Fields;
            string searchCollections = RequestSpecificValues.Current_Mode.SubAggregation;
            Display_Mode_Enum lastMode = RequestSpecificValues.Current_Mode.Mode;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            RequestSpecificValues.Current_Mode.SubAggregation = String.Empty;
            string searchString = RequestSpecificValues.Current_Mode.Search_String;

            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string redirectStem = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
            string browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Search_String = searchString;
            RequestSpecificValues.Current_Mode.Search_Fields = fields;
            RequestSpecificValues.Current_Mode.SubAggregation = searchCollections;
            RequestSpecificValues.Current_Mode.Mode = lastMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            Search_Script_Action = "advanced_search_sobekcm('" + redirectStem + "','" + browse_url + "')";
        }
        /// <summary> Constructor for a new version of the <see cref="Permissions_Reports_AdminViewer"/> class. </summary>
        /// <param name="RequestSpecificValues">All the necessary, non-global data specific to the current request</param>
        public Permissions_Reports_AdminViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Permissions_Reports_AdminViewer.Constructor", String.Empty);
            actionMessage = String.Empty;

            // Ensure the user is the system admin
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.Is_System_Admin))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is posted back, look for the reset
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                string reset_value = HttpContext.Current.Request.Form[""];
                if ((!String.IsNullOrEmpty(reset_value)) && (reset_value == "reset"))
                {
                    // Just ensure everything is emptied out
                    HttpContext.Current.Cache.Remove("GlobalPermissionsReport");
                    HttpContext.Current.Cache.Remove("GlobalPermissionsUsersLinked");
                    HttpContext.Current.Cache.Remove("GlobalPermissionsLinkedAggr");
                    HttpContext.Current.Cache.Remove("GlobalPermissionsReportSubmit");
                }
            }
        }
        /// <summary> Constructor for a new instance of the Builder_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Builder_AdminViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Ensure the user is the system admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin )))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

               // If this is a postback, handle any events first
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                if (((RequestSpecificValues.Current_User.Is_System_Admin) && (!UI_ApplicationCache_Gateway.Settings.isHosted)) ||
                    (RequestSpecificValues.Current_User.Is_Host_Admin))
                {
                    // Pull the hidden value
                    string save_value = HttpContext.Current.Request.Form["admin_builder_tosave"].ToUpper().Trim();
                    if (save_value.Length > 0)
                    {
                        // Set this value
                        SobekCM_Database.Set_Setting("Builder Operation Flag", save_value);
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                }
            }
        }
        /// <summary> Constructor for a new instancee of the Print_Item_HtmlSubwriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Print_Item_HtmlSubwriter(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Check for IP restriction
            restriction_message = String.Empty;
            if (RequestSpecificValues.Current_Item.Behaviors.IP_Restriction_Membership > 0)
            {
                if (HttpContext.Current != null)
                {
                    int user_mask = (int)HttpContext.Current.Session["IP_Range_Membership"];
                    int comparison = RequestSpecificValues.Current_Item.Behaviors.IP_Restriction_Membership & user_mask;
                    if (comparison == 0)
                    {
                        int restriction = RequestSpecificValues.Current_Item.Behaviors.IP_Restriction_Membership;
                        int restriction_counter = 1;
                        while (restriction % 2 != 1)
                        {
                            restriction = restriction >> 1;
                            restriction_counter++;
                        }
                        if (UI_ApplicationCache_Gateway.IP_Restrictions[restriction_counter] != null)
                            restriction_message = UI_ApplicationCache_Gateway.IP_Restrictions[restriction_counter].Item_Restricted_Statement;
                        else
                            restriction_message = "Restricted Item";
                    }
                }
            }

            isRestricted = restriction_message.Length > 0;
        }
        /// <summary> Constructor for a new instance of the dLOC_Search_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public dLOC_Search_AggregationViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            textBoxValue = String.Empty;
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                textBoxValue = RequestSpecificValues.Current_Mode.Search_String.Replace(",newspaper", "");
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = RequestSpecificValues.Current_Mode.Mode;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            Search_Type_Enum searchType = RequestSpecificValues.Current_Mode.Search_Type;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Full_Text;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            arg1 = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
            browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            Search_Script_Action = "dloc_search_sobekcm('" + arg1 + "', '" + browse_url + "');";

            RequestSpecificValues.Current_Mode.Mode = displayMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            RequestSpecificValues.Current_Mode.Search_Type = searchType;
            RequestSpecificValues.Current_Mode.Search_String = search_string;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty;
        }
        /// <summary> Constructor for a new instance of the MySobek_HtmlSubwriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public MySobek_HtmlSubwriter(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session");

            if (RequestSpecificValues.Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out)
            {
                RequestSpecificValues.Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout");

                HttpContext.Current.Session["user"] = null;
                HttpContext.Current.Response.Redirect("?", false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                RequestSpecificValues.Current_Mode.Request_Completed = true;
                return;
            }

            if ((RequestSpecificValues.Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.Is_Temporary_Password))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password;
            }

            if (RequestSpecificValues.Current_Mode.Logon_Required)
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;

            RequestSpecificValues.Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object");

            // Get the appropriate mysobek viewer from the factory
            mySobekViewer = MySobekViewer_Factory.Get_MySobekViewer(RequestSpecificValues);
        }
        /// <summary> Add the header to the output </summary>
        /// <param name="Output"> Stream to which to write the HTML for this header </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="Behaviors"> List of behaviors from the html subwriters </param>
        public static void Add_Footer(TextWriter Output, RequestCache RequestSpecificValues, List<HtmlSubwriter_Behaviors_Enum> Behaviors)
        {
            // Determine which header and footer to display
            bool useItemFooter = (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Item_Display) || (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Item_Print) || ((Behaviors != null) && (Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.MySobek_Subwriter_Mimic_Item_Subwriter)));

            // Get the current contact URL
            Display_Mode_Enum thisMode = RequestSpecificValues.Current_Mode.Mode;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Contact;
            string contact = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            // Restore the old mode
            RequestSpecificValues.Current_Mode.Mode = thisMode;

            // Get the URL options
            string url_options = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode);
            string urlOptions1 = String.Empty;
            string urlOptions2 = String.Empty;
            if (url_options.Length > 0)
            {
                urlOptions1 = "?" + url_options;
                urlOptions2 = "&" + url_options;
            }

            // Get the base url
            string base_url = RequestSpecificValues.Current_Mode.Base_URL;
            if (RequestSpecificValues.Current_Mode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn)
                base_url = base_url + "l/";

            // Get the skin url
            string skin_url = RequestSpecificValues.Current_Mode.Base_Design_URL + "skins/" + RequestSpecificValues.HTML_Skin.Skin_Code + "/";

            bool end_div = !((RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Simple_HTML_CMS) && (RequestSpecificValues.Site_Map != null));

            string version = UI_ApplicationCache_Gateway.Settings.Current_Web_Version;
            if (version.IndexOf(" ") > 0)
                version = version.Split(" ".ToCharArray())[0];

            if (useItemFooter)
            {
                Output.WriteLine(RequestSpecificValues.HTML_Skin.Footer_Item_HTML.Replace("<%CONTACT%>", contact).Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%VERSION%>", version).Replace("<%BASEURL%>", base_url).Replace("<%SKINURL%>", skin_url).Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name).Trim());
            }
            else
            {
                if (( RequestSpecificValues.HTML_Skin.Footer_Has_Container_Directive.HasValue) && (RequestSpecificValues.HTML_Skin.Footer_Has_Container_Directive.Value))
                {
                    if (!end_div)
                        Output.WriteLine(RequestSpecificValues.HTML_Skin.Footer_HTML.Replace("<%CONTACT%>", contact).Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%VERSION%>", version).Replace("<%BASEURL%>", base_url).Replace("<%SKINURL%>", skin_url).Replace("<%CONTAINER%>", "").Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name).Trim());
                    else
                        Output.WriteLine(RequestSpecificValues.HTML_Skin.Footer_HTML.Replace("<%CONTACT%>", contact).Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%VERSION%>", version).Replace("<%BASEURL%>", base_url).Replace("<%SKINURL%>", skin_url).Replace("<%CONTAINER%>", "</div>").Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name).Trim());
                }
                else
                {
                    if (!end_div)
                        Output.WriteLine(RequestSpecificValues.HTML_Skin.Footer_HTML.Replace("<%CONTACT%>", contact).Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%VERSION%>", version).Replace("<%BASEURL%>", base_url).Replace("<%SKINURL%>", skin_url).Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name).Trim());
                    else
                        Output.WriteLine(RequestSpecificValues.HTML_Skin.Footer_HTML.Replace("<%CONTACT%>", contact).Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%VERSION%>", version).Replace("<%BASEURL%>", base_url).Replace("<%SKINURL%>", skin_url).Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name).Trim() + Environment.NewLine + "</div>");
                }
            }
        }
        /// <summary> Constructor for a new instance of the NewPassword_MySobekViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public NewPassword_MySobekViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("NewPassword_MySobekViewer.Constructor", String.Empty);

            // Do nothing
            validationErrors = new List<string>();
        }
        /// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Private_Items_AggregationViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Ensure user has some permissions on this aggregation, or is a power/internal user or admin before showing
            // them this list
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Does this user have permissions on this itgem
            if (RequestSpecificValues.Current_User.PermissionedAggregations != null)
            {
                // Do they have some special permissions against this aggregation?
                bool special_permissions_found = false;
                foreach (User_Permissioned_Aggregation permissions in RequestSpecificValues.Current_User.PermissionedAggregations)
                {
                    if (String.Compare(permissions.Code, RequestSpecificValues.Hierarchy_Object.Code, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if ((permissions.CanChangeVisibility) || (permissions.CanDelete) || (permissions.CanEditBehaviors) || (permissions.CanEditItems) ||
                            (permissions.CanEditMetadata) || (permissions.CanPerformQc) || (permissions.CanUploadFiles) || (permissions.IsAdmin) || (permissions.IsCurator))
                        {
                            special_permissions_found = true;
                            break;
                        }
                    }
                }

                // Are they a portal/system admin or power user?
                if ((!special_permissions_found) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Portal_Admin) || (RequestSpecificValues.Current_User.Is_System_Admin)))
                    special_permissions_found = true;

                // If no permissions, forward them back
                if (!special_permissions_found)
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }
            else
            {
                // Are they a portal/system admin or power user?
                if ((!RequestSpecificValues.Current_User.Is_Internal_User) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_System_Admin))
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }

            // Get the list of private items
            int current_sort = RequestSpecificValues.Current_Mode.Sort.HasValue ? RequestSpecificValues.Current_Mode.Sort.Value : 0;
            int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1;
            privateItems = SobekCM_Database.Tracking_Get_Aggregation_Private_Items(RequestSpecificValues.Hierarchy_Object.Code, (int)RESULTS_PER_PAGE, current_page, current_sort, RequestSpecificValues.Tracer);
        }
        /// <summary> Returns a built collection viewer matching request </summary>
        /// <param name="ViewType"> Aggregation view type </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <returns> Collection viewer that extends the <see cref="abstractAggregationViewer"/> class. </returns>
        public static abstractAggregationViewer Get_Viewer(Item_Aggregation_Views_Searches_Enum ViewType, RequestCache RequestSpecificValues )
        {
            switch (ViewType)
            {
                case Item_Aggregation_Views_Searches_Enum.Advanced_Search:
                    return new Advanced_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Advanced_Search_MimeType:
                    return new Advanced_Search_MimeType_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Advanced_Search_YearRange:
                    return new Advanced_Search_YearRange_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Basic_Search:
                    Item_Aggregation_Front_Banner frontBannerImage = RequestSpecificValues.Hierarchy_Object.FrontBannerObj;
                    if ((frontBannerImage != null) && (RequestSpecificValues.Hierarchy_Object.Highlights != null ) && (RequestSpecificValues.Hierarchy_Object.Highlights.Count > 0))
                    {
                        return new Rotating_Highlight_Search_AggregationViewer(RequestSpecificValues);
                    }
                    return new Basic_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Basic_Search_YearRange:
                    return new Basic_Search_YearRange_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Basic_Search_FullTextOption:
                    return new Basic_Text_Search_Combined_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Basic_Search_MimeType:
                    Item_Aggregation_Front_Banner frontBannerImage2 = RequestSpecificValues.Hierarchy_Object.FrontBannerObj;
                    if ((frontBannerImage2 != null) && (RequestSpecificValues.Hierarchy_Object.Highlights != null) && (RequestSpecificValues.Hierarchy_Object.Highlights.Count > 0))
                    {
                        return new Rotating_Highlight_MimeType_AggregationViewer(RequestSpecificValues);
                    }
                    return new Basic_Search_MimeType_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.FullText_Search:
                    return new Full_Text_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.No_Home_Search:
                    return new No_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Newspaper_Search:
                    return new Newspaper_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Map_Search:
                    return new Map_Search_AggregationViewer(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.Map_Search_Beta:
                    return new Map_Search_AggregationViewer_Beta(RequestSpecificValues);

                case Item_Aggregation_Views_Searches_Enum.DLOC_FullText_Search:
                    return new dLOC_Search_AggregationViewer(RequestSpecificValues);

                default:
                    return null;
            }
        }
 /// <summary> Constructor for a new instance of the Search_Results_HtmlSubwriter class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 public Search_Results_HtmlSubwriter(RequestCache RequestSpecificValues)
     : base(RequestSpecificValues)
 {
     // Use the method in the base class to actually pull the entire hierarchy
     if (!Get_Collection(RequestSpecificValues.Current_Mode, RequestSpecificValues.Tracer, out hierarchyObject))
     {
         RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error;
     }
 }
        /// <summary> Constructor for a new instance of the Metadata_Browse_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Metadata_Browse_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // If there is not info browse mode listed, use the default
            if ( String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Info_Browse_Mode))
            {
                string defaultBrowseBy = ViewBag.Hierarchy_Object.Default_BrowseBy ?? String.Empty;
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = defaultBrowseBy;

                // Still length of zero?
                if (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Info_Browse_Mode))
                {
                    // Just look for the first browse by
                    foreach (Item_Aggregation_Child_Page browse in ViewBag.Hierarchy_Object.Child_Pages)
                    {
                        if (browse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By)
                        {
                            RequestSpecificValues.Current_Mode.Info_Browse_Mode = browse.Code;
                            break;
                        }
                    }
                }

            }

            if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Info_Browse_Mode)) && (ViewBag.Hierarchy_Object.Has_Browse_By_Pages))
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = ViewBag.Hierarchy_Object.Child_Page_By_Code(RequestSpecificValues.Current_Mode.Info_Browse_Mode).Code;

            // Get this browse
            browseObject = ViewBag.Hierarchy_Object.Child_Page_By_Code(RequestSpecificValues.Current_Mode.Info_Browse_Mode);

            // Was this a metadata browseby, or just a static html?
            if (( browseObject == null ) || ( browseObject.Source_Data_Type != Item_Aggregation_Child_Source_Data_Enum.Static_HTML))
            {
                // Determine the correct metadata code
                string metadata_code = RequestSpecificValues.Current_Mode.Info_Browse_Mode.Trim().Replace("_", " ");
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = metadata_code;

                // Only get values if there was a metadata code
                if (metadata_code.Length > 0)
                {
                    // Check the cache for this value
                    List<string> cacheInstance = CachedDataManager.Retrieve_Aggregation_Metadata_Browse(RequestSpecificValues.Current_Mode.Aggregation, RequestSpecificValues.Current_Mode.Info_Browse_Mode, RequestSpecificValues.Tracer);

                    if (cacheInstance != null)
                    {
                        results = cacheInstance;
                    }
                    else
                    {
                        results = Engine_Database.Get_Item_Aggregation_Metadata_Browse(RequestSpecificValues.Current_Mode.Aggregation, RequestSpecificValues.Current_Mode.Info_Browse_Mode, RequestSpecificValues.Tracer);
                        CachedDataManager.Store_Aggregation_Metadata_Browse(RequestSpecificValues.Current_Mode.Aggregation, RequestSpecificValues.Current_Mode.Info_Browse_Mode, results, RequestSpecificValues.Tracer);
                    }
                }
            }
        }
 /// <summary> Constructor for a new instance of the Manage_Menu_AggregationViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
 public Manage_Menu_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
     : base(RequestSpecificValues, ViewBag)
 {
     // User must AT LEAST be logged on, return
     if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
     {
         RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
         UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
     }
 }
        public Tiles_Home_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Get the list of tiles
            string aggregation_tile_directory = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, ViewBag.Hierarchy_Object.ObjDirectory, "images", "tiles");
            string[] jpeg_tiles = Directory.GetFiles(aggregation_tile_directory, "*.jpg");

            // Compute the URL for these images
            string aggregation_tile_uri = RequestSpecificValues.Current_Mode.Base_URL + "design/aggregations/" + ViewBag.Hierarchy_Object.Code + "/images/tiles/";

            // Get the list of all potential tiles, by checking name
            List<Tiles_Home_Single_Tile> allTiles = new List<Tiles_Home_Single_Tile>();
            foreach (string thisJpegTile in jpeg_tiles)
            {
                // Get the filename
                string thisFileName = Path.GetFileName(thisJpegTile);
                string thisFileNameSansExtension = Path.GetFileNameWithoutExtension(thisJpegTile);

                // Check for a link to the bibid/vid
                string bib_vid_for_link = String.Empty;
                if ((thisFileNameSansExtension.Length == 10) && ( SobekCM_Item.is_bibid_format(thisFileNameSansExtension)))
                {
                    bib_vid_for_link = thisFileNameSansExtension;
                }
                else if ((thisFileNameSansExtension.Length == 15) && (SobekCM_Item.is_bibid_format(thisFileNameSansExtension.Substring(0, 10))) && (SobekCM_Item.is_vids_format(thisFileNameSansExtension.Substring(10))))
                {
                    bib_vid_for_link = thisFileNameSansExtension.Substring(0, 10) + "/" + thisFileNameSansExtension.Substring(10);
                }
                else if ((thisFileNameSansExtension.Length == 16) && (SobekCM_Item.is_bibid_format(thisFileNameSansExtension.Substring(0, 10))) && (SobekCM_Item.is_vids_format(thisFileNameSansExtension.Substring(11))))
                {
                    bib_vid_for_link = thisFileNameSansExtension.Substring(0, 10) + "/" + thisFileNameSansExtension.Substring(11);
                }

                // If there was a link calculated, then use this jpeg
                if (!String.IsNullOrEmpty(bib_vid_for_link))
                {
                    allTiles.Add(new Tiles_Home_Single_Tile {JpegUri = aggregation_tile_uri + thisFileName, LinkUri = RequestSpecificValues.Current_Mode.Base_URL + bib_vid_for_link});
                }
            }

            // For now, just copy over all the tiles
            if ( allTiles.Count <= 15 )
                selectedTiles.AddRange(allTiles);
            else
            {
                Random randomGen = new Random();
                while (selectedTiles.Count < 15)
                {
                    int random_index = randomGen.Next(0, allTiles.Count);
                    selectedTiles.Add(allTiles[random_index]);
                    allTiles.RemoveAt(random_index);
                }
            }
        }
        /// <summary> Constructor for a new instance of the Statistics_HtmlSubwriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Statistics_HtmlSubwriter(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Check for an option in the URL
            option = -1;
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["opt"]))
            {
                int tryOption;
                if (Int32.TryParse(HttpContext.Current.Request.QueryString["opt"], out tryOption))
                {
                    option = tryOption;

                    // Ensure valid
                    if ((option != 0) && (option != 1) && (option != 2))
                        option = 0;
                    else
                    {
                        // Since an option was indicated, save the change
                        if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn))
                        {
                            if (option.ToString() != RequestSpecificValues.Current_User.Get_Setting("Statistics_HtmlSubwriter:ItemCountReportOption", "NULL"))
                            {
                                RequestSpecificValues.Current_User.Add_Setting("Statistics_HtmlSubwriter:ItemCountReportOption", option);
                                SobekCM_Database.Set_User_Setting(RequestSpecificValues.Current_User.UserID, "Statistics_HtmlSubwriter:ItemCountReportOption", option.ToString());
                            }
                        }
                    }
                }
            }

            // If no option was found, try to pull from the user
            if (option == -1)
            {
                if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn))
                {
                    int settingOption;
                    if (Int32.TryParse(RequestSpecificValues.Current_User.Get_Setting("Statistics_HtmlSubwriter:ItemCountReportOption", "0"), out settingOption))
                    {
                        option = settingOption;
                    }
                }
            }

            // If still not found, just set to zero
            if ((option < 0) || (option > 2))
                option = 0;

            // Determine if user is some sort of admin
            is_admin = false;
            if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn))
            {
                is_admin = RequestSpecificValues.Current_User.Is_Portal_Admin || RequestSpecificValues.Current_User.Is_System_Admin || RequestSpecificValues.Current_User.Is_Host_Admin;
            }
        }
        /// <summary> Constructor for a new instance of the abstract_ResultsViewer class  </summary>
        protected abstract_ResultsViewer( RequestCache RequestSpecificValues )
        {
            this.RequestSpecificValues = RequestSpecificValues;

            // Determine the current user mask
            CurrentUserMask = 0;
            if ((HttpContext.Current != null) && ( HttpContext.Current.Session["IP_Range_Membership"] != null ))
            {
                CurrentUserMask = (int)HttpContext.Current.Session["IP_Range_Membership"];
            }
        }
        /// <summary>  Constructor for a new instance of the Delete_Verify_WebContentViewer class  </summary>
        /// <param name="RequestSpecificValues">  All the necessary, non-global data specific to the current request  </param>
        public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // This should never occur, but just a double check
            if ((RequestSpecificValues.Static_Web_Content == null) || (!RequestSpecificValues.Static_Web_Content.WebContentID.HasValue))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure there IS a logged on user
            RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user");
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user was logged on, but did not have permissions, show an error message
            canDelete = true;
            if (!RequestSpecificValues.Static_Web_Content.Can_Delete(RequestSpecificValues.Current_User))
            {
                ErrorMessage = "ERROR: You do not have permission to delete this page";
                canDelete = false;
            }
            else
            {
                string save_value = HttpContext.Current.Request.Form["admin_delete_item"];

                // Better say "DELETE", or just send back to the item
                if ((save_value == null) || (save_value.ToUpper() != "DELETE"))
                {
                    ErrorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM";
                }
                else
                {
                    RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(RequestSpecificValues.Static_Web_Content.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, RequestSpecificValues.Tracer);

                    ErrorMessage = message.Message;
                    if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(ErrorMessage)))
                    {
                        ErrorMessage = "Error encountered on SobekCM engine.";
                    }
                    else
                    {
                        ErrorMessage = "Success deleting this web content page.";
                    }
                }
            }
        }
        /// <summary> Constructor for a new instance of the abstract_ResultsViewer class  </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
        /// <param name="PagedResults"> Actual pages of results </param>
        protected abstract_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List<iSearch_Title_Result> PagedResults)
        {
            this.RequestSpecificValues = RequestSpecificValues;
            this.ResultsStats = ResultsStats;
            this.PagedResults = PagedResults;

            // Determine the current user mask
            CurrentUserMask = 0;
            if ((HttpContext.Current != null) && ( HttpContext.Current.Session["IP_Range_Membership"] != null ))
            {
                CurrentUserMask = (int)HttpContext.Current.Session["IP_Range_Membership"];
            }
        }
        /// <summary> Constructor for a new instance of the Full_Text_Search_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Full_Text_Search_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Determine the sub text to use
            const string SUB_CODE = "s=";

            // Save the search term
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                textBoxValue = RequestSpecificValues.Current_Mode.Search_String;
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = RequestSpecificValues.Current_Mode.Mode;
            Search_Type_Enum searchType = RequestSpecificValues.Current_Mode.Search_Type;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Full_Text;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            arg2 = String.Empty;
            arg1 = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            // Get the browse all url, if enabled
            browse_url = String.Empty;
            if (ViewBag.Hierarchy_Object.Can_Browse_Items)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
                browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            }

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Search;
            if ((!RequestSpecificValues.Current_Mode.Show_Selection_Panel.HasValue) || (!RequestSpecificValues.Current_Mode.Show_Selection_Panel.Value) || (ViewBag.Hierarchy_Object.Children_Count == 0))
            {
                Search_Script_Action = "fulltext_search_sobekcm('" + arg1 + "', '" + browse_url + "');";
            }
            else
            {
                Search_Script_Action = "fulltext_select_search_sobekcm('" + arg1 + "', '" + SUB_CODE + "')";
                arg2 = SUB_CODE;
            }
            RequestSpecificValues.Current_Mode.Mode = displayMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            RequestSpecificValues.Current_Mode.Search_Type = searchType;
            RequestSpecificValues.Current_Mode.Search_String = search_string;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty;
        }
Exemplo n.º 23
0
        public void ItemCanExpireAndBePurged()
        {
            var c = new RequestCache(TimeSpan.FromMilliseconds(10), TimeSpan.MinValue);
            lock (c)
            {
                var item = c.GetOrCreate<FooDTO>("foo");
                item.Expiration = DateTimeOffset.UtcNow.AddSeconds(1);
                item.ItemState = CacheItemState.Complete;

                new AutoResetEvent(false).WaitOne(3000);
                c.Get<FooDTO>("foo");
                Assert.Fail("Expected exception");
            }
        }
        /// <summary> Constructor for a new instance of the Rotating_Highlight_MimeType_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Rotating_Highlight_MimeType_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Determine the sub text to use
            const string SUB_CODE = "s=";
            Sharing_Buttons_HTML = String.Empty;

            // Save the search term
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                textBoxValue = RequestSpecificValues.Current_Mode.Search_String;
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = RequestSpecificValues.Current_Mode.Mode;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            Search_Type_Enum searchType = RequestSpecificValues.Current_Mode.Search_Type;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Basic;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            arg1 = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
            browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
            if ((!RequestSpecificValues.Current_Mode.Show_Selection_Panel.HasValue) || (!RequestSpecificValues.Current_Mode.Show_Selection_Panel.Value) || (ViewBag.Hierarchy_Object.Children_Count == 0))
            {
                Search_Script_Action = "basic_search_sobekcm('" + arg1 + "', '" + browse_url + "')";
            }
            else
            {
                Search_Script_Action = "basic_select_search_sobekcm('" + arg1 + "', '" + SUB_CODE + "')";
                arg2 = SUB_CODE;
            }
            RequestSpecificValues.Current_Mode.Mode = displayMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            RequestSpecificValues.Current_Mode.Search_Type = searchType;
            RequestSpecificValues.Current_Mode.Search_String = search_string;

            // Get the front banner
            frontBannerInfo = ViewBag.Hierarchy_Object.FrontBannerObj;
        }
        /// <summary> Constructor for a new instance of the Oai_MainWriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="Query_String"> URL Query string to parse for OAI-PMH verbs and other values </param>
        public Oai_MainWriter(NameValueCollection Query_String, RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Build list of valid arguments
            validArgs = new List<string>
                            {
                                "from",
                                "until",
                                "metadataPrefix",
                                "set",
                                "resumptionToken",
                                "identifier",
                                "verb",
                                "portal",
                                "urlrelative"
                            };

            // Load the list of OAI sets
            oaiSets = SobekCM_Database.Get_OAI_Sets();
            queryString = Query_String;

            // Set the response type
            HttpContext.Current.Response.ContentType = "text/xml";

            // Determine some global settings
            if (UI_ApplicationCache_Gateway.Settings.OAI_PMH != null)
            {
                config = UI_ApplicationCache_Gateway.Settings.OAI_PMH;
                oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Identifier_Base;
                oai_repository_name = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Name;
                oai_repository_identifier = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Identifier;
            }
            else
            {
                config = new OAI_PMH_Configuration();
                config.Set_Default();
                config.Enabled = true;
            }
            if (String.IsNullOrEmpty(oai_resource_identifier_base)) oai_resource_identifier_base = "oai:" + UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation + ":";
            if (String.IsNullOrEmpty(oai_repository_name)) oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.System.System_Name;
            if (String.IsNullOrEmpty(oai_repository_identifier)) oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation;

            // Get the list of metadata prefixes permissiable by the system
            metadataPrefixes = new List<string>();
            foreach (OAI_PMH_Metadata_Format thisConfig in config.Metadata_Prefixes)
            {
                metadataPrefixes.Add(thisConfig.Prefix);
            }
        }
Exemplo n.º 26
0
        public void ItemCanBeCached()
        {
            var c = new RequestCache(TimeSpan.FromMilliseconds(10), TimeSpan.MinValue);
            lock (c)
            {
                var item = c.GetOrCreate<FooDTO>("foo");
                item.Expiration = DateTimeOffset.UtcNow.AddSeconds(2);
                item.ItemState = CacheItemState.Complete;

                new AutoResetEvent(false).WaitOne(1000);
                var actual = c.Get<FooDTO>("foo");
                Assert.IsNotNull(actual);
            }
            
        }
        /// <summary> Constructor for a new instance of the Newspaper_Search_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Newspaper_Search_AggregationViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Determine the sub text to use
            const string SUB_CODE = "s=";

            // Save the search term
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                textBoxValue = RequestSpecificValues.Current_Mode.Search_String;
            }

            // Compute the redirect stem to use
            string fields = RequestSpecificValues.Current_Mode.Search_Fields;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            RequestSpecificValues.Current_Mode.Home_Type = Home_Type_Enum.List;
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string redirect_stem = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&m=hhh", "").Replace("m=hht", "").Replace("&m=lhh", "").Replace("m=lht", "");
            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
            browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            RequestSpecificValues.Current_Mode.Search_String = search_string;
            RequestSpecificValues.Current_Mode.Search_Fields = fields;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty;

            // Write the advanced search box
            arg2 = String.Empty;
            arg1 = redirect_stem;

            if ((RequestSpecificValues.Hierarchy_Object.Children_Count > 0) && ((RequestSpecificValues.Current_Mode.Show_Selection_Panel.HasValue) && (RequestSpecificValues.Current_Mode.Show_Selection_Panel.Value )))
            {
                Search_Script_Action = "newspaper_select_search_sobekcm('" + arg1 + "', '" + SUB_CODE + "', '" + browse_url + "');";
                arg2 = SUB_CODE;
            }
            else
            {
                Search_Script_Action = "newspaper_search_sobekcm('" + arg1 + "');";
            }
        }
        /// <summary> Constructor for a new instance of the User_Permissions_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public User_Permissions_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // User must AT LEAST be logged on, return
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user is not an admin of some type, also return
            if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_Aggregation_Curator(ViewBag.Hierarchy_Object.Code)))
            {
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }
        }
        /// <summary> Constructor for a new instance of the Full_ResultsViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Google_Map_ResultsViewer_Beta(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            //holds actions from page
            string payload = HttpContext.Current.Request.Form["payload"] ?? String.Empty;

            // See if there were hidden requests
            if (!String.IsNullOrEmpty(payload))
            {
                //if (action == "action")
                Perform_Callback_Action(payload, RequestSpecificValues.Tracer);
            }
            else
            {
                //do a search for all the items in this agg
                string temp_AggregationId = RequestSpecificValues.Current_Mode.Aggregation;
                string[] temp_AggregationList = temp_AggregationId.Split(' ');
                Perform_Aggregation_Search(temp_AggregationList, RequestSpecificValues.Tracer);
            }
        }
        /// <summary> Constructor for a new instance of the Basic_Search_YearRange_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Basic_Search_YearRange_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Save the search term
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                textBoxValue = RequestSpecificValues.Current_Mode.Search_String;
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = RequestSpecificValues.Current_Mode.Mode;
            Search_Type_Enum searchType = RequestSpecificValues.Current_Mode.Search_Type;
            Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Basic;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;
            RequestSpecificValues.Current_Mode.Search_String = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            arg1 = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            // Get the browse all url, if enabled
            browse_url = String.Empty;
            if (ViewBag.Hierarchy_Object.Can_Browse_Items)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
                browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            }

            Search_Script_Action = "basic_search_years_sobekcm('" + arg1 + "', '" + browse_url + "');";

            RequestSpecificValues.Current_Mode.Mode = displayMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
            RequestSpecificValues.Current_Mode.Search_Type = searchType;
            RequestSpecificValues.Current_Mode.Search_String = search_string;
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty;
        }
Exemplo n.º 31
0
        private void ConfigurationChanged_EventHandler(object sender, NetWorkSetting networkSetting)
        {
            // Invalidate the request cache for network when things change on the connection since the user name or URL may have changed.  We could be more selective in when we need to invalidate, but for now this will do.
            RequestCache.ForNetwork(networkSetting).Invalidate();
            if (!this.Visible)
            {
                return;
            }

            try
            {
                TestConnections();

                foreach (var p in tabs.TabPages.Cast <TabPage>().ToList())
                {
                    var l = p.Controls[0] as RequestListGridView;
                    if (!Configuration.Instance.NetworkSettingCollection.NetWorkSettings.Contains(l.Network))
                    {
                        l.Dispose();
                        tabs.TabPages.Remove(p);
                    }
                    else
                    {
                        l.OnConfigurationChanged();
                    }
                }
                Configuration.Instance.NetworkSettingCollection.NetWorkSettings
                .Cast <NetWorkSetting>()
                .Except(AllLists().Select(l => l.Network))
                .ForEach(ns => CreateList(ns));

                ToggleNoNetworksMessage();
                ReloadAllLists();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MessageBox.Show(ex.Message, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 32
0
        private void SaveRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            var requestHeaderKeys = request.Headers.Keys;
            var requestHeaders    = requestHeaderKeys.Select(key => new Header(key, request.Headers[key])).ToList();
            var requestCache      = new RequestCache
            {
                Method      = request.Method,
                Path        = request.Path.Value,
                Body        = request.Body,
                Headers     = requestHeaders,
                RouteValues = request.RouteValues.Values.ToList(),
                QueryString = request.QueryString.Value,
            };

            var responseHeaderKeys = response.Headers.Keys;
            var responseHeaders    = responseHeaderKeys.Select(key => new Header(key, response.Headers[key])).ToList();
            var responseCache      = new ResponseCache
            {
                Body          = response.Body,
                ContentType   = response.ContentType,
                Headers       = responseHeaders,
                ContentLength = response.ContentLength,
                StatusCode    = response.StatusCode
            };

            var cacheContext = new CacheContext
            {
                Request     = requestCache,
                Response    = responseCache,
                PerformedAt = DateTime.Now
            };

            using (var redisClient = new RedisClient(_redisConnection))
            {
                redisClient.Set(CreateRedisKey(requestCache.Path), cacheContext);
            }
        }
Exemplo n.º 33
0
        /// <summary> Constructor for a new instance of the Full_ResultsViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
        /// <param name="PagedResults"> Actual pages of results </param>
        public Google_Map_ResultsViewer_Beta(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List<iSearch_Title_Result> PagedResults)
            : base(RequestSpecificValues, ResultsStats, PagedResults)
        {
 
            //holds actions from page
            string payload = HttpContext.Current.Request.Form["payload"] ?? String.Empty;
            
            // See if there were hidden requests
            if (!String.IsNullOrEmpty(payload))
            {
                //if (action == "action")
                Perform_Callback_Action(payload, RequestSpecificValues.Tracer);
            }
            else
            {
                //do a search for all the items in this agg
                string temp_AggregationId = RequestSpecificValues.Current_Mode.Aggregation;
                string[] temp_AggregationList = temp_AggregationId.Split(' ');
                Perform_Aggregation_Search(temp_AggregationList, RequestSpecificValues.Tracer);
            }

        }
Exemplo n.º 34
0
        public void testWithReadOnlyFile()
        {
            // Make the existing cache file readonly
            String fname = fAgent.HomeDir + Path.DirectorySeparatorChar + "work" + Path.DirectorySeparatorChar +
                           "requests.adk";
            FileInfo fi = new FileInfo(fname);

            //= new File(fname);
            if (!fi.Exists)
            {
                StreamWriter sw = fi.CreateText();
                //sw.WriteLine("");
                sw.Flush();
                sw.Close();

                // RandomAccessFile raf = new RandomAccessFile(fname, "rw");
                // raf.setLength(0);
                //raf.close();
            }
            fi.IsReadOnly = true;
            try
            {
                fRC = RequestCache.GetInstance(fAgent); //this should throw adk exception
            }
            catch (AdkException)
            {
                return;
            }
            finally
            {
                fi.IsReadOnly = false;
                fi.Delete();
            }
            //should never get here

            Assertion.AssertEquals("Exception should have been thrown because request cache file is readonly", true,
                                   false);
        }
        /// <summary> Constructor for a new instance of the Advanced_Search_YearRange_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Advanced_Search_YearRange_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Compute the redirect stem to use
            string                fields            = RequestSpecificValues.Current_Mode.Search_Fields;
            string                searchCollections = RequestSpecificValues.Current_Mode.SubAggregation;
            Display_Mode_Enum     lastMode          = RequestSpecificValues.Current_Mode.Mode;
            Aggregation_Type_Enum aggrType          = RequestSpecificValues.Current_Mode.Aggregation_Type;

            RequestSpecificValues.Current_Mode.SubAggregation = String.Empty;

            string searchString = RequestSpecificValues.Current_Mode.Search_String;

            RequestSpecificValues.Current_Mode.Search_String    = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields    = String.Empty;
            RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string redirectStem = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            // Get the browse all url, if enabled
            string browse_url = String.Empty;

            if (ViewBag.Hierarchy_Object.Can_Browse_Items)
            {
                RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all";
                browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
            }

            RequestSpecificValues.Current_Mode.Search_String    = searchString;
            RequestSpecificValues.Current_Mode.Search_Fields    = fields;
            RequestSpecificValues.Current_Mode.SubAggregation   = searchCollections;
            RequestSpecificValues.Current_Mode.Mode             = lastMode;
            RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;

            Search_Script_Action = "advanced_search_years_sobekcm('" + redirectStem + "','" + browse_url + "')";
        }
Exemplo n.º 36
0
        public void testWithCorruptFile()
        {
            // Delete the existing cache file, if it exists
            String fname = fAgent.HomeDir + Path.DirectorySeparatorChar + "work" + Path.DirectorySeparatorChar +
                           "requestcache.adk";
            FileInfo fi = new FileInfo(fname);
            StreamWriter sw = fi.CreateText();
            sw.WriteLine("!@#$!@#$");
            sw.Flush();
            sw.Close();

            //RandomAccessFile raf = new RandomAccessFile(fname, "rw");
            //raf.writeChars("!@#$!@#$");
            // raf.close();

            fRC = RequestCache.GetInstance(fAgent);
            storeAssertedRequests(fRC);
            fRC.Close();

            // Create a new instance. This one should retrieve its settings from the persistence mechanism
            fRC = RequestCache.GetInstance(fAgent);
            assertStoredRequests(fRC, true);
        }
 internal RequestCachingSectionInternal(RequestCachingSection section)
 {
     if (!section.DisableAllCaching)
     {
         this.defaultCachePolicy    = new RequestCachePolicy(section.DefaultPolicyLevel);
         this.isPrivateCache        = section.IsPrivateCache;
         this.unspecifiedMaximumAge = section.UnspecifiedMaximumAge;
     }
     else
     {
         this.disableAllCaching = true;
     }
     this.httpRequestCacheValidator = new HttpRequestCacheValidator(false, this.UnspecifiedMaximumAge);
     this.ftpRequestCacheValidator  = new FtpRequestCacheValidator(false, this.UnspecifiedMaximumAge);
     this.defaultCache = new WinInetCache(this.IsPrivateCache, true, true);
     if (!section.DisableAllCaching)
     {
         HttpCachePolicyElement defaultHttpCachePolicy = section.DefaultHttpCachePolicy;
         if (defaultHttpCachePolicy.WasReadFromConfig)
         {
             if (defaultHttpCachePolicy.PolicyLevel == HttpRequestCacheLevel.Default)
             {
                 HttpCacheAgeControl cacheAgeControl = (defaultHttpCachePolicy.MinimumFresh != TimeSpan.MinValue) ? HttpCacheAgeControl.MaxAgeAndMinFresh : HttpCacheAgeControl.MaxAgeAndMaxStale;
                 this.defaultHttpCachePolicy = new HttpRequestCachePolicy(cacheAgeControl, defaultHttpCachePolicy.MaximumAge, (defaultHttpCachePolicy.MinimumFresh != TimeSpan.MinValue) ? defaultHttpCachePolicy.MinimumFresh : defaultHttpCachePolicy.MaximumStale);
             }
             else
             {
                 this.defaultHttpCachePolicy = new HttpRequestCachePolicy(defaultHttpCachePolicy.PolicyLevel);
             }
         }
         FtpCachePolicyElement defaultFtpCachePolicy = section.DefaultFtpCachePolicy;
         if (defaultFtpCachePolicy.WasReadFromConfig)
         {
             this.defaultFtpCachePolicy = new RequestCachePolicy(defaultFtpCachePolicy.PolicyLevel);
         }
     }
 }
Exemplo n.º 38
0
        /// <summary> Constructor for a new instance of the Preferences_HtmlSubwriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Preferences_HtmlSubwriter(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["hidden_request"] ?? String.Empty;

            if (hidden_request == "submit")
            {
                NameValueCollection form = HttpContext.Current.Request.Form;

                string language_option = form["languageDropDown"];
                switch (language_option)
                {
                case "en":
                    RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.English;
                    break;

                case "fr":
                    RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.French;
                    break;

                case "es":
                    RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.Spanish;
                    break;
                }

                string defaultViewDropDown = form["defaultViewDropDown"];
                HttpContext.Current.Session["User_Default_View"] = defaultViewDropDown;

                int user_sort = Convert.ToInt32(form["defaultSortDropDown"]);
                HttpContext.Current.Session["User_Default_Sort"] = user_sort;

                RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }
        }
Exemplo n.º 39
0
        private void ShowRequestDetailDialog(NetWorkSetting ns, Guid id, Guid dataMartId)
        {
            var progress = new ProgressForm("Loading Request Information", "Loading full Request information from the Network...");

            RequestCache.ForNetwork(ns)
            .LoadRequest(id, dataMartId)
            .TakeUntil(progress.ShowAndWaitForCancel(this))
            .ObserveOn(this)
            .Finally(progress.Dispose)
            .Do(request =>
            {
                using (var f = new RequestDetailForm(request))
                {
                    f.FormClosed += Refresh_EventHandler;
                    f.Shown      += (_, __) => progress.Dispose();
                    f.ShowDialog(this);
                }
            })
            .LogExceptions(log.Error)
            .Catch(( IncompatibleProcessorException e ) => MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information))
            .Catch(( CannotLoadProcessorException e ) => MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information))
            .Catch((Exception e) => MessageBox.Show(string.Join(Environment.NewLine, OpResult.FromException(e).ErrorMessages), "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error))
            .Subscribe();
        }
Exemplo n.º 40
0
 /// <summary> Constructor for a new instance of the No_Results_ResultsViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
 /// <param name="PagedResults"> Actual pages of results </param>
 public No_Results_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults)
     : base(RequestSpecificValues, ResultsStats, PagedResults)
 {
     // Do nothing
 }
 /// <summary> Base constructor </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 protected abstractHtmlSubwriter(RequestCache RequestSpecificValues)
 {
     this.RequestSpecificValues = RequestSpecificValues;
 }
Exemplo n.º 42
0
 /// <summary>
 /// Session cache ma służyć tylko do utrzymywania itemów, ma zawierać wyłącznie propertiesy, brak wykorzystania jakiegokolwiek service.
 /// </summary>
 /// <param name="session"></param>
 public SessionCache(IHttpContextAccessor context, RequestCache requestCache)
     : base(context.HttpContext.Session, requestCache)
 {
     //
 }
Exemplo n.º 43
0
        /// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary>
        /// <param name="DefaultMetadata"> Default metadata object, if that is how this is being used </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Edit_Item_Metadata_MySobekViewer(SobekCM_Item DefaultMetadata, RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty);

            popUpFormsHtml = String.Empty;
            delayed_popup  = String.Empty;

            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the default metadata was provided, use that
            if (DefaultMetadata != null)
            {
                currentItem = DefaultMetadata;
            }
            else
            {
                // Ensure BibID and VID provided
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Validate provided bibid / vid");
                if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "BibID or VID was not provided!");
                    RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                    RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item metadata edit request";
                    return;
                }

                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Try to pull this sobek complete item");
                currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
                if (currentItem == null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Unable to build complete item");
                    RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                    RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                    return;
                }
            }

            // If the RequestSpecificValues.Current_User cannot edit this item, go back
            if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode));
            }

            // Is this a project
            isProject = currentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project;

            string template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Simple;

            if ((currentItem.Contains_Complex_Content) || (currentItem.Using_Complex_Template))
            {
                template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Complex;
            }
            if (isProject)
            {
                template_code    = "standard_project";
                completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer);
                if (completeTemplate != null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found project-specific template in cache");
                }
                else
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading project-specific template file");

                    // Look in the user-defined portion
                    string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\project.xml";
                    if (!File.Exists(user_template))
                    {
                        user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\project.xml";
                    }

                    // Read this CompleteTemplate
                    Template_XML_Reader reader = new Template_XML_Reader();
                    completeTemplate = new CompleteTemplate();
                    reader.Read_XML(user_template, completeTemplate, true);

                    // Save this into the cache
                    Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer);
                }
            }
            else
            {
                completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer);
                if (completeTemplate != null)
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache");
                }
                else
                {
                    RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file");

                    // Look in the user-defined portion
                    string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\edit\\" + template_code + ".xml";
                    if (!File.Exists(user_template))
                    {
                        user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\edit\\" + template_code + ".xml";
                    }

                    // Read this CompleteTemplate
                    Template_XML_Reader reader = new Template_XML_Reader();
                    completeTemplate = new CompleteTemplate();
                    reader.Read_XML(user_template, completeTemplate, true);
                    if (completeTemplate != null)
                    {
                        completeTemplate.Build_Final_Adjustment_And_Checks();
                    }

                    // Save this into the cache
                    Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer);
                }
            }

            // Get the current page number, or default to 1
            page = 1;
            if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode))
            {
                if ((RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "preview") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "marc") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "mets"))
                {
                    page = 0;
                }
                else
                {
                    page = 1;
                    bool isNumber = RequestSpecificValues.Current_Mode.My_Sobek_SubMode.All(Char.IsNumber);
                    if (isNumber)
                    {
                        if (isProject)
                        {
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page);
                        }
                        else
                        {
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode, out page);
                        }
                    }
                    else if (isProject)
                    {
                        if (Char.IsNumber(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0]))
                        {
                            Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page);
                        }
                    }
                }
            }

            // Handle post backs
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // See if there was a hidden request
                string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty;

                // If this was a cancel request do that
                if (hidden_request == "cancel")
                {
                    if (isProject)
                    {
                        CachedDataManager.Remove_Project(RequestSpecificValues.Current_User.UserID, currentItem.BibID, null);

                        RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Administrative;
                        RequestSpecificValues.Current_Mode.Admin_Type       = Admin_Type_Enum.Default_Metadata;
                        RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                    else
                    {
                        CachedDataManager.Items.Remove_Digital_Resource_Object(RequestSpecificValues.Current_User.UserID, currentItem.BibID, currentItem.VID, null);

                        // Also clear the engine
                        SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                    return;
                }


                // Save these changes to bib
                completeTemplate.Save_To_Bib(currentItem, RequestSpecificValues.Current_User, ((int)page));

                // See if the RequestSpecificValues.Current_User asked for a new element of a complex form type
                delayed_popup = String.Empty;
                switch (hidden_request.Trim())
                {
                case "name":
                    delayed_popup = "name";
                    currentItem.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.Personal;
                    break;

                case "title":
                    delayed_popup = "title";
                    currentItem.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.Alternative);
                    break;

                case "subject":
                    delayed_popup = "subject";
                    currentItem.Bib_Info.Add_Subject();
                    break;

                case "spatial":
                    delayed_popup = "spatial";
                    currentItem.Bib_Info.Add_Hierarchical_Geographic_Subject();
                    break;

                case "relateditem":
                    delayed_popup = "relateditem";
                    currentItem.Bib_Info.Add_Related_Item(new Related_Item_Info());
                    break;

                case "save":
                    Complete_Item_Save();
                    break;

                case "complicate":
                    currentItem.Using_Complex_Template = true;
                    HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    RequestSpecificValues.Current_Mode.Request_Completed = true;
                    return;

                case "simplify":
                    currentItem.Using_Complex_Template = false;
                    HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    RequestSpecificValues.Current_Mode.Request_Completed = true;
                    return;
                }

                // Was this for a new page?
                if (hidden_request.IndexOf("newpage") == 0)
                {
                    string page_requested = hidden_request.Replace("newpage", "");
                    if (page_requested != RequestSpecificValues.Current_Mode.My_Sobek_SubMode)
                    {
                        // forward to requested page
                        RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested;
                        if (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "0")
                        {
                            RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "preview";
                        }
                        if (isProject)
                        {
                            RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested + currentItem.BibID;
                        }

                        HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "#CompleteTemplate", false);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        RequestSpecificValues.Current_Mode.Request_Completed = true;
                    }
                }
            }
        }
Exemplo n.º 44
0
        /// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public Aliases_AdminViewer(RequestCache RequestSpecificValues)  : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty);

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the RequestSpecificValues.Current_User cannot edit this, go back
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is a postback, handle any events first
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string save_value = form["admin_forwarding_tosave"].ToLower().Trim();
                    string new_alias  = form["admin_forwarding_alias"].ToLower().Trim();

                    // Was this a save request
                    if (save_value.Length > 0)
                    {
                        // If this starts with a '-' this is a delete
                        if (save_value[0] == '-')
                        {
                            if ((RequestSpecificValues.Current_User.Is_System_Admin) && (save_value.Length > 1))
                            {
                                save_value = save_value.Substring(1);
                                RequestSpecificValues.Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Delete alias '" + save_value + "'");
                                if (SobekCM_Database.Delete_Aggregation_Alias(save_value, RequestSpecificValues.Tracer))
                                {
                                    if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value))
                                    {
                                        UI_ApplicationCache_Gateway.Collection_Aliases.Remove(save_value);
                                    }

                                    actionMessage = "Deleted existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                        else
                        {
                            RequestSpecificValues.Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Save alias '" + save_value + "'");

                            // Was this to save a new alias (from the main page) or edit an existing (from the popup form)?
                            if (save_value == new_alias)
                            {
                                string new_code = form["admin_forwarding_code"].ToLower().Trim();

                                // Validate the code
                                if (new_code.Length > 20)
                                {
                                    actionMessage = "New alias code must be twenty characters long or less";
                                }
                                else if (new_code.Length == 0)
                                {
                                    actionMessage = "You must enter a CODE for this aggregation alias";
                                }
                                else if (UI_ApplicationCache_Gateway.Aggregations[new_code.ToUpper()] != null)
                                {
                                    actionMessage = "Aggregation with this code already exists";
                                }
                                else if (UI_ApplicationCache_Gateway.Settings.Static.Reserved_Keywords.Contains(new_code.ToLower()))
                                {
                                    actionMessage = "That code is a system-reserved keyword.  Try a different code.";
                                }

                                // Save this new forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, new_code, RequestSpecificValues.Tracer))
                                {
                                    if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value))
                                    {
                                        UI_ApplicationCache_Gateway.Collection_Aliases[save_value] = new_code;
                                    }
                                    else
                                    {
                                        UI_ApplicationCache_Gateway.Collection_Aliases.Add(save_value, new_code);
                                    }

                                    actionMessage = "Saved new aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save new aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                            else
                            {
                                string edit_code = form["form_forwarding_code"].ToLower().Trim();

                                // Save this existing forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, edit_code, RequestSpecificValues.Tracer))
                                {
                                    if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value))
                                    {
                                        UI_ApplicationCache_Gateway.Collection_Aliases[save_value] = edit_code;
                                    }
                                    else
                                    {
                                        UI_ApplicationCache_Gateway.Collection_Aliases.Add(save_value, edit_code);
                                    }

                                    actionMessage = "Edited existing aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while processing request";
                }
            }
        }
Exemplo n.º 45
0
        /// <summary> Constructor for a new instance of the WebContent_History_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public WebContent_History_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("WebContent_History_AdminViewer.Constructor", String.Empty);
            actionMessage = String.Empty;

            // Ensure the user is the system admin or portal admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            //// If this is posted back, look for the reset
            //if (RequestSpecificValues.Current_Mode.isPostBack)
            //{
            //    string reset_value = HttpContext.Current.Request.Form[""];
            //    if ((!String.IsNullOrEmpty(reset_value)) && (reset_value == "reset"))
            //    {
            //        // Just ensure everything is emptied out
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsReport");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsUsersLinked");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsLinkedAggr");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsReportSubmit");
            //    }
            //}

            // Set filters initially to empty strings
            level1     = String.Empty;
            level2     = String.Empty;
            level3     = String.Empty;
            level4     = String.Empty;
            level5     = String.Empty;
            userFilter = String.Empty;

            // Get any userfilter
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["user"]))
            {
                userFilter = HttpContext.Current.Request.QueryString["user"];
            }

            // If no user filter, try to find the level filters
            if (String.IsNullOrEmpty(userFilter))
            {
                // Get any level filter information from the query string
                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"]))
                {
                    level1 = HttpContext.Current.Request.QueryString["l1"];

                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"]))
                    {
                        level2 = HttpContext.Current.Request.QueryString["l2"];

                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"]))
                        {
                            level3 = HttpContext.Current.Request.QueryString["l3"];

                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"]))
                            {
                                level4 = HttpContext.Current.Request.QueryString["l4"];

                                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"]))
                                {
                                    level5 = HttpContext.Current.Request.QueryString["l5"];
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 46
0
        /// <summary> Returns the appropriate mySobek viewer, based on requst and system settings </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request  </param>
        /// <returns> Built mySobek viewer </returns>
        public static iMySobek_Admin_Viewer Get_MySobekViewer(RequestCache RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("MySobekViewer_Factory.Get_MySobekViewer", "Building the mySobek viewer object");

            switch (RequestSpecificValues.Current_Mode.My_Sobek_Type)
            {
            case My_Sobek_Type_Enum.Import_Spreadsheet:
                return(new Import_Spreadsheet_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Home:
                return(new Home_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.New_Item:
                return(new New_Group_And_Item_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.New_TEI_Item:
                return(new New_TEI_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Folder_Management:
                return(new Folder_Mgmt_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Saved_Searches:
                return(new Saved_Searches_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Preferences:
                return(new Preferences_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Logon:
                return(new Logon_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.New_Password:
                return(new NewPassword_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Delete_Item:
                return(new Delete_Item_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_Item_Behaviors:
                return(new Edit_Item_Behaviors_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_Item_Metadata:
                return(new Edit_Item_Metadata_MySobekViewer(null, RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_TEI_Item:
                return(new Edit_TEI_Item_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_Item_Permissions:
                return(new Edit_Item_Permissions_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.File_Management:
                return(new File_Management_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_Group_Behaviors:
                return(new Edit_Group_Behaviors_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy:
                return(new Edit_Serial_Hierarchy_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Item_Tracking:
                return(new Track_Item_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Group_Add_Volume:
                return(new Group_Add_Volume_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Group_AutoFill_Volumes:
                return(new Group_AutoFill_Volume_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Group_Mass_Update_Items:
                return(new Mass_Update_Items_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Page_Images_Management:
                return(new Page_Image_Upload_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.Rights_Management:
                return(new Rights_Management_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.User_Tags:
                return(new User_Tags_MySobekViewer(RequestSpecificValues));

            case My_Sobek_Type_Enum.User_Usage_Stats:
                return(new User_Usage_Stats_MySobekViewer(RequestSpecificValues));
            }

            return(null);
        }
 /// <summary> Constructor for a new instance of the Text_MainWriter class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="HTML_File_To_Echo"> The HTML file to echo </param>
 public Html_Echo_MainWriter(RequestCache RequestSpecificValues, string HTML_File_To_Echo) : base(RequestSpecificValues)
 {
     fileToEcho = HTML_File_To_Echo;
 }
Exemplo n.º 48
0
 /// <summary>  Constructor for a new instance of the User_Permissions_WebContentViewer class  </summary>
 /// <param name="RequestSpecificValues">  All the necessary, non-global data specific to the current request  </param>
 /// <param name="StaticPage"> Static page info for this request </param>
 public User_Permissions_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage)
     : base(RequestSpecificValues, StaticPage)
 {
 }
 /// <summary> Constructor for a new instance of the Group_AutoFill_Volume_MySobekViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 public Group_AutoFill_Volume_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
 {
     // This is currently a place holder class and does nothing
 }
Exemplo n.º 50
0
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            _log.Info("Automated processing worker started.");
            while (true)
            {
                _log.Info("Checking Master Request Queue for requests requiring automated processing.");
                SystemTray.UpdateNotificationIcon(IconType.IconBusy, "Processing Requests");

                var reqs = from ns in Configuration.Instance.NetworkSettingCollection.NetWorkSettings.Cast <NetWorkSetting>().ToObservable()
                           where ns.NetworkStatus == Util.ConnectionOKStatus

                           let dmIds = ns.DataMartList
                                       // BMS: Note the ProcessAndNotUpload feature has been temporarilty disabled until we fix the processing around this feature
                                       .Where(dm => dm.AllowUnattendedOperation && (dm.NotifyOfNewQueries || /* dm.ProcessQueriesAndNotUpload || */ dm.ProcessQueriesAndUploadAutomatically))
                                       .Select(dm => dm.DataMartId)
                                       .ToArray()
                                       where dmIds.Any()

                                       from list in DnsServiceManager.GetRequestList(ns, 0, Properties.Settings.Default.AutoProcessingBatchSize,
                                                                                     new RequestFilter {
                    Statuses = new [] { Lpp.Dns.DTO.DataMartClient.Enums.DMCRoutingStatus.Submitted }, DataMartIds = dmIds
                }, null, null)

                                       from rl in list.Segment.EmptyIfNull().ToObservable()
                                       where rl.AllowUnattendedProcessing
                                       from r in RequestCache.ForNetwork(ns).LoadRequest(rl.ID, rl.DataMartID)
                                       select new { Request = r, NetworkSetting = ns };

                reqs
                .Do(r =>
                {
                    var request             = r.Request;
                    var datamartDescription = Configuration.Instance.GetDataMartDescription(request.NetworkId, request.DataMartId);
                    var modelDescription    = Configuration.Instance.GetModelDescription(request.NetworkId, request.DataMartId, request.Source.ModelID);


                    var packageIdentifier = new Lpp.Dns.DTO.DataMartClient.RequestTypeIdentifier {
                        Identifier = request.Source.RequestTypePackageIdentifier, Version = request.Source.AdapterPackageVersion
                    };
                    if (!System.IO.File.Exists(System.IO.Path.Combine(Configuration.PackagesFolderPath, packageIdentifier.PackageName())))
                    {
                        DnsServiceManager.DownloadPackage(r.NetworkSetting, packageIdentifier);
                    }

                    using (var domainManager = new DomainManger.DomainManager(Configuration.PackagesFolderPath))
                    {
                        domainManager.Load(request.Source.RequestTypePackageIdentifier, request.Source.AdapterPackageVersion);
                        IModelProcessor processor = domainManager.GetProcessor(modelDescription.ProcessorId);
                        ProcessorManager.UpdateProcessorSettings(modelDescription, processor);

                        if (processor is IEarlyInitializeModelProcessor)
                        {
                            ((IEarlyInitializeModelProcessor)processor).Initialize(modelDescription.ModelId, request.Documents.Select(d => new DocumentWithStream(d.ID, new Document(d.ID, d.Document.MimeType, d.Document.Name, d.Document.IsViewable, Convert.ToInt32(d.Document.Size), d.Document.Kind), new DocumentChunkStream(d.ID, r.NetworkSetting))).ToArray());
                        }

                        if (processor != null &&
                            processor.ModelMetadata != null &&
                            processor.ModelMetadata.Capabilities != null &&
                            processor.ModelMetadata.Capabilities.ContainsKey("CanRunAndUpload") &&
                            !(bool)processor.ModelMetadata.Capabilities["CanRunAndUpload"])
                        {
                            //can't be run, don't attempt autoprocessing
                            return;
                        }


                        request.Processor = processor;

                        if (request.RoutingStatus == Lpp.Dns.DTO.DataMartClient.Enums.DMCRoutingStatus.Submitted)
                        {
                            if (processor != null)
                            {
                                SystemTray.generate_notification(request, request.NetworkId);

                                if (datamartDescription.NotifyOfNewQueries)
                                {
                                    SystemTray.UpdateNotificationIcon(IconType.IconBusy, string.Format("Query Submitted by {0}", request.Source.Author.Username));
                                }
                                else
                                {
                                    processor.SetRequestProperties(request.Source.ID.ToString(), request.Properties);
                                    ProcessRequest(request);

                                    var statusCode = request.Processor.Status(request.Source.ID.ToString()).Code;
                                    if (datamartDescription.ProcessQueriesAndUploadAutomatically && (statusCode == RequestStatus.StatusCode.Complete || statusCode == RequestStatus.StatusCode.CompleteWithMessage))
                                    {
                                        // Post process requests that are automatically uploaded
                                        processor.PostProcess(request.Source.ID.ToString());
                                        // Increment counter
                                        _queriesProcessedCount++;
                                        SystemTray.update_notify_text(_queriesProcessedCount, request.DataMartName, request.NetworkId);
                                        UploadRequest(request);
                                    }
                                }
                            }
                        }
                        else if (request.RoutingStatus == Lpp.Dns.DTO.DataMartClient.Enums.DMCRoutingStatus.AwaitingResponseApproval)
                        {
                            if (datamartDescription.ProcessQueriesAndUploadAutomatically)
                            {
                                // Increment counter
                                _queriesProcessedCount++;
                                SystemTray.update_notify_text(_queriesProcessedCount, request.DataMartName, request.NetworkId);
                                UploadRequest(request);
                            }
                        }
                    }
                })
                .LogExceptions(_log.Error)
                .Catch()
                .LastOrDefault();

                SystemTray.UpdateNotificationIcon(IconType.IconDefault, null);
                Thread.Sleep(DMClient.Properties.Settings.Default.RefreshRate);
            }
        }
Exemplo n.º 51
0
        async Task <HubRequest[]> GetRequestsAsync()
        {
            if (_networkSetting.NetworkStatus != Util.ConnectionOKStatus)
            {
                return(new HubRequest[0]);
            }

            var datamartIDs = _networkSetting.DataMartList
                              .Where(dm => dm.AllowUnattendedOperation && (dm.NotifyOfNewQueries || dm.ProcessQueriesAndNotUpload || dm.ProcessQueriesAndUploadAutomatically))
                              .Select(dm => dm.DataMartId).ToArray();

            if (datamartIDs.Length == 0)
            {
                return(new HubRequest[0]);
            }

            var requestFilter = new RequestFilter
            {
                Statuses    = new[] { DTO.DataMartClient.Enums.DMCRoutingStatus.Submitted, DTO.DataMartClient.Enums.DMCRoutingStatus.Resubmitted },
                DataMartIds = datamartIDs
            };

            var requests = Observable.Create <DTO.DataMartClient.RequestList>(async observer =>
            {
                int index     = 0;
                int batchSize = Properties.Settings.Default.AutoProcessingBatchSize;
                DTO.DataMartClient.RequestList rl = null;

                while (rl == null || (index < rl.TotalCount))
                {
                    rl = await DnsServiceManager.GetRequestList("AutoProcessor", _networkSetting, index, batchSize, requestFilter, DTO.DataMartClient.RequestSortColumn.RequestTime, true);

                    if (rl == null || rl.TotalCount == 0)
                    {
                        break;
                    }

                    observer.OnNext(rl);

                    index += batchSize;
                }

                observer.OnCompleted();
            }).DefaultIfEmpty()
                           .Aggregate((requestList1, requestList2) =>
            {
                if (requestList1 == null && requestList2 == null)
                {
                    return(new DTO.DataMartClient.RequestList
                    {
                        Segment = Array.Empty <DTO.DataMartClient.RequestListRow>(),
                        SortedAscending = true,
                        SortedByColumn = DTO.DataMartClient.RequestSortColumn.RequestTime
                    });
                }
                else if (requestList1 != null && requestList2 == null)
                {
                    return(requestList1);
                }
                else if (requestList1 == null && requestList2 != null)
                {
                    return(requestList2);
                }
                else
                {
                    return(new DTO.DataMartClient.RequestList
                    {
                        Segment = requestList1.Segment.EmptyIfNull().Concat(requestList2.Segment.EmptyIfNull()).ToArray(),
                        SortedAscending = requestList1.SortedAscending,
                        SortedByColumn = requestList1.SortedByColumn,
                        StartIndex = requestList1.StartIndex,
                        TotalCount = requestList1.TotalCount
                    });
                }
            })
                           .SelectMany(requestList =>
            {
                if (requestList == null)
                {
                    return(Array.Empty <DTO.DataMartClient.RequestListRow>());
                }

                return(requestList.Segment.DefaultIfEmpty().Where(s => s.AllowUnattendedProcessing));
            })
                           .SelectMany(rlr => RequestCache.ForNetwork(_networkSetting).LoadRequest(rlr.ID, rlr.DataMartID))
                           .ToArray();

            return(await requests);
        }
 /// <summary> Constructor for a new instance of the Export_ResultsViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
 /// <param name="PagedResults"> Actual pages of results </param>
 public Export_ResultsViewer(RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults)
     : base(RequestSpecificValues, ResultsStats, PagedResults)
 {
     Results_Per_Page = 1000;
 }
Exemplo n.º 53
0
 /// <summary> Constructor for a new instance of the No_Search_AggregationViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
 public No_Search_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
     : base(RequestSpecificValues, ViewBag)
 {
     // Do nothing
 }
        /// <summary>  Constructor for a new instance of the Delete_Verify_WebContentViewer class  </summary>
        /// <param name="RequestSpecificValues">  All the necessary, non-global data specific to the current request  </param>
        /// <param name="StaticPage"> Static page info for this request </param>
        public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage)
            : base(RequestSpecificValues, StaticPage)
        {
            // Pull the web content page
            if (RequestSpecificValues.Current_Mode.WebContentID.HasValue)
            {
                webContent = SobekEngineClient.WebContent.Get_HTML_Based_Content(RequestSpecificValues.Current_Mode.WebContentID.Value, true, RequestSpecificValues.Tracer);
            }

            // This should never occur, but just a double check
            if ((webContent == null) || (!webContent.WebContentID.HasValue))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure there IS a logged on user
            RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user");
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user was logged on, but did not have permissions, show an error message
            canDelete = true;
            deleted   = false;
            if (!webContent.Can_Delete(RequestSpecificValues.Current_User))
            {
                errorMessage = "ERROR: You do not have permission to delete this page";
                canDelete    = false;
            }
            else if (HttpContext.Current.Request.RequestType == "POST")
            {
                string save_value = HttpContext.Current.Request.Form["admin_delete_item"];

                // Better say "DELETE", or just send back to the item
                if ((save_value != null) && (String.Compare(save_value, "DELETE", StringComparison.OrdinalIgnoreCase) == 0))
                {
                    string entered_value = HttpContext.Current.Request.Form["admin_delete_confirm"];
                    if ((entered_value == null) || (entered_value.ToUpper() != "DELETE"))
                    {
                        errorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM";
                    }
                    else
                    {
                        string deleteReason = "Requested via web application";


                        RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(webContent.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, deleteReason, RequestSpecificValues.Tracer);

                        errorMessage = message.Message;
                        if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(errorMessage)))
                        {
                            errorMessage = "Error encountered on SobekCM engine.";
                        }
                        else
                        {
                            errorMessage = "Successfully deleted this web content page.";

                            // Clear cached data here on the client
                            CachedDataManager.WebContent.Clear_All_Web_Content_Lists();
                            CachedDataManager.WebContent.Clear_All_Web_Content_Pages();
                            CachedDataManager.WebContent.Clear_Page_Details();
                            UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear();

                            deleted = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 55
0
        /// <summary> Constructor for a new instance of the Map_Search_AggregationViewer class </summary>
        ///<param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Map_Search_AggregationViewer_Beta(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            ////redirect
            //currentMode.Redirect_URL();

            #region MY STUFF

            // Start to build the response
            StringBuilder mapSearchBuilder = new StringBuilder();

            //start of custom content
            mapSearchBuilder.AppendLine("<td> MapSearchHolder");

            #region TEMP HEADER FILES

            ////standard css
            //mapSearchBuilder.AppendLine(" <link rel=\"stylesheet\" href=\"" + CurrentMode.Base_URL + "default/jquery-ui.css\"/> ");
            //mapSearchBuilder.AppendLine(" <link rel=\"stylesheet\" href=\"" + CurrentMode.Base_URL + "default/jquery-searchbox.css\"/> ");

            ////standard js files
            //mapSearchBuilder.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.10.3.custom.min.js\"></script> ");
            //mapSearchBuilder.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-migrate-1.1.1.min.js\"></script> ");
            //mapSearchBuilder.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-rotate.js\"></script> ");
            //mapSearchBuilder.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-knob.js\"></script> ");
            //mapSearchBuilder.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-json-2.4.min.js\"></script> ");

            mapSearchBuilder.AppendLine("     <script type=\"text/javascript\" src=\"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key=AIzaSyCzliz5FjUlEI9D2605b33-etBrENSSBZM&libraries=drawing\"></script> ");
            mapSearchBuilder.AppendLine("     <script src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/external_markerclusterer_compiled.js\"></script>  ");
            mapSearchBuilder.AppendLine("     <script src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/external_jquery_1.10.2.js\"></script> ");
            mapSearchBuilder.AppendLine("     <script src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/external_jquery_ui.min.js\"></script> ");
            mapSearchBuilder.AppendLine("     <script src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/external_jquery_ui_labeledslider.js\"></script> ");
            mapSearchBuilder.AppendLine("     <script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Gmaps_Infobox_Js + "\" /></script> ");
            mapSearchBuilder.AppendLine("     <script type=\"text/javascript\" src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/custom_geoObjects.js\"></script>  ");
            mapSearchBuilder.AppendLine("     <script type=\"text/javascript\" src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/scripts/mapsearch/sobekcm_mapsearch.js\"></script> ");
            mapSearchBuilder.AppendLine("     <link rel=\"stylesheet\" href=\"" + Static_Resources_Gateway.Jquery_1_10_2_Js + "default/external_jquery_ui_1.10.4.css\"> ");
            mapSearchBuilder.AppendLine("     <link rel=\"stylesheet\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/SobekCM_MapSearch.css\"> ");

            //apply theming
            mapSearchBuilder.AppendLine("     <link rel=\"stylesheet\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "default/themes/mapsearch/custom_theme_grey.css\"> ");

            #endregion

            #region Literal

            //mapSearchBuilder.AppendLine("  ");
            //mapSearchBuilder.AppendLine("  ");
            //mapSearchBuilder.AppendLine("  ");
            //mapSearchBuilder.AppendLine(" <div id=\"container_main\"> ");
            ////mapSearchBuilder.AppendLine("     <div id=\"container_header\"> ");
            ////mapSearchBuilder.AppendLine("       <div id=\"container_header_pt1\"></div> ");
            ////mapSearchBuilder.AppendLine("         <div id=\"container_header_pt2\"></div> ");
            ////mapSearchBuilder.AppendLine("         <div id=\"container_header_pt3\"></div> ");
            ////mapSearchBuilder.AppendLine("     </div> ");
            //mapSearchBuilder.AppendLine("     <div id=\"container_body\"> ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_toolbar1\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_addSearch\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_searchControl\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"searchControl_text\">New Search</div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"searchControl_inputs\" class=\"form-wrapper cf\"> ");
            //mapSearchBuilder.AppendLine("                         <input type=\"text\" id=\"userDefinedSearch\" placeholder=\"Search for...\" /> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_searchText\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"searchText\"> ");
            //mapSearchBuilder.AppendLine("                     You searched for <div id=\"searchText_filter\">all items <a></a></div> <div id=\"searchText_filter\">something <a></a></div> <div id=\"searchText_filter\">points <a></a></div> <div id=\"searchText_filter\">stuff <a></a></div> <div id=\"searchText_filter\">this <a></a></div> <div id=\"searchText_filter\">that <a></a></div> <div id=\"searchText_filter\">something else <a></a></div> <div id=\"searchText_filter\">bacon <a></a></div> <div id=\"searchText_filter\">st augustine <a></a></div> <div id=\"searchText_filter\">wells <a></a></div> inside the \"Unearthing St. Augustine's Colonial Heritage\" collection.  ");
            //mapSearchBuilder.AppendLine("                     <!-- Here is enough text for the third line, aaahh the third line! We are not quite there yet... wait for it.. are you waiting? I thought so... --> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_addFilter\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_filterControl\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"filterControl_text\">Add Filter</div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"filterControl_inputs\" class=\"form-wrapper cf\"> ");
            //mapSearchBuilder.AppendLine("                         <input id=\"userDefinedFilter\" type=\"text\" placeholder=\"Filter for...\"> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"searchBox_in\">IN</div> ");
            //mapSearchBuilder.AppendLine("                         <select id=\"filterList\"> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Language</option>  ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Publisher</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Topic</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Geographic Area</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Genre</option> ");
            //mapSearchBuilder.AppendLine("                         </select> ");
            //mapSearchBuilder.AppendLine("                     </div>   ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("             </div>  ");
            //mapSearchBuilder.AppendLine("         </div> ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_toolbar2\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_view\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_view_buttons\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"view_geo\" class=\"view_button\"></div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"view_brief\" class=\"view_button\"></div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"view_thumb\" class=\"view_button\"></div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"view_table\" class=\"view_button\"></div> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_resultsHeader\"> ");
            //mapSearchBuilder.AppendLine("             <div class=\"center-helper\"> ");
            //mapSearchBuilder.AppendLine("             <div class=\"center-inner\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_resultsPagingLeft\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"resultsPagingLeft\"> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"firstPage\" class=\"pagingButton\"> ");
            //mapSearchBuilder.AppendLine("                             <div class=\"line-left\"></div> ");
            //mapSearchBuilder.AppendLine("                             <div class=\"arrow-left\"></div>                     ");
            //mapSearchBuilder.AppendLine("                             &nbsp;First ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"prevPage\" class=\"pagingButton\"> ");
            //mapSearchBuilder.AppendLine("                             <div class=\"arrow-left\"></div> ");
            //mapSearchBuilder.AppendLine("                             &nbsp;Previous ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                 </div>             ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_resultsCounter\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"resultsCounter\"></div> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_resultsPagingRight\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"resultsPagingRight\"> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"nextPage\" class=\"pagingButton\"> ");
            //mapSearchBuilder.AppendLine("                             Next&nbsp; ");
            //mapSearchBuilder.AppendLine("                             <div class=\"arrow-right\"></div> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"lastPage\" class=\"pagingButton\"> ");
            //mapSearchBuilder.AppendLine("                             Last&nbsp; ");
            //mapSearchBuilder.AppendLine("                             <div class=\"line-right\"></div>  ");
            //mapSearchBuilder.AppendLine("                             <div class=\"arrow-right\"></div> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                 </div>               ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_resultsSorter\"> ");
            //mapSearchBuilder.AppendLine("                 <form > ");
            //mapSearchBuilder.AppendLine("                     <select id=\"resultsSorter\" class=\"desc\"> ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By Title (Desc)</option>  ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By Title (Asc)</option>  ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By BibID (Desc)</option> ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By BibID (Asc)</option> ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By Date (Desc)</option> ");
            //mapSearchBuilder.AppendLine("                         <option class=\"opt\">Sort By Date (Asc)</option> ");
            //mapSearchBuilder.AppendLine("                     </select> ");
            //mapSearchBuilder.AppendLine("                 </form> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("         </div>                 ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_toolbox1\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_filterBox\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_filterBox_header\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"filterBox_header\">Narrow Results By:</div> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("                  ");
            //mapSearchBuilder.AppendLine("                 <!-- <div id=\"container_addFilter2\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_filterControl2\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"filterControl_text2\">Add Filter</div> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"filterControl_inputs2\" class=\"form-wrapper cf\"> ");
            //mapSearchBuilder.AppendLine("                         <input id=\"userDefinedFilter2\" type=\"text\" placeholder=\"Filter for...\"> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"filterBox_in2\">IN</div> ");
            //mapSearchBuilder.AppendLine("                         <select id=\"filterList2\"> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Language</option>  ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Publisher</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Topic</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Geographic Area</option> ");
            //mapSearchBuilder.AppendLine("                             <option class=\"filterListItem\">Genre</option> ");
            //mapSearchBuilder.AppendLine("                         </select> ");
            //mapSearchBuilder.AppendLine("                     </div>   ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("                 </div> --> ");
            //mapSearchBuilder.AppendLine("                  ");
            //mapSearchBuilder.AppendLine("                 <div id=\"filterBox\"> ");
            //mapSearchBuilder.AppendLine("                     <h3>Language</h3> ");
            //mapSearchBuilder.AppendLine("                     <div> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"sortResults\">sort A - z</div> ");
            //mapSearchBuilder.AppendLine("                         <ul> ");
            //mapSearchBuilder.AppendLine("                         <li>French <a>(503)</a></li> ");
            //mapSearchBuilder.AppendLine("                         <li>Spanish <a>(74)</a></li> ");
            //mapSearchBuilder.AppendLine("                         <li>French <a>(5)</a></li> ");
            //mapSearchBuilder.AppendLine("                         <li>Other <a>(4)</a></li> ");
            //mapSearchBuilder.AppendLine("                         </ul> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"loadmoreResults\">load more</div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                     <h3>Publisher</h3> ");
            //mapSearchBuilder.AppendLine("                     <div> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"sortResults\">sort A - z</div> ");
            //mapSearchBuilder.AppendLine("                         <ul> ");
            //mapSearchBuilder.AppendLine("                           <li>St. Augustine Restoration, Inc. <a>(1108)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>St. Augustine Historical Restoration and  Preservation Commission <a>(219)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>The St. Augustine Record <a>(80)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Planning and Building Department, City of St.  Augustine, FL <a>(41)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Ramola Drost <a>(36)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>National Archives and Records Office, United  States of America <a>(30)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>St. Augustine Historical Society <a>(27)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Historic St. Augustine Preservation Board <a>(23)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>State Photographic Archives, Strozier Library,  Florida State University <a>(14)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>National Archives <a>(12)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Florida Souvenir, Co. <a>(10)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Library of Congress <a>(9)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Florida State News Bureau <a>(8)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>George A. Smathers Libraries, University of  Florida <a>(7)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Koppel Color Cards <a>(7)</a></li> ");
            //mapSearchBuilder.AppendLine("                         </ul> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"loadmoreResults\">load more</div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                      ");
            //mapSearchBuilder.AppendLine("                     <h3>Topic</h3> ");
            //mapSearchBuilder.AppendLine("                     <div> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"sortResults\">sort A - z</div> ");
            //mapSearchBuilder.AppendLine("                         <ul> ");
            //mapSearchBuilder.AppendLine("                           <li>Saint Augustine <a>(890)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Saint Augustine, Fl <a>(88)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>46 Saint George Street <a>(73)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Arrivas House <a>(73)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>143 Saint George Street <a>(65)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Dr. Peck House <a>(65)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Pe�a-Peck House <a>(65)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Burt House <a>(64)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Ximenez-Fatio House <a>(59)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>43 Saint George Street <a>(56)</a></li> ");
            //mapSearchBuilder.AppendLine("                         </ul> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"loadmoreResults\">load more</div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                      ");
            //mapSearchBuilder.AppendLine("                     <h3>Geographic Area</h3> ");
            //mapSearchBuilder.AppendLine("                     <div> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"sortResults\">sort A - z</div> ");
            //mapSearchBuilder.AppendLine("                         <ul> ");
            //mapSearchBuilder.AppendLine("                           <li>Florida <a>(1269)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>North America <a>(1269)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>United States of America <a>(1268)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Saint Johns <a>(870)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>Saint Augustine <a>(851)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>St. Augustine <a>(399)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>St. Johns <a>(399)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>United States <a>(1)</a></li> ");
            //mapSearchBuilder.AppendLine("                         </ul> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"loadmoreResults\">load more</div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                      ");
            //mapSearchBuilder.AppendLine("                     <h3>Genre</h3> ");
            //mapSearchBuilder.AppendLine("                     <div> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"sortResults\">sort A - z</div> ");
            //mapSearchBuilder.AppendLine("                         <ul> ");
            //mapSearchBuilder.AppendLine("                           <li>newspaper <a>(63)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>plan <a>(35)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>coastal chart <a>(29)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>map <a>(23)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>plan view <a>(20)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>survey <a>(14)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>plan and profile <a>(8)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>profile <a>(7)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>manuscript <a>(2)</a></li> ");
            //mapSearchBuilder.AppendLine("                           <li>survey and profile <a>(2)</a></li> ");
            //mapSearchBuilder.AppendLine("                         </ul> ");
            //mapSearchBuilder.AppendLine("                         <div class=\"loadmoreResults\">load more</div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                      ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("         </div> ");
            //mapSearchBuilder.AppendLine("          ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_toolbar3\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_timebar\"> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"timebar_value\"></div> ");
            //mapSearchBuilder.AppendLine("                 <div id=\"timebar\"></div> ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("         </div> ");
            //mapSearchBuilder.AppendLine("          ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_mainContent\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_content1\"></div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_content2\"></div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_content3\"></div> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_map\"></div> ");
            //mapSearchBuilder.AppendLine("         </div> ");
            //mapSearchBuilder.AppendLine("                      ");
            //mapSearchBuilder.AppendLine("         <div id=\"container_toolbox2\"> ");
            //mapSearchBuilder.AppendLine("             <div id=\"container_resultsBox\"> ");
            //mapSearchBuilder.AppendLine("                  ");
            //mapSearchBuilder.AppendLine("                 <div id=\"resultsBox_header\">Search Results</div> ");
            //mapSearchBuilder.AppendLine("                  ");
            //mapSearchBuilder.AppendLine("                 <div id=\"container_toolbox2_scrollContent\"> ");
            //mapSearchBuilder.AppendLine("                     <div id=\"resultsBox\"> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"result_1\" class=\"result\"> ");
            //mapSearchBuilder.AppendLine("                             <img class=\"result_thumb\" src=\"http://hlmatt.com/uf/part2/resources/result1.jpg\"/> ");
            //mapSearchBuilder.AppendLine("                             <p class=\"result_desc\">Aritst's rendering for possible reconstruction projects along the South side of Cuna Street</p> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"result_2\" class=\"result\"> ");
            //mapSearchBuilder.AppendLine("                             <img class=\"result_thumb\" src=\"http://hlmatt.com/uf/part2/resources/result2.jpg\"/> ");
            //mapSearchBuilder.AppendLine("                             <p class=\"result_desc\">Artist rendering of possible reconstruction projects in Block 4 and Block 5, centered on the Perez Sanchez House reconstruction; Corner of Charlotte Street and Treasury Street</p> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"result_3\" class=\"result\"> ");
            //mapSearchBuilder.AppendLine("                             <img class=\"result_thumb\" src=\"http://hlmatt.com/uf/part2/resources/result3.jpg\"/> ");
            //mapSearchBuilder.AppendLine("                             <p class=\"result_desc\">Artists rending of a concept for the reconstruction of the Ribera House, including the Blanco House and Carmona House</p> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                         <div id=\"result_4\" class=\"result\"> ");
            //mapSearchBuilder.AppendLine("                             <img class=\"result_thumb\" src=\"http://hlmatt.com/uf/part2/resources/result4.jpg\"/> ");
            //mapSearchBuilder.AppendLine("                             <p class=\"result_desc\">Artist's Rendering of Block 8, from the corner of Hypolita Street and Charlotte Street, focusing on the Regidor-Clark House</p> ");
            //mapSearchBuilder.AppendLine("                         </div> ");
            //mapSearchBuilder.AppendLine("                     </div> ");
            //mapSearchBuilder.AppendLine("                 </div> ");
            //mapSearchBuilder.AppendLine("                  ");
            //mapSearchBuilder.AppendLine("             </div> ");
            //mapSearchBuilder.AppendLine("         </div> ");
            //mapSearchBuilder.AppendLine("     </div> ");
            //mapSearchBuilder.AppendLine(" </div> ");
            //mapSearchBuilder.AppendLine("  ");

            #endregion

            //end of custom content
            mapSearchBuilder.AppendLine("</td>");

            Search_Script_Reference = (mapSearchBuilder.ToString());

            #endregion
        }
        /// <summary> Write the table of contents 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)
        {
            // If there is no TOC, just return
            if ((CurrentItem == null) || (CurrentItem.Images_TOC == null) || (CurrentItem.Images_TOC.Count <= 1))
            {
                return;
            }

            string table_of_contents = "TABLE OF CONTENTS";

            //string hide_toc = "HIDE TABLE OF CONTENTS";
            //string show_toc_text = "SHOW TABLE OF CONTENTS";

            if (RequestSpecificValues.Current_Mode.Language == Web_Language_Enum.French)
            {
                table_of_contents = "TABLE DES MATIERES";
                //hide_toc = "MASQUER L'INDEX";
                //show_toc_text = "VOIR L'INDEX";
            }

            if (RequestSpecificValues.Current_Mode.Language == Web_Language_Enum.Spanish)
            {
                table_of_contents = "INDICE";
                //hide_toc = "ESCONDA INDICE";
                //show_toc_text = "MOSTRAR INDICE";
            }

            // Get the item URL
            string item_url    = RequestSpecificValues.Current_Mode.Base_URL + CurrentItem.BibID + "/" + CurrentItem.VID;
            string viewer_code = RequestSpecificValues.Current_Mode.ViewerCode.Replace(RequestSpecificValues.Current_Mode.Page.ToString(), "#");

            if (viewer_code.IndexOf("#") < 0)
            {
                viewer_code = "#";
            }

            Output.WriteLine();
            Output.WriteLine("  <script type=\"text/javascript\" src=\"" + UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Jstree_Js + "\"></script>");
            Output.WriteLine("  <div class=\"sbkIsw_ShowTocRow\">" + table_of_contents + "</div>");
            Output.WriteLine("  <div id=\"tocTree\" class=\"sbkIsw_TocTreeView\">");
            Output.WriteLine("    <ul>");

            List <BriefItem_TocElement> tocElements = CurrentItem.Images_TOC;
            int lastLevel       = -1;
            int currentLevel    = 0;
            int nextLevel       = 0;
            int currentSequence = 0;
            int nextSequence    = 0;
            int selectSequence  = Convert.ToInt32(RequestSpecificValues.Current_Mode.Page);

            //int sequence = 0;
            for (int i = 0; i < tocElements.Count; i++)
            {
                // Get this level and sequence
                currentLevel    = tocElements[i].Level.HasValue ? tocElements[i].Level.Value : 1;
                currentSequence = tocElements[i].Sequence;

                // Get the next level and sequence
                if (i + 1 < tocElements.Count)
                {
                    nextSequence = tocElements[i + 1].Sequence;
                }
                else
                {
                    nextSequence = selectSequence + 1;
                }

                // If this is not the first, then look to close any previous ones
                if (i > 0)
                {
                    if (lastLevel == currentLevel)
                    {
                        Output.WriteLine("</li>");
                    }
                    else if (lastLevel < currentLevel)
                    {
                        Output.WriteLine();
                        Output.WriteLine(indent(lastLevel) + "  <ul>");
                    }
                    else // lastLevel > currentLevel
                    {
                        Output.WriteLine("</li>");

                        while (lastLevel > currentLevel)
                        {
                            lastLevel--;

                            Output.WriteLine(indent(lastLevel) + "  </ul>");
                            Output.WriteLine(indent(lastLevel) + "</li>");
                        }
                    }
                }

                // Write this one
                if (Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.Item_Subwriter_Suppress_TOC_Links))
                {
                    Output.Write(indent(currentLevel) + "<li><abbr title=\"" + tocElements[i].Name.Replace("\"", "'") + "\">" + tocElements[i].Shortened_Name);
                }
                else
                {
                    string page_url = item_url + "/" + viewer_code.Replace("#", currentSequence.ToString());

                    Output.Write(indent(currentLevel) + "<li><a href=\"" + page_url + "\" title=\"" + tocElements[i].Name + "\" >");

                    // Is this the current location?
                    if ((selectSequence >= currentSequence) && (selectSequence < nextSequence))
                    {
                        Output.Write("<span class=\"sbkIsw_SelectedTocTreeViewItem\">" + tocElements[i].Shortened_Name + "</span>");
                    }
                    else
                    {
                        Output.Write(tocElements[i].Shortened_Name);
                    }
                    Output.Write("</a>");
                }


                lastLevel = currentLevel;
            }

            // Close this
            Output.WriteLine("</li>");
            while (lastLevel > 1)
            {
                lastLevel--;

                Output.WriteLine(indent(lastLevel) + "  </ul>");
                Output.WriteLine(indent(lastLevel) + "</li>");
            }


            Output.WriteLine("    </ul>");
            Output.WriteLine("  </div>");
            Output.WriteLine();

            Output.WriteLine("  <script type=\"text/javascript\">");
            Output.WriteLine("    $('#tocTree').jstree( {\"core\": { \"themes\":{ \"icons\":false } } }).bind(\"select_node.jstree\", function (e, data) { var href = data.node.a_attr.href; document.location.href = href; });");
            Output.WriteLine("    $('#tocTree').jstree('open_all');");
            Output.WriteLine("  </script>");
            Output.WriteLine();
        }
        /// <summary> Constructor for a new instance of the File_Management_MySobekViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public File_Management_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty);

            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure BibID and VID provided
            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid");
            if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request";
                return;
            }

            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item");
            currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
            if (currentItem == null)
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                return;
            }

            digitalResourceDirectory = currentItem.Source_Directory;

            // If the user cannot edit this currentItem, go back
            if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is post-back, handle it
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                string[] getKeys             = HttpContext.Current.Request.Form.AllKeys;
                string   file_name_from_keys = String.Empty;
                string   label_from_keys     = String.Empty;
                foreach (string thisKey in getKeys)
                {
                    if (thisKey.IndexOf("upload_file") == 0)
                    {
                        file_name_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if (thisKey.IndexOf("upload_label") == 0)
                    {
                        label_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0))
                    {
                        HttpContext.Current.Session["file_" + currentItem.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim();
                        file_name_from_keys = String.Empty;
                        label_from_keys     = String.Empty;
                    }

                    if (thisKey == "url_input")
                    {
                        currentItem.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey];
                    }
                }

                string action = HttpContext.Current.Request.Form["action"];
                if (action == "delete")
                {
                    string filename = HttpContext.Current.Request.Form["phase"];
                    try
                    {
                        if (File.Exists(digitalResourceDirectory + "\\" + filename))
                        {
                            File.Delete(digitalResourceDirectory + "\\" + filename);
                        }

                        // Special code for PDF files and their derivatives
                        if (filename.IndexOf(".pdf", StringComparison.OrdinalIgnoreCase) > 0)
                        {
                            // Delete the PDF text
                            if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt")))
                            {
                                File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt"));
                            }

                            // Delete the PDF thumbnail
                            if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg")))
                            {
                                File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg"));
                            }
                        }

                        // Forward
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                        return;
                    }
                    catch
                    {
                        // Error was caught during attempted delete
                    }
                }

                if (action == "next_phase")
                {
                    int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]);
                    switch (phase)
                    {
                    case 2:
                        // Clear all the file keys in the session state
                        List <string> keys = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList();
                        foreach (string thisKey in keys)
                        {
                            HttpContext.Current.Session.Remove(thisKey);
                        }

                        // Redirect to the currentItem
                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                        break;

                    case 9:
                        if (!complete_item_submission(currentItem, null))
                        {
                            // Clear all the file keys in the session state
                            List <string> keys2 = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList();
                            foreach (string thisKey in keys2)
                            {
                                HttpContext.Current.Session.Remove(thisKey);
                            }

                            // Remoe from the caches (to replace the other)
                            CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Also clear the engine
                            SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Redirect to the currentItem
                            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                            UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                        }
                        break;
                    }
                }
            }
        }
 /// <summary> Constructor for a new instance of the Custom_Home_Page_AggregationViewer class </summary>
 /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
 /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
 public Custom_Home_Page_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
     : base(RequestSpecificValues, ViewBag)
 {
     // All work done in base class?
 }
Exemplo n.º 59
0
        /// <summary> Write the dublin core metadata about the aggregation into the HTML head </summary>
        /// <param name="Output"> Stream to which to write within the HTML head tag </param>
        /// <param name="CurrentAggregation"> Current aggregation being displayed </param>
        /// <param name="RequestSpecificValues"> Other, request specific values, such as the current mode, user, etc.. </param>
        public void Write_Within_HTML_Head(TextWriter Output, Item_Aggregation CurrentAggregation, RequestCache RequestSpecificValues)
        {
            // If the item is NULL, do nothing
            if (CurrentAggregation == null)
            {
                return;
            }

            Output.WriteLine("  <link title=\"Dublin Core Metadata Schema\" rel=\"schema.DC\" href=\"http://purl.org/DC/elements/1.1/\" />");
            Output.WriteLine("  <meta name=\"DC.title\" content=\"" + CurrentAggregation.Name.Replace("\"", "'") + "\" />");
        }
        /// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Group_Add_Volume_MySobekViewer(RequestCache RequestSpecificValues)  : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty);

            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure BibID provided
            RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Validate provided bibid");
            if (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID))
            {
                RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "BibID was not provided!");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID missing in item group metadata edit request";
                return;
            }

            RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Try to pull this sobek complete item group");
            currentItem = SobekEngineClient.Items.Get_Sobek_Item_Group(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Tracer);
            if (currentItem == null)
            {
                RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Unable to build complete item group");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                return;
            }

            // Pull the list of items tied to this group - Get the list of other volumes
            RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Get the list of items under " + RequestSpecificValues.Current_Mode.BibID);
            try
            {
                allVolumes = SobekEngineClient.Items.Get_Multiple_Volumes(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Tracer);
            }
            catch (Exception ee)
            {
                RequestSpecificValues.Tracer.Add_Trace("Tracking_ItemViewer.Constructor", "Unable to pull volumes under " + RequestSpecificValues.Current_Mode.BibID);
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Internal Error : Unable to pull volumes under " + RequestSpecificValues.Current_Mode.BibID;
                return;
            }

            // 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 (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Determine the default CompleteTemplate code
            string template_code = "addvolume";

            if (!RequestSpecificValues.Current_User.Include_Tracking_In_Standard_Forms)
            {
                template_code = "addvolume_notracking";
            }

            // Load this CompleteTemplate
            completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer);
            if (completeTemplate != null)
            {
                RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found CompleteTemplate in cache");
            }
            else
            {
                RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading CompleteTemplate file");

                // Look in the user-defined templates portion first
                string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\" + template_code + ".xml";
                if (!File.Exists(user_template))
                {
                    user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\" + template_code + ".xml";
                }

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                completeTemplate = new CompleteTemplate();
                reader.Read_XML(user_template, completeTemplate, true);

                // Save this into the cache
                Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.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")
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }
            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
                        Tuple <SobekCM_Item, SobekCM_Item_Error> itemAndError = SobekCM_Item_Factory.Get_Item(RequestSpecificValues.Current_Mode.BibID, vid, UI_ApplicationCache_Gateway.Icon_List, RequestSpecificValues.Tracer);
                        SobekCM_Item saveItem = itemAndError.Item1;

                        // 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            = RequestSpecificValues.Current_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 CompleteTemplate changes to this item
                        completeTemplate.Save_To_Bib(saveItem, RequestSpecificValues.Current_User, 1);

                        // Save this item and copy over
                        complete_item_submission(saveItem, RequestSpecificValues.Tracer);

                        // Clear the volume list
                        CachedDataManager.Items.Remove_Items_In_Title(saveItem.BibID, RequestSpecificValues.Tracer);
                        CachedDataManager.Items.Remove_Items_List(saveItem.BibID, RequestSpecificValues.Tracer);

                        // Also clear the engine
                        SobekEngineClient.Items.Clear_Item_Group_Cache(saveItem.BibID, RequestSpecificValues.Tracer);

                        // Also clear any searches or browses ( in the future could refine this to only remove those
                        // that are impacted by this save... but this is good enough for now )
                        CachedDataManager.Clear_Search_Results_Browses();

                        // Forward differently depending on request
                        switch (hidden_request)
                        {
                        case "save_edit":
                            RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                            RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata;
                            RequestSpecificValues.Current_Mode.VID           = saveItem.VID;
                            UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                            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":
                            RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                            RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management;
                            RequestSpecificValues.Current_Mode.VID           = saveItem.VID;
                            UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                            break;

                        default:
                            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                            RequestSpecificValues.Current_Mode.VID  = saveItem.VID;
                            UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                            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>";
                    }
                }
            }
        }