Add_Info_From_XML_File() public method

Reads the item aggregation configuration file and populates the new data into the item aggregation object
public Add_Info_From_XML_File ( Complete_Item_Aggregation HierarchyObject, string FileLocation ) : void
HierarchyObject SobekCM.Core.Aggregations.Complete_Item_Aggregation Item aggregation object to populate
FileLocation string Full name of the item aggregation configuration XML file
return void
        /// <summary> Gets a fully built item aggregation object for a particular aggregation code   </summary>
        /// <param name="AggregationCode">Code for this aggregation object</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>Fully built item aggregation object for the particular aggregation code and language code</returns>
        /// <remarks>Item aggregation object is also placed in the cache.<br /><br />
        /// Building of an item aggregation always starts by pulling the item from the database ( either <see cref="Engine_Database.Get_Item_Aggregation"/> or <see cref="Engine_Database.Get_Main_Aggregation"/> ).<br /><br />
        /// Then, either the Item Aggregation XML file is read (if present) or the entire folder hierarchy is analyzed to find the browses, infos, banners, etc..</remarks>
        public static Complete_Item_Aggregation Get_Complete_Item_Aggregation(string AggregationCode, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Creating '" + AggregationCode + "' item aggregation");
            }

            // Get the information about this collection and this entry point
            Complete_Item_Aggregation hierarchyObject;
            if ((AggregationCode.Length > 0) && (AggregationCode != "all"))
                hierarchyObject = Engine_Database.Get_Item_Aggregation(AggregationCode, false, Tracer);
            else
                hierarchyObject = Engine_Database.Get_Main_Aggregation(Tracer);

            // If no value was returned, don't do anything else here
            if (hierarchyObject != null)
            {
                // Add all the values to this object
                string xmlDataFile = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory + "\\" + hierarchyObject.Code + ".xml";
                if (File.Exists(xmlDataFile))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Reading aggregation XML configuration file");
                    }

                    // Add the ALL and NEW browses
                    Add_All_New_Browses(hierarchyObject);

                    // Add all the other data from the XML file
                    Item_Aggregation_XML_Reader reader = new Item_Aggregation_XML_Reader();
                    reader.Add_Info_From_XML_File(hierarchyObject, xmlDataFile);
                }
                else
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Aggregation XML configuration file missing.. will try to build");

                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Adding banner, home, and all/new browse information");
                    }

                    Add_HTML(hierarchyObject);
                    Add_All_New_Browses(hierarchyObject);
                    Add_Browse_Files(hierarchyObject, Tracer);

                    // If no HTML found, just add one
                    if ((hierarchyObject.Home_Page_File_Dictionary == null) || (hierarchyObject.Home_Page_File_Dictionary.Count == 0))
                    {
                        hierarchyObject.Add_Home_Page_File("html\\home\\text.html", Web_Language_Enum.DEFAULT, false);
                    }

                    // If no banner found, just add one
                    if ((hierarchyObject.Banner_Dictionary == null) || (hierarchyObject.Banner_Dictionary.Count == 0))
                    {
                        hierarchyObject.Add_Banner_Image("images/banners/coll.jpg", Web_Language_Enum.DEFAULT);
                    }

                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Write aggregation XML configuration from built object");
                    }

                    // Since there was no configuration file, save one
                    hierarchyObject.Write_Configuration_File(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory);
                }

                // Now, look for any satellite configuration files
                string contactFormFile = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory + "\\config\\sobekcm_contactform.config";
                if (File.Exists(contactFormFile))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Found aggregation-specific contact form configuration file");
                    }

                    hierarchyObject.ContactForm = ContactForm_Configuration_Reader.Read_Config(contactFormFile);
                }

                // Return this built hierarchy object
                return hierarchyObject;
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "NULL value returned from database");
            }
            return null;
        }
        /// <summary> Gets a fully built item aggregation object for a particular aggregation code   </summary>
        /// <param name="AggregationCode">Code for this aggregation object</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>Fully built item aggregation object for the particular aggregation code and language code</returns>
        /// <remarks>Item aggregation object is also placed in the cache.<br /><br />
        /// Building of an item aggregation always starts by pulling the item from the database ( either <see cref="Engine_Database.Get_Item_Aggregation"/> or <see cref="Engine_Database.Get_Main_Aggregation"/> ).<br /><br />
        /// Then, either the Item Aggregation XML file is read (if present) or the entire folder hierarchy is analyzed to find the browses, infos, banners, etc..</remarks>
        public static Complete_Item_Aggregation Get_Complete_Item_Aggregation(string AggregationCode, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Creating '" + AggregationCode + "' item aggregation");
            }

            // Get the information about this collection and this entry point
            Complete_Item_Aggregation hierarchyObject;

            if ((AggregationCode.Length > 0) && (AggregationCode != "all"))
            {
                hierarchyObject = Engine_Database.Get_Item_Aggregation(AggregationCode, false, Tracer);
            }
            else
            {
                hierarchyObject = Engine_Database.Get_Main_Aggregation(Tracer);
            }

            // If no value was returned, don't do anything else here
            if (hierarchyObject != null)
            {
                // Add all the values to this object
                string xmlDataFile = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory + "\\" + hierarchyObject.Code + ".xml";
                if (File.Exists(xmlDataFile))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Reading aggregation XML configuration file");
                    }

                    // Add the ALL and NEW browses
                    Add_All_New_Browses(hierarchyObject);

                    // Add all the other data from the XML file
                    Item_Aggregation_XML_Reader reader = new Item_Aggregation_XML_Reader();
                    reader.Add_Info_From_XML_File(hierarchyObject, xmlDataFile);
                }
                else
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Aggregation XML configuration file missing.. will try to build");

                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Adding banner, home, and all/new browse information");
                    }

                    Add_HTML(hierarchyObject);
                    Add_All_New_Browses(hierarchyObject);
                    Add_Browse_Files(hierarchyObject, Tracer);

                    // If no HTML found, just add one
                    if ((hierarchyObject.Home_Page_File_Dictionary == null) || (hierarchyObject.Home_Page_File_Dictionary.Count == 0))
                    {
                        hierarchyObject.Add_Home_Page_File("html\\home\\text.html", Web_Language_Enum.DEFAULT, false);
                    }

                    // If no banner found, just add one
                    if ((hierarchyObject.Banner_Dictionary == null) || (hierarchyObject.Banner_Dictionary.Count == 0))
                    {
                        hierarchyObject.Add_Banner_Image("images/banners/coll.jpg", Web_Language_Enum.DEFAULT);
                    }

                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Write aggregation XML configuration from built object");
                    }

                    // Since there was no configuration file, save one
                    hierarchyObject.Write_Configuration_File(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory);
                }

                // Now, look for any satellite configuration files
                string contactFormFile = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + hierarchyObject.ObjDirectory + "\\config\\sobekcm_contactform.config";
                if (File.Exists(contactFormFile))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Found aggregation-specific contact form configuration file");
                    }

                    hierarchyObject.ContactForm = ContactForm_Configuration_Reader.Read_Config(contactFormFile);
                }

                // Return this built hierarchy object
                return(hierarchyObject);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "NULL value returned from database");
            }
            return(null);
        }