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 Complete_Any_Recent_Loads_Requiring_Additional_Work() { // Get the list of recent loads requiring additional work DataTable additionalWorkRequired = Engine_Database.Items_Needing_Aditional_Work; if ((additionalWorkRequired != null) && (additionalWorkRequired.Rows.Count > 0)) { Add_NonError_To_Log("Processing recently loaded items needing additional work", "Standard", String.Empty, String.Empty, -1); // Create the incoming digital folder object which will be used for all these Actionable_Builder_Source_Folder sourceFolder = new Actionable_Builder_Source_Folder(); // Step through each one foreach (DataRow thisRow in additionalWorkRequired.Rows) { // Get the information about this item string bibID = thisRow["BibID"].ToString(); string vid = thisRow["VID"].ToString(); // Determine the file root for this string file_root = bibID.Substring(0, 2) + "\\" + bibID.Substring(2, 2) + "\\" + bibID.Substring(4, 2) + "\\" + bibID.Substring(6, 2) + "\\" + bibID.Substring(8, 2); // Determine the source folder for this resource string resource_folder = settings.Servers.Image_Server_Network + file_root + "\\" + vid; // Determine the METS file name string mets_file = resource_folder + "\\" + bibID + "_" + vid + ".mets.xml"; // Ensure these both exist if ((Directory.Exists(resource_folder)) && (File.Exists(mets_file))) { // Create the incoming digital resource object Incoming_Digital_Resource additionalWorkResource = new Incoming_Digital_Resource(resource_folder, sourceFolder) { BibID = bibID, VID = vid, File_Root = bibID.Substring(0, 2) + "\\" + bibID.Substring(2, 2) + "\\" + bibID.Substring(4, 2) + "\\" + bibID.Substring(6, 2) + "\\" + bibID.Substring(8, 2) }; Complete_Single_Recent_Load_Requiring_Additional_Work(additionalWorkResource); } else { Add_Error_To_Log("Unable to find valid resource files for reprocessing " + bibID + ":" + vid, bibID + ":" + vid, "Reprocess", -1); int itemID = Engine_Database.Get_ItemID_From_Bib_VID(bibID, vid); SobekCM_Item_Database.Update_Additional_Work_Needed_Flag(itemID, false); } } } }
private void Complete_Single_Recent_Load_Requiring_Additional_Work(Incoming_Digital_Resource AdditionalWorkResource) { AdditionalWorkResource.METS_Type_String = "Reprocess"; AdditionalWorkResource.BuilderLogId = Add_NonError_To_Log("Reprocessing '" + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID + "'", "Standard", AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, -1); try { // Load the METS file if ((!AdditionalWorkResource.Load_METS()) || (AdditionalWorkResource.BibID.Length == 0)) { Add_Error_To_Log("Error reading METS file from " + AdditionalWorkResource.Folder_Name.Replace("_", ":"), AdditionalWorkResource.Folder_Name.Replace("_", ":"), "Reprocess", AdditionalWorkResource.BuilderLogId); return; } AdditionalWorkResource.METS_Type_String = "Reprocess"; // Add thumbnail and aggregation informaiton from the database Engine_Database.Add_Minimum_Builder_Information(AdditionalWorkResource.Metadata); // Do all the item processing per instance config foreach (iSubmissionPackageModule thisModule in builderModules.ItemProcessModules) { if (verbose) { Add_NonError_To_Log("Running module " + thisModule.GetType(), true, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, String.Empty, AdditionalWorkResource.BuilderLogId); } if (!thisModule.DoWork(AdditionalWorkResource)) { Add_Error_To_Log("Unable to complete additional work for " + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, String.Empty, AdditionalWorkResource.BuilderLogId); return; } } // Save these collections to mark them for refreshing the RSS feeds, etc.. Add_Process_Info_To_PostProcess_Lists(AdditionalWorkResource.BibID, AdditionalWorkResource.VID, AdditionalWorkResource.Metadata.Behaviors.Aggregation_Code_List); // Finally, clear the memory a little bit AdditionalWorkResource.Clear_METS(); } catch (Exception ee) { Add_Error_To_Log("Unable to complete additional work for " + AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.BibID + ":" + AdditionalWorkResource.VID, AdditionalWorkResource.METS_Type_String, AdditionalWorkResource.BuilderLogId, ee); } }