Beispiel #1
0
        static void Main(string[] args)
        {
            // Collect the list of directories to look for and read all .xml files
            List <string> directories = new List <string>();

            // Add the default configuration directory first
            directories.Add(@"C:\GitRepository\SobekCM-Web-Application\SobekCM\config\default");

            // Add all of the plug-in foldersm but ensure they are sorted
            string plug_in_folder = @"C:\GitRepository\SobekCM-Web-Application\SobekCM\plugins";

            if (Directory.Exists(plug_in_folder))
            {
                // Get the list of subdirectories
                string[] subdirs = Directory.GetDirectories(plug_in_folder);

                // Ensure it is sorted alphabetically
                SortedList <string, string> subdirs_sorted = new SortedList <string, string>();
                foreach (string thisSubDir in subdirs)
                {
                    // Get the directory name and add to the sorted list
                    string dirName = (new DirectoryInfo(thisSubDir)).Name;
                    subdirs_sorted.Add(dirName, thisSubDir);
                }

                // Now, add each folder correctly sorted
                foreach (string thisSubDir in subdirs_sorted.Values)
                {
                    directories.Add(thisSubDir);
                    if (Directory.Exists(Path.Combine(thisSubDir, "config")))
                    {
                        directories.Add(Path.Combine(thisSubDir, "config"));
                    }
                }
            }

            // Add the final user configuration directory last
            directories.Add(@"C:\GitRepository\SobekCM-Web-Application\SobekCM\config\user");

            InstanceWide_Settings settings = new InstanceWide_Settings();

            // Read the configuration files
            InstanceWide_Configuration config = SobekCM.Engine_Library.Configuration.Configuration_Files_Reader.Read_Config_Files(directories, settings);

            StringBuilder XmlSb     = new StringBuilder();
            TextWriter    writerXml = new StringWriter(XmlSb);

            // Write out the config file
            XmlSerializer x = new XmlSerializer(config.GetType());

            x.Serialize(writerXml, config);

            StreamWriter writer = new StreamWriter("output.xml", false);

            writer.Write(XmlSb);
            writer.Flush();
            writer.Close();

            Console.ReadLine();
        }
        /// <summary> Processes any incoming FDA (Florida Dark Archive) reports, saves the data to the database, and archives the report in the resource folder </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // Step through each incoming folder and look for FDA reports
            if ((!String.IsNullOrEmpty(Settings.Florida.FDA_Report_DropBox)) && (Directory.Exists(Settings.Florida.FDA_Report_DropBox)))
            {
                // Create the FDA process
                FDA_Report_Processor fdaProcessor = new FDA_Report_Processor();

                // Process all pending FDA reports
                fdaProcessor.Process(Settings.Florida.FDA_Report_DropBox);

                // Log successes and failures
                if ((fdaProcessor.Error_Count > 0) || (fdaProcessor.Success_Count > 0))
                {
                    // Clear any previous report
                    Engine_Database.Builder_Clear_Item_Error_Log("FDA REPORT", "", "SobekCM Builder");

                    if (fdaProcessor.Error_Count > 0)
                    {
                        OnError("Processed " + fdaProcessor.Success_Count + " FDA reports with " + fdaProcessor.Error_Count + " errors", String.Empty, String.Empty, -1);
                    }
                    else
                    {
                        OnProcess("Processed " + fdaProcessor.Success_Count + " FDA reports", "Standard", String.Empty, String.Empty, -1);
                    }
                }
            }
        }
        /// <summary> Clears the old logs that are ready to be expired, per instance-wide settings </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // Clear the old logs
            OnProcess("ExpireOldLogEntriesModule : Expiring old log entries", "Standard", null, null, -1);

            // Clear the logs
            Engine_Database.Builder_Expire_Log_Entries(Settings.Builder.Log_Expiration_Days);
        }
        /// <summary> Saves all the metadata types from the database, to be treated as constant settings
        /// for the period of time the web application functios </summary>
        /// <param name="SettingsObject"> Settings instance to be populated with the metadata types </param>
        /// <param name="MetadataTypesTable"> DataTable with all the possible metadata types, from the database </param>
        public static void Set_Metadata_Types(InstanceWide_Settings SettingsObject, DataTable MetadataTypesTable)
        {
            SettingsObject.Metadata_Search_Fields.Clear();

            // Add ANYWHERE
            SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-1, String.Empty, "Anywhere", "ZZ", "all", "Anywhere"));

            // Add OCLC
            SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-2, String.Empty, "OCLC", "OC", "oclc", "OCLC"));


            // Add ALEPH
            SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-3, String.Empty, "ALEPH", "AL", "aleph", "ALEPH"));

            // Add Full Text
            SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-4, String.Empty, "Full Text", "TX", "fulltext", "Full Text"));


            // Get the data columns
            DataColumn idColumn      = MetadataTypesTable.Columns["MetadataTypeID"];
            DataColumn codeColumn    = MetadataTypesTable.Columns["SobekCode"];
            DataColumn displayColumn = MetadataTypesTable.Columns["DisplayTerm"];
            DataColumn facetColumn   = MetadataTypesTable.Columns["FacetTerm"];
            DataColumn solrColumn    = MetadataTypesTable.Columns["SolrCode"];
            DataColumn nameColumn    = MetadataTypesTable.Columns["MetadataName"];

            // Now add the rest of the fields
            foreach (DataRow thisRow in MetadataTypesTable.Rows)
            {
                // Only add here if there is a sobek code
                if (thisRow[codeColumn] == DBNull.Value)
                {
                    continue;
                }

                // Retrieve each individual value
                short  id      = Convert.ToInt16(thisRow[idColumn]);
                string code    = thisRow[codeColumn].ToString().Trim();
                string display = thisRow[displayColumn].ToString();
                string facet   = thisRow[facetColumn].ToString();
                string solr    = thisRow[solrColumn].ToString();
                string name    = thisRow[nameColumn].ToString();

                // Also, only continue if the name is NOT user defined
                if (name.IndexOf("UserDefined", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    continue;
                }

                // Create the new field object
                Metadata_Search_Field newField = new Metadata_Search_Field(id, facet, display, code, solr, name);

                // Add this to the collections
                SettingsObject.Metadata_Search_Fields.Add(newField);
            }
        }
        private void Recreate_Library_XML_and_RSS(long Builderid, InstanceWide_Settings Settings, string WorkSpaceDirectory, string PrimaryUrl)
        {
            // Update the RSS Feeds and Item Lists for ALL
            // Build the simple XML result for this build
            OnProcess("........Building XML list for all digital resources", Builderid);
            try
            {
                DataSet simple_list = Engine_Database.Simple_Item_List(String.Empty, null);
                if (simple_list != null)
                {
                    try
                    {
                        string aggregation_list_file = Settings.Servers.Static_Pages_Location + "\\all.xml";
                        if (File.Exists(aggregation_list_file))
                        {
                            File.Delete(aggregation_list_file);
                        }
                        simple_list.WriteXml(aggregation_list_file, XmlWriteMode.WriteSchema);
                    }
                    catch (Exception ee)
                    {
                        OnError("........Error in building XML list for all digital resources on " + Settings.Servers.Static_Pages_Location + "\n" + ee.Message, Builderid);
                    }
                }
            }
            catch (Exception ee)
            {
                OnError("........Error in building XML list for all digital resources\n" + ee.Message, Builderid);
            }

            // Create the RSS feed for all ufdc items
            try
            {
                OnProcess("........Building RSS feed for all digital resources", Builderid);
                DataSet complete_list = Engine_Database.Simple_Item_List(String.Empty, null);

                Create_RSS_Feed("all", WorkSpaceDirectory, "All Items", complete_list, PrimaryUrl);
                try
                {
                    File.Copy(Path.Combine(WorkSpaceDirectory, "all_rss.xml"), Path.Combine(Settings.Servers.Static_Pages_Location, "rss", "all_rss.xml"), true);
                    File.Copy(Path.Combine(WorkSpaceDirectory, "all_short_rss.xml"), Path.Combine(Settings.Servers.Static_Pages_Location, "rss", "all_short_rss.xml"), true);
                }
                catch (Exception ee)
                {
                    OnError("........Error in copying RSS feed for all digital resources to " + Settings.Servers.Static_Pages_Location + "\n" + ee.Message, Builderid);
                }
            }
            catch (Exception ee)
            {
                OnError("........Error in building RSS feed for all digital resources\n" + ee.Message, Builderid);
            }
        }
        /// <summary> Refreshes the values from the database settings </summary>
        /// <returns> A fully builder instance-wide setting object </returns>
        public static InstanceWide_Settings Build_Settings(Database_Instance_Configuration DbInstance)
        {
            InstanceWide_Settings returnValue = new InstanceWide_Settings();

            // Don't read the configuration file now.. we already have the db data
            Engine_Database.Connection_String = DbInstance.Connection_String;

            DataSet sobekCMSettings = Engine_Database.Get_Settings_Complete(false, null);

            if (sobekCMSettings == null)
            {
                return(null);
            }

            Refresh(returnValue, sobekCMSettings);

            return(returnValue);
        }
        /// <summary> Saves the possible workflow types and disposition values from the database, to be treated as constant settings
        /// for the period of time the web application functions </summary>
        /// <param name="SettingsObject"> Settings instance to be populated with the metadata types </param>
        /// <param name="WorkflowTable"> DataTable with all the possible workflow types, from the database </param>
        /// <param name="DispositionTypeTable"> DataTable with all the possible disposition types, from the database </param>
        public static void Set_Workflow_And_Disposition_Types(InstanceWide_Settings SettingsObject, DataTable WorkflowTable, DataTable DispositionTypeTable)
        {
            foreach (DataRow thisRow in DispositionTypeTable.Rows)
            {
                int    id     = Convert.ToInt32(thisRow["DispositionID"]);
                string future = thisRow["DispositionFuture"].ToString();
                string past   = thisRow["DispositionPast"].ToString();

                Disposition_Option newOption = new Disposition_Option(id, past, future);
                SettingsObject.Disposition_Options.Add(newOption);
            }

            foreach (DataRow thisRow in WorkflowTable.Rows)
            {
                int    id       = Convert.ToInt32(thisRow["WorkFlowID"]);
                string workflow = thisRow["WorkFlowName"].ToString();

                Workflow_Type newWorkFlow = new Workflow_Type(id, workflow);
                SettingsObject.Workflow_Types.Add(newWorkFlow);
            }
        }
Beispiel #8
0
        /// <summary> Saves the MarcXML file, used for creating MARC feeds, for this incoming digital resource </summary>
        /// <param name="CollectionCodes"> Collection codes to include in the resultant MarcXML file </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public bool Save_MARC_XML(DataTable CollectionCodes, InstanceWide_Settings Settings)
        {
            try
            {
                // Set the image location
                Metadata.Web.Image_Root = Settings.Servers.Image_URL + Metadata.Web.File_Root.Replace("\\", "/");
                Metadata.Web.Set_BibID_VID(Metadata.BibID, Metadata.VID);


                List <string> collectionnames = new List <string>();
                // Get the collection names
                if ((Metadata.Behaviors.Aggregation_Count > 0) && (CollectionCodes != null))
                {
                    collectionnames.AddRange(from aggregation in Metadata.Behaviors.Aggregations select aggregation.Code into altCollection select CollectionCodes.Select("collectioncode = '" + altCollection + "'") into altCode where altCode.Length > 0 select altCode[0]["ShortName"].ToString());
                }

                // Create the options dictionary used when saving information to the database, or writing MarcXML
                Dictionary <string, object> options = new Dictionary <string, object>();
                if (Settings.MarcGeneration != null)
                {
                    options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"] = Settings.MarcGeneration.Cataloging_Source_Code;
                    options["MarcXML_File_ReaderWriter:MARC Location Code"]          = Settings.MarcGeneration.Location_Code;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"]    = Settings.MarcGeneration.Reproduction_Agency;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Place"]     = Settings.MarcGeneration.Reproduction_Place;
                    options["MarcXML_File_ReaderWriter:MARC XSLT File"] = Settings.MarcGeneration.XSLT_File;
                }
                options["MarcXML_File_ReaderWriter:System Name"]         = Settings.System.System_Name;
                options["MarcXML_File_ReaderWriter:System Abbreviation"] = Settings.System.System_Abbreviation;

                // Save the marc xml file
                MarcXML_File_ReaderWriter marcWriter = new MarcXML_File_ReaderWriter();
                string errorMessage;
                return(marcWriter.Write_Metadata(Metadata.Source_Directory + "\\marc.xml", Metadata, options, out errorMessage));
            }
            catch
            {
                return(false);
            }
        }
        /// <summary> Refreshes the values from the database settings </summary>
        /// <returns> A fully builder instance-wide setting object </returns>
        public static InstanceWide_Settings Build_Settings(string ConfigFileLocation)
        {
            InstanceWide_Settings returnValue = new InstanceWide_Settings();

            // Read the main configuration file, with database and error information
            // returnValue.Servers.Base_Directory = AppDomain.CurrentDomain.BaseDirectory;
            Read_Configuration_File(returnValue, ConfigFileLocation);

            // Set the error URL
            UrlWriterHelper.Unhandled_Error_URL = returnValue.Servers.System_Error_URL;

            // Set the connection string to the database
            Engine_Database.Connection_String       = returnValue.Database_Connection.Connection_String;
            SobekCM_Item_Database.Connection_String = returnValue.Database_Connection.Connection_String;

            // Get the settings
            DataSet sobekCMSettings = Engine_Database.Get_Settings_Complete(false, null);

            Refresh(returnValue, sobekCMSettings);

            return(returnValue);
        }
Beispiel #10
0
 /// <summary> Optimizes the solr/lucene indexes for this instance </summary>
 /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
 public override void DoWork(InstanceWide_Settings Settings)
 {
     //// Initiate a solr/lucene index optimization since we are done loading for a while
     //if (DateTime.Now.Day % 2 == 0)
     //{
     //	if (InstanceWide_Settings_Singleton.Settings.Document_Solr_Index_URL.Length > 0)
     //	{
     //		Console.WriteLine("Initiating Solr/Lucene document index optimization");
     //		Solr_Controller.Optimize_Document_Index(InstanceWide_Settings_Singleton.Settings.Document_Solr_Index_URL);
     //	}
     //}
     //else
     //{
     //	if (InstanceWide_Settings_Singleton.Settings.Page_Solr_Index_URL.Length > 0)
     //	{
     //		Console.WriteLine("Initiating Solr/Lucene page index optimization");
     //		Solr_Controller.Optimize_Page_Index(InstanceWide_Settings_Singleton.Settings.Page_Solr_Index_URL);
     //	}
     //}
     //// Sleep for twenty minutes to end this (the index rebuild might take some time)
     //Thread.Sleep(1000 * 20 * 60);
 }
        /// <summary> Refresh the settings object by pulling the data back from the database </summary>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public static bool RefreshSettings(Database_Instance_Configuration DbInstance)
        {
            try
            {
                lock (settingsLock)
                {
                    if (settings == null)
                    {
                        settings = InstanceWide_Settings_Builder.Build_Settings(DbInstance);
                    }
                    else
                    {
                        InstanceWide_Settings newSettings = InstanceWide_Settings_Builder.Build_Settings(DbInstance);
                        settings = newSettings;
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary> Refresh the settings object by pulling the data back from the database </summary>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public static bool RefreshSettings()
        {
            try
            {
                lock (settingsLock)
                {
                    if (settings == null)
                    {
                        settings = InstanceWide_Settings_Builder.Build_Settings();
                    }
                    else
                    {
                        InstanceWide_Settings newSettings = InstanceWide_Settings_Builder.Build_Settings();
                        settings = newSettings;
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #13
0
 /// <summary> Method performs the work of the post-process builder module </summary>
 /// <param name="AggregationsAffected"> List of aggregations affected during the last process of incoming digital resources </param>
 /// <param name="ProcessedItems"> List of all items just processed (or reprocessed) </param>
 /// <param name="DeletedItems"> List of all delete requests just processed </param>
 /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
 public abstract void DoWork(List <string> AggregationsAffected, List <BibVidStruct> ProcessedItems, List <BibVidStruct> DeletedItems, InstanceWide_Settings Settings);
Beispiel #14
0
        /// <summary> Builds the static aggregation-level (and instance-level) browse and RSS feed files </summary>
        /// <param name="AggregationsAffected"> List of aggregations affected during the last process of incoming digital resources </param>
        /// <param name="ProcessedItems"> List of all items just processed (or reprocessed) </param>
        /// <param name="DeletedItems"> List of all delete requests just processed </param>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(List <string> AggregationsAffected, List <BibVidStruct> ProcessedItems, List <BibVidStruct> DeletedItems, InstanceWide_Settings Settings)
        {
            // If no aggregations were affected, skip out
            if (AggregationsAffected.Count == 0)
            {
                return;
            }

            // Add the primary log entry
            long updatedId = OnProcess("....Performing some aggregation update functions", "Aggregation Updates", String.Empty, String.Empty, -1);

            // Create the (new) helper class
            Aggregation_Static_Page_Writer staticWriter = new Aggregation_Static_Page_Writer();

            staticWriter.Process += staticWriter_Process;
            staticWriter.Error   += staticWriter_Error;

            // IN THIS CASE, WE DO NEED TO SET THE SINGLETON, SINCE THIS CALLS THE LIBRARIES
            //Engine_ApplicationCache_Gateway.Settings = Settings;

            // Build the aggregation browses
            staticWriter.ReCreate_Aggregation_Level_Pages(AggregationsAffected, Settings, updatedId);
        }
Beispiel #15
0
 /// <summary> Method releases all resources </summary>
 public virtual void ReleaseResources()
 {
     Settings = null;
 }
        /// <summary> Rebuilds the static browse pages for the instance and aggregations </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // Add the primary log entry
            long updatedId = OnProcess("RebuildAllAggregationBrowsesModule:Performing some aggregation update functions", "Aggregation Updates", String.Empty, String.Empty, -1);

            // Create a list of all the collection codes
            DataTable allCollections = Engine_Database.Get_Codes_Item_Aggregations(null);
            DataView  collectionView = new DataView(allCollections)
            {
                Sort = "Name ASC"
            };
            List <string> allCodes = new List <string>();

            foreach (DataRowView collectionRow in collectionView)
            {
                bool hidden = bool.Parse(collectionRow["Hidden"].ToString());
                bool active = bool.Parse(collectionRow["isActive"].ToString());

                if ((!hidden) && (active))
                {
                    allCodes.Add(collectionRow["Code"].ToString().ToLower());
                }
            }

            // Create the (new) helper class
            Aggregation_Static_Page_Writer staticWriter = new Aggregation_Static_Page_Writer();

            staticWriter.Process += staticWriter_Process;
            staticWriter.Error   += staticWriter_Error;

            // IN THIS CASE, WE DO NEED TO SET THE SINGLETON, SINCE THIS CALLS THE LIBRARIES
            //Engine_ApplicationCache_Gateway.Settings = Settings;

            // Build the aggregation browses
            staticWriter.ReCreate_Aggregation_Level_Pages(allCodes, Settings, updatedId);

            // Build the primary URL
            string primaryUrl = Settings.Servers.Application_Server_URL;

            if (String.IsNullOrEmpty(primaryUrl))
            {
                OnError("Primary system URL is not set", null, null, updatedId);
                return;
            }
            if (primaryUrl[primaryUrl.Length - 1] != '/')
            {
                primaryUrl = primaryUrl + "/";
            }

            // Find the data source
            string staticSobekcmDataLocation = Settings.Servers.Base_Data_Directory;

            OnProcess("Creating sitemaps and top-level link pages", "Aggregation Updates", String.Empty, String.Empty, updatedId);


            // Build the sitemap for all the collections
            StreamWriter sitemap_writer = new StreamWriter(Path.Combine(staticSobekcmDataLocation, "sitemap_collections.xml"), false);

            sitemap_writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            sitemap_writer.WriteLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
            sitemap_writer.WriteLine("\t<url>");
            sitemap_writer.WriteLine("\t\t<loc>" + primaryUrl + "</loc>");
            sitemap_writer.WriteLine("\t</url>");

            // Prepare to build all the links to static pages
            StringBuilder static_browse_links     = new StringBuilder();
            StringBuilder recent_rss_link_builder = new StringBuilder();
            StringBuilder all_rss_link_builder    = new StringBuilder();
            int           col = 2;

            foreach (DataRowView collectionRow in collectionView)
            {
                // If hidden or in active, skip this
                bool hidden = bool.Parse(collectionRow["Hidden"].ToString());
                bool active = bool.Parse(collectionRow["isActive"].ToString());
                if ((hidden) || (!active))
                {
                    continue;
                }

                string code = collectionRow["Code"].ToString().ToLower();

                // Add this to the sitemap
                sitemap_writer.WriteLine("\t<url>");
                sitemap_writer.WriteLine("\t\t<loc>" + primaryUrl + code + "</loc>");
                sitemap_writer.WriteLine("\t</url>");

                // build the HTML section for the page that links to all the collections
                if (File.Exists(Path.Combine(staticSobekcmDataLocation, code + "_all.html")))
                {
                    static_browse_links.Append("<td><a href=\"" + code + "_all.html\">" + code + "</a></td>" + Environment.NewLine);
                    col++;
                    if (col > 5)
                    {
                        static_browse_links.Append("</tr>" + Environment.NewLine + "<tr>");
                        col = 1;
                    }
                }

                // Also, we will link to each collections' rss feed
                if (File.Exists(Path.Combine(staticSobekcmDataLocation, "rss", code + "_rss.xml")))
                {
                    recent_rss_link_builder.Append("<img src=\"http://cdn.sobekrepository.org/images/misc/16px-Feed-icon.svg.png\" alt=\"RSS\" width=\"16\" height=\"16\">&nbsp;<a href=\"" + primaryUrl + "rss/" + code + "_short_rss.xml\">" + collectionRow["Name"] + "</a><br />" + Environment.NewLine);
                    all_rss_link_builder.Append("<img src=\"http://cdn.sobekrepository.org/images/misc/16px-Feed-icon.svg.png\" alt=\"RSS\" width=\"16\" height=\"16\">&nbsp;<a href=\"" + primaryUrl + "rss/" + code + "_rss.xml\">" + collectionRow["Name"] + "</a><br />" + Environment.NewLine);
                }
            }

            // Finish out the collection sitemap
            sitemap_writer.WriteLine("</urlset>");
            sitemap_writer.Flush();
            sitemap_writer.Close();

            // Build the indiviual site maps
            int sitemaps = staticWriter.Build_Site_Maps(staticSobekcmDataLocation, primaryUrl);

            // Create the sitemaps collection index
            StreamWriter sitemap_collections_writer = new StreamWriter(Path.Combine(staticSobekcmDataLocation, "sitemaps.xml"), false);

            sitemap_collections_writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            sitemap_collections_writer.WriteLine("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
            string current_date = DateTime.Now.Year + "-" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "-" + DateTime.Now.Day.ToString().PadLeft(2, '0');

            sitemap_collections_writer.WriteLine("  <sitemap>");
            sitemap_collections_writer.WriteLine("    <loc>" + primaryUrl + "data/sitemap_collections.xml</loc>");
            sitemap_collections_writer.WriteLine("    <lastmod>" + current_date + "</lastmod>");
            sitemap_collections_writer.WriteLine("  </sitemap>");
            for (int i = 1; i <= sitemaps; i++)
            {
                sitemap_collections_writer.WriteLine("  <sitemap>");
                sitemap_collections_writer.WriteLine("    <loc>" + primaryUrl + "data/sitemap" + i + ".xml</loc>");
                sitemap_collections_writer.WriteLine("    <lastmod>" + current_date + "</lastmod>");
                sitemap_collections_writer.WriteLine("  </sitemap>");
            }
            sitemap_collections_writer.WriteLine("</sitemapindex>");
            sitemap_collections_writer.Flush();
            sitemap_collections_writer.Close();

            // Get the top-level html windows
            const string TOKEN = "<div id=\"empty\"></div>";

            // Try to get the collection empty page
            string empty_page_source;

            try
            {
                using (WebClient client = new WebClient())
                {
                    string empty_page = primaryUrl + "empty";
                    empty_page_source = client.DownloadString(empty_page);
                }
            }
            catch (Exception ee)
            {
                OnError("RebuildAllAggregationBrowsesModule:Unable to pull the top-level empty page", null, null, updatedId);
                return;
            }

            // Ensure this has length and has the token to replace
            if ((String.IsNullOrEmpty(empty_page_source)) || (empty_page_source.IndexOf(TOKEN) < 0))
            {
                OnError("RebuildAllAggregationBrowsesModule:Top-level empty page content is invalid", null, null, updatedId);
                return;
            }

            // Build the main HTML page linking to all RSS feeds
            OnProcess("Building HTML page with links to all the RSS feeds", "Aggregation Updates", null, null, updatedId);
            using (StreamWriter main_rss_writer = new StreamWriter(Path.Combine(staticSobekcmDataLocation, "rss", "index.htm"), false))
            {
                StringBuilder main_rss_builder = new StringBuilder(2000);
                main_rss_builder.AppendLine("<div id=\"pagecontainer\">");
                main_rss_builder.AppendLine("<div class=\"SobekText\" role=\"main\" id=\"main-content\">");
                main_rss_builder.AppendLine("<h1><strong>RSS Feeds for the " + Settings.System.System_Name + "</strong></h1>");
                main_rss_builder.AppendLine();

                main_rss_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_rss_builder.AppendLine("  <p>This page provides links to RSS feeds for items within " + Settings.System.System_Name + ".  The first group of RSS feeds below contains the last 20 items added to the collection.  The second group of items contains links to every item in a collection.  These rss feeds can grow quite lengthy and the load time is often non-trivial.</p>");
                main_rss_builder.AppendLine("  <p>In addition, the following three RSS feeds are provided:</p>");
                main_rss_builder.AppendLine("  <blockquote>");
                main_rss_builder.AppendLine("    <img src=\"http://cdn.sobekrepository.org/images/misc/16px-Feed-icon.svg.png\" alt=\"RSS\" width=\"16\" height=\"16\">&nbsp;<a href=\"" + primaryUrl + "rss/all_rss.xml\">All items in " + Settings.System.System_Abbreviation + "</a><br />");
                main_rss_builder.AppendLine("    <img src=\"http://cdn.sobekrepository.org/images/misc/16px-Feed-icon.svg.png\" alt=\"RSS\" width=\"16\" height=\"16\">&nbsp;<a href=\"" + primaryUrl + "rss/all_short_rss.xml\">Most recently added items in " + Settings.System.System_Abbreviation + " (last 100)</a><br />");
                main_rss_builder.AppendLine("  </blockquote>");
                main_rss_builder.AppendLine("  <p>RSS feeds are a way to keep up-to-date on new materials that are added to the Digital Collections. RSS feeds are written in XML    and require a news reader to access.</p>");
                main_rss_builder.AppendLine("  <p>You can download and install a <a href=\"http://dmoz.org/Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/RSS/News_Readers/\">news reader</a>.  Or, you can use a Web-based reader such as <a href=\"http://www.google.com/reader\">Google Reader </a>or <a href=\"http://my.yahoo.com/\">My Yahoo!</a>.</p>");
                main_rss_builder.AppendLine("  <p>Follow the instructions in your reader to subscribe to the feed of   your choice. You will usually need to copy and paste the feed URL into the reader. </p>");
                main_rss_builder.AppendLine("</div>");
                main_rss_builder.AppendLine();
                main_rss_builder.AppendLine("<h2>Most Recent Items (By Collection)</h2>");
                main_rss_builder.AppendLine();
                main_rss_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_rss_builder.AppendLine("  <blockquote>");
                main_rss_builder.AppendLine(recent_rss_link_builder.ToString());
                main_rss_builder.AppendLine("  </blockquote>");
                main_rss_builder.AppendLine("</div>");

                main_rss_builder.AppendLine("<h2>All Items (By Collection)</h2>");

                main_rss_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_rss_builder.AppendLine("  <blockquote>");
                main_rss_builder.AppendLine(all_rss_link_builder.ToString());
                main_rss_builder.AppendLine("  </blockquote>");
                main_rss_builder.AppendLine("</div>");

                main_rss_builder.AppendLine("</div>");
                main_rss_builder.AppendLine("</div>");

                // Now, use this to replace the token
                main_rss_writer.WriteLine(empty_page_source.Replace(TOKEN, main_rss_builder.ToString()));

                main_rss_writer.Flush();
                main_rss_writer.Close();
            }

            // Create the HTML page with links to the sitemap pages
            OnProcess("Building HTML page with links to all the sitemaps", "Aggregation Updates", null, null, updatedId);
            using (StreamWriter main_html_sitemap_writer = new StreamWriter(Path.Combine(staticSobekcmDataLocation, "sitemaps.htm"), false))
            {
                StringBuilder main_html_subwriter_builder = new StringBuilder(2000);
                main_html_subwriter_builder.AppendLine("<div id=\"pagecontainer\">");
                main_html_subwriter_builder.AppendLine("<div class=\"SobekText\" role=\"main\" id=\"main-content\">");
                main_html_subwriter_builder.AppendLine("<h1><strong>Sitemaps for the " + Settings.System.System_Name + "</strong></h1>");
                main_html_subwriter_builder.AppendLine();


                main_html_subwriter_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_html_subwriter_builder.AppendLine("  <p>This page provides links to all the sitemaps with links for " + Settings.System.System_Name + ".</p>");
                main_html_subwriter_builder.AppendLine("  <p>Sitemaps are a primary source of links to index for search engines.  Inclusion of your collections materials in these sitemaps facilitates indexing by search engines and ensures your material will be included in searches from Google, Bing, etc.. </p>");
                main_html_subwriter_builder.AppendLine("  <br />");
                main_html_subwriter_builder.AppendLine("</div>");
                main_html_subwriter_builder.AppendLine();
                main_html_subwriter_builder.AppendLine("<h2>Sitemap Collection</h2>");
                main_html_subwriter_builder.AppendLine();
                main_html_subwriter_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_html_subwriter_builder.AppendLine("  <p>This is a sitemap which includes links to all the other sitemaps in your digital repository.  This is generally the sitemap that should be referenced in your robots.txt file.</p>");
                main_html_subwriter_builder.AppendLine("  <blockquote>");
                main_html_subwriter_builder.AppendLine("    <a href=\"" + primaryUrl + "data/sitemaps.xml\">Collection of all sitemaps</a><br />");
                main_html_subwriter_builder.AppendLine("  </blockquote>");
                main_html_subwriter_builder.AppendLine("</div>");
                main_html_subwriter_builder.AppendLine();

                main_html_subwriter_builder.AppendLine("<h2>Individual Sitemaps</h2>");
                main_html_subwriter_builder.AppendLine();
                main_html_subwriter_builder.AppendLine("<div class=\"SobekHomeText\">");
                main_html_subwriter_builder.AppendLine("  <p>These sitemaps link to your individual collections and digital resources.  Sitemaps are generally limited to 30,000 links each, so you may have many sitemaps linked to your individual digital resources.</p>");
                main_html_subwriter_builder.AppendLine("  <blockquote>");
                main_html_subwriter_builder.AppendLine("  <a href=\"" + primaryUrl + "data/sitemap_collections.xml\">Sitemap pointing to all the collections</a><br />");

                for (int i = 1; i <= sitemaps; i++)
                {
                    main_html_subwriter_builder.AppendLine("  <a href=\"" + primaryUrl + "data/sitemap" + i + ".xml\">Sitemap #" + i + "</a><br />");
                }

                main_html_subwriter_builder.AppendLine("  </blockquote>");
                main_html_subwriter_builder.AppendLine("</div>");
                main_html_subwriter_builder.AppendLine();

                main_html_subwriter_builder.AppendLine("</div>");
                main_html_subwriter_builder.AppendLine("</div>");

                // Now, use this to replace the token
                main_html_sitemap_writer.WriteLine(empty_page_source.Replace(TOKEN, main_html_subwriter_builder.ToString()));

                main_html_sitemap_writer.Flush();
                main_html_sitemap_writer.Close();
            }
        }
        /// <summary> Reads the inficated configuration file </summary>
        /// <param name="SettingsObject"> Settings instance to be populated with the metadata types </param>
        /// <param name="ConfigFile"> Configuration file to read </param>
        /// <exception>File is checked for existence first, otherwise all encountered exceptions will be thrown</exception>
        public static void Read_Configuration_File(InstanceWide_Settings SettingsObject, string ConfigFile)
        {
            if (!File.Exists(ConfigFile))
            {
                return;
            }

            SettingsObject.Database_Connection = null;

            StreamReader  reader    = new StreamReader(ConfigFile);
            XmlTextReader xmlReader = new XmlTextReader(reader);

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element)
                {
                    string node_name = xmlReader.Name.ToLower();
                    switch (node_name)
                    {
                    case "connection_string":
                        Database_Instance_Configuration newDb = new Database_Instance_Configuration();
                        if (xmlReader.MoveToAttribute("type"))
                        {
                            if (xmlReader.Value.ToLower() == "postgresql")
                            {
                                newDb.Database_Type = EalDbTypeEnum.PostgreSQL;
                            }
                        }
                        if (xmlReader.MoveToAttribute("isHosted"))
                        {
                            if (xmlReader.Value.ToLower() == "true")
                            {
                                SettingsObject.Servers.isHosted = true;
                            }
                        }

                        xmlReader.Read();
                        newDb.Connection_String            = xmlReader.Value;
                        SettingsObject.Database_Connection = newDb;
                        break;

                    case "erroremails":
                        xmlReader.Read();
                        SettingsObject.Email.System_Error_Email = xmlReader.Value;
                        break;

                    case "errorpage":
                        xmlReader.Read();
                        SettingsObject.Servers.System_Error_URL = xmlReader.Value;
                        break;

                    case "ghostscript_executable":
                        xmlReader.Read();
                        SettingsObject.Builder.Ghostscript_Executable = xmlReader.Value;
                        break;

                    case "imagemagick_executable":
                        xmlReader.Read();
                        SettingsObject.Builder.ImageMagick_Executable = xmlReader.Value;
                        break;

                    case "pause_between_polls":
                        xmlReader.Read();
                        int testValue;
                        if (Int32.TryParse(xmlReader.Value, out testValue))
                        {
                            SettingsObject.Builder.Override_Seconds_Between_Polls = testValue;
                        }
                        break;
                    }
                }
            }

            xmlReader.Close();
            reader.Close();
        }
        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);
            }
        }
Beispiel #19
0
 /// <summary> Method performs the work of the pre-process builder module </summary>
 /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
 public abstract void DoWork(InstanceWide_Settings Settings);
        /// <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);
            }
        }
Beispiel #21
0
        /// <summary> Checks to see if there are web logs that need to be processed to the usage statistics </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // If there is no IIS web log set, then do nothing.  Don't even need a log here.
            if (String.IsNullOrEmpty(Settings.Builder.IIS_Logs_Directory))
            {
                return;
            }

            // Just don't run the first day of the month - ensures logs still not being written
            if (DateTime.Now.Day < 2)
            {
                return;
            }

            // Ensure directory exists and is accessible
            string log_directory = Settings.Builder.IIS_Logs_Directory;

            try
            {
                if (!Directory.Exists(log_directory))
                {
                    OnError("CalculateUsageStatisticsModule : IIS web log directory ( " + log_directory + " ) does not exists or is inaccessible", null, null, -1);
                    return;
                }
            }
            catch (Exception ee)
            {
                OnError("CalculateUsageStatisticsModule : IIS web log directory ( " + log_directory + " ) does not exists or is inaccessible : " + ee.Message, null, null, -1);
                return;
            }

            // Get the temporary workspace directory, and ensure it exists
            string temporary_workspace = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Temporary", "CalculateUsageStatisticsModule");

            try
            {
                if (!Directory.Exists(temporary_workspace))
                {
                    Directory.CreateDirectory(temporary_workspace);
                }
            }
            catch (Exception ee)
            {
                OnError("CalculateUsageStatisticsModule : Unable to create the temporary workspace ( " + temporary_workspace + " ) : " + ee.Message, null, null, -1);
                return;
            }

            // Clear the temporary workspace
            try
            {
                string[] files = Directory.GetFiles(temporary_workspace);
                foreach (string thisFile in files)
                {
                    File.Delete(thisFile);
                }
            }
            catch (Exception ee)
            {
                OnError("CalculateUsageStatisticsModule : Error caught clearing existing files from the temporary workspace ( " + temporary_workspace + " ) : " + ee.Message, null, null, -1);
                return;
            }


            // Get (and double check) the web directory
            if (String.IsNullOrEmpty(Settings.Servers.Application_Server_Network))
            {
                OnError("CalculateUsageStatisticsModule : No application server network setting!  Correct ASAP!", null, null, -1);
                return;
            }

            // Ensure directory exists and is accessible
            string sobekcm_directory = Settings.Servers.Application_Server_Network;

            try
            {
                if (!Directory.Exists(sobekcm_directory))
                {
                    OnError("CalculateUsageStatisticsModule : Web application server network directory ( " + sobekcm_directory + " ) does not exists or is inaccessible", null, null, -1);
                    return;
                }
            }
            catch (Exception ee)
            {
                OnError("CalculateUsageStatisticsModule : Web application server network  ( " + sobekcm_directory + " ) does not exists or is inaccessible : " + ee.Message, null, null, -1);
                return;
            }

            // Determine which year/months already have been analyzed for this instance
            Statistics_Dates statsDates = new Statistics_Dates();

            if (Engine_ApplicationCache_Gateway.Stats_Date_Range != null)
            {
                Engine_Database.Populate_Statistics_Dates(statsDates, null);
            }
            else
            {
                statsDates = Engine_ApplicationCache_Gateway.Stats_Date_Range;
            }

            // Get the list of all IIS web logs
            string[] log_files = Directory.GetFiles(log_directory, "u_ex*.log");

            // If no log files, just return
            if (log_files.Length == 0)
            {
                OnError("CalculateUsageStatisticsModule : No IIS web logs found in directory  ( " + log_directory + " )", null, null, -1);
                return;
            }

            // Get the earliest and latest log files from the IIS web logs
            string earliest = "ZZZZZZZZ";
            string latest   = "AAAAAAAA";

            foreach (string thisFile in log_files)
            {
                string thisFileName = Path.GetFileNameWithoutExtension(thisFile);
                if (String.Compare(thisFileName, earliest, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    earliest = thisFileName;
                }
                if (String.Compare(thisFileName, latest, StringComparison.OrdinalIgnoreCase) > 0)
                {
                    latest = thisFileName;
                }
            }

            // Parse them to determine the earliest and latest year/months
            int earliest_year;
            int earliest_month;
            int latest_year;
            int latest_month;

            try
            {
                earliest_year  = 2000 + Int32.Parse(earliest.Substring(4, 2));
                earliest_month = Int32.Parse(earliest.Substring(6, 2));
                latest_year    = 2000 + Int32.Parse(latest.Substring(4, 2));
                latest_month   = Int32.Parse(latest.Substring(6, 2));
            }
            catch (Exception)
            {
                OnError("CalculateUsageStatisticsModule : Error parsing the earliest or latest log for year/month (" + earliest + " or " + latest + " )", null, null, -1);
                return;
            }



            // Determine what years/months are missing
            List <string> year_month = new List <string>();

            if (statsDates.Earliest_Year == 2000)
            {
                // No stats every collected, so collect them all
                int curr_year  = earliest_year;
                int curr_month = earliest_month;
                while ((curr_year < latest_year) || ((curr_year == latest_year) && (curr_month <= latest_month)))
                {
                    if ((curr_year == DateTime.Now.Year) && (curr_month == DateTime.Now.Month))
                    {
                        break;
                    }

                    year_month.Add(curr_year + curr_month.ToString().PadLeft(2, '0'));

                    curr_month++;
                    if (curr_month > 12)
                    {
                        curr_year++;
                        curr_month = 1;
                    }
                }
            }
            else
            {
                // No stats every collected, so collect them all
                int curr_year  = earliest_year;
                int curr_month = earliest_month;
                while ((curr_year < latest_year) || ((curr_year == latest_year) && (curr_month <= latest_month)))
                {
                    if ((curr_year == DateTime.Now.Year) && (curr_month == DateTime.Now.Month))
                    {
                        break;
                    }

                    if ((curr_year > statsDates.Latest_Year) || ((curr_year == statsDates.Latest_Year) && (curr_month > statsDates.Latest_Month)))
                    {
                        year_month.Add(curr_year + curr_month.ToString().PadLeft(2, '0'));
                    }

                    curr_month++;
                    if (curr_month > 12)
                    {
                        curr_year++;
                        curr_month = 1;
                    }
                }
            }

            // If no year/months were added , then no work to do
            if (year_month.Count == 0)
            {
                return;
            }

            // Create the processor
            SobekCM_Stats_Reader_Processor processor = new SobekCM_Stats_Reader_Processor(log_directory, temporary_workspace, sobekcm_directory, year_month);

            processor.New_Status += processor_New_Status;

            // Create the thread
            processor.Process_IIS_Logs();

            // Delete the cached file, if one exists
            try
            {
                string temp_directory = Path.Combine(Settings.Servers.Application_Server_Network, "temp");
                if (Directory.Exists(temp_directory))
                {
                    string cache_xml_file = Path.Combine(temp_directory, "overall_usage.xml");
                    if (File.Exists(cache_xml_file))
                    {
                        File.Delete(cache_xml_file);
                    }
                }
            }
            catch { }

            // Shoudl emails be sent?
            if (Settings.Builder.Send_Usage_Emails)
            {
                // Load the text
                string possible_email_body_dir = Path.Combine(Settings.Servers.Application_Server_Network, "design", "extra", "stats");
                Usage_Stats_Email_Helper.Set_Email_Body(Path.Combine(possible_email_body_dir, "stats_email_body.txt"));

                // Send emails for each year/month (in order)
                foreach (string thisYearMonth in year_month)
                {
                    int year  = Convert.ToInt32(thisYearMonth.Substring(0, 4));
                    int month = Convert.ToInt32(thisYearMonth.Substring(4, 2));

                    Send_Usage_Emails(year, month, Settings.Servers.System_Base_URL, Settings.System.System_Name, Settings.Email.Setup.DefaultFromAddress, Settings.Email.Setup.DefaultFromDisplay);
                }
            }
        }
Beispiel #22
0
        /// <summary> Saves this item to the SobekCM database </summary>
        /// <param name="NewItem"> Flag indicates this is an entirely new item </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public bool Save_to_Database(bool NewItem, InstanceWide_Settings Settings)
        {
            if (Metadata == null)
            {
                return(false);
            }

            try
            {
                // save the bib package to the SobekCM database
                bool     existed    = !NewItem;
                DateTime createTime = packageTime;

                // Create the options dictionary used when saving information to the database, or writing MarcXML
                Dictionary <string, object> options = new Dictionary <string, object>();
                if (Settings.MarcGeneration != null)
                {
                    options["MarcXML_File_ReaderWriter:MARC Cataloging Source Code"] = Settings.MarcGeneration.Cataloging_Source_Code;
                    options["MarcXML_File_ReaderWriter:MARC Location Code"]          = Settings.MarcGeneration.Location_Code;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Agency"]    = Settings.MarcGeneration.Reproduction_Agency;
                    options["MarcXML_File_ReaderWriter:MARC Reproduction Place"]     = Settings.MarcGeneration.Reproduction_Place;
                    options["MarcXML_File_ReaderWriter:MARC XSLT File"] = Settings.MarcGeneration.XSLT_File;
                }
                options["MarcXML_File_ReaderWriter:System Name"]         = Settings.System.System_Name;
                options["MarcXML_File_ReaderWriter:System Abbreviation"] = Settings.System.System_Abbreviation;

                // Set the file root again
                Metadata.Web.File_Root = fileRoot;
                SobekCM_Item_Database.Save_Digital_Resource(Metadata, options, createTime, existed);

                // Save the behaviors if this is a new item
                if (!existed)
                {
                    // Some work here just in case the METS is missing stuff, or has old data

                    // Make sure not set to UFDC as only web skin by default (used to list UFDC on all METS files )
                    if ((Metadata.Behaviors.Web_Skin_Count == 1) && (Metadata.Behaviors.Web_Skins[0].ToUpper().Trim() == "UFDC"))
                    {
                        Metadata.Behaviors.Clear_Web_Skins();
                    }

                    // Now, save the behaviors for this item
                    SobekCM_Item_Database.Save_Behaviors(Metadata, Metadata.Behaviors.Text_Searchable, false, false);
                }
                else
                {
                    // Now, save the MINIMAL behaviors for this item
                    SobekCM_Item_Database.Save_Behaviors(Metadata, Metadata.Behaviors.Text_Searchable, false, true);
                }

                //// Set the suppress endeca flag
                //if ((New_Item) && (!bibPackage.Behaviors.Suppress_Endeca))
                //{
                //    SobekCM.Library.Database.SobekCM_Database.Set_Endeca_Flag(bibPackage.BibID, bibPackage.Behaviors.Suppress_Endeca);
                //}
                return(true);
            }
            catch (Exception ee)
            {
                return(false);
            }
        }
Beispiel #23
0
 /// <summary> Updates the database-based cached aggregation browse information </summary>
 /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
 public override void DoWork(InstanceWide_Settings Settings)
 {
     Engine_Database.Admin_Update_Cached_Aggregation_Metadata_Links();
 }
Beispiel #24
0
        /// <summary> Looks in the aggregation design folders for tiles and pulls the metadata for each
        /// tile to enable the hover-over in the aggregation tile display </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // Get the spot where the aggregations sit
            string aggregation_base = Path.Combine(Settings.Servers.Base_Design_Location, "aggregations");

            // Ensure it exists before continuing
            if (!Directory.Exists(aggregation_base))
            {
                return;
            }

            // Step through each aggregation folder
            string[] aggregation_folders = Directory.GetDirectories(aggregation_base);
            foreach (string thisAggrFolder in aggregation_folders)
            {
                // Find the associated aggregation tiles folder
                string tile_folder = Path.Combine(thisAggrFolder, "images", "tiles");

                // Skip this aggregation if it doesn't exist
                if (!Directory.Exists(tile_folder))
                {
                    continue;
                }

                // Get JPEG images
                string[] tile_images = Directory.GetFiles(tile_folder, "*.jpg");

                // Skip this aggregation if no images exist
                if (tile_images.Length == 0)
                {
                    continue;
                }

                // Step through each image, collecting the bibs and vids
                List <string> bibs = new List <string>();
                List <string> vids = new List <string>();
                foreach (string thisTile in tile_images)
                {
                    string thisFileNameSansExtension = Path.GetFileNameWithoutExtension(thisTile);
                    if ((thisFileNameSansExtension.Length == 10) && (SobekCM_Item.is_bibid_format(thisFileNameSansExtension)))
                    {
                        bibs.Add(thisFileNameSansExtension);
                        vids.Add("00001");
                    }
                    else if ((thisFileNameSansExtension.Length == 15) && (SobekCM_Item.is_bibid_format(thisFileNameSansExtension.Substring(0, 10))) && (SobekCM_Item.is_vids_format(thisFileNameSansExtension.Substring(10))))
                    {
                        bibs.Add(thisFileNameSansExtension.Substring(0, 10));
                        vids.Add(thisFileNameSansExtension.Substring(10));
                    }
                    else if ((thisFileNameSansExtension.Length == 16) && (SobekCM_Item.is_bibid_format(thisFileNameSansExtension.Substring(0, 10))) && (SobekCM_Item.is_vids_format(thisFileNameSansExtension.Substring(11))))
                    {
                        bibs.Add(thisFileNameSansExtension.Substring(0, 10));
                        vids.Add(thisFileNameSansExtension.Substring(11));
                    }
                }

                // Skip if no valid bib/vid names were found
                if (bibs.Count == 0)
                {
                    continue;
                }

                // Now, look up each of these bib/vids

                // First, pad the lists correctly
                while (bibs.Count % 10 != 0)
                {
                    bibs.Add(String.Empty);
                    vids.Add(String.Empty);
                }

                // Get the aggregation code
                string aggrCode = Path.GetFileName(thisAggrFolder);

                // FOR TESTING DON'T USE COLLECTION CODE
                aggrCode = "";

                // Start the results object
                Database_Results_Info allResults = new Database_Results_Info();

                // Now, get the results
                int offset = 0;
                while (offset < bibs.Count)
                {
                    //Get the results from the database
                    Database_Results_Info results = Engine_Library.Database.Engine_Database.Metadata_By_Bib_Vid(aggrCode, bibs[offset + 0], vids[offset + 0], bibs[offset + 1], vids[offset + 1],
                                                                                                                bibs[offset + 2], vids[offset + 2], bibs[offset + 3], vids[offset + 3],
                                                                                                                bibs[offset + 4], vids[offset + 4], bibs[offset + 5], vids[offset + 5],
                                                                                                                bibs[offset + 6], vids[offset + 6], bibs[offset + 7], vids[offset + 7],
                                                                                                                bibs[offset + 8], vids[offset + 8], bibs[offset + 9], vids[offset + 9], null);

                    // Combine into full results
                    if ((results != null) && (results.Metadata_Labels != null) && (results.Metadata_Labels.Count > 0))
                    {
                        allResults.Metadata_Labels = results.Metadata_Labels;
                    }

                    if ((results != null) && (results.Results != null) && (results.Results.Count > 0))
                    {
                        allResults.Results.AddRange(results.Results);
                    }

                    offset += 10;
                }


                // Save these results
                string       cached_results_file = Path.Combine(tile_folder, "tile_metadata.xml");
                StreamWriter writer = new StreamWriter(cached_results_file, false);

                XmlSerializer x = new XmlSerializer(allResults.GetType());
                x.Serialize(writer, allResults);
            }
        }
        /// <summary> Moves all packages from the inbound folder into the processing folder
        /// to queue them for loading into the library  </summary>
        /// <param name="Message"> Message to be passed out if something occurred during this attempted move </param>
        /// <returns> TRUE if successful, or FALSE if an error occurs </returns>
        public bool Move_From_Inbound_To_Processing(InstanceWide_Settings Settings, out string Message)
        {
            Message = String.Empty;

            // Get the directories
            string inboundFolder = Inbound_Folder;

            // Make sure the inbound directory exists
            if (!Directory.Exists(inboundFolder))
            {
                try
                {
                    Directory.CreateDirectory(inboundFolder);
                }
                catch
                {
                    Message = "Unable to create the non-existent inbound folder " + inboundFolder;
                    return(false);
                }
            }

            // Make sure the processing directory exists
            if (!Directory.Exists(Processing_Folder))
            {
                try
                {
                    Directory.CreateDirectory(Processing_Folder);
                }
                catch
                {
                    Message = "Unable to create the non-existent processing folder " + Processing_Folder;
                    return(false);
                }
            }

            // Make sure the failures directory exists
            if (!Directory.Exists(Failures_Folder))
            {
                try
                {
                    Directory.CreateDirectory(Failures_Folder);
                }
                catch
                {
                    Message = "Unable to create the non-existent failures folder " + Failures_Folder;
                    return(false);
                }
            }

            // If there are loose METS here, move them into flat folders of the same name
            try
            {
                string[] looseMets = SobekCM_File_Utilities.GetFiles(inboundFolder, "*.mets*|*.xml");
                foreach (string thisLooseMetsXml in looseMets)
                {
                    string filename         = Path.GetFileName(thisLooseMetsXml);
                    string filenameSplitter = Path.GetFileNameWithoutExtension(thisLooseMetsXml);
                    if (!Directory.Exists(inboundFolder + "\\" + filenameSplitter))
                    {
                        Directory.CreateDirectory(inboundFolder + "\\" + filenameSplitter);
                    }
                    if (File.Exists(inboundFolder + "\\" + filenameSplitter + "\\" + filename))
                    {
                        File.Delete(thisLooseMetsXml);
                    }
                    else
                    {
                        File.Move(thisLooseMetsXml, inboundFolder + "\\" + filenameSplitter + "\\" + filename);
                    }
                }
            }
            catch (Exception ee)
            {
                Message = "Error moving the package from " + inboundFolder + " to " + Processing_Folder + ":" + ee.Message;
                return(false);
            }


            // Get the list of all terminal directories
            IEnumerable <string> terminalDirectories = Get_Terminal_SubDirectories(inboundFolder);

            // Create a digital resource object for each directory
            List <Incoming_Digital_Resource> inboundResources = terminalDirectories.Select(ThisDirectory => new Incoming_Digital_Resource(ThisDirectory, this)).ToList();

            // Step through each resource which came in
            bool returnVal = true;

            foreach (Incoming_Digital_Resource resource in inboundResources)
            {
                // Is this resource a candidate to move for continued processing?
                long resource_age = resource.AgeInTicks;
                if ((resource_age > Settings.Builder.Complete_Package_Required_Aging) || ((resource_age > Settings.Builder.METS_Only_Package_Required_Aging) && (resource.METS_Only_Package)))
                {
                    if (!resource.Move(Processing_Folder))
                    {
                        returnVal = false;
                    }
                }
                else
                {
                    Message = "Resource ( " + resource.Resource_Folder + " ) needs to age more before it will be processed";
                }
            }

            return(returnVal);
        }
        /// <summary> Refresh the settings and item list from the database </summary>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        public bool Refresh_Settings_And_Item_List()
        {
            // Create the tracer for this
            Custom_Tracer tracer = new Custom_Tracer();

            // Disable the cache
            CachedDataManager.Settings.Disabled = true;

            // Set all the database strings appropriately
            Engine_Database.Connection_String       = instanceInfo.DatabaseConnection.Connection_String;
            SobekCM_Item_Database.Connection_String = instanceInfo.DatabaseConnection.Connection_String;

            // Get the settings values directly from the database
            settings = InstanceWide_Settings_Builder.Build_Settings(instanceInfo.DatabaseConnection);
            if (settings == null)
            {
                Add_Error_To_Log("Unable to pull the newest settings from the database", String.Empty, String.Empty, -1);
                return(false);
            }

            // If this was not refreshed yet, ensure [BASEURL] is replaced
            if (!refreshed)
            {
                // Determine the base url
                string baseUrl = String.IsNullOrWhiteSpace(settings.Servers.Base_URL) ? settings.Servers.Application_Server_URL : settings.Servers.Base_URL;
                List <MicroservicesClient_Endpoint> endpoints = instanceInfo.Microservices.Endpoints;
                foreach (MicroservicesClient_Endpoint thisEndpoint in endpoints)
                {
                    if (thisEndpoint.URL.IndexOf("[BASEURL]") > 0)
                    {
                        thisEndpoint.URL = thisEndpoint.URL.Replace("[BASEURL]", baseUrl).Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    }
                    else if ((thisEndpoint.URL.IndexOf("http:/") < 0) && (thisEndpoint.URL.IndexOf("https:/") < 0))
                    {
                        thisEndpoint.URL = (baseUrl + thisEndpoint.URL).Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    }
                }
                refreshed = true;
            }

            // Set the microservice endpoints
            SobekEngineClient.Set_Endpoints(instanceInfo.Microservices);

            // Load the necessary configuration objects into the engine application cache gateway
            try
            {
                Engine_ApplicationCache_Gateway.Configuration.OAI_PMH = SobekEngineClient.Admin.Get_OAI_PMH_Configuration(tracer);
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to pull the OAI-PMH settings from the engine", String.Empty, String.Empty, -1);
                Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                return(false);
            }

            try
            {
                Engine_ApplicationCache_Gateway.Configuration.Metadata = SobekEngineClient.Admin.Get_Metadata_Configuration(tracer);
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to pull the metadata settings from the engine", String.Empty, String.Empty, -1);
                Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                return(false);
            }

            try
            {
                Engine_ApplicationCache_Gateway.Configuration.Extensions = SobekEngineClient.Admin.Get_Extensions_Configuration(tracer);
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to pull the extension settings from the engine", String.Empty, String.Empty, -1);
                Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                return(false);
            }


            // Check for any enabled extensions with assemblies
            ResourceObjectSettings.Clear_Assemblies();
            try
            {
                if ((Engine_ApplicationCache_Gateway.Configuration.Extensions.Extensions != null) && (Engine_ApplicationCache_Gateway.Configuration.Extensions.Extensions.Count > 0))
                {
                    // Step through each extension
                    foreach (ExtensionInfo extensionInfo in Engine_ApplicationCache_Gateway.Configuration.Extensions.Extensions)
                    {
                        // If not enabled, skip it
                        if (!extensionInfo.Enabled)
                        {
                            continue;
                        }

                        // Look for assemblies
                        if ((extensionInfo.Assemblies != null) && (extensionInfo.Assemblies.Count > 0))
                        {
                            // Step through each assembly
                            foreach (ExtensionAssembly assembly in extensionInfo.Assemblies)
                            {
                                // Find the relative file name
                                if (assembly.FilePath.IndexOf("plugins", StringComparison.OrdinalIgnoreCase) > 0)
                                {
                                    // Determine the network way to get there
                                    string from_plugins        = assembly.FilePath.Substring(assembly.FilePath.IndexOf("plugins", StringComparison.OrdinalIgnoreCase));
                                    string network_plugin_file = Path.Combine(settings.Servers.Application_Server_Network, from_plugins);

                                    // Get the plugin filename
                                    string plugin_filename = Path.GetFileName(assembly.FilePath);

                                    // Does this local plugin directory exist for this extension?
                                    string local_path = Path.Combine(pluginRootDirectory, instanceInfo.Name, extensionInfo.Code);
                                    if (!Directory.Exists(local_path))
                                    {
                                        try
                                        {
                                            Directory.CreateDirectory(local_path);
                                        }
                                        catch (Exception ee)
                                        {
                                            Add_Error_To_Log("Error creating the necessary plug-in subdirectory", String.Empty, String.Empty, -1);
                                            Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                                            return(false);
                                        }
                                    }

                                    // Determine if the assembly is here
                                    string local_file = Path.Combine(local_path, plugin_filename);
                                    if (!File.Exists(local_file))
                                    {
                                        File.Copy(network_plugin_file, local_file);
                                    }
                                    else
                                    {
                                        // Do a date check
                                        DateTime webFileDate   = File.GetLastWriteTime(network_plugin_file);
                                        DateTime localFileDate = File.GetLastWriteTime(local_file);

                                        if (webFileDate.CompareTo(localFileDate) > 0)
                                        {
                                            File.Copy(network_plugin_file, local_file, true);
                                        }
                                    }

                                    // Also, point the assembly to use the local file
                                    assembly.FilePath = local_file;
                                }
                            }
                        }
                    }

                    // Now, also set this all in the metadata portion
                    // Copy over all the extension information
                    foreach (ExtensionInfo thisExtension in Engine_ApplicationCache_Gateway.Configuration.Extensions.Extensions)
                    {
                        if ((thisExtension.Enabled) && (thisExtension.Assemblies != null))
                        {
                            foreach (ExtensionAssembly thisAssembly in thisExtension.Assemblies)
                            {
                                ResourceObjectSettings.Add_Assembly(thisAssembly.ID, thisAssembly.FilePath);
                            }
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to copy the extension files from the web", String.Empty, String.Empty, -1);
                Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                return(false);
            }

            // Finalize the metadata config
            Engine_ApplicationCache_Gateway.Configuration.Metadata.Finalize_Metadata_Configuration();

            // Set the metadata preferences for writing
            ResourceObjectSettings.MetadataConfig = Engine_ApplicationCache_Gateway.Configuration.Metadata;

            // Also, load the builder configuration this way
            try
            {
                builderSettings = SobekEngineClient.Builder.Get_Builder_Settings(false, tracer);
            }
            catch (Exception ee)
            {
                Add_Error_To_Log("Unable to pull the builder settings from the engine", String.Empty, String.Empty, -1);
                Add_Error_To_Log(ee.Message, String.Empty, String.Empty, -1);
                return(false);
            }


            // Build the modules
            builderModules = new Builder_Modules(builderSettings);
            List <string> errors = builderModules.Builder_Modules_From_Settings(instanceInfo.Name);

            if ((errors != null) && (errors.Count > 0))
            {
                long logId = Add_Error_To_Log("Error(s) builder the modules from the settings", String.Empty, String.Empty, -1);
                foreach (string thisError in errors)
                {
                    Add_Error_To_Log(thisError, String.Empty, String.Empty, logId);
                }
                return(false);
            }

            // Add the event listeners
            foreach (iPreProcessModule thisModule in builderModules.PreProcessModules)
            {
                thisModule.Error   += module_Error;
                thisModule.Process += module_Process;
            }
            foreach (iSubmissionPackageModule thisModule in builderModules.DeleteItemModules)
            {
                thisModule.Error   += module_Error;
                thisModule.Process += module_Process;
            }
            foreach (iSubmissionPackageModule thisModule in builderModules.ItemProcessModules)
            {
                thisModule.Error   += module_Error;
                thisModule.Process += module_Process;
            }
            foreach (iPostProcessModule thisModule in builderModules.PostProcessModules)
            {
                thisModule.Error   += module_Error;
                thisModule.Process += module_Process;
            }
            foreach (iFolderModule thisModule in builderModules.AllFolderModules)
            {
                thisModule.Error   += module_Error;
                thisModule.Process += module_Process;
            }

            return(true);
        }
        /// <summary> Sends aggregated emails on all newly submitted items since the last email </summary>
        /// <param name="Settings"> Instance-wide settings which may be required for this process </param>
        public override void DoWork(InstanceWide_Settings Settings)
        {
            // NOTE: This was all brought over from the BulkLoader this way, it had been commented out ther as well.
            //       To get this to work, will need to do some development here, pull the list of impacted items, etc..

            //Add_NonError_To_Log("\t\tSending emails for new items");

            //// Get the list of institutions
            //DataTable institutions = SobekCM.Library.Database.SobekCM_Database.Get_All_Institutions();

            //// Step through each institution in the item list
            //foreach (string thisInstitution in items_by_location.Keys)
            //{
            //    // Determine the email address
            //    string email = String.Empty;
            //    string institution = String.Empty;

            //    // Determine if these are dLOC
            //    string software = "dLOC";
            //    string help_email = "*****@*****.**";
            //    foreach (string html in items_by_location[thisInstitution])
            //    {
            //        if (html.IndexOf("dloc") < 0)
            //        {
            //            software = "UFDC";
            //            help_email = "*****@*****.**";
            //            break;
            //        }
            //    }

            //    if (thisInstitution.IndexOf("@") > 0)
            //    {
            //        email = thisInstitution;
            //        institution = "New " + software + " items";
            //    }
            //    else
            //    {
            //        // Search the list of institutions by the code
            //        DataRow[] selected = institutions.Select("InstitutionCode = '" + thisInstitution + "' and Load_Email_Notification=1");
            //        if (selected.Length > 0)
            //        {
            //            // Get the email and name of institution from the database
            //            email = selected[0]["Load_Email"].ToString();
            //            institution = "New " + software + " items for " + selected[0]["InstitutionName"].ToString();
            //        }
            //    }

            //    if (email.Length > 0)
            //    {
            //        // Get the name of the institution

            //        // Build the text for the email
            //        StringBuilder bodyBuilder = new StringBuilder();
            //        bodyBuilder.AppendLine("The following items are now available online in " + software + ".<br />");
            //        bodyBuilder.AppendLine("Los siguientes artículos, que usted mandó, están disponibles en línea a través de " + software + ".<br />");
            //        bodyBuilder.AppendLine("Les fichiers suivants ont été téléchargés sur le serveur " + software + ".<br />");
            //        bodyBuilder.AppendLine("<br />");
            //        bodyBuilder.AppendLine("<blockquote>");

            //        foreach (string html in items_by_location[thisInstitution])
            //        {
            //            bodyBuilder.AppendLine(html + "<br />");
            //        }

            //        bodyBuilder.AppendLine("</blockquote>");
            //        bodyBuilder.AppendLine("<br />");
            //        bodyBuilder.AppendLine("This is an automatic email.  Please do not respond to this email.  For any issues please contact " + help_email + ".<br />");
            //        bodyBuilder.AppendLine("Este correo se mandó automáticamente. Por favor no conteste este correo. Si usted tiene alguna pregunta o problema por favor mande un correo a " + help_email + ".<br />");
            //        bodyBuilder.AppendLine("Ceci est une réponse automatique. Veuillez ne pas répondre à ce message.  Envoyez-vos enquêtes directement à " + help_email + ".<br />");

            //        // Send this email
            //        try
            //        {
            //            System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage("*****@*****.**", email);
            //            myMail.Subject = institution;
            //            myMail.IsBodyHtml = true;
            //            myMail.Body = bodyBuilder.ToString();
            //            myMail.IsBodyHtml = true;

            //            // Mail this
            //            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.ufl.edu");
            //            client.Send(myMail);
            //        }
            //        catch (Exception ee)
            //        {
            //            string valu = "rerror";
            //        }
            //    }
            //}
        }