/// <summary>
        /// Store_s the content of the aggregation_ HTM l_ based_.
        /// </summary>
        /// <param name="Aggregation_Code">The aggregation_ code.</param>
        /// <param name="Language">The language.</param>
        /// <param name="ChildPageCode">The child page code.</param>
        /// <param name="StoreObject">The store object.</param>
        /// <param name="Tracer">The tracer.</param>
        public void Store_Aggregation_HTML_Based_Content(string Aggregation_Code, Web_Language_Enum Language, string ChildPageCode, HTML_Based_Content StoreObject, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Entering Store_Aggregation_HTML_Based_Content method");
            }

            // If the cache is disabled, just return before even tracing
            if (settings.Disabled)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Caching is disabled");
                }
                return;
            }

            // Determine the key
            string key = "AGGR|" + Aggregation_Code.ToUpper() + "|" + Web_Language_Enum_Converter.Enum_To_Code(Language) + "|" + ChildPageCode;

            // Check the number of item aggregationPermissions currently locally cached
            const int LOCAL_EXPIRATION = 15;

            // Locally cache if this doesn't exceed the limit
            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Adding object '" + key + "' to the local cache with expiration of " + LOCAL_EXPIRATION + " minute(s)");
            }

            HttpContext.Current.Cache.Insert(key, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(LOCAL_EXPIRATION));
        }
 internal void Write_Translations(StreamWriter writer)
 {
     foreach (KeyValuePair <Web_Language_Enum, string> translation in typeTranslations)
     {
         writer.WriteLine("\t\t\t\t\t<Translation language=\"" + Web_Language_Enum_Converter.Enum_To_Code(translation.Key) + "\" text=\"" + Convert_String_To_XML_Safe(translation.Value) + "\" />");
     }
 }
Ejemplo n.º 3
0
 internal void Write_In_Configuration_XML_File(StreamWriter Writer)
 {
     Writer.WriteLine("    <hi:highlight>");
     Writer.WriteLine("      <hi:source>" + Image + "</hi:source>");
     if (Link.Length > 0)
     {
         Writer.WriteLine("      <hi:link>" + Link + "</hi:link>");
     }
     foreach (KeyValuePair <Web_Language_Enum, string> thisTooltip in tooltips)
     {
         if (thisTooltip.Key == Web_Language_Enum.UNDEFINED)
         {
             Writer.WriteLine("      <hi:tooltip>" + thisTooltip.Value + "</hi:tooltip>");
         }
         else
         {
             Writer.WriteLine("      <hi:tooltip lang=\"" + Web_Language_Enum_Converter.Enum_To_Code(thisTooltip.Key) + "\">" + thisTooltip.Value + "</hi:tooltip>");
         }
     }
     foreach (KeyValuePair <Web_Language_Enum, string> thisText in text)
     {
         if (thisText.Key == Web_Language_Enum.UNDEFINED)
         {
             Writer.WriteLine("      <hi:text>" + thisText.Value + "</hi:text>");
         }
         else
         {
             Writer.WriteLine("      <hi:text lang=\"" + Web_Language_Enum_Converter.Enum_To_Code(thisText.Key) + "\">" + thisText.Value + "</hi:text>");
         }
     }
     Writer.WriteLine("    </hi:highlight>");
 }
Ejemplo n.º 4
0
        /// <summary> Get the language-specific web skin, by skin code and language </summary>
        /// <param name="SkinCode"> Code for the web skin </param>
        /// <param name="RequestedLanguage"> Requested language for the web skin code </param>
        /// <param name="DefaultLanguage"> Default UI language for the instance </param>
        /// <param name="Cache_On_Build"> Flag indicates whether to use the cache </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Language-specific web skin object </returns>
        public Web_Skin_Object Get_LanguageSpecific_Web_Skin(string SkinCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, bool Cache_On_Build, Custom_Tracer Tracer)
        {
            // If no interface yet, look in the cache
            if ((SkinCode != "new") && (Cache_On_Build))
            {
                Web_Skin_Object htmlSkin = CachedDataManager.WebSkins.Retrieve_Skin(SkinCode, Web_Language_Enum_Converter.Enum_To_Code(RequestedLanguage), Tracer);
                if (htmlSkin != null)
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("SobekEngineClient_WebSkinEndpoints.Get_LanguageSpecific_Web_Skin", "Web skin '" + SkinCode + "' found in cache");
                    }
                    return(htmlSkin);
                }
            }

            // If still not interface, build one
            Web_Skin_Object new_skin = WebSkinServices.get_web_skin(SkinCode, RequestedLanguage, DefaultLanguage, Tracer);

            // Look in the web skin row and see if it should be kept around, rather than momentarily cached
            if ((new_skin != null) && (String.IsNullOrEmpty(new_skin.Exception)))
            {
                if (Cache_On_Build)
                {
                    // Momentarily cache this web skin object
                    CachedDataManager.WebSkins.Store_Skin(SkinCode, Web_Language_Enum_Converter.Enum_To_Code(RequestedLanguage), new_skin, Tracer);
                }
            }

            return(new_skin);
        }
        private static void read_banners(XmlNodeReader nodeReader, Item_Aggregation hierarchyObject)
        {
            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        // Check for any attributes to this banner node
                        string lang    = String.Empty;
                        bool   special = false;

                        if (nodeReader.HasAttributes)
                        {
                            if (nodeReader.MoveToAttribute("lang"))
                            {
                                lang = nodeReader.Value.Trim().ToUpper();
                            }
                            if (nodeReader.MoveToAttribute("type"))
                            {
                                if (nodeReader.Value.Trim().ToUpper() == "HIGHLIGHT")
                                {
                                    special = true;
                                }
                            }
                        }

                        // Now read the banner information and add to the aggregation object
                        nodeReader.Read();
                        if (special)
                        {
                            hierarchyObject.Add_Front_Banner_Image(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                        }
                        else
                        {
                            hierarchyObject.Add_Banner_Image(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                        }


                        break;
                    }
                }

                if ((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeReader.Name.Trim().ToUpper() == "HI:BANNER"))
                {
                    return;
                }
            }
        }
        /// <summary> Constructor for a new instance of the simple aggregation class </summary>
        /// <param name="FullAggregation"> Full (language-specific) aggregation object </param>
        public Simple_Aggregation(Item_Aggregation FullAggregation)
        {
            // Assign the simple properties
            Language        = Web_Language_Enum_Converter.Enum_To_Code(FullAggregation.Language);
            ID              = FullAggregation.ID;
            Code            = FullAggregation.Code;
            Name            = FullAggregation.Name;
            BannerImage     = FullAggregation.BannerImage;
            Last_Item_Added = FullAggregation.Last_Item_Added;

            // Assign search fields
            if ((FullAggregation.Search_Fields != null) && (FullAggregation.Search_Fields.Count > 0))
            {
                Search_Fields = new List <Item_Aggregation_Metadata_Type>();
                foreach (Item_Aggregation_Metadata_Type searchField in FullAggregation.Search_Fields)
                {
                    Search_Fields.Add(new Item_Aggregation_Metadata_Type(searchField.DisplayTerm, searchField.SobekCode));
                }
            }

            // Assign browseable fields
            if ((FullAggregation.Browseable_Fields != null) && (FullAggregation.Browseable_Fields.Count > 0))
            {
                Browseable_Fields = new List <Item_Aggregation_Metadata_Type>();
                foreach (Item_Aggregation_Metadata_Type searchField in FullAggregation.Browseable_Fields)
                {
                    Browseable_Fields.Add(new Item_Aggregation_Metadata_Type(searchField.DisplayTerm, searchField.SobekCode));
                }
            }

            // Assign searches and views
            if ((FullAggregation.Views_And_Searches != null) && (FullAggregation.Views_And_Searches.Count > 0))
            {
                Views_And_Searches = new List <string>();
                foreach (Item_Aggregation_Views_Searches_Enum viewEnum in FullAggregation.Views_And_Searches)
                {
                    Views_And_Searches.Add(viewEnum.ToString("G"));
                }
            }

            // Assign the name and code of each child page
            if ((FullAggregation.Child_Pages != null) && (FullAggregation.Child_Pages.Count > 0))
            {
                Child_Pages = new List <Simple_Aggregation_Child_Page>();
                foreach (Item_Aggregation_Child_Page thisChild in FullAggregation.Child_Pages)
                {
                    Child_Pages.Add(new Simple_Aggregation_Child_Page(thisChild.Code, thisChild.Label));
                }
            }
        }
Ejemplo n.º 7
0
        protected void Write_Lang_Code()
        {
            // If the was a very basic error, or the request was complete, do nothing here
            if ((pageGlobals.currentMode == null) || (pageGlobals.currentMode.Request_Completed))
            {
                return;
            }

            if (pageGlobals.currentMode.Language == Web_Language_Enum.DEFAULT)
            {
                Response.Output.Write(Web_Language_Enum_Converter.Enum_To_Code(UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language));
            }
            else
            {
                Response.Output.Write(Web_Language_Enum_Converter.Enum_To_Code(pageGlobals.currentMode.Language));
            }
        }
        private static void read_home(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:BODY":
                        Web_Language_Enum langEnum = Web_Language_Enum.DEFAULT;
                        bool isCustom = false;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            string bodyLanguage = NodeReader.GetAttribute("lang");
                            langEnum = Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage);
                        }
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("isCustom")))
                        {
                            string attribute = NodeReader.GetAttribute("isCustom");
                            if (attribute != null && attribute.ToLower() == "true")
                            {
                                isCustom = true;
                            }
                        }

                        NodeReader.Read();
                        HierarchyObject.Add_Home_Page_File(NodeReader.Value, langEnum, isCustom);
                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME"))
                {
                    return;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary> [HELPER] Gets the language-specific web skin, by web skin code and language code </summary>
        /// <param name="SkinCode"> Web skin code </param>
        /// <param name="RequestedLanguage"> Web language </param>
        /// <param name="DefaultLanguage"> Default language, in case the requested web language does nto exist </param>
        /// <param name="Tracer"></param>
        /// <returns> A build language-specific web skin </returns>
        /// <remarks> This may be public now, but this will be converted into a protected helped class with
        /// the release of SobekCM 5.0 </remarks>
        public static Web_Skin_Object get_web_skin(string SkinCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, Custom_Tracer Tracer)
        {
            Complete_Web_Skin_Object completeSkin = get_complete_web_skin(SkinCode, Tracer);

            if (completeSkin == null)
            {
                Tracer.Add_Trace("WebSkinServices.get_web_skin", "Complete skin retrieved was NULL, so returning NULL");
                return(null);
            }

            // Look in the cache for this first
            Web_Skin_Object cacheObject = CachedDataManager.WebSkins.Retrieve_Skin(SkinCode, Web_Language_Enum_Converter.Enum_To_Code(RequestedLanguage), Tracer);

            if (cacheObject != null)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("WebSkinServices.get_web_skin", "Web skin found in the memory cache");
                }
                return(cacheObject);
            }

            // Try to get this language-specifi web skin
            Web_Skin_Object returnValue = Web_Skin_Utilities.Build_Skin(completeSkin, Web_Language_Enum_Converter.Enum_To_Code(RequestedLanguage), Tracer);

            // If this web skin has a value (an no exception) store in the cache
            if ((returnValue != null) && (String.IsNullOrEmpty(returnValue.Exception)))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("WebSkinServices.get_web_skin", "Store the web skin in the memory cache");
                }
                CachedDataManager.WebSkins.Store_Skin(SkinCode, Web_Language_Enum_Converter.Enum_To_Code(RequestedLanguage), returnValue, Tracer);
            }

            // Return the object
            return(returnValue);
        }
        /// <summary> Gets the item aggregation and search fields for the current item aggregation </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <param name="Aggregation_Object"> [OUT] Fully-built object for the current aggregation object </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This attempts to pull the objects from the cache.  If unsuccessful, it builds the objects from the
        /// database and hands off to the <see cref="CachedDataManager" /> to store in the cache. </remarks>
        protected static bool Get_Top_Level_Collection(Navigation_Object Current_Mode, Custom_Tracer Tracer, out Item_Aggregation Aggregation_Object)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("abstractHtmlSubwriter.Get_Top_Level_Collection", String.Empty);
            }

            string languageCode = Web_Language_Enum_Converter.Enum_To_Code(Current_Mode.Language);

            // Get the ALL collection group
            try
            {
                // Try to pull this from the cache
                Aggregation_Object = CachedDataManager.Aggregations.Retrieve_Item_Aggregation("all", Web_Language_Enum_Converter.Code_To_Enum(languageCode), Tracer);
                if (Aggregation_Object != null)
                {
                    return(true);
                }

                // Get the item aggregation from the Sobek Engine Client
                Aggregation_Object = SobekEngineClient.Aggregations.Get_Aggregation("all", Web_Language_Enum_Converter.Code_To_Enum(languageCode), UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language, Tracer);
            }
            catch (Exception ee)
            {
                Aggregation_Object         = null;
                Current_Mode.Error_Message = "Error pulling the item aggregation corresponding to all collection groups : " + ee.Message;
                return(false);
            }

            // If this is null, just stop
            if (Aggregation_Object == null)
            {
                Current_Mode.Error_Message = "Unable to pull the item aggregation corresponding to all collection groups";
                return(false);
            }

            return(true);
        }
        /// <summary> Retrieves the item aggregation obejct from the cache  </summary>
        /// <param name="AggregationCode"> Code for the item aggregation to retrieve </param>
        /// <param name="Language"> Current language code (item aggregation instances are currently language-specific)</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Either NULL or the item aggregation object </returns>
        public Item_Aggregation Retrieve_Item_Aggregation(string AggregationCode, Web_Language_Enum Language, Custom_Tracer Tracer)
        {
            // If the cache is disabled, just return before even tracing
            if ((settings.Disabled) || (HttpContext.Current == null))
            {
                return(null);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager.Retrieve_Item_Aggregation", "");
            }

            // Determine the key
            string languageCode = Web_Language_Enum_Converter.Enum_To_Code(Language);
            string key          = "AGGR|" + AggregationCode.ToUpper() + "|" + languageCode;

            // See if this is in the local cache first
            Item_Aggregation returnValue = HttpContext.Current.Cache.Get(key) as Item_Aggregation;

            if (returnValue != null)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("CachedDataManager.Retrieve_Item_Aggregation", "Found " + AggregationCode + " item aggregation on local cache for " + languageCode);
                }

                return(returnValue);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager.Retrieve_Item_Aggregation", "Aggregation ( " + AggregationCode + " ) not found in the local cache for " + languageCode);
            }

            // Since everything failed, just return null
            return(null);
        }
        /// <summary> Retrieve the aggregation-level static HTML browse object, including the text itself, from the cache </summary>
        /// <param name="Aggregation_Code"> Aggregation code </param>
        /// <param name="Language"> Requested language version </param>
        /// <param name="ChildPageCode"> Code for the child page in question </param>
        /// <param name="Tracer">The tracer.</param>
        /// <returns> Fully built object with the information about the aggregation-level HTML browse object </returns>
        public HTML_Based_Content Retrieve_Aggregation_HTML_Based_Content(string Aggregation_Code, Web_Language_Enum Language, string ChildPageCode, Custom_Tracer Tracer)
        {
            // If the cache is disabled, just return before even tracing
            if (settings.Disabled)
            {
                return(null);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", "");
            }

            // Determine the key
            string key = "AGGR|" + Aggregation_Code.ToUpper() + "|" + Web_Language_Enum_Converter.Enum_To_Code(Language) + "|" + ChildPageCode;

            // See if this is in the local cache first
            HTML_Based_Content returnValue = HttpContext.Current.Cache.Get(key) as HTML_Based_Content;

            if (returnValue != null)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", "Found aggregation HTML based content on local cache");
                }

                return(returnValue);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", "Aggregation HTML based content not found in either the local cache");
            }

            // Since everything failed, just return null
            return(null);
        }
Ejemplo n.º 13
0
        private static void read_home(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:BODY":
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            string bodyLanguage = NodeReader.GetAttribute("lang");
                            NodeReader.Read();
                            HierarchyObject.Add_Home_Page_File(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        }
                        else
                        {
                            NodeReader.Read();
                            HierarchyObject.Add_Home_Page_File(NodeReader.Value, Web_Language_Enum.DEFAULT);
                        }

                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME"))
                {
                    return;
                }
            }
        }
        /// <summary> Stores the item aggregation object to the cache  </summary>
        /// <param name="AggregationCode"> Code for the item aggregation to store </param>
        /// <param name="Language"> Current language code (item aggregation instances are currently language-specific)</param>
        /// <param name="StoreObject"> Item aggregation object to store for later retrieval </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        public void Store_Item_Aggregation(string AggregationCode, Web_Language_Enum Language, Item_Aggregation StoreObject, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager.Store_Item_Aggregation", "Entering Store_Item_Aggregation method");
            }

            // Don't store nulls
            if (StoreObject == null)
            {
                return;
            }

            // If the cache is disabled, just return before even tracing
            if (settings.Disabled)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("CachedDataManager.Store_Item_Aggregation", "Caching is disabled");
                }
                return;
            }

            // Determine the key
            string key = "AGGR|" + AggregationCode.ToUpper() + "|" + Web_Language_Enum_Converter.Enum_To_Code(Language);

            const int LOCAL_EXPIRATION = 15;

            // Locally cache if this doesn't exceed the limit
            if (Tracer != null)
            {
                Tracer.Add_Trace("CachedDataManager.Store_Item_Aggregation", "Adding object '" + key + "' to the local cache with expiration of " + LOCAL_EXPIRATION + " minute(s)");
            }

            HttpContext.Current.Cache.Insert(key, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(LOCAL_EXPIRATION));
        }
        /// <summary> Gets the item aggregation and search fields for the current item aggregation </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <param name="Aggregation_Object"> [OUT] Fully-built object for the current aggregation object </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This attempts to pull the objects from the cache.  If unsuccessful, it builds the objects from the
        /// database and hands off to the <see cref="CachedDataManager" /> to store in the cache. </remarks>
        protected static bool Get_Collection(Navigation_Object Current_Mode, Custom_Tracer Tracer, out Item_Aggregation Aggregation_Object)
        {
            string languageCode = Web_Language_Enum_Converter.Enum_To_Code(Current_Mode.Language);

            if (Tracer != null)
            {
                Tracer.Add_Trace("abstractHtmlSubwriter.Get_Collection", "Get aggregation (" + Current_Mode.Aggregation + ") or (" + Current_Mode.Default_Aggregation + ") for language (" + languageCode + ")");
            }

            // If there is an aggregation listed, try to get that now
            if ((Current_Mode.Aggregation.Length > 0) && (Current_Mode.Aggregation != "all"))
            {
                // Try to pull the aggregation information
                Aggregation_Object = CachedDataManager.Aggregations.Retrieve_Item_Aggregation(Current_Mode.Aggregation, Web_Language_Enum_Converter.Code_To_Enum(languageCode), Tracer);
                if (Aggregation_Object != null)
                {
                    set_web_skin_from_aggregation(Current_Mode, Aggregation_Object);
                    return(true);
                }

                // Get the item aggregation from the Sobek Engine Client (which checks the local cache as well)
                Aggregation_Object = SobekEngineClient.Aggregations.Get_Aggregation(Current_Mode.Aggregation, Web_Language_Enum_Converter.Code_To_Enum(languageCode), UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language, Tracer);

                // Return if this was valid
                if (Aggregation_Object != null)
                {
                    set_web_skin_from_aggregation(Current_Mode, Aggregation_Object);
                    return(true);
                }

                Current_Mode.Error_Message = "Invalid item aggregation '" + Current_Mode.Aggregation + "' referenced.";
                return(false);
            }

            return(Get_Top_Level_Collection(Current_Mode, Tracer, out Aggregation_Object));
        }
Ejemplo n.º 16
0
        /// <summary> Constructor for a new instance of the Static_Browse_Info_AggregationViewer class </summary>
        /// <param name="Browse_Object"> Browse or information object to be displayed </param>
        /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects.  These are objects which are read from a static HTML file and much of the head information must be maintained </param>
        /// <param name="Current_Collection"> Current collection being displayed</param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_User"> Current user/session information </param>
        public Static_Browse_Info_AggregationViewer(Item_Aggregation_Child_Page Browse_Object, HTML_Based_Content Static_Web_Content, Item_Aggregation Current_Collection, SobekCM_Navigation_Object Current_Mode, User_Object Current_User) : base(Current_Collection, Current_Mode)
        {
            browseObject     = Browse_Object;
            staticWebContent = Static_Web_Content;
            currentUser      = Current_User;

            bool isAdmin = (currentUser != null) && (currentUser.Is_Aggregation_Admin(currentCollection.Code));

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (!isAdmin))
            {
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            }

            NameValueCollection form = HttpContext.Current.Request.Form;

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (form["sbkSbia_ChildTextEdit"] != null) && (currentUser != null))
            {
                string aggregation_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + currentCollection.Code + "\\";
                string file = aggregation_folder + browseObject.Get_Static_HTML_Source(currentMode.Language);

                // Get the header information as well
                if (!String.IsNullOrEmpty(form["admin_childpage_title"]))
                {
                    staticWebContent.Title = form["admin_childpage_title"];
                }
                if (form["admin_childpage_author"] != null)
                {
                    staticWebContent.Author = form["admin_childpage_author"];
                }
                if (form["admin_childpage_date"] != null)
                {
                    staticWebContent.Date = form["admin_childpage_date"];
                }
                if (form["admin_childpage_description"] != null)
                {
                    staticWebContent.Description = form["admin_childpage_description"];
                }
                if (form["admin_childpage_keywords"] != null)
                {
                    staticWebContent.Keywords = form["admin_childpage_keywords"];
                }
                if (form["admin_childpage_extrahead"] != null)
                {
                    staticWebContent.Extra_Head_Info = form["admin_childpage_extrahead"];
                }


                // Make a backup from today, if none made yet
                if (File.Exists(file))
                {
                    DateTime lastWrite = (new FileInfo(file)).LastWriteTime;
                    string   new_file  = file.ToLower().Replace(".txt", "").Replace(".html", "").Replace(".htm", "") + lastWrite.Year + lastWrite.Month.ToString().PadLeft(2, '0') + lastWrite.Day.ToString().PadLeft(2, '0') + ".bak";
                    if (File.Exists(new_file))
                    {
                        File.Delete(new_file);
                    }
                    File.Move(file, new_file);
                }


                // Assign the new text
                Static_Web_Content.Static_Text = form["sbkSbia_ChildTextEdit"];
                Static_Web_Content.Date        = DateTime.Now.ToLongDateString();
                Static_Web_Content.Save_To_File(file);

                // Also save this change
                SobekCM_Database.Save_Item_Aggregation_Milestone(currentCollection.Code, "Child page '" + browseObject.Code + "' edited (" + Web_Language_Enum_Converter.Enum_To_Name(currentMode.Language) + ")", currentUser.Full_Name);

                // Forward along
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                if (Browse_Object.Browse_Type == Item_Aggregation_Child_Page.Visibility_Type.METADATA_BROWSE_BY)
                {
                    currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_By;
                }

                string redirect_url = currentMode.Redirect_URL();
                if (redirect_url.IndexOf("?") > 0)
                {
                    redirect_url = redirect_url + "&refresh=always";
                }
                else
                {
                    redirect_url = redirect_url + "?refresh=always";
                }
                currentMode.Request_Completed = true;
                HttpContext.Current.Response.Redirect(redirect_url, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        /// <summary> Builds the complete web skin object </summary>
        /// <param name="Skin_Row"> Row for this web skin, from the database query </param>
        /// <param name="Tracer"></param>
        /// <returns> Complete web skin </returns>
        public static Complete_Web_Skin_Object Build_Skin_Complete(DataRow Skin_Row, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Building the complete web skin from the row and design files");
            }

            // Pull values out from this row
            string code            = Skin_Row["WebSkinCode"].ToString();
            string base_interface  = Skin_Row["BaseInterface"].ToString();
            bool   override_banner = Convert.ToBoolean(Skin_Row["OverrideBanner"]);
            string banner_link     = Skin_Row["BannerLink"].ToString();
            string notes           = Skin_Row["Notes"].ToString();
            string this_style      = code + ".css";
            string this_javascript = code + ".js";

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Verifying existence of the CSS file");
            }

            string style_file = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", code, this_style);

            if (!File.Exists(style_file))
            {
                this_style = String.Empty;
            }

            string javascript_file = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", code, this_javascript);

            if (!File.Exists(javascript_file))
            {
                this_javascript = String.Empty;
            }

            // Create the web skin object
            Complete_Web_Skin_Object completeSkin = new Complete_Web_Skin_Object(code, this_style)
            {
                Override_Banner         = override_banner,
                Suppress_Top_Navigation = Convert.ToBoolean(Skin_Row["SuppressTopNavigation"]),
                Notes           = notes,
                Javascript_File = this_javascript
            };

            // Assign the optional values
            if (!String.IsNullOrEmpty(base_interface))
            {
                completeSkin.Base_Skin_Code = base_interface;
            }
            if (!String.IsNullOrEmpty(banner_link))
            {
                completeSkin.Banner_Link = banner_link;
            }

            // Look for source files
            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Look for all the source files in the design folder");
            }

            string html_soure_directory = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", code, "html");

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Design folder = " + html_soure_directory);
            }

            try
            {
                if (Directory.Exists(html_soure_directory))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Building the dictionary of language-specific headers and footers");
                    }

                    string[] possible_header_files = Directory.GetFiles(html_soure_directory, "*.htm*");
                    foreach (string thisHeaderFile in possible_header_files)
                    {
                        // Get the filename
                        string fileName = Path.GetFileName(thisHeaderFile);

                        // Should not ever really be null, but if so. just skip it
                        if (String.IsNullOrEmpty(fileName))
                        {
                            continue;
                        }

                        // Was this an item header file?
                        if (fileName.IndexOf("header_item", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            // If this is default (with no language specified) add as DEFAULT
                            if (fileName.ToLower().Contains("header_item.htm"))
                            {
                                if (completeSkin.SourceFiles.ContainsKey(Web_Language_Enum.DEFAULT))
                                {
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT].Header_Item_Source_File = Path.Combine("html", fileName);
                                }
                                else
                                {
                                    Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                        Header_Item_Source_File = Path.Combine("html", fileName)
                                    };
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT] = sourceFiles;
                                }
                            }
                            else
                            {
                                // Look for and parse the language code in the file
                                string[] parsed = fileName.Split("_-.".ToCharArray());
                                if (parsed.Length == 4)
                                {
                                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(parsed[2]);
                                    if (languageEnum != Web_Language_Enum.UNDEFINED)
                                    {
                                        if (completeSkin.SourceFiles.ContainsKey(languageEnum))
                                        {
                                            completeSkin.SourceFiles[languageEnum].Header_Item_Source_File = Path.Combine("html", fileName);
                                        }
                                        else
                                        {
                                            Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                                Header_Item_Source_File = Path.Combine("html", fileName)
                                            };
                                            completeSkin.SourceFiles[languageEnum] = sourceFiles;
                                        }
                                    }
                                }
                            }
                        }
                        // Was this a non-item header file?
                        else if (fileName.IndexOf("header", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            // If this is default (with no language specified) add as DEFAULT
                            if (fileName.ToLower().Contains("header.htm"))
                            {
                                if (completeSkin.SourceFiles.ContainsKey(Web_Language_Enum.DEFAULT))
                                {
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT].Header_Source_File = Path.Combine("html", fileName);
                                }
                                else
                                {
                                    Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                        Header_Source_File = Path.Combine("html", fileName)
                                    };
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT] = sourceFiles;
                                }
                            }
                            else
                            {
                                // Look for and parse the language code in the file
                                string[] parsed = fileName.Split("_-.".ToCharArray());
                                if (parsed.Length == 3)
                                {
                                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(parsed[1]);
                                    if (languageEnum != Web_Language_Enum.UNDEFINED)
                                    {
                                        if (completeSkin.SourceFiles.ContainsKey(languageEnum))
                                        {
                                            completeSkin.SourceFiles[languageEnum].Header_Source_File = Path.Combine("html", fileName);
                                        }
                                        else
                                        {
                                            Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                                Header_Source_File = Path.Combine("html", fileName)
                                            };
                                            completeSkin.SourceFiles[languageEnum] = sourceFiles;
                                        }
                                    }
                                }
                            }
                        }
                        // Was this a item footer file?
                        else if (fileName.IndexOf("footer_item", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            // If this is default (with no language specified) add as DEFAULT
                            if (fileName.ToLower().Contains("footer_item.htm"))
                            {
                                if (completeSkin.SourceFiles.ContainsKey(Web_Language_Enum.DEFAULT))
                                {
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT].Footer_Item_Source_File = Path.Combine("html", fileName);
                                }
                                else
                                {
                                    Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                        Footer_Item_Source_File = Path.Combine("html", fileName)
                                    };
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT] = sourceFiles;
                                }
                            }
                            else
                            {
                                // Look for and parse the language code in the file
                                string[] parsed = fileName.Split("_-.".ToCharArray());
                                if (parsed.Length == 4)
                                {
                                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(parsed[2]);
                                    if (languageEnum != Web_Language_Enum.UNDEFINED)
                                    {
                                        if (completeSkin.SourceFiles.ContainsKey(languageEnum))
                                        {
                                            completeSkin.SourceFiles[languageEnum].Footer_Item_Source_File = Path.Combine("html", fileName);
                                        }
                                        else
                                        {
                                            Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                                Footer_Item_Source_File = Path.Combine("html", fileName)
                                            };
                                            completeSkin.SourceFiles[languageEnum] = sourceFiles;
                                        }
                                    }
                                }
                            }
                        }
                        // Was this a non-item footer file?
                        else if (fileName.IndexOf("footer", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            // If this is default (with no language specified) add as DEFAULT
                            if (fileName.ToLower().Contains("footer.htm"))
                            {
                                if (completeSkin.SourceFiles.ContainsKey(Web_Language_Enum.DEFAULT))
                                {
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT].Footer_Item_Source_File = Path.Combine("html", fileName);
                                }
                                else
                                {
                                    Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                        Footer_Source_File = Path.Combine("html", fileName)
                                    };
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT] = sourceFiles;
                                }
                            }
                            else
                            {
                                // Look for and parse the language code in the file
                                string[] parsed = fileName.Split("_-.".ToCharArray());
                                if (parsed.Length == 3)
                                {
                                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(parsed[1]);
                                    if (languageEnum != Web_Language_Enum.UNDEFINED)
                                    {
                                        if (completeSkin.SourceFiles.ContainsKey(languageEnum))
                                        {
                                            completeSkin.SourceFiles[languageEnum].Footer_Source_File = Path.Combine("html", fileName);
                                        }
                                        else
                                        {
                                            Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                                Footer_Source_File = Path.Combine("html", fileName)
                                            };
                                            completeSkin.SourceFiles[languageEnum] = sourceFiles;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Unable to find the design folder ( '" + html_soure_directory + "')");
                    }
                    completeSkin.Exception = "Unable to find the design folder ( '" + html_soure_directory + "')";
                }
            }
            catch (Exception ee)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Exception encountered while checking for web skin source files: " + ee.Message);
                }
                completeSkin.Exception = "Exception encountered while checking for web skin source files: " + ee.Message;
            }


            // Look for banners as well
            if (override_banner)
            {
                try
                {
                    string banner_source_directory = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", code);
                    if (Directory.Exists(banner_source_directory))
                    {
                        string[] possible_banner_files = Directory.GetFiles(banner_source_directory, "banner*.*");
                        foreach (string thisBannerFile in possible_banner_files)
                        {
                            // Get the filename
                            string fileName = Path.GetFileName(thisBannerFile);

                            // If this is default (with no language specified) add as DEFAULT
                            if (fileName.ToLower().Contains("banner."))
                            {
                                if (completeSkin.SourceFiles.ContainsKey(Web_Language_Enum.DEFAULT))
                                {
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT].Banner = fileName;
                                }
                                else
                                {
                                    Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                        Banner = fileName
                                    };
                                    completeSkin.SourceFiles[Web_Language_Enum.DEFAULT] = sourceFiles;
                                }
                            }
                            else
                            {
                                // Look for and parse the language code in the file
                                string[] parsed = fileName.Split("_-.".ToCharArray());
                                if (parsed.Length == 3)
                                {
                                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(parsed[1]);
                                    if (languageEnum != Web_Language_Enum.UNDEFINED)
                                    {
                                        if (completeSkin.SourceFiles.ContainsKey(languageEnum))
                                        {
                                            completeSkin.SourceFiles[languageEnum].Banner = fileName;
                                        }
                                        else
                                        {
                                            Complete_Web_Skin_Source_Files sourceFiles = new Complete_Web_Skin_Source_Files {
                                                Banner = fileName
                                            };
                                            completeSkin.SourceFiles[languageEnum] = sourceFiles;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Exception encountered while checking for web skin banner: " + ee.Message);
                    }
                    completeSkin.Exception = "Exception encountered while checking for web skin banner: " + ee.Message;
                }
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin_Complete", "Return the built complete web skin");
            }

            return(completeSkin);
        }
        /// <summary> Builds a language-specific <see cref="Web_Skin_Object"/> when needed by a user's request </summary>
        /// <param name="CompleteSkin"> Complete web skin object </param>
        /// <param name="Language_Code"> Code for the language, which determines which HTML to use </param>
        /// <param name="Tracer"></param>
        /// <returns> Completely built HTML interface object </returns>
        /// <remarks> The datarow for this method is retrieved from the database by calling the <see cref="Database.Engine_Database.Get_All_Web_Skins"/> method during
        /// application startup and is then stored in the <see cref="Web_Skin_Collection"/> class until needed. </remarks>
        public static Web_Skin_Object Build_Skin(Complete_Web_Skin_Object CompleteSkin, string Language_Code, Custom_Tracer Tracer)
        {
            // Look for the language
            Web_Language_Enum language          = Web_Language_Enum_Converter.Code_To_Enum(Language_Code);
            Web_Language_Enum original_language = language;

            if (!CompleteSkin.SourceFiles.ContainsKey(language))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Language requested ( " + Web_Language_Enum_Converter.Enum_To_Name(language) + " ) not in language list");
                }

                language = Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language;
                if ((original_language == language) || (!CompleteSkin.SourceFiles.ContainsKey(language)))
                {
                    if ((Tracer != null) && (original_language != language))
                    {
                        Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Default UI language ( " + Web_Language_Enum_Converter.Enum_To_Name(language) + " ) not in language list");
                    }

                    language = Web_Language_Enum.DEFAULT;
                    if (!CompleteSkin.SourceFiles.ContainsKey(language))
                    {
                        if (Tracer != null)
                        {
                            Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "DEFAULT language not in language list");
                        }

                        language = Web_Language_Enum.English;

                        if (!CompleteSkin.SourceFiles.ContainsKey(language))
                        {
                            if (Tracer != null)
                            {
                                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "English language also not in language list");
                            }

                            if (CompleteSkin.SourceFiles.Count > 0)
                            {
                                language = CompleteSkin.SourceFiles.Keys.First();
                            }
                            else
                            {
                                if (Tracer != null)
                                {
                                    Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Apparently there are NO source files.. returning NULL");
                                }
                                language = Web_Language_Enum.UNDEFINED;
                            }
                        }
                    }
                }
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Will build language-specific web skin for '" + Web_Language_Enum_Converter.Enum_To_Name(language) + "'");
            }

            // Now, look in the cache for this
            if (language != Web_Language_Enum.UNDEFINED)
            {
                Web_Skin_Object cacheObject = CachedDataManager.WebSkins.Retrieve_Skin(CompleteSkin.Skin_Code, Web_Language_Enum_Converter.Enum_To_Code(language), null);
                if (cacheObject != null)
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Web skin found in the memory cache");
                    }

                    return(cacheObject);
                }
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Web skin not found in the memory cache, so building it now");
            }

            // Build this then
            Web_Skin_Object returnValue = new Web_Skin_Object(CompleteSkin.Skin_Code, CompleteSkin.Base_Skin_Code);

            if (!String.IsNullOrEmpty(CompleteSkin.CSS_Style))
            {
                returnValue.CSS_Style = "design/skins/" + CompleteSkin.Skin_Code + "/" + CompleteSkin.CSS_Style;
            }
            if (!String.IsNullOrEmpty(CompleteSkin.Javascript_File))
            {
                returnValue.Javascript = "design/skins/" + CompleteSkin.Skin_Code + "/" + CompleteSkin.Javascript_File;
            }

            // Set the language code
            if (language == Web_Language_Enum.DEFAULT)
            {
                returnValue.Language_Code = Web_Language_Enum_Converter.Enum_To_Code(Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language);
            }
            else if (language == Web_Language_Enum.UNDEFINED)
            {
                returnValue.Language_Code = Web_Language_Enum_Converter.Enum_To_Code(language);
            }

            // Set some optional (nullable) flags
            if (CompleteSkin.Override_Banner)
            {
                returnValue.Override_Banner = true;
            }
            if (CompleteSkin.Suppress_Top_Navigation)
            {
                returnValue.Suppress_Top_Navigation = true;
            }

            // If no suitable language was found, probably an error (no source files at all)
            if (language == Web_Language_Enum.UNDEFINED)
            {
                if (!String.IsNullOrEmpty(CompleteSkin.Exception))
                {
                    returnValue.Exception = CompleteSkin.Exception;
                }
                else
                {
                    returnValue.Exception = "No valid source files found";
                }

                // Also set the headers and footers to the exception
                returnValue.Header_HTML      = returnValue.Exception;
                returnValue.Footer_HTML      = returnValue.Exception;
                returnValue.Header_Item_HTML = returnValue.Exception;
                returnValue.Footer_Item_HTML = returnValue.Exception;

                return(returnValue);
            }

            // Get the source file
            Complete_Web_Skin_Source_Files sourceFiles = CompleteSkin.SourceFiles[language];

            // Build the banner
            if ((returnValue.Override_Banner.HasValue) && (returnValue.Override_Banner.Value))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Skin overrides the banner, so build the banner HTML");
                }

                // Find the LANGUAGE-SPECIFIC high-bandwidth banner image
                if (!String.IsNullOrEmpty(sourceFiles.Banner))
                {
                    if (!String.IsNullOrEmpty(CompleteSkin.Banner_Link))
                    {
                        returnValue.Banner_HTML = "<a href=\"" + CompleteSkin.Banner_Link + "\"><img border=\"0\" src=\"<%BASEURL%>skins/" + CompleteSkin.Skin_Code + "/" + sourceFiles.Banner + "\" alt=\"MISSING BANNER\" /></a>";
                    }
                    else
                    {
                        returnValue.Banner_HTML = "<img border=\"0\" src=\"<%BASEURL%>skins/" + CompleteSkin.Skin_Code + "/" + sourceFiles.Banner + "\" alt=\"MISSING BANNER\" />";
                    }
                }
            }

            // Now, set the header and footer html
            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Determine the header footer source HTML files");
            }
            string this_header      = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", CompleteSkin.Skin_Code, sourceFiles.Header_Source_File);
            string this_footer      = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", CompleteSkin.Skin_Code, sourceFiles.Footer_Source_File);
            string this_item_header = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", CompleteSkin.Skin_Code, sourceFiles.Header_Item_Source_File);
            string this_item_footer = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, "skins", CompleteSkin.Skin_Code, sourceFiles.Footer_Item_Source_File);

            // If the item specific stuff doesn't exist, use the regular
            if (!File.Exists(this_item_header))
            {
                this_item_header = this_header;
            }
            if (!File.Exists(this_item_footer))
            {
                this_item_footer = this_footer;
            }

            // Now, assign all of these
            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Get the HTML source for all the headers and footers");
            }
            returnValue.Set_Header_Footer_Source(this_header, this_footer, this_item_header, this_item_footer);

            if (Tracer != null)
            {
                Tracer.Add_Trace("Web_Skin_Utilities.Build_Skin", "Returning the fully built web skin");
            }
            return(returnValue);
        }
        private static void read_highlights(XmlNodeReader nodeReader, Item_Aggregation hierarchyObject)
        {
            Item_Aggregation_Highlights highlight = new Item_Aggregation_Highlights();


            // Determine if this is a rotating type of highlight or not
            if (nodeReader.HasAttributes)
            {
                if (nodeReader.MoveToAttribute("type"))
                {
                    if (nodeReader.Value == "ROTATING")
                    {
                        hierarchyObject.Rotating_Highlights = true;
                    }
                }
                if (nodeReader.MoveToAttribute("bannerSide"))
                {
                    if (nodeReader.Value.Trim().ToUpper() == "RIGHT")
                    {
                        hierarchyObject.Front_Banner_Left_Side = false;
                    }
                }
                if (nodeReader.MoveToAttribute("bannerHeight"))
                {
                    hierarchyObject.Front_Banner_Height = Convert.ToUInt16(nodeReader.Value);
                }
                if (nodeReader.MoveToAttribute("bannerWidth"))
                {
                    hierarchyObject.Front_Banner_Width = Convert.ToUInt16(nodeReader.Value);
                }
            }

            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    string languageText;
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        nodeReader.Read();
                        highlight.Image = nodeReader.Value.ToLower();
                        break;

                    case "HI:LINK":
                        nodeReader.Read();
                        highlight.Link = nodeReader.Value.ToLower();
                        break;

                    case "HI:TOOLTIP":
                        languageText = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            languageText = nodeReader.Value.ToUpper();
                        }
                        nodeReader.Read();
                        highlight.Add_Tooltip(Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value);
                        break;

                    case "HI:TEXT":
                        languageText = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            languageText = nodeReader.Value.ToUpper();
                        }
                        nodeReader.Read();
                        highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value);
                        break;
                    }
                }

                if (nodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT")
                    {
                        hierarchyObject.Highlights.Add(highlight);
                        highlight = new Item_Aggregation_Highlights();
                    }

                    if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS")
                    {
                        // Done with all the highlights so return
                        return;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary> Gets the language-specific web skin, by web skin code and language code </summary>
        /// <param name="Response"></param>
        /// <param name="UrlSegments"></param>
        /// <param name="QueryString"></param>
        /// <param name="Protocol"></param>
        /// <param name="IsDebug"></param>
        public void GetWebSkin(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            if (UrlSegments.Count > 1)
            {
                Custom_Tracer   tracer = new Custom_Tracer();
                Web_Skin_Object returnValue;
                try
                {
                    // Get the code and language from the URL
                    string skinCode = UrlSegments[0];
                    tracer.Add_Trace("WebSkinServices.GetWebSkin", "Getting skin for '" + skinCode + "'");

                    string            language     = UrlSegments[1];
                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(language);
                    tracer.Add_Trace("WebSkinServices.GetWebSkin", "Getting skin for language '" + Web_Language_Enum_Converter.Enum_To_Name(languageEnum) + "'");

                    returnValue = get_web_skin(skinCode, languageEnum, Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language, tracer);

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

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

                        return;
                    }

                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("Error completing request");
                    Response.StatusCode = 500;
                    return;
                }

                // Get the JSON-P callback function
                string json_callback = "parseWebSkin";
                if ((Protocol == Microservice_Endpoint_Protocol_Enum.JSON_P) && (!String.IsNullOrEmpty(QueryString["callback"])))
                {
                    json_callback = QueryString["callback"];
                }

                // Use the base class to serialize the object according to request protocol
                Serialize(returnValue, Response, Protocol, json_callback);
            }
        }
Ejemplo n.º 21
0
        /// <summary> Save this configuration to a XML config file </summary>
        /// <param name="FilePath"> File/path for the resulting XML config file </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public bool Save_To_Config_File(string FilePath)
        {
            bool         returnValue = true;
            StreamWriter writer      = null;

            try
            {
                // Start the output file
                writer = new StreamWriter(FilePath, false, Encoding.UTF8);
                writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                writer.WriteLine("<SobekCM_Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
                writer.WriteLine("\txmlns=\"http://sobekrepository.org/schemas/sobekcm_config\" ");
                writer.WriteLine("\txsi:schemaLocation=\"http://sobekrepository.org/schemas/sobekcm_config ");
                writer.WriteLine("\t\thttp://sobekrepository.org/schemas/sobekcm_config.xsd\">");
                if (String.IsNullOrEmpty(Name))
                {
                    writer.WriteLine("\t<ContactForm>");
                }
                else
                {
                    writer.WriteLine("\t<ContactForm Name=\"" + Convert_String_To_XML_Safe(Name) + "\">");
                }

                if (FormElements.Count > 0)
                {
                    writer.WriteLine("\t\t<Elements>");

                    // Add the elements
                    foreach (ContactForm_Configuration_Element thisElement in FormElements)
                    {
                        string elementName = String.Empty;
                        switch (thisElement.Element_Type)
                        {
                        case ContactForm_Configuration_Element_Type_Enum.CheckBoxSet:
                            elementName = "CheckBoxSet";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.Email:
                            elementName = "Email";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.ExplanationText:
                            elementName = "ExplanationText";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.HiddenValue:
                            elementName = "HiddenValue";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.RadioSet:
                            elementName = "RadioSet";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.SelectBox:
                            elementName = "SelectBox";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.Subject:
                            elementName = "Subject";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.TextArea:
                            elementName = "TextArea";
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.TextBox:
                            elementName = "TextBox";
                            break;
                        }
                        writer.Write("\t\t\t<" + elementName);
                        if (!String.IsNullOrEmpty(thisElement.Name))
                        {
                            writer.Write(" Name=\"" + thisElement.Name + "\"");
                        }

                        if (!String.IsNullOrEmpty(thisElement.QueryText.DefaultValue))
                        {
                            if (thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.ExplanationText)
                            {
                                writer.Write(" Query=\"" + Convert_String_To_XML_Safe(thisElement.QueryText.DefaultValue) + "\"");
                            }
                            else
                            {
                                writer.Write(" Text=\"" + Convert_String_To_XML_Safe(thisElement.QueryText.DefaultValue) + "\"");
                            }
                        }
                        if (!String.IsNullOrEmpty(thisElement.CssClass))
                        {
                            writer.Write(" CssClass=\"" + thisElement.CssClass + "\"");
                        }
                        if (thisElement.UserAttribute != User_Object_Attribute_Mapping_Enum.NONE)
                        {
                            writer.Write(" UserAttribute=\"" + User_Object_Attribute_Mapping_Enum_Converter.ToString(thisElement.UserAttribute) + "\"");
                            if ((thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.ExplanationText) && (thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.HiddenValue))
                            {
                                writer.Write(" AlwaysShow=\"" + thisElement.AlwaysShow.ToString().ToLower() + "\"");
                            }
                        }
                        if ((thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.ExplanationText) && (thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.HiddenValue))
                        {
                            if (thisElement.Required)
                            {
                                writer.Write(" Required=\"true\"");
                            }
                        }

                        if (((thisElement.Options == null) || (thisElement.Options.Count == 0)) && (thisElement.QueryText.Count <= 1))
                        {
                            writer.WriteLine(" />");
                        }
                        else
                        {
                            writer.WriteLine(">");

                            // Add the query in different languages
                            List <Web_Language_Translation_Value> translations = thisElement.QueryText.Values;
                            if (translations.Count > 0)
                            {
                                writer.WriteLine("\t\t\t\t<Translations>");
                                foreach (Web_Language_Translation_Value thisTranslation in translations)
                                {
                                    writer.WriteLine("\t\t\t\t\t<Language Code=\"" + Web_Language_Enum_Converter.Enum_To_Code(thisTranslation.Language) + "\">" + Convert_String_To_XML_Safe(thisTranslation.Value) + "</Language>");
                                }
                                writer.WriteLine("\t\t\t\t</Translations>");
                            }

                            // Add the possible options
                            if ((thisElement.Options != null) && (thisElement.Options.Count > 0))
                            {
                                writer.WriteLine("\t\t\t\t<Options>");
                                foreach (string thisOption in thisElement.Options)
                                {
                                    writer.WriteLine("\t\t\t\t\t<Option>" + Convert_String_To_XML_Safe(thisOption) + "</Option>");
                                }
                                writer.WriteLine("\t\t\t\t</Options>");
                            }


                            writer.WriteLine("\t\t\t</" + elementName + ">");
                        }
                    }

                    writer.WriteLine("\t\t</Elements>");
                }
                writer.WriteLine("\t</ContactForm>");
                writer.WriteLine("</SobekCM_Config>");
                writer.Flush();
                writer.Close();
            }
            catch
            {
                returnValue = false;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }

            return(returnValue);
        }
        private static void read_browse(bool browse, XmlNodeReader nodeReader, Item_Aggregation hierarchyObject)
        {
            // Create a new browse/info object
            Item_Aggregation_Browse_Info newBrowse = new Item_Aggregation_Browse_Info
            {
                Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_Home,
                Source      = Item_Aggregation_Browse_Info.Source_Type.Static_HTML,
                Data_Type   = Item_Aggregation_Browse_Info.Result_Data_Type.Text
            };

            bool isDefault = false;

            string code = String.Empty;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";

            if (!browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Info;
            }

            // Check for the attributes
            if (nodeReader.HasAttributes)
            {
                if (nodeReader.MoveToAttribute("location"))
                {
                    if (nodeReader.Value == "BROWSEBY")
                    {
                        newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By;
                    }
                }
                if (nodeReader.MoveToAttribute("default"))
                {
                    if (nodeReader.Value == "DEFAULT")
                    {
                        isDefault = true;
                    }
                }
            }

            // Step through the XML and build this browse/info object
            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:METADATA":
                        nodeReader.Read();
                        newBrowse.Code      = nodeReader.Value.ToLower();
                        newBrowse.Source    = Item_Aggregation_Browse_Info.Source_Type.Database;
                        newBrowse.Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Table;
                        break;

                    case "HI:CODE":
                        nodeReader.Read();
                        newBrowse.Code = nodeReader.Value.ToLower();
                        break;

                    case "HI:TITLE":
                        // Look for a language attached to this title
                        string titleLanguage = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            titleLanguage = nodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        nodeReader.Read();
                        newBrowse.Add_Label(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                        break;

                    case "HI:BODY":
                        // Look for a language attached to this title
                        string bodyLanguage = String.Empty;
                        if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                        {
                            bodyLanguage = nodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        nodeReader.Read();
                        string bodySource = nodeReader.Value;
                        newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        break;
                    }
                }

                if (nodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (nodeReader.Name.Trim().ToUpper() == lastName)
                    {
                        hierarchyObject.Add_Browse_Info(newBrowse);

                        // If this set the default browse by save that information
                        if ((newBrowse.Browse_Type == Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By) && (isDefault))
                        {
                            hierarchyObject.Default_BrowseBy = newBrowse.Code;
                        }

                        return;
                    }
                }
            }
        }
        private static void read_browse(bool Browse, XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            // Create a new browse/info object
            Complete_Item_Aggregation_Child_Page newBrowse = new Complete_Item_Aggregation_Child_Page
            {
                Browse_Type      = Item_Aggregation_Child_Visibility_Enum.Main_Menu,
                Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML
            };

            bool isDefault = false;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";

            if (!Browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
            }

            // Check for the attributes
            if (NodeReader.HasAttributes)
            {
                if (NodeReader.MoveToAttribute("location"))
                {
                    if (NodeReader.Value == "BROWSEBY")
                    {
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                    }
                }
                if (NodeReader.MoveToAttribute("default"))
                {
                    if (NodeReader.Value == "DEFAULT")
                    {
                        isDefault = true;
                    }
                }
                if (NodeReader.MoveToAttribute("visibility"))
                {
                    switch (NodeReader.Value)
                    {
                    case "NONE":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
                        break;

                    case "MAIN_MENU":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu;
                        break;

                    case "BROWSEBY":
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                        break;
                    }
                }
                if (NodeReader.MoveToAttribute("parent"))
                {
                    newBrowse.Parent_Code = NodeReader.Value;
                }
            }

            // Step through the XML and build this browse/info object
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:METADATA":
                        NodeReader.Read();
                        newBrowse.Code             = NodeReader.Value.ToLower();
                        newBrowse.Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Database_Table;
                        break;

                    case "HI:CODE":
                        NodeReader.Read();
                        newBrowse.Code = NodeReader.Value.ToLower();
                        break;

                    case "HI:TITLE":
                        // Look for a language attached to this title
                        string titleLanguage = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            titleLanguage = NodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        NodeReader.Read();
                        newBrowse.Add_Label(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                        break;

                    case "HI:BODY":
                        // Look for a language attached to this title
                        string bodyLanguage = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            bodyLanguage = NodeReader.GetAttribute("lang");
                        }

                        // read and save the title
                        NodeReader.Read();
                        string bodySource = NodeReader.Value;
                        newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == lastName)
                    {
                        // Don't add ALL or NEW here
                        if ((String.Compare(newBrowse.Code, "all", StringComparison.InvariantCultureIgnoreCase) != 0) && (String.Compare(newBrowse.Code, "new", StringComparison.InvariantCultureIgnoreCase) != 0))
                        {
                            HierarchyObject.Add_Child_Page(newBrowse);
                            //HierarchyObject.Add

                            // If this set the default browse by save that information
                            if ((newBrowse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By) && (isDefault))
                            {
                                HierarchyObject.Default_BrowseBy = newBrowse.Code;
                            }
                        }

                        return;
                    }
                }
            }
        }
        /// <summary> Saves the information about this item aggregation to the database </summary>
        /// <param name="ItemAggr"> Item aggregation object with all the information to be saved </param>
        /// <param name="Username"> Name of the user performing this save, for the item aggregation milestones</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        public static bool Save_To_Database(Complete_Item_Aggregation ItemAggr, string Username, Custom_Tracer Tracer)
        {
            // Build the list of language variants
            List <string> languageVariants = new List <string>
            {
                Web_Language_Enum_Converter.Enum_To_Code(Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language)
            };

            if (ItemAggr.Home_Page_File_Dictionary != null)
            {
                foreach (Web_Language_Enum language in ItemAggr.Home_Page_File_Dictionary.Keys)
                {
                    string code = Web_Language_Enum_Converter.Enum_To_Code(language);
                    if (!languageVariants.Contains(code))
                    {
                        languageVariants.Add(code);
                    }
                }
            }
            if (ItemAggr.Banner_Dictionary != null)
            {
                foreach (Web_Language_Enum language in ItemAggr.Banner_Dictionary.Keys)
                {
                    string code = Web_Language_Enum_Converter.Enum_To_Code(language);
                    if (!languageVariants.Contains(code))
                    {
                        languageVariants.Add(code);
                    }
                }
            }
            if (ItemAggr.Child_Pages != null)
            {
                foreach (Complete_Item_Aggregation_Child_Page childPage in ItemAggr.Child_Pages)
                {
                    if (childPage.Label_Dictionary != null)
                    {
                        foreach (Web_Language_Enum language in childPage.Label_Dictionary.Keys)
                        {
                            string code2 = Web_Language_Enum_Converter.Enum_To_Code(language);
                            if (!languageVariants.Contains(code2))
                            {
                                languageVariants.Add(code2);
                            }
                        }
                    }
                    if (childPage.Source_Dictionary != null)
                    {
                        foreach (Web_Language_Enum language in childPage.Source_Dictionary.Keys)
                        {
                            string code2 = Web_Language_Enum_Converter.Enum_To_Code(language);
                            if (!languageVariants.Contains(code2))
                            {
                                languageVariants.Add(code2);
                            }
                        }
                    }
                }
            }
            StringBuilder languageVariantsBuilder = new StringBuilder();

            foreach (string language in languageVariants)
            {
                if (language.Length > 0)
                {
                    if (languageVariantsBuilder.Length > 0)
                    {
                        languageVariantsBuilder.Append("|" + language);
                    }
                    else
                    {
                        languageVariantsBuilder.Append(language);
                    }
                }
            }


            return(Engine_Database.Save_Item_Aggregation(ItemAggr.ID, ItemAggr.Code, ItemAggr.Name, ItemAggr.ShortName,
                                                         ItemAggr.Description, ItemAggr.Thematic_Heading, ItemAggr.Type, ItemAggr.Active, ItemAggr.Hidden,
                                                         ItemAggr.Display_Options, 0, ItemAggr.Map_Search_Beta, 0, ItemAggr.Map_Display_Beta,
                                                         ItemAggr.OAI_Enabled, ItemAggr.OAI_Metadata, ItemAggr.Contact_Email, String.Empty, ItemAggr.External_Link, -1, Username,
                                                         languageVariantsBuilder.ToString(), Tracer));
        }
Ejemplo n.º 25
0
        private static void read_contactform_element(XmlReader readerXml, ContactForm_Configuration config, ContactForm_Configuration_Element_Type_Enum type)
        {
            // Create the element object
            ContactForm_Configuration_Element newElement = new ContactForm_Configuration_Element(type);

            // Read the attributes
            if (readerXml.MoveToAttribute("Name"))
            {
                newElement.Name = readerXml.Value.Trim();
                if (String.IsNullOrEmpty(newElement.QueryText.DefaultValue))
                {
                    newElement.QueryText.DefaultValue = newElement.Name.Replace("_", " ") + ":";
                }
            }
            if (readerXml.MoveToAttribute("CssClass"))
            {
                newElement.CssClass = readerXml.Value.Trim();
            }
            if (readerXml.MoveToAttribute("Query"))
            {
                newElement.QueryText.DefaultValue = readerXml.Value.Trim();
            }
            else if (readerXml.MoveToAttribute("Text"))
            {
                newElement.QueryText.DefaultValue = readerXml.Value.Trim();
            }
            if (readerXml.MoveToAttribute("UserAttribute"))
            {
                string attr = readerXml.Value.Trim();
                newElement.UserAttribute = User_Object_Attribute_Mapping_Enum_Converter.ToEnum(attr);
            }
            if (readerXml.MoveToAttribute("AlwaysShow"))
            {
                string alwaysShow = readerXml.Value.Trim();
                switch (alwaysShow.ToLower())
                {
                case "false":
                    newElement.AlwaysShow = false;
                    break;

                case "true":
                    newElement.AlwaysShow = true;
                    break;
                }
            }
            if (readerXml.MoveToAttribute("Required"))
            {
                string required = readerXml.Value.Trim();
                switch (required.ToLower())
                {
                case "false":
                    newElement.Required = false;
                    break;

                case "true":
                    newElement.Required = true;
                    break;
                }
            }

            readerXml.MoveToElement();

            // Just step through the subtree of this
            XmlReader subTreeReader = readerXml.ReadSubtree();

            while (subTreeReader.Read())
            {
                if (subTreeReader.NodeType == XmlNodeType.Element)
                {
                    switch (subTreeReader.Name.ToLower())
                    {
                    case "option":
                        if (!subTreeReader.IsEmptyElement)
                        {
                            subTreeReader.Read();
                            if (newElement.Options == null)
                            {
                                newElement.Options = new List <string>();
                            }
                            newElement.Options.Add(subTreeReader.Value.Trim());
                        }
                        break;

                    case "language":
                        if (!subTreeReader.IsEmptyElement)
                        {
                            if (subTreeReader.MoveToAttribute("Code"))
                            {
                                string            language_code = subTreeReader.Value.Trim();
                                Web_Language_Enum enum_lang     = Web_Language_Enum_Converter.Code_To_Enum(language_code);
                                if (enum_lang != Web_Language_Enum.UNDEFINED)
                                {
                                    subTreeReader.Read();
                                    newElement.QueryText.Add_Translation(enum_lang, subTreeReader.Value.Trim());
                                }
                            }
                        }
                        break;
                    }
                }
            }


            config.Add_Element(newElement);
        }
        /// <summary> Gets the all information, including the HTML, for an item aggregation child page </summary>
        /// <param name="Response"></param>
        /// <param name="UrlSegments"></param>
        /// <param name="QueryString"></param>
        /// <param name="Protocol"></param>
        /// <param name="IsDebug"></param>
        public void GetCollectionStaticPage(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            if (UrlSegments.Count > 2)
            {
                Custom_Tracer tracer = new Custom_Tracer();

                try
                {
                    // Get the code and language from the URL
                    string            aggrCode  = UrlSegments[0];
                    string            language  = UrlSegments[1];
                    string            childCode = UrlSegments[2];
                    Web_Language_Enum langEnum  = Web_Language_Enum_Converter.Code_To_Enum(language);

                    if (langEnum == Web_Language_Enum.UNDEFINED)
                    {
                        tracer.Add_Trace("AggregationServices.GetCollectionStaticPage", "Language code '" + language + "' not recognized");
                    }

                    // Build the language-specific item aggregation
                    tracer.Add_Trace("AggregationServices.GetCollectionStaticPage", "Build and return child page '" + childCode + "' in aggregation '" + aggrCode + "' for '" + Web_Language_Enum_Converter.Enum_To_Name(langEnum) + "'");

                    // Get the aggregation code manager
                    HTML_Based_Content returnValue = get_item_aggregation_html_child_page(aggrCode, langEnum, Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language, childCode, tracer);

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

                        return;
                    }

                    // Get the JSON-P callback function
                    string json_callback = "parseCollectionStaticPage";
                    if ((Protocol == Microservice_Endpoint_Protocol_Enum.JSON_P) && (!String.IsNullOrEmpty(QueryString["callback"])))
                    {
                        json_callback = QueryString["callback"];
                    }

                    // Use the base class to serialize the object according to request protocol
                    Serialize(returnValue, Response, Protocol, json_callback);
                }
                catch (Exception ee)
                {
                    if (IsDebug)
                    {
                        Response.ContentType = "text/plain";
                        Response.Output.WriteLine("EXCEPTION CAUGHT!");
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ee.Message);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(ee.StackTrace);
                        Response.Output.WriteLine();
                        Response.Output.WriteLine(tracer.Text_Trace);
                        return;
                    }

                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("Error completing request");
                    Response.StatusCode = 500;
                }
            }
        }
        private static void read_banners(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        // Check for any attributes to this banner node
                        string lang    = String.Empty;
                        bool   special = false;
                        Item_Aggregation_Front_Banner_Type_Enum type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                        ushort width  = 550;
                        ushort height = 230;

                        if (NodeReader.HasAttributes)
                        {
                            if (NodeReader.MoveToAttribute("lang"))
                            {
                                lang = NodeReader.Value.Trim().ToUpper();
                            }
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                if ((NodeReader.Value.Trim().ToUpper() == "HIGHLIGHT") || (NodeReader.Value.Trim().ToUpper() == "FRONT"))
                                {
                                    special = true;
                                }
                            }
                            if (NodeReader.MoveToAttribute("side"))
                            {
                                switch (NodeReader.Value.Trim().ToUpper())
                                {
                                case "RIGHT":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Right;
                                    break;

                                case "LEFT":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                                    break;

                                case "FULL":
                                    type = Item_Aggregation_Front_Banner_Type_Enum.Full;
                                    break;
                                }
                            }
                            if (NodeReader.MoveToAttribute("width"))
                            {
                                ushort.TryParse(NodeReader.Value, out width);
                            }
                            if (NodeReader.MoveToAttribute("height"))
                            {
                                ushort.TryParse(NodeReader.Value, out height);
                            }
                        }

                        // Now read the banner information and add to the aggregation object
                        NodeReader.Read();
                        if (special)
                        {
                            Item_Aggregation_Front_Banner bannerObj = HierarchyObject.Add_Front_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                            bannerObj.Width  = width;
                            bannerObj.Height = height;
                            bannerObj.Type   = type;
                        }
                        else
                        {
                            HierarchyObject.Add_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                        }


                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:BANNER"))
                {
                    return;
                }
            }
        }
        private static void read_highlights(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            Complete_Item_Aggregation_Highlights highlight = new Complete_Item_Aggregation_Highlights();


            // Determine if this is a rotating type of highlight or not
            if (NodeReader.HasAttributes)
            {
                if (NodeReader.MoveToAttribute("type"))
                {
                    if (NodeReader.Value == "ROTATING")
                    {
                        HierarchyObject.Rotating_Highlights = true;
                    }
                }

                if (HierarchyObject.Front_Banner_Dictionary != null)
                {
                    // The following three values are for reading legacy XML files.  These
                    // data fields have been moved to be attached to the actual banner
                    if (NodeReader.MoveToAttribute("bannerSide"))
                    {
                        if (NodeReader.Value.Trim().ToUpper() == "RIGHT")
                        {
                            foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                            {
                                banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Right;
                            }
                        }
                        else
                        {
                            foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                            {
                                banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Left;
                            }
                        }
                    }
                    if (NodeReader.MoveToAttribute("bannerHeight"))
                    {
                        foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                        {
                            banners.Value.Height = Convert.ToUInt16(NodeReader.Value);
                        }
                    }
                    if (NodeReader.MoveToAttribute("bannerWidth"))
                    {
                        foreach (KeyValuePair <Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary)
                        {
                            banners.Value.Width = Convert.ToUInt16(NodeReader.Value);
                        }
                    }
                }
            }

            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    string languageText;
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        NodeReader.Read();
                        highlight.Image = NodeReader.Value.ToLower();
                        break;

                    case "HI:LINK":
                        NodeReader.Read();
                        highlight.Link = NodeReader.Value.ToLower();
                        break;

                    case "HI:TOOLTIP":
                        languageText = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            languageText = NodeReader.Value.ToUpper();
                        }
                        NodeReader.Read();
                        highlight.Add_Tooltip(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value);
                        break;

                    case "HI:TEXT":
                        languageText = String.Empty;
                        if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                        {
                            languageText = NodeReader.Value.ToUpper();
                        }
                        NodeReader.Read();
                        highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value);
                        break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT")
                    {
                        if (HierarchyObject.Highlights == null)
                        {
                            HierarchyObject.Highlights = new List <Complete_Item_Aggregation_Highlights>();
                        }
                        HierarchyObject.Highlights.Add(highlight);
                        highlight = new Complete_Item_Aggregation_Highlights();
                    }

                    if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS")
                    {
                        // Done with all the highlights so return
                        return;
                    }
                }
            }
        }
        /// <summary> Add a new aggregation to the system </summary>
        /// <param name="NewAggregation"> Information for the new aggregation </param>
        /// <returns> Message indicating success or any errors encountered </returns>
        public static RestResponseMessage add_new_aggregation(New_Aggregation_Arguments NewAggregation)
        {
            // Convert to the integer id for the parent and begin to do checking
            List <string> errors   = new List <string>();
            int           parentid = -1;

            if (NewAggregation.ParentCode.Length > 0)
            {
                Item_Aggregation_Related_Aggregations parentAggr = Engine_ApplicationCache_Gateway.Codes[NewAggregation.ParentCode];
                if (parentAggr != null)
                {
                    parentid = parentAggr.ID;
                }
                else
                {
                    errors.Add("Parent code is not valid");
                }
            }
            else
            {
                errors.Add("You must select a PARENT for this new aggregation");
            }

            // Validate the code

            if (NewAggregation.Code.Length > 20)
            {
                errors.Add("New aggregation code must be twenty characters long or less");
            }
            else if (NewAggregation.Code.Length == 0)
            {
                errors.Add("You must enter a CODE for this item aggregation");
            }
            else if (Engine_ApplicationCache_Gateway.Codes[NewAggregation.Code.ToUpper()] != null)
            {
                errors.Add("New code must be unique... <i>" + NewAggregation.Code + "</i> already exists");
            }
            else if (Engine_ApplicationCache_Gateway.Settings.Static.Reserved_Keywords.Contains(NewAggregation.Code.ToLower()))
            {
                errors.Add("That code is a system-reserved keyword.  Try a different code.");
            }
            else
            {
                bool alphaNumericTest = NewAggregation.Code.All(C => Char.IsLetterOrDigit(C) || C == '_' || C == '-');
                if (!alphaNumericTest)
                {
                    errors.Add("New aggregation code must be only letters and numbers");
                    NewAggregation.Code = NewAggregation.Code.Replace("\"", "");
                }
            }

            // Was there a type and name
            if (NewAggregation.Type.Length == 0)
            {
                errors.Add("You must select a TYPE for this new aggregation");
            }
            if (NewAggregation.Description.Length == 0)
            {
                errors.Add("You must enter a DESCRIPTION for this new aggregation");
            }
            if (NewAggregation.Name.Length == 0)
            {
                errors.Add("You must enter a NAME for this new aggregation");
            }
            else
            {
                if (NewAggregation.ShortName.Length == 0)
                {
                    NewAggregation.ShortName = NewAggregation.Name;
                }
            }

            // Check for the thematic heading
            int thematicHeadingId = -1;

            if (!String.IsNullOrEmpty(NewAggregation.Thematic_Heading))
            {
                // Look for the matching thematic heading
                foreach (Thematic_Heading thisHeading in Engine_ApplicationCache_Gateway.Thematic_Headings)
                {
                    if (String.Compare(thisHeading.Text, NewAggregation.Thematic_Heading, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        thematicHeadingId = thisHeading.ID;
                        break;
                    }
                }

                // If there was no match, the thematic heading was invalid, unless it was new
                if (thematicHeadingId < 0)
                {
                    if ((!NewAggregation.NewThematicHeading.HasValue) || (!NewAggregation.NewThematicHeading.Value))
                    {
                        errors.Add("Invalid thematic heading indicated");
                    }
                    else if (errors.Count == 0)
                    {
                        // Add the thematic heading first
                        if ((thematicHeadingId < 0) && (NewAggregation.NewThematicHeading.HasValue) && (NewAggregation.NewThematicHeading.Value))
                        {
                            thematicHeadingId = Engine_Database.Edit_Thematic_Heading(-1, 10, NewAggregation.Thematic_Heading, null);
                        }
                    }
                }
            }

            if (errors.Count > 0)
            {
                // Create the error message
                StringBuilder actionMessage = new StringBuilder("ERROR: Invalid entry for new item aggregation.<br />");
                foreach (string error in errors)
                {
                    actionMessage.Append("<br />" + error);
                }

                return(new RestResponseMessage(ErrorRestTypeEnum.InputError, actionMessage.ToString()));
            }



            string language = Web_Language_Enum_Converter.Enum_To_Code(Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language);

            // Try to save the new item aggregation
            if (!Engine_Database.Save_Item_Aggregation(NewAggregation.Code, NewAggregation.Name, NewAggregation.ShortName, NewAggregation.Description, thematicHeadingId, NewAggregation.Type, NewAggregation.Active, NewAggregation.Hidden, NewAggregation.External_Link, parentid, NewAggregation.User, language, null))
            {
                return(new RestResponseMessage(ErrorRestTypeEnum.Exception, "ERROR saving the new item aggregation to the database"));
            }
            // Ensure a folder exists for this, otherwise create one
            try
            {
                string folder = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "aggregations\\" + NewAggregation.Code.ToLower();
                if (!Directory.Exists(folder))
                {
                    // Create this directory and all the subdirectories
                    Directory.CreateDirectory(folder);
                    Directory.CreateDirectory(folder + "/html");
                    Directory.CreateDirectory(folder + "/images");
                    Directory.CreateDirectory(folder + "/html/home");
                    Directory.CreateDirectory(folder + "/html/custom/home");
                    Directory.CreateDirectory(folder + "/images/buttons");
                    Directory.CreateDirectory(folder + "/images/banners");
                    Directory.CreateDirectory(folder + "/uploads");

                    // Get the parent name
                    string link_to_parent = String.Empty;
                    Item_Aggregation_Related_Aggregations parentAggr = Engine_ApplicationCache_Gateway.Codes.Aggregation_By_ID(parentid);
                    if (parentAggr != null)
                    {
                        if (String.Compare(parentAggr.Code, "all", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            link_to_parent = "<p>&larr; Back to <a href=\"<%BASEURL%>\" alt=\"Return to parent collection\">" + parentAggr.Name + "</a></p>" + Environment.NewLine;
                        }
                        else
                        {
                            link_to_parent = "<p>&larr; Back to <a href=\"<%BASEURL%>" + parentAggr.Code + "\" alt=\"Return to parent collection\">" + parentAggr.Name + "</a></p>" + Environment.NewLine;
                        }
                    }

                    // Create a default home text file
                    StreamWriter writer = new StreamWriter(folder + "/html/home/text.html");
                    writer.WriteLine(link_to_parent + "<h3>About " + NewAggregation.Name + "</h3>" + Environment.NewLine + "<p>" + NewAggregation.Description + "</p>" + Environment.NewLine + "<p>To edit this, log on as the aggregation admin and hover over this text to edit it.</p>" + Environment.NewLine);

                    writer.Flush();
                    writer.Close();

                    // Was a button indicated, and does it exist?
                    if ((!String.IsNullOrEmpty(NewAggregation.ButtonFile)) && (File.Exists(NewAggregation.ButtonFile)))
                    {
                        File.Copy(NewAggregation.ButtonFile, folder + "/images/buttons/coll.gif");
                    }
                    else
                    {
                        // Copy the default banner and buttons from images
                        if (File.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_button.png"))
                        {
                            File.Copy(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_button.png", folder + "/images/buttons/coll.png");
                        }
                        if (File.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_button.gif"))
                        {
                            File.Copy(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_button.gif", folder + "/images/buttons/coll.gif");
                        }
                    }

                    // Was a banner indicated, and does it exist?
                    string banner_file = String.Empty;
                    if ((!String.IsNullOrEmpty(NewAggregation.BannerFile)) && (File.Exists(NewAggregation.BannerFile)))
                    {
                        banner_file = "images/banners/" + Path.GetFileName(NewAggregation.BannerFile);
                        File.Copy(NewAggregation.BannerFile, folder + "//" + banner_file, true);
                    }
                    else
                    {
                        // Try to create a new custom banner
                        bool custom_banner_created = false;

                        // Create the banner with the name of the collection
                        if (Directory.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network + "\\default\\banner_images"))
                        {
                            try
                            {
                                string[] banners = Directory.GetFiles(Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network + "\\default\\banner_images", "*.jpg");
                                if (banners.Length > 0)
                                {
                                    Random randomizer    = new Random();
                                    string banner_to_use = banners[randomizer.Next(0, banners.Length - 1)];
                                    Bitmap bitmap        = (Bitmap)(Image.FromFile(banner_to_use));

                                    RectangleF rectf = new RectangleF(30, bitmap.Height - 55, bitmap.Width - 40, 40);
                                    Graphics   g     = Graphics.FromImage(bitmap);
                                    g.SmoothingMode     = SmoothingMode.AntiAlias;
                                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                                    g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                                    g.DrawString(NewAggregation.Name, new Font("Tahoma", 25, FontStyle.Bold), Brushes.Black, rectf);
                                    g.Flush();

                                    string new_file = folder + "/images/banners/coll.jpg";
                                    if (!File.Exists(new_file))
                                    {
                                        bitmap.Save(new_file, ImageFormat.Jpeg);
                                        custom_banner_created = true;
                                        banner_file           = "images/banners/coll.jpg";
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                // Suppress this Error...
                            }
                        }

                        if ((!custom_banner_created) && (!File.Exists(folder + "/images/banners/coll.jpg")))
                        {
                            if (File.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_banner.jpg"))
                            {
                                banner_file = "images/banners/coll.jpg";
                                File.Copy(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design/aggregations/default_banner.jpg", folder + "/images/banners/coll.jpg", true);
                            }
                        }
                    }

                    // Now, try to create the item aggregation and write the configuration file
                    Custom_Tracer             tracer          = new Custom_Tracer();
                    Complete_Item_Aggregation itemAggregation = SobekEngineClient.Aggregations.Get_Complete_Aggregation(NewAggregation.Code, true, tracer);
                    if (banner_file.Length > 0)
                    {
                        itemAggregation.Banner_Dictionary.Clear();
                        itemAggregation.Add_Banner_Image(banner_file, Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language);
                    }
                    itemAggregation.Write_Configuration_File(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + itemAggregation.ObjDirectory);

                    // If an email shoudl be sent, do that now
                    if (String.Compare(Engine_ApplicationCache_Gateway.Settings.Email.Send_On_Added_Aggregation, "always", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        string user = String.Empty;
                        if (!String.IsNullOrEmpty(NewAggregation.User))
                        {
                            user = NewAggregation.User;
                        }

                        string body = "New aggregation added to this system:\n\n\tCode:\t" + itemAggregation.Code + "\n\tType:\t" + itemAggregation.Type + "\n\tName:\t" + itemAggregation.Name + "\n\tShort:\t" + itemAggregation.ShortName + "\n\tUser:\t" + user + "\n\n" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + "/" + itemAggregation.Code;
                        Email_Helper.SendEmail(Engine_ApplicationCache_Gateway.Settings.Email.System_Email, "New " + itemAggregation.Type + " - " + itemAggregation.ShortName, body, false, Engine_ApplicationCache_Gateway.Settings.System.System_Name);
                    }
                }
            }
            catch
            {
                // Reload the list of all codes, to include this new one and the new hierarchy
                lock (Engine_ApplicationCache_Gateway.Codes)
                {
                    Engine_Database.Populate_Code_Manager(Engine_ApplicationCache_Gateway.Codes, null);
                }

                return(new RestResponseMessage(ErrorRestTypeEnum.Exception, "ERROR completing the new aggregation add"));
            }

            // Reload the list of all codes, to include this new one and the new hierarchy
            lock (Engine_ApplicationCache_Gateway.Codes)
            {
                Engine_Database.Populate_Code_Manager(Engine_ApplicationCache_Gateway.Codes, null);
            }

            // Clear all aggregation information (and thematic heading info) from the cache as well
            CachedDataManager.Aggregations.Clear();

            return(new RestResponseMessage(ErrorRestTypeEnum.Successful, null));
        }
        /// <summary> Compares the two aggregation objects and returns a list of differences for saving as milestones
        /// during aggregation curatorial or administrative work </summary>
        /// <param name="Base"> Base item aggregation </param>
        /// <param name="Compared"> New item aggregation object to compare to the base </param>
        /// <returns> List of changes between the two aggregation objects </returns>
        public static List <string> Compare(Complete_Item_Aggregation Base, Complete_Item_Aggregation Compared)
        {
            // TODO: Facet comparison below needs to look up the name of the facet,
            // TODO: rather than just showing the primary key to the facet

            List <string> changes = new List <string>();

            // code
            if (!Base.Code.Equals(Compared.Code))
            {
                changes.Add("Changed code ( '" + Base.Code + "' --> '" + Compared.Code + "' )");
            }

            // parents
            List <string> base_parents     = new List <string>();
            List <string> compared_parents = new List <string>();

            if (Base.Parents != null)
            {
                foreach (Item_Aggregation_Related_Aggregations parentAggr in Base.Parents)
                {
                    // Look in compared for a match
                    if ((Compared.Parents == null) || (Compared.Parents.All(CompareAggr => String.Compare(parentAggr.Code, CompareAggr.Code, StringComparison.InvariantCultureIgnoreCase) != 0)))
                    {
                        base_parents.Add(parentAggr.Code);
                    }
                }
            }
            if (Compared.Parents != null)
            {
                foreach (Item_Aggregation_Related_Aggregations parentAggr in Compared.Parents)
                {
                    // Look in base for a match
                    if ((Base.Parents == null) || (Base.Parents.All(CompareAggr => String.Compare(parentAggr.Code, CompareAggr.Code, StringComparison.InvariantCultureIgnoreCase) != 0)))
                    {
                        compared_parents.Add(parentAggr.Code);
                    }
                }
            }
            if (base_parents.Count > 0)
            {
                if (base_parents.Count == 1)
                {
                    changes.Add("Removed parent " + base_parents[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed parents " + base_parents[0]);
                    for (int i = 1; i < base_parents.Count; i++)
                    {
                        builder.Append(", " + base_parents[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }
            if (compared_parents.Count > 0)
            {
                if (compared_parents.Count == 1)
                {
                    changes.Add("Added parent " + compared_parents[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added parents " + compared_parents[0]);
                    for (int i = 1; i < compared_parents.Count; i++)
                    {
                        builder.Append(", " + compared_parents[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }

            // name
            if (!Base.Name.Equals(Compared.Name))
            {
                changes.Add("Changed name ( '" + Base.Name + "' --> '" + Compared.Name + "' )");
            }

            // short name
            if (!Base.ShortName.Equals(Compared.ShortName))
            {
                changes.Add("Changed short name ( '" + Base.ShortName + "' --> '" + Compared.ShortName + "' )");
            }

            // description
            if (!Base.Description.Equals(Compared.Description))
            {
                changes.Add("Changed description");
            }

            // type
            if (!Base.Type.Equals(Compared.Type))
            {
                changes.Add("Changed type ( '" + Base.Type + "' --> '" + Compared.Type + "' )");
            }

            // email address
            compare_nullable_strings(Base.Contact_Email, Compared.Contact_Email, "contact email", changes);

            // external link
            compare_nullable_strings(Base.External_Link, Compared.External_Link, "external link", changes);

            // Hidden flag
            if (Base.Hidden != Compared.Hidden)
            {
                if (Compared.Hidden)
                {
                    changes.Add("Removed from parent home page");
                }
                else
                {
                    changes.Add("Added to parent home page");
                }
            }

            // active flag
            if (Base.Active != Compared.Active)
            {
                if (Compared.Active)
                {
                    changes.Add("Aggregation activated");
                }
                else
                {
                    changes.Add("Aggregation deactivated");
                }
            }

            // thematic headings
            if (Base.Thematic_Heading == null)
            {
                if (Compared.Thematic_Heading != null)
                {
                    changes.Add("Added to thematic heading '" + Compared.Thematic_Heading.Text + "'");
                }
            }
            else
            {
                if (Compared.Thematic_Heading == null)
                {
                    changes.Add("Removed from thematic heading '" + Base.Thematic_Heading.Text + "'");
                }
                else
                {
                    if (Base.Thematic_Heading.ID != Compared.Thematic_Heading.ID)
                    {
                        changes.Add("Changed thematic heading ( '" + Base.Thematic_Heading.Text + "' --> '" + Compared.Thematic_Heading.Text + "' )");
                    }
                }
            }

            // web skin
            List <string> base_skins     = new List <string>();
            List <string> compared_skins = new List <string>();

            if (Base.Web_Skins != null)
            {
                foreach (string thisSkin in Base.Web_Skins)
                {
                    // Look in compared for a match
                    if ((Compared.Web_Skins == null) || (Compared.Web_Skins.All(CompareSkin => String.Compare(thisSkin, CompareSkin, StringComparison.InvariantCultureIgnoreCase) != 0)))
                    {
                        base_skins.Add(thisSkin);
                    }
                }
            }
            if (Compared.Web_Skins != null)
            {
                foreach (string thisSkin in Compared.Web_Skins)
                {
                    // Look in base for a match
                    if ((Base.Web_Skins == null) || (Base.Web_Skins.All(CompareSkin => String.Compare(thisSkin, CompareSkin, StringComparison.InvariantCultureIgnoreCase) != 0)))
                    {
                        compared_skins.Add(thisSkin);
                    }
                }
            }
            if (base_skins.Count > 0)
            {
                if (base_skins.Count == 1)
                {
                    changes.Add("Removed web skin " + base_skins[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed web skins " + base_skins[0]);
                    for (int i = 1; i < base_skins.Count; i++)
                    {
                        builder.Append(", " + base_skins[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }
            if (compared_skins.Count > 0)
            {
                if (compared_skins.Count == 1)
                {
                    changes.Add("Added web skin " + compared_skins[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added web skins " + compared_skins[0]);
                    for (int i = 1; i < compared_skins.Count; i++)
                    {
                        builder.Append(", " + compared_skins[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }

            // default web skin
            compare_nullable_strings(Base.Default_Skin, Compared.Default_Skin, "default web skin", changes);

            // custom css
            if (String.IsNullOrEmpty(Base.CSS_File))
            {
                if (!String.IsNullOrEmpty(Compared.CSS_File))
                {
                    changes.Add("Enabled the aggregation-level stylesheet");
                }
            }
            else
            {
                if (String.IsNullOrEmpty(Compared.CSS_File))
                {
                    changes.Add("Disabled the aggregation-level stylesheet");
                }
            }

            // home pages (multilingual)
            List <Web_Language_Enum> removedLanguages = new List <Web_Language_Enum>();
            List <Web_Language_Enum> addedLanguages   = new List <Web_Language_Enum>();

            if (Base.Home_Page_File_Dictionary != null)
            {
                foreach (KeyValuePair <Web_Language_Enum, Complete_Item_Aggregation_Home_Page> thisHomePage in Base.Home_Page_File_Dictionary)
                {
                    // Look in compared for a match
                    if ((Compared.Home_Page_File_Dictionary == null) || (Compared.Home_Page_File_Dictionary.All(CompareHomePage => thisHomePage.Key != CompareHomePage.Key)))
                    {
                        removedLanguages.Add(thisHomePage.Key);
                    }
                }
            }
            if (Compared.Home_Page_File_Dictionary != null)
            {
                foreach (KeyValuePair <Web_Language_Enum, Complete_Item_Aggregation_Home_Page> thisHomePage in Compared.Home_Page_File_Dictionary)
                {
                    // Look in base for a match
                    if ((Base.Home_Page_File_Dictionary == null) || (Base.Home_Page_File_Dictionary.All(CompareHomePage => thisHomePage.Key != CompareHomePage.Key)))
                    {
                        addedLanguages.Add(thisHomePage.Key);
                    }
                }
            }
            if (removedLanguages.Count > 0)
            {
                if (removedLanguages.Count == 1)
                {
                    changes.Add("Removed " + Web_Language_Enum_Converter.Enum_To_Name(removedLanguages[0]) + " home page");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed " + Web_Language_Enum_Converter.Enum_To_Name(removedLanguages[0]));
                    for (int i = 1; i < removedLanguages.Count; i++)
                    {
                        builder.Append(", " + removedLanguages[i]);
                    }
                    changes.Add(builder + " home pages");
                }
            }
            if (addedLanguages.Count > 0)
            {
                if (addedLanguages.Count == 1)
                {
                    changes.Add("Added " + Web_Language_Enum_Converter.Enum_To_Name(addedLanguages[0]) + " home page");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added " + Web_Language_Enum_Converter.Enum_To_Name(removedLanguages[0]));
                    for (int i = 1; i < addedLanguages.Count; i++)
                    {
                        builder.Append(", " + addedLanguages[i]);
                    }
                    changes.Add(builder + " home pages");
                }
            }


            // banners (multilingual)
            removedLanguages.Clear();
            addedLanguages.Clear();
            if (Base.Banner_Dictionary != null)
            {
                foreach (KeyValuePair <Web_Language_Enum, string> thisBanner in Base.Banner_Dictionary)
                {
                    // Look in compared for a match
                    bool match = false;
                    if (Compared.Banner_Dictionary != null)
                    {
                        foreach (KeyValuePair <Web_Language_Enum, string> compareBanner in Compared.Banner_Dictionary)
                        {
                            if (thisBanner.Key == compareBanner.Key)
                            {
                                match = true;

                                // Now, compare the source file as well
                                if (String.Compare(thisBanner.Value, compareBanner.Value, StringComparison.InvariantCultureIgnoreCase) != 0)
                                {
                                    changes.Add("Changed " + Web_Language_Enum_Converter.Enum_To_Name(thisBanner.Key) + " banner source file (" + thisBanner.Value + " --> " + compareBanner.Value + ")");
                                }

                                break;
                            }
                        }
                    }
                    if (!match)
                    {
                        removedLanguages.Add(thisBanner.Key);
                    }
                }
            }
            if (Compared.Banner_Dictionary != null)
            {
                foreach (KeyValuePair <Web_Language_Enum, string> thisBanner in Compared.Banner_Dictionary)
                {
                    // Look in base for a match
                    if ((Base.Banner_Dictionary == null) || (Base.Banner_Dictionary.All(CompareBanner => thisBanner.Key != CompareBanner.Key)))
                    {
                        addedLanguages.Add(thisBanner.Key);
                    }
                }
            }
            if (removedLanguages.Count > 0)
            {
                if (removedLanguages.Count == 1)
                {
                    changes.Add("Removed " + Web_Language_Enum_Converter.Enum_To_Name(removedLanguages[0]) + " banner");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed " + Web_Language_Enum_Converter.Enum_To_Name(removedLanguages[0]));
                    for (int i = 1; i < removedLanguages.Count; i++)
                    {
                        builder.Append(", " + removedLanguages[i]);
                    }
                    changes.Add(builder + " banners");
                }
            }
            if (addedLanguages.Count > 0)
            {
                if (addedLanguages.Count == 1)
                {
                    changes.Add("Added " + Web_Language_Enum_Converter.Enum_To_Name(addedLanguages[0]) + " banner");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added " + Web_Language_Enum_Converter.Enum_To_Name(addedLanguages[0]));
                    for (int i = 1; i < addedLanguages.Count; i++)
                    {
                        builder.Append(", " + addedLanguages[i]);
                    }
                    changes.Add(builder + " banners");
                }
            }

            // search types
            List <Search_Type_Enum> removedSearches = new List <Search_Type_Enum>();
            List <Search_Type_Enum> addedSearches   = new List <Search_Type_Enum>();

            if (Base.Search_Types != null)
            {
                foreach (Search_Type_Enum thisSearch in Base.Search_Types)
                {
                    // Look in compared for a match
                    if ((Compared.Search_Types == null) || (Compared.Search_Types.All(CompareSearch => thisSearch != CompareSearch)))
                    {
                        removedSearches.Add(thisSearch);
                    }
                }
            }
            if (Compared.Search_Types != null)
            {
                foreach (Search_Type_Enum thisSearch in Compared.Search_Types)
                {
                    // Look in base for a match
                    if ((Base.Search_Types == null) || (Base.Search_Types.All(CompareSearch => thisSearch != CompareSearch)))
                    {
                        addedSearches.Add(thisSearch);
                    }
                }
            }
            if (removedSearches.Count > 0)
            {
                if (removedSearches.Count == 1)
                {
                    changes.Add("Removed " + removedSearches[0].ToString() + " search");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed " + removedSearches[0].ToString());
                    for (int i = 1; i < removedSearches.Count; i++)
                    {
                        builder.Append(", " + removedSearches[i].ToString());
                    }
                    changes.Add(builder + " searches");
                }
            }
            if (addedSearches.Count > 0)
            {
                if (addedSearches.Count == 1)
                {
                    changes.Add("Added " + addedSearches[0] + " search");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added " + addedSearches[0]);
                    for (int i = 1; i < addedSearches.Count; i++)
                    {
                        builder.Append(", " + addedSearches[i]);
                    }
                    changes.Add(builder + " searches");
                }
            }

            // other display types? ( all/new item browse, map browse )

            // map search default area
            if ((Base.Map_Search_Display != null) || (Compared.Map_Search_Display != null))
            {
                if (Base.Map_Search_Display == null)
                {
                    changes.Add("Added default area for map search display");
                }
                else if (Compared.Map_Search_Display == null)
                {
                    changes.Add("Removed default area information for map search display");
                }
                else
                {
                    // Are these different?
                    bool different = false;
                    if (Base.Map_Search_Display.Type != Compared.Map_Search_Display.Type)
                    {
                        different = true;
                    }
                    else
                    {
                        if ((Base.Map_Search_Display.ZoomLevel.HasValue != Compared.Map_Search_Display.ZoomLevel.HasValue) ||
                            ((Base.Map_Search_Display.ZoomLevel.HasValue) && (Base.Map_Search_Display.ZoomLevel.Value != Compared.Map_Search_Display.ZoomLevel.Value)))
                        {
                            different = true;
                        }
                        if ((Base.Map_Search_Display.Latitude.HasValue != Compared.Map_Search_Display.Latitude.HasValue) ||
                            ((Base.Map_Search_Display.Latitude.HasValue) && (Base.Map_Search_Display.Latitude.Value != Compared.Map_Search_Display.Latitude.Value)))
                        {
                            different = true;
                        }
                        if ((Base.Map_Search_Display.Longitude.HasValue != Compared.Map_Search_Display.Longitude.HasValue) ||
                            ((Base.Map_Search_Display.Longitude.HasValue) && (Base.Map_Search_Display.Longitude.Value != Compared.Map_Search_Display.Longitude.Value)))
                        {
                            different = true;
                        }
                    }

                    if (different)
                    {
                        changes.Add("Changed default area for map search display");
                    }
                }
            }

            // map browse default area
            if ((Base.Map_Browse_Display != null) || (Compared.Map_Browse_Display != null))
            {
                if (Base.Map_Browse_Display == null)
                {
                    changes.Add("Added default area for map browse display");
                }
                else if (Compared.Map_Browse_Display == null)
                {
                    changes.Add("Removed default area information for map browse display");
                }
                else
                {
                    // Are these different?
                    bool different = false;
                    if (Base.Map_Browse_Display.Type != Compared.Map_Browse_Display.Type)
                    {
                        different = true;
                    }
                    else
                    {
                        if ((Base.Map_Browse_Display.ZoomLevel.HasValue != Compared.Map_Browse_Display.ZoomLevel.HasValue) ||
                            ((Base.Map_Browse_Display.ZoomLevel.HasValue) && (Base.Map_Browse_Display.ZoomLevel.Value != Compared.Map_Browse_Display.ZoomLevel.Value)))
                        {
                            different = true;
                        }
                        if ((Base.Map_Browse_Display.Latitude.HasValue != Compared.Map_Browse_Display.Latitude.HasValue) ||
                            ((Base.Map_Browse_Display.Latitude.HasValue) && (Base.Map_Browse_Display.Latitude.Value != Compared.Map_Browse_Display.Latitude.Value)))
                        {
                            different = true;
                        }
                        if ((Base.Map_Browse_Display.Longitude.HasValue != Compared.Map_Browse_Display.Longitude.HasValue) ||
                            ((Base.Map_Browse_Display.Longitude.HasValue) && (Base.Map_Browse_Display.Longitude.Value != Compared.Map_Browse_Display.Longitude.Value)))
                        {
                            different = true;
                        }
                    }

                    if (different)
                    {
                        changes.Add("Changed default area for map browse display");
                    }
                }
            }

            // facets
            List <Complete_Item_Aggregation_Metadata_Type> addedFacets   = new List <Complete_Item_Aggregation_Metadata_Type>();
            List <Complete_Item_Aggregation_Metadata_Type> removedFacets = new List <Complete_Item_Aggregation_Metadata_Type>();

            if (Base.Facets != null)
            {
                foreach (Complete_Item_Aggregation_Metadata_Type thisFacet in Base.Facets)
                {
                    // Look in compared for a match
                    if ((Compared.Facets == null) || (Compared.Facets.All(CompareFacet => thisFacet.ID != CompareFacet.ID)))
                    {
                        removedFacets.Add(thisFacet);
                    }
                }
            }
            if (Compared.Facets != null)
            {
                foreach (Complete_Item_Aggregation_Metadata_Type thisFacet in Compared.Facets)
                {
                    // Look in base for a match
                    if ((Base.Facets == null) || (Base.Facets.All(CompareFacet => thisFacet.ID != CompareFacet.ID)))
                    {
                        addedFacets.Add(thisFacet);
                    }
                }
            }
            if (removedFacets.Count > 0)
            {
                if (removedFacets.Count == 1)
                {
                    changes.Add("Removed facet " + removedFacets[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed facets " + removedFacets[0]);
                    for (int i = 1; i < removedFacets.Count; i++)
                    {
                        builder.Append(", " + removedFacets[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }
            if (addedFacets.Count > 0)
            {
                if (addedFacets.Count == 1)
                {
                    changes.Add("Added facet " + addedFacets[0]);
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added facets " + addedFacets[0]);
                    for (int i = 1; i < addedFacets.Count; i++)
                    {
                        builder.Append(", " + addedFacets[i]);
                    }
                    changes.Add(builder.ToString());
                }
            }

            // result views
            List <string> removedResultsDisplay = new List <string>();
            List <string> addedResultsDisplays  = new List <string>();

            if (Base.Result_Views != null)
            {
                foreach (string thisSearch in Base.Result_Views)
                {
                    // Look in compared for a match
                    if ((Compared.Result_Views == null) || (Compared.Result_Views.All(CompareSearch => thisSearch != CompareSearch)))
                    {
                        removedResultsDisplay.Add(thisSearch);
                    }
                }
            }
            if (Compared.Search_Types != null)
            {
                foreach (string thisSearch in Compared.Result_Views)
                {
                    // Look in base for a match
                    if ((Base.Result_Views == null) || (Base.Result_Views.All(CompareSearch => thisSearch != CompareSearch)))
                    {
                        addedResultsDisplays.Add(thisSearch);
                    }
                }
            }
            if (removedResultsDisplay.Count > 0)
            {
                if (removedResultsDisplay.Count == 1)
                {
                    changes.Add("Removed " + removedResultsDisplay[0].ToString() + " result display type");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Removed " + removedResultsDisplay[0]);
                    for (int i = 1; i < removedResultsDisplay.Count; i++)
                    {
                        builder.Append(", " + removedResultsDisplay[i]);
                    }
                    changes.Add(builder + " result display types");
                }
            }
            if (addedResultsDisplays.Count > 0)
            {
                if (addedResultsDisplays.Count == 1)
                {
                    changes.Add("Added " + addedResultsDisplays[0] + " result display type");
                }
                else
                {
                    StringBuilder builder = new StringBuilder("Added " + addedResultsDisplays[0]);
                    for (int i = 1; i < addedResultsDisplays.Count; i++)
                    {
                        builder.Append(", " + addedResultsDisplays[i]);
                    }
                    changes.Add(builder + " result display types");
                }
            }

            // default browse
            compare_nullable_strings(Base.Default_BrowseBy, Compared.Default_BrowseBy, "default browse", changes);

            // metadata browse


            // oai-pmh flag
            if (Base.OAI_Enabled != Compared.OAI_Enabled)
            {
                if (Compared.OAI_Enabled)
                {
                    changes.Add("OAI-PMH enabled");
                }
                else
                {
                    changes.Add("OAI-PMH disabled");
                }
            }

            // oai-pmh description
            compare_nullable_strings(Base.OAI_Metadata, Compared.OAI_Metadata, "additional OAI-PMH metadata", changes);

            // child pages


            return(changes);
        }