SobekCM.Core.Aggregations.Complete_Item_Aggregation.Home_Page_File C# (CSharp) Method

Home_Page_File() public method

Gets the home page source file for this aggregation, by language
If NO home page files were included in the aggregation XML, then this could be the empty string.
public Home_Page_File ( Web_Language_Enum Language ) : Complete_Item_Aggregation_Home_Page
Language Web_Language_Enum Language code
return Complete_Item_Aggregation_Home_Page
        public Complete_Item_Aggregation_Home_Page Home_Page_File(Web_Language_Enum Language)
        {
            if (Home_Page_File_Dictionary == null)
                return null;

            // Does this language exist in the home page file lookup dictionary?
            if (Home_Page_File_Dictionary.ContainsKey(Language))
            {
                return Home_Page_File_Dictionary[Language];
            }

            // Default to the system language then
            if (Home_Page_File_Dictionary.ContainsKey(defaultUiLanguage))
            {
                return Home_Page_File_Dictionary[defaultUiLanguage];
            }

            // Just return the first, assuming one exists
            return Home_Page_File_Dictionary.Count > 0 ? Home_Page_File_Dictionary.ElementAt(0).Value : null;
        }

Usage Example

        /// <summary> Method gets the HOME PAGE html for the appropriate UI settings </summary>
        /// <param name="CompAggr"> Complete item aggregation object </param>
        /// <param name = "Language"> Current language of the user interface </param>
        /// <param name = "Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>Home page HTML</returns>
        private static HTML_Based_Content Get_Home_HTML(Complete_Item_Aggregation CompAggr, Web_Language_Enum Language, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Home_HTML", "Reading home text source file");
            }

            string homeFileSource = "";
            // Get the home file source
            if(CompAggr.Home_Page_File(Language) != null)
               homeFileSource = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, CompAggr.ObjDirectory, CompAggr.Home_Page_File(Language).Source);

            // If no home file source even found, return a message to that affect
            if (homeFileSource.Length == 0)
            {
                return new HTML_Based_Content("<div class=\"error_div\">NO HOME PAGE SOURCE FILE FOUND</div>", null, homeFileSource);
            }

            // Do the rest in a try/catch
            try
            {
                // Does the file exist?
                if (!File.Exists(homeFileSource))
                {
                    return new HTML_Based_Content("<div class=\"error_div\">HOME PAGE SOURCE FILE '" + homeFileSource + "' DOES NOT EXIST.</div>", null, homeFileSource);
                }

                HTML_Based_Content content = HTML_Based_Content_Reader.Read_HTML_File(homeFileSource, true, Tracer);
                content.Source = homeFileSource;

                return content;
            }
            catch (Exception ee)
            {
                return new HTML_Based_Content("<div class=\"error_div\">EXCEPTION CAUGHT WHILE TRYING TO READ THE HOME PAGE SOURCE FILE '" + homeFileSource + "'.<br /><br />ERROR: " + ee.Message + "</div>", null, homeFileSource);
            }
        }
All Usage Examples Of SobekCM.Core.Aggregations.Complete_Item_Aggregation::Home_Page_File