/// <summary> Refreshes the specified instance-wide settings object from the data pulled from the database </summary> /// <param name="SettingsObject"> Instance-wide settings object to refresh </param> /// <param name="SobekCM_Settings"> Setting information, from the database, to read into the settings object </param> /// <returns> TRUE if successful, FALSE otherwise </returns> public static bool Refresh(InstanceWide_Settings SettingsObject, DataSet SobekCM_Settings) { // Set some values that used to be constants in the original settings object. // These are all canidates to be pushed into the database at some point SettingsObject.Static.Reserved_Keywords = new List <string> { "l", "my", "fragment", "json", "empty", "dataset", "dataprovider", "xml", "textonly", "shibboleth", "internal", "contact", "folder", "admin", "preferences", "stats", "statistics", "adminhelp", "partners", "tree", "brief", "personalized", "all", "new", "map", "advanced", "text", "results", "contains", "exact", "resultslike", "browseby", "info", "inprocess", "engine", "register", "xyzzyxyzzy", "aggrmanage", "aggrpermissions", "aggrhistory" }; SettingsObject.System.Page_Image_Extensions = new List <string> { "JPG", "JP2", "JPX", "GIF", "PNG", "BMP", "JPEG" }; SettingsObject.Resources.Backup_Files_Folder_Name = BACKUP_FILES_FOLDER_NAME; SettingsObject.Static.Current_Web_Version = CURRENT_WEB_VERSION; SettingsObject.Static.Current_Builder_Version = CURRENT_BUILDER_VERSION; SettingsObject.Builder.Complete_Package_Required_Aging = COMPLETE_PACKAGE_REQUIRED_AGING; SettingsObject.Builder.METS_Only_Package_Required_Aging = METS_ONLY_PACKAGE_REQUIRED_AGING; SettingsObject.Builder.VerifyCheckSum = VERIFY_CHECKSUM; SettingsObject.Search.Pull_Facets_On_Browse = true; SettingsObject.Search.Pull_Facets_On_Search = true; try { bool error = false; // Get the settings table DataTable settingsTable = SobekCM_Settings.Tables[0]; // Create the dictionary for quick lookups for the next work Dictionary <string, string> settingsDictionary = new Dictionary <string, string>(); foreach (DataRow thisRow in settingsTable.Rows) { settingsDictionary[thisRow["Setting_Key"].ToString()] = thisRow["Setting_Value"].ToString().Trim(); } // Pull all of the builder settings value ( from UFDC_Builder_Settings ) Get_String_Value(settingsDictionary, "Ace Editor Theme", SettingsObject.UI, X => X.Ace_Editor_Theme, ref error); Get_String_Value(settingsDictionary, "Application Server Network", SettingsObject.Servers, X => X.Application_Server_Network, ref error); Get_String_Value(settingsDictionary, "Application Server URL", SettingsObject.Servers, X => X.Application_Server_URL, ref error); Get_String_Value(settingsDictionary, "Archive DropBox", SettingsObject.Archive, X => X.Archive_DropBox, ref error); Get_Boolean_Value(settingsDictionary, "Builder Add PageTurner ItemViewer", SettingsObject.Builder, X => X.Add_PageTurner_ItemViewer, ref error, false); Get_String_Value(settingsDictionary, "Builder IIS Logs Directory", SettingsObject.Builder, X => X.IIS_Logs_Directory, ref error); Get_Integer_Value(settingsDictionary, "Builder Log Expiration in Days", SettingsObject.Builder, X => X.Log_Expiration_Days, ref error, 10); Get_Integer_Value(settingsDictionary, "Builder Seconds Between Polls", SettingsObject.Builder, X => X.Seconds_Between_Polls, ref error, 60); Get_Boolean_Value(settingsDictionary, "Builder Send Usage Emails", SettingsObject.Builder, X => X.Send_Usage_Emails, ref error, false); Get_Boolean_Value(settingsDictionary, "Builder Verbose Flag", SettingsObject.Builder, X => X.Verbose_Flag, ref error, false); Get_Boolean_Value(settingsDictionary, "Can Remove Single Search Term", SettingsObject.Search, X => X.Can_Remove_Single_Term, ref error, true); Get_Boolean_Value(settingsDictionary, "Can Submit Items Online", SettingsObject.Resources, X => X.Online_Item_Submit_Enabled, ref error, true); Get_Boolean_Value(settingsDictionary, "Convert Office Files to PDF", SettingsObject.Builder, X => X.Convert_Office_Files_To_PDF, ref error, false); Get_Boolean_Value(settingsDictionary, "Detailed User Permissions", SettingsObject.System, X => X.Detailed_User_Aggregation_Permissions, ref error, false); Get_Boolean_Value(settingsDictionary, "Disable Standard User Logon Flag", SettingsObject.System, X => X.Disable_Standard_User_Logon_Flag, ref error, false); Get_String_Value(settingsDictionary, "Disable Standard User Logon Message", SettingsObject.System, X => X.Disable_Standard_User_Logon_Message, ref error); Get_String_Value(settingsDictionary, "Document Solr Index URL", SettingsObject.Servers, X => X.Document_Solr_Index_URL, ref error); Get_String_Value(settingsDictionary, "Email Default From Address", SettingsObject.Email.Setup, X => X.DefaultFromAddress, ref error); Get_String_Value(settingsDictionary, "Email Default From Name", SettingsObject.Email.Setup, X => X.DefaultFromDisplay, ref error); Get_String_Value(settingsDictionary, "Email Method", SettingsObject.Email.Setup, X => X.MethodString, "DATABASE MAIL"); Get_Integer_Value(settingsDictionary, "Email SMTP Port", SettingsObject.Email.Setup, X => X.SmtpPort, ref error, 25); Get_String_Value(settingsDictionary, "Email SMTP Server", SettingsObject.Email.Setup, X => X.SmtpServer, ref error); Get_Boolean_Value(settingsDictionary, "Facets Collapsible", SettingsObject.Search, X => X.Facets_Collapsible, ref error, false); Get_String_Value(settingsDictionary, "FDA Report DropBox", SettingsObject.Florida, X => X.FDA_Report_DropBox, ref error); Get_String_Value(settingsDictionary, "Files To Exclude From Downloads", SettingsObject.Resources, X => X.Files_To_Exclude_From_Downloads, ref error); Get_String_Value(settingsDictionary, "Google Map API Key", SettingsObject.System, X => X.Google_Map_API_Key, ref error); Get_Boolean_Value(settingsDictionary, "Include Result Count In Text", SettingsObject.Search, X => X.Include_Result_Count_In_Search_Text, ref error, false); Get_String_Value(settingsDictionary, "Help URL", SettingsObject.System, X => X.Help_URL_Base, "http://sobekrepository.org/"); Get_String_Value(settingsDictionary, "Help Metadata URL", SettingsObject.System, X => X.Metadata_Help_URL_Base, "http://sobekrepository.org/"); Get_String_Value(settingsDictionary, "Image Server Network", SettingsObject.Servers, X => X.Image_Server_Network, ref error); //add by Keven for FIU dPanther's separate image server Get_String_Value(settingsDictionary, "Image Server Root", SettingsObject.Servers, X => X.Image_Server_Root, ref error); Get_String_Value(settingsDictionary, "Image Server URL", SettingsObject.Servers, X => X.Image_URL, ref error); Get_Boolean_Value(settingsDictionary, "Include TreeView On System Home", SettingsObject.System, X => X.Include_TreeView_On_System_Home, ref error, false); Get_Boolean_Value(settingsDictionary, "Include Partners On System Home", SettingsObject.System, X => X.Include_Partners_On_System_Home, ref error, false); Get_Integer_Value(settingsDictionary, "JPEG Height", SettingsObject.Resources, X => X.JPEG_Height, ref error, -1); Get_Integer_Value(settingsDictionary, "JPEG Width", SettingsObject.Resources, X => X.JPEG_Width, ref error, -1); Get_String_Value(settingsDictionary, "JPEG2000 Server", SettingsObject.Servers, X => X.JP2ServerUrl, ref error); Get_String_Value(settingsDictionary, "JPEG2000 Server Type", SettingsObject.Servers, X => X.JP2ServerType, ref error); //Get_String_Value(settingsDictionary, "Kakadu JPEG2000 Create Command", ref kakaduJp2CreateCommand, ref error); Get_String_Value(settingsDictionary, "Main Builder Input Folder", SettingsObject.Builder, X => X.Main_Builder_Input_Folder, String.Empty); Get_String_Value(settingsDictionary, "Mango Union Search Base URL", SettingsObject.Florida, X => X.Mango_Union_Search_Base_URL, ref error); Get_String_Value(settingsDictionary, "Mango Union Search Text", SettingsObject.Florida, X => X.Mango_Union_Search_Text, ref error); Get_String_Value(settingsDictionary, "OCR Engine Command", SettingsObject.Builder, X => X.OCR_Command_Prompt, String.Empty); Get_String_Value(settingsDictionary, "Page Solr Index URL", SettingsObject.Servers, X => X.Page_Solr_Index_URL, String.Empty); Get_String_Value(settingsDictionary, "PostArchive Files To Delete", SettingsObject.Archive, X => X.PostArchive_Files_To_Delete, String.Empty); Get_String_Value(settingsDictionary, "PreArchive Files To Delete", SettingsObject.Archive, X => X.PreArchive_Files_To_Delete, String.Empty); Get_String_Value(settingsDictionary, "Privacy Email Address", SettingsObject.Email, X => X.Privacy_Email, String.Empty); Get_String_Value(settingsDictionary, "Send Email On Added Aggregation", SettingsObject.Email, X => X.Send_On_Added_Aggregation, "Always"); Get_Boolean_Value(settingsDictionary, "Show Citation For Dark Items", SettingsObject.Resources, X => X.Show_Citation_For_Dark_Items, ref error, true); Get_String_Value(settingsDictionary, "SobekCM Image Server", SettingsObject.Servers, X => X.SobekCM_ImageServer, String.Empty); Get_String_Value(settingsDictionary, "SobekCM Web Server IP", SettingsObject.Servers, X => X.SobekCM_Web_Server_IP, String.Empty); Get_String_Value(settingsDictionary, "Static Pages Location", SettingsObject.Servers, X => X.Static_Pages_Location, ref error); Get_String_Value(settingsDictionary, "Static Resources Source", SettingsObject.Servers, X => X.Static_Resources_Config_File, "CDN"); Get_Boolean_Value(settingsDictionary, "Statistics Caching Enabled", SettingsObject.Servers, X => X.Statistics_Caching_Enabled, ref error, false); Get_String_Value(settingsDictionary, "System Base Abbreviation", SettingsObject.System, X => X.System_Abbreviation, String.Empty); Get_String_Value(settingsDictionary, "System Base Name", SettingsObject.System, X => X.System_Name, SettingsObject.System.System_Abbreviation); Get_String_Value(settingsDictionary, "System Base URL", SettingsObject.Servers, X => X.System_Base_URL, String.Empty); Get_String_Value(settingsDictionary, "System Email", SettingsObject.Email, X => X.System_Email, ref error); Get_String_Value(settingsDictionary, "System Error Email", SettingsObject.Email, X => X.System_Error_Email, String.Empty); Get_Integer_Value(settingsDictionary, "Thumbnail Height", SettingsObject.Resources, X => X.Thumbnail_Height, ref error, -1); Get_Integer_Value(settingsDictionary, "Thumbnail Width", SettingsObject.Resources, X => X.Thumbnail_Width, ref error, -1); Get_String_Value(settingsDictionary, "Upload File Types", SettingsObject.Resources, X => X.Upload_File_Types, ".aif,.aifc,.aiff,.au,.avi,.bz2,.c,.c++,.css,.dbf,.ddl,.doc,.docx,.dtd,.dvi,.flac,.gz,.htm,.html,.java,.jps,.js,.m4p,.mid,.midi,.mp2,.mp3,.mpg,.odp,.ogg,.pdf,.pgm,.ppt,.pptx,.ps,.ra,.ram,.rar,.rm,.rtf,.sgml,.swf,.sxi,.tbz2,.tgz,.wav,.wave,.wma,.wmv,.xls,.xlsx,.xml,.zip"); Get_String_Value(settingsDictionary, "Upload Image Types", SettingsObject.Resources, X => X.Upload_Image_Types, ".txt,.tif,.jpg,.jp2,.pro"); Get_String_Value(settingsDictionary, "Web In Process Submission Location", SettingsObject.Servers, X => X.In_Process_Submission_Location, String.Empty); Get_Integer_Value(settingsDictionary, "Web Output Caching Minutes", SettingsObject.Servers, X => X.Web_Output_Caching_Minutes, ref error, 0); // Load the subsetting object for MarcXML Marc21_Settings marcSettings = new Marc21_Settings(); Get_String_Value(settingsDictionary, "MarcXML Feed Location", marcSettings, X => X.MarcXML_Feed_Location, String.Empty); Get_Boolean_Value(settingsDictionary, "Create MARC Feed By Default", marcSettings, X => X.Build_MARC_Feed_By_Default, ref error, false); Get_String_Value(settingsDictionary, "MARC Cataloging Source Code", marcSettings, X => X.Cataloging_Source_Code, String.Empty); Get_String_Value(settingsDictionary, "MARC Location Code", marcSettings, X => X.Location_Code, String.Empty); Get_String_Value(settingsDictionary, "MARC Reproduction Agency", marcSettings, X => X.Reproduction_Agency, SettingsObject.System.System_Name); Get_String_Value(settingsDictionary, "MARC Reproduction Place", marcSettings, X => X.Reproduction_Place, String.Empty); Get_String_Value(settingsDictionary, "MARC XSLT File", marcSettings, X => X.XSLT_File, String.Empty); SettingsObject.MarcGeneration = marcSettings; // Pull the language last, since it must be converted into a Language_Enum Get_String_Value(settingsDictionary, "System Default Language", SettingsObject.System, X => X.Default_UI_Language_String, "English"); // Pull out some values, which are stored in this portion of the database, // but are not really setting values settingsDictionary.Remove("Builder Last Message"); settingsDictionary.Remove("Builder Last Run Finished"); settingsDictionary.Remove("Builder Version"); settingsDictionary.Remove("Builder Operation Flag"); // Save the remaining values SettingsObject.Additional_Settings.Clear(); foreach (KeyValuePair <string, string> thisSetting in settingsDictionary) { SettingsObject.Add_Additional_Setting(thisSetting.Key, thisSetting.Value); } // Save the metadata types Set_Metadata_Types(SettingsObject, SobekCM_Settings.Tables[1]); // Set the workflow and disposition options Set_Workflow_And_Disposition_Types(SettingsObject, SobekCM_Settings.Tables[2], SobekCM_Settings.Tables[3]); // This fills some dictionaries and such used for easy lookups SettingsObject.PostUnSerialization(); // Ensure the base directory ends correctly if ((!String.IsNullOrEmpty(SettingsObject.Servers.Application_Server_Network)) && (SettingsObject.Servers.Application_Server_Network[SettingsObject.Servers.Application_Server_Network.Length - 1] != '\\')) { SettingsObject.Servers.Application_Server_Network = SettingsObject.Servers.Application_Server_Network + "\\"; } // Also, load all the buidler information if (SettingsObject.Builder == null) { SettingsObject.Builder = new Builder_Settings(); } Builder_Settings_Builder.Refresh(SettingsObject.Builder, SobekCM_Settings, true, 4); // Finally, add all the item viewer config from the database if (SobekCM_Settings.Tables.Count >= 8) { // Get the data and add each viewer for each row foreach (DataRow thisRow in SobekCM_Settings.Tables[7].Rows) { // Pull the data out of the row int viewerId = Int32.Parse(thisRow[0].ToString()); string viewerType = thisRow[1].ToString(); int viewerOrder = Int32.Parse(thisRow[2].ToString()); bool viewerDefault = bool.Parse(thisRow[3].ToString()); decimal viewerMenuOrder = decimal.Parse(thisRow[4].ToString()); // Add the viewer SettingsObject.DbItemViewers.Add_ViewerType(viewerId, viewerType, viewerOrder, viewerDefault, viewerMenuOrder); } // Add all the extension information to the settings object SettingsObject.DbExtensions = Engine_Database.DataTable_to_Extensions(SobekCM_Settings.Tables[8]); } // If this is running in debug, set base directory to this one #if DEBUG string baseDir = System.Web.HttpContext.Current.Server.MapPath("~"); SettingsObject.Servers.Base_Directory = baseDir; SettingsObject.Servers.In_Process_Submission_Location = Path.Combine(baseDir, "mySobek", "InProcess"); #endif return(true); } catch { return(false); } }