/// <summary> Imports the records from the indicated source file </summary> protected void Import_Records() { // Step through each constant map control Constant_Fields constantCollection = new Constant_Fields(); foreach (Constant_Assignment_Control thisConstant in constant_map_inputs) { constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant); } // METS files are not created from the MARC Importer; set flag to false. bool create_mets = false; bool deriveCopyrightStatusFromMARC = false; // validate the form if (!Validate_Import_MARC_Form()) { this.Enable_FormControls(); return; } // disable some of the form controls this.Disable_FormControls(); // Show the progress bar this.progressBar1.Visible = true; this.progressBar1.Maximum = 10; this.progressBar1.Value = 0; // reset the status label labelStatus.Text = ""; try { // Create the Processor and assign the Delegate method for event processing. processor = new MARC_Importer_Processor(this.sourceTextBox.Text, justSaveMarcXmlCheckBox.Checked, "", constantCollection, previewCheckBox.Checked, workingFolder + "\\ERROR"); processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress); processor.Complete += new New_Importer_Progress_Delegate(processor_Complete); // Create the thread to do the processing work, and start it. processThread = new Thread(new ThreadStart(processor.Do_Work)); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception e) { // display the error message DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); // enable form controls on the Importer form this.Enable_FormControls(); this.Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }
private void executeButton_Button_Pressed(object sender, EventArgs e) { // Step through each constant map control Constant_Fields constantCollection = new Constant_Fields(); string first_bibid = String.Empty; foreach (Constant_Assignment_Control thisConstant in constant_map_inputs) { if (thisConstant.Mapped_Name == "First BibID") { first_bibid = thisConstant.Mapped_Constant; } else { constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant); } } // validate the form if ((folderTextBox.Text.Trim().Length == 0) || (!Directory.Exists(folderTextBox.Text.Trim()))) { MessageBox.Show("Enter a valid destination folder. ", "Invalid Destination Folder", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (first_bibid.Length < 3) { MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters. \n\nThis is the first ObjectID that will be used for the resulting METS files. ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (first_bibid.Length > 10) { MessageBox.Show("The complete BibID/ObjectID cannot be longer than 10 digits. ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Pad the bibid to 10 digits, in case it is not 10 first_bibid = first_bibid.PadRight(10, '0'); // First two must be characters if ((!Char.IsLetter(first_bibid[0])) || (!Char.IsLetter(first_bibid[1]))) { MessageBox.Show("You must enter a constant for the 'First BibID' value and it must begin with two letters. \n\nThis is the first ObjectID that will be used for the resulting METS files. ", "Choose First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check that it ends in numbers if ((!Char.IsNumber(first_bibid[9])) || (!Char.IsNumber(first_bibid[8])) || (!Char.IsNumber(first_bibid[7])) || (!Char.IsNumber(first_bibid[6]))) { MessageBox.Show("The last four digits of the BibID must be numeric. \n\nTry shortening the length or changing trailing characters to numers. ", "Invalid First BibID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Try to break the first_bibid up into character portion and number portion int numbers_start = 9; for (int i = 9; i >= 0; i--) { if (!Char.IsNumber(first_bibid[i])) { numbers_start = i + 1; break; } } string bibid_start = first_bibid.Substring(0, numbers_start); int first_bibid_int = Convert.ToInt32(first_bibid.Substring(numbers_start)); executeButton.Button_Enabled = false; string set_to_import = setComboBox.Text; if (set_to_import.IndexOf("(") > 0) { set_to_import = set_to_import.Substring(0, set_to_import.IndexOf("(")).Trim(); } // Show the progress bar progressBar1.Visible = true; progressBar1.Maximum = 10; progressBar1.Value = 0; // reset the status label labelStatus.Text = ""; try { // Create the Processor and assign the Delegate method for event processing. OAI_PMH_Importer_Processor processor = new OAI_PMH_Importer_Processor(constantCollection, folderTextBox.Text.Trim(), repository, set_to_import, bibid_start, first_bibid_int, mappings_directory); processor.New_Progress += processor_New_Progress; processor.Complete += processor_Complete; // Create the thread to do the processing work, and start it. processThread = new Thread(processor.Do_Work); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception ee) { // display the error message ErrorMessageBox.Show("Error encountered while processing!\n\n" + ee.Message, "METS Editor Error", ee); Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; executeButton.Button_Enabled = true; } }
/// <summary> Imports the records from the indicated source file </summary> protected void Import_Records(System.Data.DataTable inputFile) { // update class variable this.excelDataTbl = inputFile; // Display an hourglass cursor and set max value on the ProgressBar this.Cursor = Cursors.WaitCursor; progressBar1.Maximum = this.Total_Records; // Step through each column map control List <SobekCM.Resource_Object.Mapped_Fields> mapping = new List <SobekCM.Resource_Object.Mapped_Fields>(); foreach (Column_Assignment_Control thisColumn in column_map_inputs) { mapping.Add(thisColumn.Mapped_Field); } // Step through each constant map control Constant_Fields constantCollection = new Constant_Fields(); foreach (Constant_Assignment_Control thisConstant in constant_map_inputs) { constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant); } //add columns to the input data table if (!excelDataTbl.Columns.Contains("New BIB ID")) { excelDataTbl.Columns.Add("New BIB ID"); } else { excelDataTbl.Columns.Remove("New BIB ID"); excelDataTbl.Columns.Add("New BIB ID"); } if (!excelDataTbl.Columns.Contains("New VID ID")) { excelDataTbl.Columns.Add("New VID ID"); } else { excelDataTbl.Columns.Remove("New VID ID"); excelDataTbl.Columns.Add("New VID ID"); } if (!excelDataTbl.Columns.Contains("Messages")) { excelDataTbl.Columns.Add("Messages"); } else { excelDataTbl.Columns.Remove("Messages"); excelDataTbl.Columns.Add("Messages"); } // disable some of the form controls this.Disable_FormControls(); // enable the Stop button this.executeButton.Button_Enabled = true; // Show the progress bar this.progressBar1.Visible = true; progressBar1.Value = progressBar1.Minimum; // reset the status label labelStatus.Text = ""; this.previewCheckBox.Enabled = false; // Write the current mappings, etc.. write_mappings_and_constants(inputFile, mapping, constantCollection); try { // Create the Processor and assign the Delegate method for event processing. processor = new SpreadSheet_Importer_Processor(inputFile, mapping, constantCollection, previewCheckBox.Checked); processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress); processor.Complete += new New_Importer_Progress_Delegate(processor_Complete); // Create the thread to do the processing work, and start it. processThread = new Thread(new ThreadStart(processor.Do_Work)); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception e) { // display the error message DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); // enable form controls on the Importer form this.Enable_FormControls(); this.Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }
/// <summary> Imports the records from the indicated source file </summary> protected void Import_Records() { // Step through each constant map control Constant_Fields constantCollection = new Constant_Fields(); foreach (Constant_Assignment_Control thisConstant in constant_map_inputs) { constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant); } // METS files are not created from the MARC Importer; set flag to false. bool create_mets = false; bool deriveCopyrightStatusFromMARC = false; // validate the form if (!Validate_Import_MARC_Form()) { this.Enable_FormControls(); return; } // disable some of the form controls this.Disable_FormControls(); // Show the progress bar this.progressBar1.Visible = true; this.progressBar1.Maximum = 10; this.progressBar1.Value = 0; // reset the status label labelStatus.Text = ""; try { // Create the Processor and assign the Delegate method for event processing. processor = new MARC_Importer_Processor(this.sourceTextBox.Text, justSaveMarcXmlCheckBox.Checked, "", constantCollection, previewCheckBox.Checked, workingFolder + "\\ERROR" ); processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress); processor.Complete += new New_Importer_Progress_Delegate(processor_Complete); // Create the thread to do the processing work, and start it. processThread = new Thread(new ThreadStart(processor.Do_Work)); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception e) { // display the error message DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); // enable form controls on the Importer form this.Enable_FormControls(); this.Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }
/// <summary> Imports the records from the indicated source file </summary> protected void Import_Records(System.Data.DataTable inputFile) { // update class variable this.excelDataTbl = inputFile; // Display an hourglass cursor and set max value on the ProgressBar this.Cursor = Cursors.WaitCursor; progressBar1.Maximum = this.Total_Records; // Step through each column map control List<SobekCM.Resource_Object.Mapped_Fields> mapping = new List<SobekCM.Resource_Object.Mapped_Fields>(); foreach (Column_Assignment_Control thisColumn in column_map_inputs) { mapping.Add(thisColumn.Mapped_Field); } // Step through each constant map control Constant_Fields constantCollection = new Constant_Fields(); foreach (Constant_Assignment_Control thisConstant in constant_map_inputs) { constantCollection.Add(thisConstant.Mapped_Field, thisConstant.Mapped_Constant); } //add columns to the input data table if (!excelDataTbl.Columns.Contains("New BIB ID")) excelDataTbl.Columns.Add("New BIB ID"); else { excelDataTbl.Columns.Remove("New BIB ID"); excelDataTbl.Columns.Add("New BIB ID"); } if (!excelDataTbl.Columns.Contains("New VID ID")) excelDataTbl.Columns.Add("New VID ID"); else { excelDataTbl.Columns.Remove("New VID ID"); excelDataTbl.Columns.Add("New VID ID"); } if (!excelDataTbl.Columns.Contains("Messages")) excelDataTbl.Columns.Add("Messages"); else { excelDataTbl.Columns.Remove("Messages"); excelDataTbl.Columns.Add("Messages"); } // disable some of the form controls this.Disable_FormControls(); // enable the Stop button this.executeButton.Button_Enabled = true; // Show the progress bar this.progressBar1.Visible = true; progressBar1.Value = progressBar1.Minimum; // reset the status label labelStatus.Text = ""; this.previewCheckBox.Enabled = false; // Write the current mappings, etc.. write_mappings_and_constants( inputFile, mapping, constantCollection); try { // Create the Processor and assign the Delegate method for event processing. processor = new SpreadSheet_Importer_Processor(inputFile, mapping, constantCollection, previewCheckBox.Checked ); processor.New_Progress += new New_Importer_Progress_Delegate(processor_New_Progress); processor.Complete += new New_Importer_Progress_Delegate(processor_Complete); // Create the thread to do the processing work, and start it. processThread = new Thread(new ThreadStart(processor.Do_Work)); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception e) { // display the error message DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); // enable form controls on the Importer form this.Enable_FormControls(); this.Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }