コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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;
                }
            }
        }
コード例 #3
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;
                }
            }
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
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);
            }
        }
コード例 #9
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);
        }
コード例 #10
0
        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;
                    }
                }
            }
        }
コード例 #11
0
        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;
                    }
                }
            }
        }
コード例 #12
0
        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;
                }
            }
        }
コード例 #13
0
        /// <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;
                }
            }
        }
コード例 #14
0
        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;
                    }
                }
            }
        }
コード例 #15
0
        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;
                    }
                }
            }
        }