/// <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); } } } }
private void Process_Single_Incoming_Package(Incoming_Digital_Resource ResourcePackage) { ResourcePackage.BuilderLogId = Add_NonError_To_Log("........Processing '" + ResourcePackage.Folder_Name + "'", "Standard", ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.METS_Type_String, -1); // Clear any existing error linked to this item Engine_Database.Builder_Clear_Item_Error_Log(ResourcePackage.BibID, ResourcePackage.VID, "SobekCM Builder"); // Before we save this or anything, let's see if this is truly a new resource ResourcePackage.NewPackage = (Engine_Database.Get_Item_Information(ResourcePackage.BibID, ResourcePackage.VID, null) == null); ResourcePackage.Package_Time = DateTime.Now; try { // Do all the item processing per instance config foreach (iSubmissionPackageModule thisModule in builderModules.ItemProcessModules) { //if ( superverbose) //{ // Add_NonError_To_Log("Running module " + thisModule.GetType().ToString(), true, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId); //} if (!thisModule.DoWork(ResourcePackage)) { Add_Error_To_Log("Unable to complete new/replacement for " + ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId); // Try to move the whole package to the failures folder string final_failures_folder = Path.Combine(ResourcePackage.Source_Folder.Failures_Folder, ResourcePackage.BibID + "_" + ResourcePackage.VID); if (Directory.Exists(final_failures_folder)) { final_failures_folder = final_failures_folder + "_" + DateTime.Now.Year + "_" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Day.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Hour.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Minute.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Second.ToString().PadLeft(2, '0'); } try { Directory.Move(ResourcePackage.Resource_Folder, final_failures_folder); } catch { } return; } } // Save these collections to mark them for refreshing the RSS feeds, etc.. Add_Process_Info_To_PostProcess_Lists(ResourcePackage.BibID, ResourcePackage.VID, ResourcePackage.Metadata.Behaviors.Aggregation_Code_List); // Finally, clear the memory a little bit ResourcePackage.Clear_METS(); } catch (Exception ee) { StreamWriter errorWriter = new StreamWriter(logFileDirectory + "\\error.log", true); errorWriter.WriteLine("Message: " + ee.Message); errorWriter.WriteLine("Stack Trace: " + ee.StackTrace); errorWriter.Flush(); errorWriter.Close(); Add_Error_To_Log("Unable to complete new/replacement for " + ResourcePackage.BibID + ":" + ResourcePackage.VID, ResourcePackage.BibID + ":" + ResourcePackage.VID, String.Empty, ResourcePackage.BuilderLogId, ee); } }
private void Create_Complete_MarcXML_Feed(bool Test_Feed_Flag) { // Determine some values based on whether this is for thr test feed or something else string feed_name = "Production MarcXML Feed"; string file_name = "complete_marc.xml"; string error_file_name = "complete_marc_last_error.html"; if (Test_Feed_Flag) { feed_name = "Test MarcXML Feed"; file_name = "test_marc.xml"; error_file_name = "test_marc_last_error.html"; } // Before doing this, create the Mango load try { // Create the Mango load stuff Console.WriteLine("Building " + feed_name); MarcXML_Load_Creator createEndeca = new MarcXML_Load_Creator(); bool reportSuccess = createEndeca.Create_MarcXML_Data_File(Test_Feed_Flag, Path.Combine(logFileDirectory, file_name)); // Publish this feed if (reportSuccess) { Engine_Database.Builder_Clear_Item_Error_Log(feed_name.ToUpper(), "", "UFDC Builder"); File.Copy(Path.Combine(logFileDirectory, file_name), Engine_ApplicationCache_Gateway.Settings.MarcGeneration.MarcXML_Feed_Location + file_name, true); } else { string errors = createEndeca.Errors; if (errors.Length > 0) { StreamWriter writer = new StreamWriter(Engine_ApplicationCache_Gateway.Settings.MarcGeneration.MarcXML_Feed_Location + error_file_name, false); writer.WriteLine("<html><head><title>" + feed_name + " Errors</title></head><body><h1>" + feed_name + " Errors</h1>"); writer.Write(errors.Replace("\r\n", "<br />").Replace("\n", "<br />").Replace("<br />", "<br />\r\n")); writer.Write("</body></html>"); writer.Flush(); writer.Close(); Engine_Database.Builder_Add_Log_Entry(-1, feed_name.ToUpper(), "Error", "Resulting file failed validation", ""); File.Copy(Path.Combine(logFileDirectory, file_name), Engine_ApplicationCache_Gateway.Settings.MarcGeneration.MarcXML_Feed_Location + file_name.Replace(".xml", "_error.xml"), true); } } } catch { Engine_Database.Builder_Add_Log_Entry(-1, feed_name.ToUpper(), "Error", "Unknown exception caught", ""); Console.WriteLine("ERROR BUILDING THE " + feed_name.ToUpper()); } }
/// <summary> Performs a delete from the database and moves all digital resource /// files into the recycle bin </summary> /// <param name="Resource"> Incoming digital resource object </param> /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns> public override bool DoWork(Incoming_Digital_Resource Resource) { // Read the METS and load the basic information before continuing Resource.Load_METS(); Engine_Database.Add_Minimum_Builder_Information(Resource.Metadata); Resource.BuilderLogId = OnProcess("........Processing '" + Resource.Folder_Name + "'", "Standard", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, -1); Engine_Database.Builder_Clear_Item_Error_Log(Resource.BibID, Resource.VID, "SobekCM Builder"); Resource.File_Root = Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8); string existing_folder = Settings.Servers.Image_Server_Network + Resource.File_Root + "\\" + Resource.VID; // Remove from the primary collection area try { if (Directory.Exists(existing_folder)) { // Make sure the delete folder exists if (!Directory.Exists(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN")) { Directory.CreateDirectory(Settings.Servers.Image_Server_Network + "\\RECYCLE BIN"); } // Create the final directory string final_folder = Settings.Servers.Image_Server_Network + "\\RECYCLE BIN\\" + Resource.File_Root + "\\" + Resource.VID; if (!Directory.Exists(final_folder)) { Directory.CreateDirectory(final_folder); } // Move each file string[] delete_files = Directory.GetFiles(existing_folder); foreach (string thisDeleteFile in delete_files) { string destination_file = final_folder + "\\" + Path.GetFileName(thisDeleteFile); if (File.Exists(destination_file)) { File.Delete(destination_file); } File.Move(thisDeleteFile, destination_file); } } } catch (Exception ee) { OnError("Unable to move resource ( " + Resource.BibID + ":" + Resource.VID + " ) to deletes", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId); OnError(ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId); return(false); } // Delete the static page string static_page1 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.VID + "\\" + Resource.BibID + "_" + Resource.VID + ".html"; if (File.Exists(static_page1)) { File.Delete(static_page1); } string static_page2 = Settings.Servers.Static_Pages_Location + Resource.BibID.Substring(0, 2) + "\\" + Resource.BibID.Substring(2, 2) + "\\" + Resource.BibID.Substring(4, 2) + "\\" + Resource.BibID.Substring(6, 2) + "\\" + Resource.BibID.Substring(8) + "\\" + Resource.BibID + "_" + Resource.VID + ".html"; if (File.Exists(static_page2)) { File.Delete(static_page2); } // Delete the file from the database Engine_Database.Delete_SobekCM_Item(Resource.BibID, Resource.VID, true, "Deleted upon request by builder"); // Delete from the solr/lucene indexes if (Settings.Servers.Document_Solr_Index_URL.Length > 0) { try { Solr_Controller.Delete_Resource_From_Index(Settings.Servers.Document_Solr_Index_URL, Settings.Servers.Page_Solr_Index_URL, Resource.BibID, Resource.VID); } catch (Exception ee) { OnError("Error deleting item from the Solr/Lucene index. The index may not reflect this delete.", Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId); OnError("Solr Error: " + ee.Message, Resource.BibID + ":" + Resource.VID, Resource.METS_Type_String, Resource.BuilderLogId); return(false); } } // Delete the handled METS file and package Resource.Delete(); return(true); }