/// <summary> Load all the file attributes into this wrapper class </summary> /// <param name="Metadata_Location"> Directory to find the metadata for this package </param> /// <param name="File_Location"> Directory to fine the files for this package </param> /// <remarks> This reads the width and height of all the page image files and stores this /// in the internal SobekCM_Item object </remarks> public void Load_File_Attributes(string Metadata_Location, string File_Location) { // First, check to see if there is an existing service METS if ((Metadata_Location.Length > 0) && (Directory.Exists(Metadata_Location)) && (File.Exists(Metadata_Location + "/" + bibid + "_" + vid + ".mets.xml"))) { try { SobekCM_Item serviceMETS = SobekCM_Item.Read_METS(Metadata_Location + "/" + bibid + "_" + vid + ".mets.xml"); // Create a hashtable of all the files in the service METS and tep through each file in this mets and look for attributes in the other Dictionary <string, SobekCM_File_Info> serviceMetsFiles = serviceMETS.Divisions.Files.ToDictionary(thisFile => thisFile.System_Name); // Now, step through each file in this mets and look for attributes in the other foreach (SobekCM_File_Info thisFile in bibPackage.Divisions.Files) { // Is there a match? if (serviceMetsFiles.ContainsKey(thisFile.System_Name)) { // Get the match SobekCM_File_Info serviceFile = serviceMetsFiles[thisFile.System_Name]; // Copy the data over thisFile.Width = serviceFile.Width; thisFile.Height = serviceFile.Height; thisFile.System_Name = serviceFile.System_Name; } } } catch (Exception) { // No need to do anything here.. can still function without this information being saved } } // Now, just look for the data being present in each file if (Directory.Exists(File_Location)) { foreach (SobekCM_File_Info thisFile in bibPackage.Divisions.Files) { // Is this a jpeg? if (thisFile.System_Name.ToUpper().IndexOf(".JPG") > 0) { if (thisFile.System_Name.ToUpper().IndexOf("THM.JPG") < 0) { Compute_Jpeg_Attributes(thisFile, File_Location); } } // Is this a jpeg2000? if (thisFile.System_Name.ToUpper().IndexOf("JP2") > 0) { Compute_Jpeg2000_Attributes(thisFile, File_Location); } } } }
/// <summary> Find the most current METS file by looking in a variety of workflow /// and service locations, pulling the latest file or eventually building the file from /// database information if necessary </summary> /// <param name="BibID"> Bibliographic identifier for the item to find </param> /// <param name="VID"> Volume identifier for the item to find </param> /// <param name="Folder"> Folder in which to place the found or built METS file </param> /// <param name="VolumeInfoFromDB"> DataSet of data about this volume from the database (or NULL)</param> /// <returns> SobekCM Item object read from the METS file, or NULL if unable to perform the tasks </returns> public static SobekCM_Item Find_UFDC_METS(string BibID, string VID, string Folder, DataSet VolumeInfoFromDB) { SobekCM_Item bibPackage = null; bool mets_found = false; DateTime lastWriteDate = new DateTime(1900, 1, 1); // Look for pre-existing mets files in the inbound Folder(s) if (Directory.Exists(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "\\" + VID)) { if (File.Exists(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")) { mets_found = true; lastWriteDate = (new FileInfo(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")).LastWriteTime; if (Folder.Length > 0) { File.Copy(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml", Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml"); } } } // Look for a flattened inbound mets file if ((!mets_found) && (Directory.Exists(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "_" + VID))) { if (File.Exists(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "_" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")) { mets_found = true; lastWriteDate = (new FileInfo(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "_" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")).LastWriteTime; if (Folder.Length > 0) { File.Copy(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "_" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml", Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(SOBEKCM_DROPBOX_LOCATION + "inbound\\" + BibID + "_" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml"); } } } // Look for a processing mets file if ((!mets_found) && (Directory.Exists(SOBEKCM_DROPBOX_LOCATION + "processing\\" + BibID + "\\" + VID))) { if (File.Exists(SOBEKCM_DROPBOX_LOCATION + "processing\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")) { mets_found = true; lastWriteDate = (new FileInfo(SOBEKCM_DROPBOX_LOCATION + "processing\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml")).LastWriteTime; if (Folder.Length > 0) { File.Copy(SOBEKCM_DROPBOX_LOCATION + "processing\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml", Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(SOBEKCM_DROPBOX_LOCATION + "processing\\" + BibID + "\\" + VID + "\\" + BibID + "_" + VID + ".METS_Header.xml"); } } } // Get the directory for the files already loaded to UFDC string sobekcm_folder = BibID.Substring(0, 2) + "\\" + BibID.Substring(2, 2) + "\\" + BibID.Substring(4, 2) + "\\" + BibID.Substring(6, 2) + "\\" + BibID.Substring(8, 2) + "\\" + VID; if (Directory.Exists(SOBEKCM_IMAGE_LOCATION + sobekcm_folder)) { string folders_and_mets = sobekcm_folder + "\\" + BibID + "_" + VID + ".METS_Header.xml"; if (File.Exists(SOBEKCM_IMAGE_LOCATION + folders_and_mets)) { if (mets_found) { // If the METS was already found, still check for a NEWER one online DateTime compareWriteDate = (new FileInfo(SOBEKCM_IMAGE_LOCATION + folders_and_mets)).LastWriteTime; if (compareWriteDate.CompareTo(lastWriteDate) > 0) { if (Folder.Length > 0) { File.Copy(SOBEKCM_IMAGE_LOCATION + folders_and_mets, Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(SOBEKCM_IMAGE_LOCATION + folders_and_mets); } } } else { mets_found = true; if (Folder.Length > 0) { File.Copy(SOBEKCM_IMAGE_LOCATION + folders_and_mets, Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(SOBEKCM_IMAGE_LOCATION + folders_and_mets); } } } } // Look in the DATA Folder if ((!mets_found) && (SOBEKCM_DATA_LOCATION.Length > 0)) { string data_mets_folder = SOBEKCM_DATA_LOCATION + "METS\\" + BibID[0] + "\\" + BibID[1] + "\\" + BibID[2] + "\\" + BibID[3] + "\\" + BibID[4] + "\\" + BibID[5] + "\\" + BibID[6] + "\\" + BibID[7] + "\\" + BibID[8] + "\\" + BibID[9] + "\\" + VID; if (Directory.Exists(data_mets_folder)) { string data_mets_file = data_mets_folder + "\\" + BibID + "_" + VID + ".mets"; if (File.Exists(data_mets_file)) { mets_found = true; if (Folder.Length > 0) { File.Copy(data_mets_file, Folder + "\\" + BibID + "_" + VID + ".mets", true); bibPackage = SobekCM_Item.Read_METS(Folder + "\\" + BibID + "_" + VID + ".mets"); } else { bibPackage = SobekCM_Item.Read_METS(data_mets_file); } } } } // Look in the local folder if ((!mets_found) && (Folder.Length > 0)) { string[] mets_files = Directory.GetFiles(Folder, "*.mets*"); if (mets_files.Length > 0) { bibPackage = SobekCM_Item.Read_METS(mets_files[0]); if (bibPackage != null) { mets_found = true; } } } // If still no METS, have to build one from the values provided and // any existing MARC record in the DATA Folder if ((!mets_found) && (VolumeInfoFromDB != null)) { bool recordCreated = false; DataRow itemRow = VolumeInfoFromDB.Tables[2].Rows[0]; string materialType = itemRow["Type"].ToString(); string title = itemRow["Title"].ToString(); string publisher = String.Empty; string author = String.Empty; string donor = String.Empty; string pubDate = String.Empty; string alephNumber = String.Empty; string oclcNumber = String.Empty; if (itemRow["Publisher"] != DBNull.Value) { publisher = itemRow["Publisher"].ToString(); } if (itemRow["Author"] != DBNull.Value) { author = itemRow["Author"].ToString(); } if (itemRow["Donor"] != DBNull.Value) { donor = itemRow["Donor"].ToString(); } if (itemRow["PubDate"] != DBNull.Value) { pubDate = itemRow["PubDate"].ToString(); } if (itemRow["ALEPH_Number"] != DBNull.Value) { alephNumber = itemRow["ALEPH_Number"].ToString(); } if (itemRow["OCLC_Number"] != DBNull.Value) { oclcNumber = itemRow["OCLC_Number"].ToString(); } // Look for an OCLC record MarcXML file if (oclcNumber.Length > 1) { oclcNumber = oclcNumber.PadLeft(8, '0'); StringBuilder oclcDirBuilder = new StringBuilder(SOBEKCM_DATA_LOCATION + "MARCXML\\OCLC\\"); foreach (char thisChar in oclcNumber) { oclcDirBuilder.Append(thisChar + "\\"); } if ((Directory.Exists(oclcDirBuilder.ToString())) && (File.Exists(oclcDirBuilder.ToString() + oclcNumber + ".xml"))) { // Read this in then bibPackage = new SobekCM_Item(); recordCreated = true; bibPackage.Read_From_MARC_XML(oclcDirBuilder.ToString() + oclcNumber + ".xml"); bibPackage.Bib_Info.Record.Record_Origin = "Imported from (OCLC)" + oclcNumber; } } // Look for a local catalog record MarcXML file if ((!recordCreated) && (alephNumber.Length > 1)) { alephNumber = alephNumber.PadLeft(9, '0'); StringBuilder alephDirBuilder = new StringBuilder(SOBEKCM_DATA_LOCATION + "MARCXML\\"); foreach (char thisChar in alephNumber) { alephDirBuilder.Append(thisChar + "\\"); } if ((Directory.Exists(alephDirBuilder.ToString())) && (File.Exists(alephDirBuilder.ToString() + alephNumber + ".xml"))) { // Read this in then bibPackage = new SobekCM_Item(); recordCreated = true; bibPackage.Read_From_MARC_XML(alephDirBuilder.ToString() + alephNumber + ".xml"); bibPackage.Bib_Info.Record.Record_Origin = "Imported from (ALEPH)" + alephNumber; } } // If not created, make a blank item if (!recordCreated) { bibPackage = new SobekCM_Item(); bibPackage.Bib_Info.Record.Record_Origin = "Derived from the SobekCM databse"; bibPackage.Bib_Info.Main_Title.Title = title; if (author.IndexOf("|") > 0) { string[] authors = author.Split("|".ToCharArray()); bibPackage.Bib_Info.Main_Entity_Name.Full_Name = authors[0].Replace("<i>", "").Replace("</i>", ""); for (int i = 1; i < authors.Length; i++) { bibPackage.Bib_Info.Add_Named_Entity(authors[i].Replace("<i>", "").Replace("</i>", "")); } } else { bibPackage.Bib_Info.Main_Entity_Name.Full_Name = author.Replace("<i>", "").Replace("</i>", ""); } if (donor.Length > 0) { bibPackage.Bib_Info.Donor.Full_Name = donor; } if (pubDate.Length > 0) { bibPackage.Bib_Info.Origin_Info.Date_Issued = pubDate; } if (alephNumber.Length > 1) { bibPackage.Bib_Info.Add_Identifier(alephNumber, "ALEPH"); } if (oclcNumber.Length > 1) { bibPackage.Bib_Info.Add_Identifier(oclcNumber, "OCLC"); } if (publisher.IndexOf("|") > 0) { string[] publishers = publisher.Split("|".ToCharArray()); for (int i = 0; i < publishers.Length; i++) { if (publishers[i] != "(multiple)") { bibPackage.Bib_Info.Add_Publisher(publishers[i]); } } } else { bibPackage.Bib_Info.Add_Publisher(publisher); } } // Add the values needed for all the records originated this way bibPackage.BibID = BibID; bibPackage.VID = VID; } return(bibPackage); }
/// <summary> Indexes all the items within a SobekCM library or a single item aggregation within a SobekCM library </summary> /// <param name="SolrDocumentUrl"> URL for the solr/lucene core used for searching for a single document within the library </param> /// <param name="SolrPageUrl"> URL for the solr/lucene core used for searching within a single document for matching pages </param> /// <param name="File_Location"> Location where all resource files are located </param> /// <param name="Collection"> Code the item aggreagtion to index, or empty string to index the entire library </param> public static void Index_Collection(string SolrDocumentUrl, string SolrPageUrl, string File_Location, string Collection) { // Initialize the document-level Solr/Lucene worker and add the solr url Startup.Init <SolrDocument>(SolrDocumentUrl); var solrDocumentWorker = ServiceLocator.Current.GetInstance <ISolrOperations <SolrDocument> >(); // Initialize the page-level Solr/Lucene worker and add the solr url Startup.Init <SolrPage>(SolrPageUrl); var solrPageWorker = ServiceLocator.Current.GetInstance <ISolrOperations <SolrPage> >(); // Get the start time DateTime startTime = DateTime.Now; // Get the list of all items in this collection int itemcount = 1; int sincelastcommit = 0; DataSet items = Engine_Database.Simple_Item_List(Collection, null); List <SolrDocument> index_files = new List <SolrDocument>(); List <SolrPage> index_pages = new List <SolrPage>(); // Temporarily write each bib:vid StreamWriter bibVidWriter = new StreamWriter("bib_vid_list.txt"); foreach (DataRow thisRow in items.Tables[0].Rows) { string bibid = thisRow[0].ToString(); string vid = thisRow[1].ToString(); bibVidWriter.WriteLine(bibid + ":" + vid); } bibVidWriter.Flush(); bibVidWriter.Close(); // Temporarily log this StreamWriter logWriter = new StreamWriter("log" + DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + ".txt", false); // Step through each row foreach (DataRow thisRow in items.Tables[0].Rows) { string bibid = thisRow[0].ToString(); string vid = thisRow[1].ToString(); string directory = File_Location + bibid.Substring(0, 2) + "\\" + bibid.Substring(2, 2) + "\\" + bibid.Substring(4, 2) + "\\" + bibid.Substring(6, 2) + "\\" + bibid.Substring(8) + "\\" + vid.PadLeft(5, '0'); string metsFile = directory + "\\" + bibid + "_" + vid + ".mets.xml"; if ((Directory.Exists(directory)) && (File.Exists(metsFile))) { Console.WriteLine(itemcount.ToString() + @":" + bibid + @":" + vid); // Read a METS file SobekCM_Item item = SobekCM_Item.Read_METS(metsFile); // Only continue if this is not NULL if (item != null) { logWriter.WriteLine(itemcount.ToString() + ":" + bibid + ":" + vid); // Pull some data from the database DataSet itemInfoSet = Engine_Database.Get_Item_Information(bibid, vid, true, null); if ((itemInfoSet != null) && (itemInfoSet.Tables[0].Rows.Count > 0)) { DataRow itemRow = itemInfoSet.Tables[0].Rows[0]; // Copy over the serial hierarchy item.Behaviors.Serial_Info.Clear(); string level1_text = itemRow["Level1_Text"].ToString(); if (level1_text.Length > 0) { item.Behaviors.Serial_Info.Add_Hierarchy(0, Convert.ToInt32(itemRow["Level1_Index"]), level1_text); string level2_text = itemRow["Level2_Text"].ToString(); if (level2_text.Length > 0) { item.Behaviors.Serial_Info.Add_Hierarchy(0, Convert.ToInt32(itemRow["Level2_Index"]), level2_text); string level3_text = itemRow["Level3_Text"].ToString(); if (level1_text.Length > 0) { item.Behaviors.Serial_Info.Add_Hierarchy(0, Convert.ToInt32(itemRow["Level3_Index"]), level3_text); } } } // Copy the main thumbnail item.Behaviors.Main_Thumbnail = itemRow["MainThumbnailFile"].ToString(); long aleph = Convert.ToInt64(itemRow["ALEPH_Number"]); long oclc = Convert.ToInt64(itemRow["OCLC_Number"]); if (aleph > 1) { item.Bib_Info.ALEPH_Record = aleph.ToString(); } if (oclc > 1) { item.Bib_Info.OCLC_Record = oclc.ToString(); } // Set the aggregationPermissions item.Behaviors.Clear_Aggregations(); foreach (DataRow thisAggrRow in itemInfoSet.Tables[1].Rows) { string code = thisAggrRow["Code"].ToString(); string name = thisAggrRow["Name"].ToString(); item.Behaviors.Add_Aggregation(code, name); } } // Add this document to the list of documents to index index_files.Add(new SolrDocument(item, directory)); // Index five documents at a time, since this could be alot of pages at a time if (index_files.Count > 4) { logWriter.Flush(); // Add to document index logWriter.WriteLine("ADDING TO DOCUMENT INDEX"); Console.WriteLine(@"Adding to Lucene/Solr Document Index"); bool document_success = false; int document_attempts = 0; while (!document_success) { try { solrDocumentWorker.Add(index_files); document_success = true; } catch (Exception) { if (document_attempts > 5) { throw; } document_attempts++; logWriter.WriteLine("ERROR " + document_attempts); Console.WriteLine(@"ERROR " + document_attempts); Thread.Sleep(document_attempts * 1000); } } // Add each page to be indexed foreach (SolrDocument document in index_files) { index_pages.AddRange(document.Solr_Pages); } // Add to page index logWriter.WriteLine("ADDING TO PAGE INDEX"); Console.WriteLine(@"Adding to Lucene/Solr Page Index"); bool page_success = false; int page_attempts = 0; while (!page_success) { try { solrPageWorker.Add(index_pages); page_success = true; } catch (Exception) { if (page_attempts > 5) { throw; } page_attempts++; logWriter.WriteLine("ERROR " + page_attempts); Console.WriteLine(@"ERROR " + page_attempts); Thread.Sleep(page_attempts * 1000); } } // Clear the documents and pages index_files.Clear(); index_pages.Clear(); if (sincelastcommit > 500) { logWriter.WriteLine("DOCUMENT COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Comitting Changes to Lucene/Solr Document Index ( {0} )", DateTime.Now.ToString()); try { solrDocumentWorker.Commit(); } catch { logWriter.WriteLine("ERROR CAUGHT DURING COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Error caught during document commit ( {0} )", DateTime.Now.ToString()); Thread.Sleep(10 * 60 * 1000); } logWriter.WriteLine("PAGE COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Comitting Changes to Lucene/Solr Page Index ( {0} )", DateTime.Now.ToString()); try { solrPageWorker.Commit(); } catch { logWriter.WriteLine("ERROR CAUGHT DURING COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Error caught during document commit ( {0} )", DateTime.Now.ToString()); Thread.Sleep(10 * 60 * 1000); } sincelastcommit = 0; //if (commitssinceoptimize >= 5) //{ // logWriter.WriteLine("DOCUMENT OPTIMIZE ( " + DateTime.Now.ToString() + " )"); // Console.WriteLine("Optimizing Lucene/Solr Document Index ( " + DateTime.Now.ToString() + " )"); // try // { // solrDocumentWorker.Optimize(); // } // catch (Exception ee) // { // logWriter.WriteLine("ERROR CAUGHT DURING OPTIMIZE ( " + DateTime.Now.ToString() + " )"); // Console.WriteLine("Error caught during document optimize ( " + DateTime.Now.ToString() + " )"); // Thread.Sleep(10 * 60 * 1000); // } // logWriter.WriteLine("PAGE OPTIMIZE ( " + DateTime.Now.ToString() + " )"); // Console.WriteLine("Optimizing Lucene/Solr Page Index ( " + DateTime.Now.ToString() + " )"); // try // { // solrPageWorker.Optimize(); // } // catch (Exception ee) // { // logWriter.WriteLine("ERROR CAUGHT DURING OPTIMIZE ( " + DateTime.Now.ToString() + " )"); // Console.WriteLine("Error caught during document optimize ( " + DateTime.Now.ToString() + " )"); // Thread.Sleep(10 * 60 * 1000); // } // commitssinceoptimize = 0; //} } } } sincelastcommit++; } itemcount++; } if (index_files.Count > 0) { logWriter.Flush(); // Add to document index Console.WriteLine(@"Adding to Lucene/Solr Document Index"); solrDocumentWorker.Add(index_files); // Add each page to be indexed foreach (SolrDocument document in index_files) { index_pages.AddRange(document.Solr_Pages); } // Add to page index Console.WriteLine(@"Adding to Lucene/Solr Page Index"); solrPageWorker.Add(index_pages); // Clear the documents and pages index_files.Clear(); index_pages.Clear(); } // Comit the changes to the solr/lucene index logWriter.WriteLine("DOCUMENT COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Comitting Changes to Lucene/Solr Document Index ( {0} )", DateTime.Now.ToString()); try { solrDocumentWorker.Commit(); } catch { logWriter.WriteLine("ERROR CAUGHT DURING COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Error caught during document commit ( {0} )", DateTime.Now.ToString()); Thread.Sleep(10 * 60 * 1000); } logWriter.WriteLine("PAGE COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Comitting Changes to Lucene/Solr Page Index ( {0} )", DateTime.Now.ToString()); try { solrPageWorker.Commit(); } catch { logWriter.WriteLine("ERROR CAUGHT DURING COMMIT ( " + DateTime.Now.ToString() + " )"); Console.WriteLine(@"Error caught during document commit ( {0} )", DateTime.Now.ToString()); Thread.Sleep(10 * 60 * 1000); } logWriter.WriteLine("Final document optimize"); Console.WriteLine(@"Final document optimize"); try { solrDocumentWorker.Optimize(); } catch (Exception) { // Do not do anything here. It may throw an exception when it runs very longs } Thread.Sleep(30 * 60 * 1000); logWriter.WriteLine("Final page optimize"); Console.WriteLine(@"Final page optimize"); try { solrPageWorker.Optimize(); } catch (Exception) { // Do not do anything here. It may throw an exception when it runs very longs } Thread.Sleep(30 * 60 * 1000); // Add final meessage Console.WriteLine(@"Process Complete at {0}", DateTime.Now.ToString()); Console.WriteLine(@"Process Started at {0}", startTime.ToString()); Console.WriteLine(); Console.WriteLine(@"Enter any key to exit:"); Console.ReadKey(); logWriter.Flush(); logWriter.Close(); }
static void Main(string[] args) { // Try to read the metadata configuration file string app_start_config = Application.StartupPath + "\\config"; if ((Directory.Exists(app_start_config)) && (File.Exists(app_start_config + "\\sobekCM_metadata.config"))) { Metadata_Configuration.Read_Metadata_Configuration(app_start_config + "\\sobekCM_metadata.config"); } bool complete_static_rebuild = false; bool marc_rebuild = false; bool run_preloader = true; bool run_background = false; bool show_help = false; bool build_production_marcxml_feed = false; bool build_test_marcxml_feed = false; string invalid_arg = String.Empty; bool refresh_oai = false; bool verbose = false; // Get values from the arguments foreach (string thisArgs in args) { bool arg_handled = false; // Check for the config flag if (thisArgs == "--config") { if (File.Exists(app_start_config + "\\SobekCM_Builder_Configuration.exe")) { Process.Start(app_start_config + "\\SobekCM_Builder_Configuration.exe"); return; } Console.WriteLine("ERROR: Unable to find configuration executable file!!"); return; } // Check for versioning option if (thisArgs == "--version") { Console.WriteLine("You are running version " + SobekCM_Library_Settings.CURRENT_BUILDER_VERSION + " of the SobekCM Builder."); return; } // Check for no loader flag if (thisArgs == "--background") { run_background = true; arg_handled = true; } // Check for verbose flag if (thisArgs == "--verbose") { verbose = true; arg_handled = true; } // Check for no loader flag if (thisArgs == "--refresh_oai") { refresh_oai = true; arg_handled = true; } // Check for no oading flag if (thisArgs == "--noload") { run_preloader = false; arg_handled = true; } // Check for static rebuild if (thisArgs == "--staticrebuild") { complete_static_rebuild = true; arg_handled = true; } // Check for static rebuild if (thisArgs == "--createmarc") { marc_rebuild = true; arg_handled = true; } // Check for marc xml feed creation flags if (thisArgs.IndexOf("--marcxml") == 0) { build_production_marcxml_feed = true; arg_handled = true; } if (thisArgs.IndexOf("--testmarcxml") == 0) { build_test_marcxml_feed = true; arg_handled = true; } // Check for help if ((thisArgs == "--help") || (thisArgs == "?") || (thisArgs == "-help")) { show_help = true; arg_handled = true; } // If not handled, set as error if (!arg_handled) { invalid_arg = thisArgs; break; } } // Was there an invalid argument or was help requested if ((invalid_arg.Length > 0) || (show_help)) { StringBuilder builder = new StringBuilder(); builder.Append("\nThis application is used to bulk load SobekCM items, perform post-processing\n"); builder.Append("for items loaded through the web, and perform some regular maintenance activities\n"); builder.Append("in support of a SobekCM web application.\n\n"); builder.Append("Usage: SobekCM_Builder [options]\n\n"); builder.Append("Options:\n\n"); builder.Append(" --config\tRuns the configuration tool\n\n"); builder.Append(" --version\tDisplays the current version of the SobekCM Builder\n\n"); builder.Append(" --verbose\tFlag indicates to be verbose in the logs and console\n\n"); builder.Append(" --background\tContinues to run in the background\n\n"); builder.Append(" --help\t\tShows these instructions\n\n"); builder.Append(" --noload\t\tSupresses the loading portion of the SobekCM Builder\n\n"); builder.Append(" --staticrebuild\tPerform a complete rebuild on static pages\n\n"); builder.Append(" --marcxml\tBuild the marcxml production feed\n\n"); builder.Append(" --testmarcxml\tBuild the marcxml test feed\n\n"); builder.Append(" --createmarc\tRecreate all of the MARC.xml files\n\n"); builder.Append(" --refresh_oai\tResave the OAI-PMH DC data for every item in the library\n\n"); builder.Append("Examples:\n\n"); builder.Append(" 1. To just rebuild all the static pages:\n"); builder.Append(" SobekCM_Builder --nopreload --noload --staticrebuild"); builder.Append(" 2. To have the SobekCM Builder constantly run in the background"); builder.Append(" SobekCM_Builder --background"); // If invalid arg, save to log file if (invalid_arg.Length > 0) { // Show INVALID ARGUMENT error in console Console.WriteLine("\nINVALID ARGUMENT PROVIDED ( " + invalid_arg + " )"); } Console.WriteLine(builder.ToString()); return; } // Now, veryify the configuration file exists string config_file = Application.StartupPath + "\\config\\sobekcm.config"; if (!File.Exists(config_file)) { Console.WriteLine("The configuration file is missing!!\n"); Console.Write("Would you like to run the configuration tool? [Y/N]: "); string result = Console.ReadLine().ToUpper(); if ((result == "Y") || (result == "YES")) { // Does the config app exist? if (File.Exists(Application.StartupPath + "\\config\\SobekCM_Builder_Configuration.exe")) { // Run the config app Process configProcess = new Process { StartInfo = { FileName = Application.StartupPath + "\\config\\SobekCM_Builder_Configuration.exe" } }; configProcess.Start(); configProcess.WaitForExit(); // If still no config file, just abort if (!File.Exists(config_file)) { Console.WriteLine("Execution aborted due to missing configuration file."); return; } } else { Console.WriteLine("ERROR: Unable to find configuration executable file!!"); return; } } else { Console.WriteLine("Execution aborted due to missing configuration file."); return; } } // Should be a config file now, so read it SobekCM_Library_Settings.Read_Configuration_File(config_file); if ((SobekCM_Library_Settings.Database_Connections.Count == 0) || (SobekCM_Library_Settings.Database_Connections[0].Connection_String.Length == 0)) { Console.WriteLine("Missing database connection string!!\n"); Console.Write("Would you like to run the configuration tool? [Y/N]: "); string result = Console.ReadLine().ToUpper(); if ((result == "Y") || (result == "YES")) { // Does the config app exist? if (File.Exists(Application.StartupPath + "\\config\\SobekCM_Builder_Configuration.exe")) { // Run the config app Process configProcess = new Process { StartInfo = { FileName = Application.StartupPath + "\\config\\SobekCM_Builder_Configuration.exe" } }; configProcess.Start(); configProcess.WaitForExit(); // If still no config file, just abort if (!File.Exists(config_file)) { Console.WriteLine("Execution aborted due to missing configuration file."); return; } } else { Console.WriteLine("ERROR: Unable to find configuration executable file!!"); return; } } else { Console.WriteLine("Execution aborted due to missing configuration file."); return; } } // Assign the connection string and test the connection (if only a single connection listed) if (SobekCM_Library_Settings.Database_Connections.Count == 1) { SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; if (!SobekCM_Database.Test_Connection()) { Console.WriteLine("Unable to connect to the database using provided connection string:"); Console.WriteLine(); Console.WriteLine(SobekCM_Database.Connection_String); Console.WriteLine(); Console.WriteLine("Run this application with an argument of '--config' to launch the configuration tool."); return; } } // Verify connectivity and rights on the logs subfolder SobekCM_Library_Settings.Local_Log_Directory = Application.StartupPath + "\\logs"; if (!Directory.Exists(SobekCM_Library_Settings.Local_Log_Directory)) { try { Directory.CreateDirectory(SobekCM_Library_Settings.Local_Log_Directory); } catch { Console.WriteLine("Error creating necessary logs subfolder under the application folder.\n"); Console.WriteLine("Please create manually.\n"); Console.WriteLine(SobekCM_Library_Settings.Local_Log_Directory); return; } } try { StreamWriter testWriter = new StreamWriter(SobekCM_Library_Settings.Local_Log_Directory + "\\test.log", false); testWriter.WriteLine("TEST"); testWriter.Flush(); testWriter.Close(); File.Delete(SobekCM_Library_Settings.Local_Log_Directory + "\\test.log"); } catch { Console.WriteLine("The service account needs modify rights on the logs subfolder.\n"); Console.WriteLine("Please correct manually.\n"); Console.WriteLine(SobekCM_Library_Settings.Local_Log_Directory); return; } // Look for Ghostscript from the registry, if not provided in the config file if (SobekCM_Library_Settings.Ghostscript_Executable.Length == 0) { // LOOK FOR THE GHOSTSCRIPT DIRECTORY string possible_ghost = Look_For_Variable_Registry_Key("SOFTWARE\\GPL Ghostscript", "GS_DLL"); if (!String.IsNullOrEmpty(possible_ghost)) { SobekCM_Library_Settings.Ghostscript_Executable = possible_ghost; } } // Look for Imagemagick from the registry, if not provided in the config file string possible_imagemagick = Look_For_Variable_Registry_Key("SOFTWARE\\ImageMagick", "BinPath"); if (!String.IsNullOrEmpty(possible_imagemagick)) { SobekCM_Library_Settings.ImageMagick_Executable = possible_imagemagick; } // If this is to refresh the OAI, don't use the worker controller if ((refresh_oai) && (SobekCM_Library_Settings.Database_Connections.Count == 1)) { // Set the item for the current mode int successes = 0; DataTable item_list_table = SobekCM_Database.Get_All_Groups_First_VID( ); foreach (DataRow thisRow in item_list_table.Rows) { string bibid = thisRow["BibID"].ToString(); string vid = thisRow["VID"].ToString(); int groupid = Convert.ToInt32(thisRow["groupid"]); string directory = SobekCM_Library_Settings.Image_Server_Network + bibid.Substring(0, 2) + "\\" + bibid.Substring(2, 2) + "\\" + bibid.Substring(4, 2) + "\\" + bibid.Substring(6, 2) + "\\" + bibid.Substring(8, 2) + "\\" + vid; string mets = directory + "\\" + bibid + "_" + vid + ".mets.xml"; try { SobekCM_Item thisItem = SobekCM_Item.Read_METS(mets); if (thisItem != null) { // Get the OAI-PMH dublin core information StringBuilder oaiDataBuilder = new StringBuilder(1000); StringWriter writer = new StringWriter(oaiDataBuilder); DC_METS_dmdSec_ReaderWriter.Write_Simple_Dublin_Core(writer, thisItem.Bib_Info); // Also add the URL as identifier oaiDataBuilder.AppendLine("<dc:identifier>" + SobekCM_Library_Settings.System_Base_URL + bibid + "</dc:identifier>"); Resource_Object.Database.SobekCM_Database.Save_Item_Group_OAI(groupid, oaiDataBuilder.ToString(), "oai_dc", true); writer.Flush(); writer.Close(); successes++; if (successes % 1000 == 0) { Console.WriteLine(@"{0} complete", successes); } } } catch { } } return; } // Two ways to run this... constantly in background or once Worker_Controller controller = new Worker_Controller(verbose); if (!run_background) { controller.Execute_Immediately(build_production_marcxml_feed, build_test_marcxml_feed, run_preloader, complete_static_rebuild, marc_rebuild); } else { controller.Execute_In_Background(); } // If this was set to aborting, set to last execution aborted Builder_Operation_Flag_Enum operationFlag = Abort_Database_Mechanism.Builder_Operation_Flag; if ((operationFlag == Builder_Operation_Flag_Enum.ABORTING) || (operationFlag == Builder_Operation_Flag_Enum.ABORT_REQUESTED)) { Abort_Database_Mechanism.Builder_Operation_Flag = Builder_Operation_Flag_Enum.LAST_EXECUTION_ABORTED; } }
/// <summary> Read the METS file and load the data into this object </summary> /// <param name="Source_File"> METS source file to read </param> /// <returns> TRUE if successful, otherwise FALSE </returns> public bool Load_METS(string Source_File) { try { // Load the METS file bibPackage = SobekCM_Item.Read_METS(Source_File); // If null was returned, this failed if (bibPackage == null) { return(false); } // TEMPORARY foreach (Identifier_Info thisIdentifier in bibPackage.Bib_Info.Identifiers) { if (thisIdentifier.Type == "accn") { thisIdentifier.Type = "accession number"; } } // Save the BibID and VID. If a VID already existed here, and not in the METS, // assign that to the METS. (For example, when '00001' can be assumed bibid = bibPackage.BibID; if (bibPackage.VID.Length > 0) { vid = bibPackage.VID; } else if (!String.IsNullOrEmpty(vid)) { bibPackage.VID = vid; } switch (bibPackage.METS_Header.RecordStatus_Enum) { case METS_Record_Status.METADATA_UPDATE: type = Incoming_Digital_Resource_Type.METADATA_UPDATE; break; case METS_Record_Status.COMPLETE: type = Incoming_Digital_Resource_Type.COMPLETE_PACKAGE; break; case METS_Record_Status.PARTIAL: type = Incoming_Digital_Resource_Type.PARTIAL_PACKAGE; break; case METS_Record_Status.DELETE: type = Incoming_Digital_Resource_Type.DELETE; break; case METS_Record_Status.BIB_LEVEL: type = Incoming_Digital_Resource_Type.BIB_LEVEL; break; } return(true); } catch (Exception) { return(false); } }
/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Admin_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } // If the user is not an admin, and admin was selected, reroute this if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; Current_Mode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.Admin_Type) { case Admin_Type_Enum.Aggregation_Single: adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Home: adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Builder_Status: adminViewer = new Builder_AdminViewer(user, Current_Mode); break; case Admin_Type_Enum.Interfaces: adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Forwarding: adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Tracer); break; case Admin_Type_Enum.Wordmarks: adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.URL_Portals: adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Tracer); break; case Admin_Type_Enum.Users: adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.User_Groups: adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.Aggregations_Mgmt: adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.IP_Restrictions: adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer); break; case Admin_Type_Enum.Thematic_Headings: adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, Tracer); break; case Admin_Type_Enum.Settings: adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Projects: if (Current_Mode.My_Sobek_SubMode.Length > 1) { string project_code = Current_Mode.My_Sobek_SubMode.Substring(1); Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file"); if (user != null) { SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer); if (projectObject != null) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid project file found in cache"); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, Tracer); } else { if (SobekCM_Database.Get_All_Projects_Templates(Tracer).Tables[0].Select("ProjectCode='" + project_code + "'").Length > 0) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building project file from (possible) PMETS"); string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Project level metadata for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\"; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache"); Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, Tracer); } } } } if (adminViewer == null) { adminViewer = new Projects_AdminViewer(user, Current_Mode, Tracer); } break; } // Pass in the navigation and translator information adminViewer.CurrentMode = Current_Mode; adminViewer.Translator = translator; }
/// <summary> Perform the importing process </summary> public void Go() { int currentRow = 0; string username = String.Empty; var windowsIdentity = WindowsIdentity.GetCurrent(); if (windowsIdentity != null) { username = windowsIdentity.Name; } // Get column references DataColumn bibCol = tableToImport.Columns[0]; DataColumn firstLevelTextCol = tableToImport.Columns[3]; DataColumn firstLevelIndexCol = tableToImport.Columns[4]; DataColumn secondLevelTextCol = tableToImport.Columns[5]; DataColumn secondLevelIndexCol = tableToImport.Columns[6]; DataColumn thirdLevelTextCol = tableToImport.Columns[7]; DataColumn thirdLevelIndexCol = tableToImport.Columns[8]; DataColumn pubDateCol = tableToImport.Columns[9]; DataColumn trackingBoxCol = tableToImport.Columns[10]; DataColumn receivedDateCol = tableToImport.Columns[11]; DataColumn dispositionAdviceCol = tableToImport.Columns[12]; foreach (DataRow thisRow in tableToImport.Rows) { // Get the bibid from the table if (bibid.Length == 0) { bibid = thisRow[bibCol].ToString().ToUpper(); } // Find the source mets string thisSourceMets = String.Empty; if (sourceMets.ContainsKey(bibid)) { thisSourceMets = sourceMets[bibid]; } else { // Try to find the source mets file string assocFilePath = bibid.Substring(0, 2) + "\\" + bibid.Substring(2, 2) + "\\" + bibid.Substring(4, 2) + "\\" + bibid.Substring(6, 2) + "\\" + bibid.Substring(8, 2); string server_location = Library.SobekCM_Library_Settings.Image_Server_Network + "\\" + assocFilePath; if (Directory.Exists(server_location)) { string[] vidFolders = Directory.GetDirectories(server_location); if (vidFolders.Length > 0) { string[] possibleMets = Directory.GetFiles(vidFolders[0], bibid + "_*.mets.xml"); if (possibleMets.Length > 0) { thisSourceMets = possibleMets[0]; sourceMets[bibid] = thisSourceMets; } } } } // Load this METS and clear some values if (thisSourceMets.Length > 0) { SobekCM_Item newItem = SobekCM_Item.Read_METS(thisSourceMets); newItem.VID = String.Empty; newItem.Divisions.Clear(); newItem.Bib_Info.Origin_Info.Date_Copyrighted = String.Empty; newItem.Bib_Info.Origin_Info.Date_Issued = String.Empty; newItem.Bib_Info.Origin_Info.Date_Reprinted = String.Empty; // Assign the hierarchy values newItem.Bib_Info.Origin_Info.Date_Issued = thisRow[pubDateCol].ToString(); newItem.Behaviors.Serial_Info.Clear(); if (thisRow[firstLevelTextCol].ToString().Length > 0) { newItem.Behaviors.Serial_Info.Add_Hierarchy(1, Convert.ToInt32(thisRow[firstLevelIndexCol]), thisRow[firstLevelTextCol].ToString()); if (thisRow[secondLevelTextCol].ToString().Length > 0) { newItem.Behaviors.Serial_Info.Add_Hierarchy(2, Convert.ToInt32(thisRow[secondLevelIndexCol]), thisRow[secondLevelTextCol].ToString()); if (thisRow[thirdLevelTextCol].ToString().Length > 0) { newItem.Behaviors.Serial_Info.Add_Hierarchy(3, Convert.ToInt32(thisRow[thirdLevelIndexCol]), thisRow[thirdLevelTextCol].ToString()); } } } // Assign some tracking values as well, if present if ((thisRow[trackingBoxCol] != null) && (thisRow[trackingBoxCol].ToString().Length > 0)) { newItem.Tracking.Tracking_Box = thisRow[trackingBoxCol].ToString(); } if ((thisRow[receivedDateCol] != null) && (thisRow[receivedDateCol].ToString().Length > 0)) { try { newItem.Tracking.Material_Received_Date = Convert.ToDateTime(thisRow[receivedDateCol]); newItem.Tracking.Material_Rec_Date_Estimated = false; } catch { } } if ((thisRow[dispositionAdviceCol] != null) && (thisRow[dispositionAdviceCol].ToString().Length > 0)) { newItem.Tracking.Disposition_Advice_Notes = thisRow[dispositionAdviceCol].ToString(); string advice_notes_as_caps = newItem.Tracking.Disposition_Advice_Notes.ToUpper(); if ((advice_notes_as_caps.IndexOf("RETURN") >= 0) || (advice_notes_as_caps.IndexOf("RETAIN") >= 0)) { newItem.Tracking.Disposition_Advice = 1; } else { if (advice_notes_as_caps.IndexOf("WITHDRAW") >= 0) { newItem.Tracking.Disposition_Advice = 2; } else if (advice_notes_as_caps.IndexOf("DISCARD") >= 0) { newItem.Tracking.Disposition_Advice = 3; } } } // Save this to the database newItem.Tracking.VID_Source = "SMaRT Volume Import:" + username; newItem.Behaviors.Dark_Flag = dark; newItem.Behaviors.IP_Restriction_Membership = (short)restrictionMask; SobekCM_Database.Save_New_Digital_Resource(newItem, false, false, username, String.Empty, -1); // Save this VID to the table thisRow[0] = newItem.VID; // Save this METS newItem.METS_Header.RecordStatus_Enum = METS_Record_Status.METADATA_UPDATE; newItem.Source_Directory = workingFolder; newItem.Save_SobekCM_METS(); // Copy to the INBOUND and DATA FOLDERS string inbound_folder = Library.SobekCM_Library_Settings.Main_Builder_Input_Folder + "\\" + newItem.BibID + "_" + newItem.VID; if (!Directory.Exists(inbound_folder)) { Directory.CreateDirectory(inbound_folder); } string newbibid = newItem.BibID; File.Copy(workingFolder + "\\" + newbibid + "_" + newItem.VID + ".mets.xml", inbound_folder + "\\" + newbibid + "_" + newItem.VID + ".mets.xml", true); } // Update progress currentRow++; OnNewProgress(currentRow); } OnComplete(currentRow); }
/// <summary> Validates and reads the data from the METS file associated with this incoming digital resource </summary> /// <param name="Resource"></param> /// <param name="ThisMetsValidator"></param> /// <param name="MetsSchemeValidator"></param> /// <returns></returns> public string Validate_and_Read_METS(Incoming_Digital_Resource Resource, SobekCM_METS_Validator ThisMetsValidator, METS_Validator_Object MetsSchemeValidator) { if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Start ( " + Resource.Folder_Name + " )", "Verbose", String.Empty, String.Empty, -1); } // Determine invalid bib id and vid for any errors string invalid_bibid = String.Empty; string invalid_vid = String.Empty; string bib_vid = String.Empty; if ((Resource.Folder_Name.Length == 16) && (Resource.Folder_Name[10] == '_')) { invalid_bibid = Resource.Folder_Name.Substring(0, 10); invalid_vid = Resource.Folder_Name.Substring(11, 5); bib_vid = invalid_bibid + ":" + invalid_vid; } else if (Resource.Folder_Name.Length == 10) { invalid_bibid = Resource.Folder_Name; invalid_vid = "none"; bib_vid = invalid_bibid + ":" + invalid_vid; } // Verify that a METS file exists if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Check for METS existence", "Verbose", bib_vid, String.Empty, -1); } if (ThisMetsValidator.METS_Existence_Check(Resource.Resource_Folder) == false) { // Save this error log and return the error Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, ThisMetsValidator.ValidationError, "Missing"); return(ThisMetsValidator.ValidationError); } // Get the name of this METS file string[] mets_files = Directory.GetFiles(Resource.Resource_Folder, invalid_bibid + "_" + invalid_vid + ".mets*"); string mets_file = String.Empty; try { mets_file = mets_files.Length == 0 ? Directory.GetFiles(Resource.Resource_Folder, "*mets*")[0] : mets_files[0]; } catch (Exception) { Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, "Unable to locate correct METS file", "UNKNOWN"); } if (mets_file == String.Empty) { Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, "Unable to locate correct METS file", "UNKNOWN"); } // check the mets file against the scheme FileInfo metsFileInfo = new FileInfo(mets_file); if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Validate against " + metsFileInfo.Name + " against the schema", "Verbose", bib_vid, String.Empty, -1); } if (MetsSchemeValidator.Validate_Against_Schema(mets_file) == false) { // Save this error log and return the error Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, MetsSchemeValidator.Errors, "UNKNOWN", "METS Scheme Validation Error"); return(MetsSchemeValidator.Errors); } SobekCM_Item returnValue; try { if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Read validated METS file", "Verbose", Resource.Folder_Name.Replace("_", ":"), "UNKNOWN", -1); } returnValue = SobekCM_Item.Read_METS(mets_file); } catch { // Save this error log and return the error Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, "Error encountered while reading the METS file '" + mets_file, "UNKNOWN"); return("Error encountered while reading the METS file '" + mets_file); } // If the METS file was read, determine if this is valid by the METS type if (returnValue != null) { // If there is a bibid and no vid, check to see what's going on here if ((returnValue.BibID.Length == 10) && (returnValue.VID.Length == 0)) { DataRow[] matches = itemTable.Select("BibID='" + returnValue.BibID + "'"); if (matches.Length == 0) { returnValue.VID = "00001"; } else { if ((matches.Length == 1) && (matches[0]["VID"].ToString() == "00001")) { returnValue.VID = "00001"; } else { // Save this error log and return the error Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, "METS file does not have a VID and belongs to a multi-volume title", Resource.METS_Type_String); return("METS file does not have a VID and belongs to a multi-volume title"); } } } // Do the basic check first if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Perform basic check", "Verbose", Resource.Resource_Folder.Replace("_", ":"), Resource.METS_Type_String, -1); } if (!ThisMetsValidator.SobekCM_Standard_Check(returnValue, Resource.Resource_Folder)) { // Save this error log and return null Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, ThisMetsValidator.ValidationError, Resource.METS_Type_String); return(ThisMetsValidator.ValidationError); } // If this is a COMPLETE package, check files if (returnValue.METS_Header.RecordStatus_Enum == METS_Record_Status.COMPLETE) { if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Check resource files (existence and checksum)", "Verbose", Resource.Resource_Folder.Replace("_", ":"), Resource.METS_Type_String, -1); } // check if all files exist in the package and the MD5 checksum if the checksum flag is true if (!ThisMetsValidator.Check_Files(Resource.Resource_Folder, Settings.Builder.VerifyCheckSum)) { // Save this error log and return null Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, ThisMetsValidator.ValidationError, Resource.METS_Type_String); return(ThisMetsValidator.ValidationError); } } // This is apparently valid, so do some final checks and copying into the resource wrapper Resource.BibID = returnValue.BibID; Resource.VID = returnValue.VID; switch (returnValue.METS_Header.RecordStatus_Enum) { case METS_Record_Status.METADATA_UPDATE: Resource.Resource_Type = Incoming_Digital_Resource.Incoming_Digital_Resource_Type.METADATA_UPDATE; break; case METS_Record_Status.COMPLETE: Resource.Resource_Type = Incoming_Digital_Resource.Incoming_Digital_Resource_Type.COMPLETE_PACKAGE; break; case METS_Record_Status.PARTIAL: Resource.Resource_Type = Incoming_Digital_Resource.Incoming_Digital_Resource_Type.PARTIAL_PACKAGE; break; case METS_Record_Status.DELETE: Resource.Resource_Type = Incoming_Digital_Resource.Incoming_Digital_Resource_Type.DELETE; break; case METS_Record_Status.BIB_LEVEL: Resource.Resource_Type = Incoming_Digital_Resource.Incoming_Digital_Resource_Type.BIB_LEVEL; break; } if (Settings.Builder.Verbose_Flag) { OnProcess("ValidateAndClassifyModule.Validate_and_Read_METS: Complete - validated", "Verbose", Resource.Resource_Folder.Replace("_", ":"), Resource.METS_Type_String, -1); } return(String.Empty); } // Save this error log and return the error Create_Error_Log(Resource.Resource_Folder, Resource.Folder_Name, "Error encountered while reading the METS file '" + mets_file, "UNKNOWN"); return("Error encountered while reading the METS file '" + mets_file); }
/// <summary> Returns the appropriate admin viewer, based on requst and system settings </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <returns> Built admin viewer </returns> public static iMySobek_Admin_Viewer Get_AdminViewer(RequestCache RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Admin_HtmlSubwriter.Get_AdminViewer", "Building the admin viewer object"); switch (RequestSpecificValues.Current_Mode.Admin_Type) { case Admin_Type_Enum.Add_Collection_Wizard: return(new Add_Collection_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Aggregation_Single: return(new Aggregation_Single_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Aggregations_Mgmt: return(new Aggregations_Mgmt_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Home: return(new Home_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Builder_Status: return(new Builder_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Builder_Folder_Mgmt: return(new Builder_Folder_Mgmt_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Skins_Single: return(new Skin_Single_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Skins_Mgmt: return(new Skins_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Aliases: return(new Aliases_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.WebContent_Add_New: return(new WebContent_Add_New_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.WebContent_Mgmt: return(new WebContent_Mgmt_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.WebContent_History: return(new WebContent_History_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.WebContent_Single: return(new WebContent_Single_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.WebContent_Usage: return(new WebContent_Usage_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Wordmarks: return(new Wordmarks_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.URL_Portals: return(new Portals_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Users: return(new Users_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.User_Groups: return(new User_Group_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.User_Permissions_Reports: return(new Permissions_Reports_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.IP_Restrictions: return(new IP_Restrictions_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Thematic_Headings: return(new Thematic_Headings_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.TEI: return(new TEI_PlugIn_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Settings: return(new Settings_AdminViewer(RequestSpecificValues)); case Admin_Type_Enum.Default_Metadata: if ((!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode)) && (RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Length > 1)) { string project_code = RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Substring(1); RequestSpecificValues.Tracer.Add_Trace("AdminViewer_Factory.Get_AdminViewer", "Checking cache for valid project file"); if (RequestSpecificValues.Current_User != null) { SobekCM_Item projectObject = CachedDataManager.Retrieve_Project(RequestSpecificValues.Current_User.UserID, project_code, RequestSpecificValues.Tracer); if (projectObject != null) { RequestSpecificValues.Tracer.Add_Trace("AdminViewer_Factory.Get_AdminViewer", "Valid default metadata set found in cache"); return(new Edit_Item_Metadata_MySobekViewer(projectObject, RequestSpecificValues)); } else { if (Engine_Database.Get_All_Template_DefaultMetadatas(RequestSpecificValues.Tracer).Tables[0].Select("MetadataCode='" + project_code + "'").Length > 0) { RequestSpecificValues.Tracer.Add_Trace("AdminViewer_Factory.Get_AdminViewer", "Building default metadata set from (possible) PMETS"); string pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Default metadata set for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\"; RequestSpecificValues.Tracer.Add_Trace("AdminViewer_Factory.Get_AdminViewer", "Adding project file to cache"); CachedDataManager.Store_Project(RequestSpecificValues.Current_User.UserID, project_code, pmets_item, RequestSpecificValues.Tracer); return(new Edit_Item_Metadata_MySobekViewer(pmets_item, RequestSpecificValues)); } } } } // If it made it here, it must be manage all the default metadatas return(new Default_Metadata_AdminViewer(RequestSpecificValues)); } return(null); }
public void Do_Work() { string username = WindowsIdentity.GetCurrent().Name; List <string> directories_to_process = new List <string>(); try { recurse_through_directories(directory, directories_to_process); } catch { } // Now, iterate through all the directories int current_directory = 1; int errors_encountered = 0; foreach (string thisDirectory in directories_to_process) { try { DirectoryInfo thisDirectoryInfo = new DirectoryInfo(thisDirectory); string folder_name_for_progress = thisDirectoryInfo.Name; if (folder_name_for_progress.Length <= 5) { folder_name_for_progress = (thisDirectoryInfo.Parent.Name) + "\\" + folder_name_for_progress; } OnNewFolder(folder_name_for_progress + " ( " + current_directory + " of " + directories_to_process.Count + " )"); // Get the metadata file string[] metadata = Directory.GetFiles(thisDirectory, filter); if (metadata.Length > 0) { SobekCM_Item newItem = null; if (metadata_type.IndexOf("METS") >= 0) { newItem = SobekCM_Item.Read_METS(metadata[0]); } else { newItem = new SobekCM_Item(); newItem.Source_Directory = thisDirectory; newItem = new SobekCM_Item(); List <string> addOns = MetaTemplate_UserSettings.AddOns_Enabled; // Set the initial agents if (MetaTemplate_UserSettings.Individual_Creator.Length > 0) { newItem.METS_Header.Creator_Individual = MetaTemplate_UserSettings.Individual_Creator; } else { newItem.METS_Header.Creator_Individual = username; } newItem.METS_Header.Creator_Software = "SobekCM METS Editor"; // Add FCLA add-on defaults if (addOns.Contains("FCLA")) { PALMM_Info palmmInfo = newItem.Get_Metadata_Module(GlobalVar.PALMM_METADATA_MODULE_KEY) as PALMM_Info; if (palmmInfo == null) { palmmInfo = new PALMM_Info(); newItem.Add_Metadata_Module(GlobalVar.PALMM_METADATA_MODULE_KEY, palmmInfo); } palmmInfo.PALMM_Project = MetaTemplate_UserSettings.PALMM_Code; palmmInfo.toPALMM = MetaTemplate_UserSettings.FCLA_Flag_PALMM; DAITSS_Info daitssInfo = newItem.Get_Metadata_Module(GlobalVar.DAITSS_METADATA_MODULE_KEY) as DAITSS_Info; if (daitssInfo == null) { daitssInfo = new DAITSS_Info(); newItem.Add_Metadata_Module(GlobalVar.DAITSS_METADATA_MODULE_KEY, daitssInfo); } daitssInfo.toArchive = MetaTemplate_UserSettings.FCLA_Flag_FDA; daitssInfo.Account = MetaTemplate_UserSettings.FDA_Account; daitssInfo.SubAccount = MetaTemplate_UserSettings.FDA_SubAccount; daitssInfo.Project = MetaTemplate_UserSettings.FDA_Project; } // Add SobekCM add-on defaults if (addOns.Contains("SOBEKCM")) { // Add any wordmarks List <string> wordmarks = MetaTemplate_UserSettings.SobekCM_Wordmarks; foreach (string thisWordmark in wordmarks) { newItem.Behaviors.Add_Wordmark(thisWordmark); } // Add any aggregations List <string> aggregations = MetaTemplate_UserSettings.SobekCM_Aggregations; foreach (string thisAggregation in aggregations) { newItem.Behaviors.Add_Aggregation(thisAggregation); } // Add any web skins List <string> webskins = MetaTemplate_UserSettings.SobekCM_Web_Skins; foreach (string thisWebSkin in webskins) { newItem.Behaviors.Add_Web_Skin(thisWebSkin); } // Add any viewers List <string> viewers = MetaTemplate_UserSettings.SobekCM_Viewers; foreach (string thisViewer in viewers) { if (String.Compare(thisViewer, "Page Image (JPEG)") == 0) { newItem.Behaviors.Add_View(View_Enum.JPEG); } if (String.Compare(thisViewer, "Zoomable (JPEG2000)") == 0) { newItem.Behaviors.Add_View(View_Enum.JPEG2000); } if (String.Compare(thisViewer, "Page Turner") == 0) { newItem.Behaviors.Add_View(View_Enum.PAGE_TURNER); } if (String.Compare(thisViewer, "Text") == 0) { newItem.Behaviors.Add_View(View_Enum.TEXT); } if (String.Compare(thisViewer, "Thumbnails") == 0) { newItem.Behaviors.Add_View(View_Enum.RELATED_IMAGES); } } } // Add all other defaults newItem.Bib_Info.Source.Code = MetaTemplate_UserSettings.Default_Source_Code; newItem.Bib_Info.Source.Statement = MetaTemplate_UserSettings.Default_Source_Statement; if (MetaTemplate_UserSettings.Default_Funding_Note.Length > 0) { newItem.Bib_Info.Add_Note(MetaTemplate_UserSettings.Default_Funding_Note, Note_Type_Enum.funding); } if (MetaTemplate_UserSettings.Default_Rights_Statement.Length > 0) { newItem.Bib_Info.Access_Condition.Text = MetaTemplate_UserSettings.Default_Rights_Statement; } // Set some final values newItem.Bib_Info.Type.MODS_Type = TypeOfResource_MODS_Enum.Text; // Assign an ObjectID switch (next_bibid_counter) { case -1: newItem.METS_Header.ObjectID = thisDirectoryInfo.Name; if ((newItem.METS_Header.ObjectID.Length == 16) && (newItem.METS_Header.ObjectID[10] == '_')) { newItem.VID = newItem.BibID.Substring(11); newItem.BibID = newItem.BibID.Substring(0, 10).ToUpper(); } break; case -2: newItem.METS_Header.ObjectID = (new FileInfo(metadata[0])).Name; if ((newItem.METS_Header.ObjectID.Length == 16) && (newItem.METS_Header.ObjectID[10] == '_')) { newItem.VID = newItem.BibID.Substring(11); newItem.BibID = newItem.BibID.Substring(0, 10).ToUpper(); } break; default: string next_bibid = next_bibid_counter.ToString(); next_bibid_counter++; newItem.BibID = (bibid_start + next_bibid.PadLeft(10 - bibid_start.Length, '0')).ToUpper(); newItem.VID = "00001"; break; } string errors = String.Empty; if (metadata_type.IndexOf("DUBLIN CORE") >= 0) { // Open a stream to read the indicated import file Stream reader = new FileStream(metadata[0], FileMode.Open, FileAccess.Read); DC_File_ReaderWriter dcreader = new DC_File_ReaderWriter(); dcreader.Read_Metadata(reader, newItem, null, out errors); } if (metadata_type.IndexOf("MODS") >= 0) { // Open a stream to read the indicated import file Stream reader = new FileStream(metadata[0], FileMode.Open, FileAccess.Read); MODS_File_ReaderWriter dcreader = new MODS_File_ReaderWriter(); dcreader.Read_Metadata(reader, newItem, null, out errors); } if (metadata_type.IndexOf("MARCXML") >= 0) { // Open a stream to read the indicated import file Stream reader = new FileStream(metadata[0], FileMode.Open, FileAccess.Read); MarcXML_File_ReaderWriter dcreader = new MarcXML_File_ReaderWriter(); dcreader.Read_Metadata(reader, newItem, null, out errors); } } // Make sure there is a title if (newItem.Bib_Info.Main_Title.ToString().Trim().Length == 0) { newItem.Bib_Info.Main_Title.Title = "Missing Title"; } // We now have a good METS file, so let's look for files to add string[] existing_files = Directory.GetFiles(thisDirectory); bool image_files_found = false; List <string> otherFiles = new List <string>(); foreach (string thisFile in existing_files) { string upper_case = new FileInfo(thisFile).Name.ToUpper(); if ((upper_case.IndexOf(".TIF") > 0) || (upper_case.IndexOf(".JPG") > 0) || (upper_case.IndexOf(".JP2") > 0)) { image_files_found = true; } else if ((upper_case.IndexOf(".METS") < 0) && (upper_case.IndexOf(".TXT") < 0) && (upper_case.IndexOf(".PRO") < 0) && (upper_case.IndexOf(".XML") < 0) && (upper_case.IndexOf(".MODS") < 0) && (upper_case.IndexOf(".DC") < 0)) { otherFiles.Add((new FileInfo(thisFile)).Name); } } // Add the image files first newItem.Source_Directory = thisDirectory; Bib_Package_Builder.Add_All_Files(newItem, "*.tif|*.jpg|*.jp2|*.txt|*.pro|*.gif", MetaTemplate_UserSettings.Always_Recurse_Through_Subfolders_On_New, MetaTemplate_UserSettings.Page_Images_In_Seperate_Folders_Can_Be_Same_Page); // Add any downloads next foreach (string thisFile in otherFiles) { newItem.Divisions.Download_Tree.Add_File(thisFile); } // Now, save this METS file // Prepare to save the enw METS // Determine the filename string mets_file = thisDirectory + "\\" + newItem.METS_Header.ObjectID + MetaTemplate_UserSettings.METS_File_Extension; // Save the actual file newItem.Divisions.Suppress_Checksum = !MetaTemplate_UserSettings.Include_Checksums; // Save the actual file METS_File_ReaderWriter metsWriter = new METS_File_ReaderWriter(); string writing_error = String.Empty; metsWriter.Write_Metadata(mets_file, newItem, null, out writing_error); } } catch (Exception ee) { errors_encountered++; } OnNewProgress(current_directory, directories_to_process.Count); current_directory++; } OnComplete(current_directory, errors_encountered); }