Save_To_File() public method

Saves all this data to a file
public Save_To_File ( string File ) : bool
File string Name (and path) of the file to save
return bool
        private void Save_Page_7_Postback(NameValueCollection Form)
        {
            string action = Form["admin_aggr_action"];
            if (!String.IsNullOrEmpty(action))
            {
                if ((action.IndexOf("delete_") == 0) && ( action.Length > 7 ))
                {
                    string code_to_delete = action.Substring(7);
                    itemAggregation.Remove_Child_Page(code_to_delete);

                    // Save to the admins session
                    HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation;
                }

                if (action == "save_childpage")
                {
                    childPageCode = Form["admin_aggr_code"];
                    childPageLabel = Form["admin_aggr_label"];
                    childPageVisibility = Form["admin_aggr_visibility"];
                    childPageParent = Form["admin_aggr_parent"];

                    // Convert to the integer id for the parent and begin to do checking
                    List<string> errors = new List<string>();

                    // Validate the code
                    if (childPageCode.Length > 20)
                    {
                        errors.Add("New child page code must be twenty characters long or less");
                    }
                    else if (childPageCode.Length == 0)
                    {
                        errors.Add("You must enter a CODE for this child page");

                    }
                    else if (UI_ApplicationCache_Gateway.Settings.Static.Reserved_Keywords.Contains(childPageCode.ToLower()))
                    {
                        errors.Add("That code is a system-reserved keyword.  Try a different code.");
                    }
                    else if (itemAggregation.Child_Page_By_Code(childPageCode.ToUpper()) != null)
                    {
                        errors.Add("New code must be unique... <i>" + childPageCode + "</i> already exists");
                    }

                    if (childPageLabel.Trim().Length == 0)
                        errors.Add("You must enter a LABEL for this child page");
                    if (childPageVisibility.Trim().Length == 0)
                        errors.Add("You must select a VISIBILITY for this child page");

                    if (errors.Count > 0)
                    {
                        // Create the error message
                        actionMessage = "ERROR: Invalid entry for new item child page<br />";
                        foreach (string error in errors)
                            actionMessage = actionMessage + "<br />" + error;
                    }
                    else
                    {
                        Complete_Item_Aggregation_Child_Page newPage = new Complete_Item_Aggregation_Child_Page { Code = childPageCode, Parent_Code = childPageParent, Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML };
                        newPage.Add_Label(childPageLabel, UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language);
                        switch (childPageVisibility)
                        {
                            case "none":
                                newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
                                newPage.Parent_Code = String.Empty;
                                break;

                            case "browse":
                                newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu;
                                break;

                            case "browseby":
                                newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                                newPage.Parent_Code = String.Empty;
                                break;
                        }
                        string html_source_dir = aggregationDirectory + "\\html\\browse";
                        if (!Directory.Exists(html_source_dir))
                            Directory.CreateDirectory(html_source_dir);
                        string html_source_file = html_source_dir + "\\" + childPageCode + "_" + Web_Language_Enum_Converter.Enum_To_Code(UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language) + ".html";
                        if (!File.Exists(html_source_file))
                        {
                            HTML_Based_Content htmlContent = new HTML_Based_Content
                            {
                                Content = "<br /><br />This is a new browse page.<br /><br />" + childPageLabel + "<br /><br />The code for this browse is: " + childPageCode,
                                Author = RequestSpecificValues.Current_User.Full_Name,
                                Date = DateTime.Now.ToLongDateString(),
                                Title = childPageLabel
                            };
                            htmlContent.Save_To_File(html_source_file);
                        }
                        newPage.Add_Static_HTML_Source("html\\browse\\" + childPageCode + "_" + Web_Language_Enum_Converter.Enum_To_Code(UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language) + ".html", UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language);

                        itemAggregation.Add_Child_Page(newPage);

                        // Save to the admins session
                        HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation;

                    }
                }
            }
        }
        private void Save_Child_Page_Postback(NameValueCollection Form)
        {
            string code = RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Substring(2);
            Complete_Item_Aggregation_Child_Page childPage = itemAggregation.Child_Page_By_Code(code);

            // Check for action flag
            string action = Form["admin_aggr_action"];
            if (action == "add_version")
            {
                try
                {
                    string language = Form["admin_aggr_new_version_lang"];
                    string title = Form["admin_aggr_new_version_label"];
                    string copyFrom = Form["admin_aggr_new_version_copy"];

                    string file = "html\\browse\\" + childPage.Code + "_" + language + ".html";
                    string fileDir = aggregationDirectory + "\\" + file;
                    Web_Language_Enum languageEnum = Web_Language_Enum_Converter.Code_To_Enum(language);

                    // Create the source file FIRST
                    string copyFromFull = aggregationDirectory + "\\" + copyFrom;
                    if ((copyFrom.Length > 0) && (File.Exists(copyFromFull)))
                    {
                        File.Copy(copyFromFull, fileDir, true );
                    }
                    else if ( !File.Exists(fileDir))
                    {
                        HTML_Based_Content htmlContent = new HTML_Based_Content
                        {
                            Content = "<br /><br />This is a new " + Web_Language_Enum_Converter.Enum_To_Name(languageEnum) + " browse page.<br /><br />" + title + "<br /><br />The code for this browse is: " + childPage.Code,
                            Author = RequestSpecificValues.Current_User.Full_Name,
                            Date = DateTime.Now.ToLongDateString(),
                            Title = title
                        };
                        htmlContent.Save_To_File(fileDir);
                    }

                    // Add to this child page
                    childPage.Add_Label(title, languageEnum);
                    childPage.Add_Static_HTML_Source(file, languageEnum);

                }
                catch
                {
                    actionMessage = "Error adding new version to this child page";
                }

            }
            else if ((action.IndexOf("delete_") == 0) && (action.Length > 7))
            {
                string delete_code = action.Substring(7);
                childPage.Remove_Language(Web_Language_Enum_Converter.Code_To_Enum(delete_code));

            }
            else
            {
                childPageVisibility = Form["admin_aggr_visibility"];
                childPage.Parent_Code = Form["admin_aggr_parent"];

                switch (childPageVisibility)
                {
                    case "none":
                        childPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
                        break;

                    case "browse":
                        childPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu;
                        break;

                    case "browseby":
                        childPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                        break;
                }
            }
        }