private void executeButton_Button_Pressed(object sender, EventArgs e) { // Make sure some rows of data are ready to be imported if (transformedDataTbl.Rows.Count == 0) { MessageBox.Show("No data rows to import! ", "Import Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check to see if multiple bibids loaded string check_bib = transformedDataTbl.Rows[0][0].ToString().ToUpper(); bool multiple_bibs_in_table = transformedDataTbl.Rows.Cast<DataRow>().Any(thisRow => thisRow[0].ToString().ToUpper() != check_bib); // Create a temporary folder string temp_folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary"; try { if (!Directory.Exists(temp_folder)) { Directory.CreateDirectory(temp_folder); } } catch { } string bibid = bibidLabel.Text; string vid = vidComboBox.Text; int visibility_index = visibilityComboBox.SelectedIndex; bool dark = false; int visibility = 0; switch (visibility_index) { case 0: dark = true; visibility = -1; break; case 1: visibility = -1; break; case 2: visibility = 1; break; case 3: visibility = 0; break; } // Look for the online directory string mets_file = String.Empty; if (!multiple_bibs_in_table) { string online_folder = Library.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) + "\\" + vid; if (!Directory.Exists(online_folder)) { MessageBox.Show("Select a different VID, since this VID is not yet fully loaded into " + Library.SobekCM_Library_Settings.System_Abbreviation + ". \n\nDirectory not present online.", "VID not loaded", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Look for the online METS mets_file = online_folder + "\\" + bibid + "_" + vid + ".mets.xml"; if (!File.Exists(mets_file)) { MessageBox.Show("Select a different VID, since this VID is not yet fully loaded into " + Library.SobekCM_Library_Settings.System_Abbreviation + ". \n\nMETS file missing online.", "VID not loaded", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Try to copy this to a local temporary folder for speed purposes try { File.Copy(mets_file, temp_folder + "\\" + bibid + "_" + vid + ".mets.xml", true); mets_file = temp_folder + "\\" + bibid + "_" + vid + ".mets.xml"; } catch { } } // Display an hourglass cursor and set max value on the ProgressBar Cursor = Cursors.WaitCursor; progressBar1.Maximum = transformedDataTbl.Rows.Count; // enable the Stop button executeButton.Button_Enabled = true; // Show the progress bar progressBar1.Visible = true; progressBar1.Value = progressBar1.Minimum; try { // Create the Processor and assign the Delegate method for event processing. processor = !multiple_bibs_in_table ? new Volume_Import_Processor(transformedDataTbl, bibid, mets_file, temp_folder, visibility, dark) : new Volume_Import_Processor(transformedDataTbl, String.Empty, String.Empty, temp_folder, visibility, dark); 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.Go); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception ee) { // display the error message ErrorMessageBox.Show("Error encountered while processing!\n\n" + ee.Message, "Volume Import Error", ee); Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }
private void executeButton_Button_Pressed(object sender, EventArgs e) { // Make sure some rows of data are ready to be imported if (transformedDataTbl.Rows.Count == 0) { MessageBox.Show("No data rows to import! ", "Import Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check to see if multiple bibids loaded string check_bib = transformedDataTbl.Rows[0][0].ToString().ToUpper(); bool multiple_bibs_in_table = transformedDataTbl.Rows.Cast <DataRow>().Any(thisRow => thisRow[0].ToString().ToUpper() != check_bib); // Create a temporary folder string temp_folder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary"; try { if (!Directory.Exists(temp_folder)) { Directory.CreateDirectory(temp_folder); } } catch { } string bibid = bibidLabel.Text; string vid = vidComboBox.Text; int visibility_index = visibilityComboBox.SelectedIndex; bool dark = false; int visibility = 0; switch (visibility_index) { case 0: dark = true; visibility = -1; break; case 1: visibility = -1; break; case 2: visibility = 1; break; case 3: visibility = 0; break; } // Look for the online directory string mets_file = String.Empty; if (!multiple_bibs_in_table) { string online_folder = Library.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) + "\\" + vid; if (!Directory.Exists(online_folder)) { MessageBox.Show("Select a different VID, since this VID is not yet fully loaded into " + Library.SobekCM_Library_Settings.System_Abbreviation + ". \n\nDirectory not present online.", "VID not loaded", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Look for the online METS mets_file = online_folder + "\\" + bibid + "_" + vid + ".mets.xml"; if (!File.Exists(mets_file)) { MessageBox.Show("Select a different VID, since this VID is not yet fully loaded into " + Library.SobekCM_Library_Settings.System_Abbreviation + ". \n\nMETS file missing online.", "VID not loaded", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Try to copy this to a local temporary folder for speed purposes try { File.Copy(mets_file, temp_folder + "\\" + bibid + "_" + vid + ".mets.xml", true); mets_file = temp_folder + "\\" + bibid + "_" + vid + ".mets.xml"; } catch { } } // Display an hourglass cursor and set max value on the ProgressBar Cursor = Cursors.WaitCursor; progressBar1.Maximum = transformedDataTbl.Rows.Count; // enable the Stop button executeButton.Button_Enabled = true; // Show the progress bar progressBar1.Visible = true; progressBar1.Value = progressBar1.Minimum; try { // Create the Processor and assign the Delegate method for event processing. processor = !multiple_bibs_in_table ? new Volume_Import_Processor(transformedDataTbl, bibid, mets_file, temp_folder, visibility, dark) : new Volume_Import_Processor(transformedDataTbl, String.Empty, String.Empty, temp_folder, visibility, dark); 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.Go); processThread.SetApartmentState(ApartmentState.STA); processThread.Start(); } catch (Exception ee) { // display the error message ErrorMessageBox.Show("Error encountered while processing!\n\n" + ee.Message, "Volume Import Error", ee); Cursor = Cursors.Default; progressBar1.Value = progressBar1.Minimum; } }