public void ReCreate_Aggregation_Level_Pages(List <string> AggregationsAffected, InstanceWide_Settings Settings, long UpdateID) { // Determine, and create the local work space string localWorkArea = Path.Combine(MultiInstance_Builder_Settings.Builder_Executable_Directory, "temp"); try { if (!Directory.Exists(localWorkArea)) { Directory.CreateDirectory(localWorkArea); } } catch { OnError("Error creating the temporary work area in BuildAggregationBrowsesModule: " + localWorkArea, UpdateID); return; } // Build the primary URL string primaryUrl = Settings.Servers.Application_Server_URL; if (String.IsNullOrEmpty(primaryUrl)) { OnError("Primary system URL is not set", UpdateID); return; } if (primaryUrl[primaryUrl.Length - 1] != '/') { primaryUrl = primaryUrl + "/"; } // Create the new statics page builder // IN THIS CASE, WE DO NEED TO SET THE SINGLETON, SINCE THIS CALLS THE LIBRARIES Engine_ApplicationCache_Gateway.Settings = Settings; // Static_Pages_Builder staticBuilder = new Static_Pages_Builder(Settings.Servers.Application_Server_URL, Settings.Servers.Static_Pages_Location, Settings.Servers.Application_Server_Network); try { // Step through each aggregation with new items foreach (string thisAggrCode in AggregationsAffected) { // Some aggregations can be excluded if ((thisAggrCode != "ALL") && (thisAggrCode.Length > 1)) { // Get the display aggregation code (lower leading 'i') string display_code = thisAggrCode; if (display_code[0] == 'I') { display_code = 'i' + display_code.Substring(1); } // Get this item aggregations Complete_Item_Aggregation aggregationCompleteObj = Engine_Database.Get_Item_Aggregation(thisAggrCode, false, null); Item_Aggregation aggregationObj = Item_Aggregation_Utilities.Get_Item_Aggregation(aggregationCompleteObj, Settings.System.Default_UI_Language, null); // Get the list of items for this aggregation DataSet aggregation_items = Engine_Database.Simple_Item_List(thisAggrCode, null); // Create the XML list for this aggregation OnProcess("........Building XML item list for " + display_code, UpdateID); try { string aggregation_list_file = Settings.Servers.Static_Pages_Location + "\\" + thisAggrCode.ToLower() + ".xml"; if (File.Exists(aggregation_list_file)) { File.Delete(aggregation_list_file); } aggregation_items.WriteXml(aggregation_list_file, XmlWriteMode.WriteSchema); } catch (Exception ee) { OnError("........Error in building XML list for " + display_code + " on " + Settings.Servers.Static_Pages_Location + "\n" + ee.Message, UpdateID); } OnProcess("........Building RSS feed for " + display_code, UpdateID); try { if (Create_RSS_Feed(thisAggrCode.ToLower(), localWorkArea, aggregationObj.Name, aggregation_items, primaryUrl)) { try { // Copy the two generated RSS files over to the server File.Copy(Path.Combine(localWorkArea, thisAggrCode.ToLower() + "_rss.xml"), Path.Combine(Settings.Servers.Static_Pages_Location, "rss", thisAggrCode.ToLower() + "_rss.xml"), true); File.Copy(Path.Combine(localWorkArea, thisAggrCode.ToLower() + "_short_rss.xml"), Path.Combine(Settings.Servers.Static_Pages_Location, "rss", thisAggrCode.ToLower() + "_short_rss.xml"), true); // Delete the temporary files as well File.Delete(Path.Combine(localWorkArea, thisAggrCode.ToLower() + "_rss.xml")); File.Delete(Path.Combine(localWorkArea, thisAggrCode.ToLower() + "_short_rss.xml")); } catch (Exception ee) { OnError("........Error in copying RSS feed for " + display_code + " to " + Settings.Servers.Static_Pages_Location + "\n" + ee.Message, UpdateID); } } } catch (Exception ee) { OnError("........Error in building RSS feed for " + display_code + "\n" + ee.Message, UpdateID); } OnProcess("........Building static HTML browse page of links for " + display_code, UpdateID); try { string destinationFile = Path.Combine(localWorkArea, thisAggrCode.ToLower() + "_all.html"); if (Build_All_Browse(aggregationObj, aggregation_items, destinationFile, primaryUrl, UpdateID)) { try { File.Copy(destinationFile, Path.Combine(Settings.Servers.Static_Pages_Location, thisAggrCode.ToLower() + "_all.html"), true); } catch (Exception ee) { OnError("........Error in copying HTML browse for " + display_code + " to " + Settings.Servers.Static_Pages_Location + "\n" + ee.Message, UpdateID); } } } catch (Exception ee) { OnError("........Error in building HTML browse for " + display_code + "\n" + ee.Message, UpdateID); } } } // Build the full instance-wide XML and RSS here as well Recreate_Library_XML_and_RSS(UpdateID, Settings, localWorkArea, primaryUrl); } catch (Exception ee) { OnError("Exception caught in BuildAggregationBrowsesModule", UpdateID); OnError(ee.Message, UpdateID); OnError(ee.StackTrace, UpdateID); } }
/// <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); }