private void saveButton_Click(object sender, EventArgs e) { if ((!createNewRecordRadioButton.Checked) && (!skipRecordRadioButton.Checked) && (!overlayRadioButton.Checked)) { MessageBox.Show("Select an option for processing the matching record. ", "No Option Selected", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // Was CreateRecord checked? if (createNewRecordRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Create_New_Record; } // Was SkipRecord checked? if (skipRecordRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Skip; } // Was overlay checked? if (overlayRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Overlay_Bib_Record; } // Was Always Use checkbox checked? alwaysUseOptionFlag = this.alwaysUseOptionCheckBox.Checked; this.Close(); } }
private void saveButton_Click(object sender, EventArgs e) { if ((!createNewRecordRadioButton.Checked) && (!skipRecordRadioButton.Checked) && ( !overlayRadioButton.Checked )) { MessageBox.Show("Select an option for processing the matching record. ", "No Option Selected", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // Was CreateRecord checked? if (createNewRecordRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Create_New_Record; } // Was SkipRecord checked? if (skipRecordRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Skip; } // Was overlay checked? if (overlayRadioButton.Checked) { selectedOptionValue = Matching_Record_Choice_Enum.Overlay_Bib_Record; } // Was Always Use checkbox checked? alwaysUseOptionFlag = this.alwaysUseOptionCheckBox.Checked; this.Close(); } }
public Matching_Record_Dialog_Form(string dialogMessage, bool allow_overlay) { InitializeComponent(); if (!allow_overlay) overlayRadioButton.Enabled = false; // Perform some additional work if this was not XP theme if (!Windows_Appearance_Checker.is_XP_Theme) { createNewRecordRadioButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; skipRecordRadioButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; alwaysUseOptionCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; saveButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; overlayRadioButton.FlatStyle = FlatStyle.Flat; } this.messageLabel.Text = dialogMessage; this.selectedOptionValue = Matching_Record_Choice_Enum.Skip; }
public Matching_Record_Dialog_Form(string dialogMessage, bool allow_overlay) { InitializeComponent(); if (!allow_overlay) { overlayRadioButton.Enabled = false; } // Perform some additional work if this was not XP theme if (!Windows_Appearance_Checker.is_XP_Theme) { createNewRecordRadioButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; skipRecordRadioButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; alwaysUseOptionCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; saveButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; overlayRadioButton.FlatStyle = FlatStyle.Flat; } this.messageLabel.Text = dialogMessage; this.selectedOptionValue = Matching_Record_Choice_Enum.Skip; }
private Matching_Record_Choice_Enum get_matching_record_choice(string matching_message, string field, string matching_record) { // Display matching row dialog form if (matching_record_dialog_form_always_use_value == Matching_Record_Choice_Enum.Undefined) { // Get users input Forms.Matching_Record_Dialog_Form matching_record_dialog_form = new Forms.Matching_Record_Dialog_Form(String.Format(matching_message, field, matching_record), allow_overlay); matching_record_dialog_form.ShowDialog(); // Did user select always answer this way? if (matching_record_dialog_form.Always_Use_Option_Flag) { matching_record_dialog_form_always_use_value = matching_record_dialog_form.Selected_Option_Value; } // Return the value return(matching_record_dialog_form.Selected_Option_Value); } else { return(matching_record_dialog_form_always_use_value); } }
private Matching_Record_Choice_Enum get_matching_record_choice(string matching_message, string field, string matching_record) { // Display matching row dialog form if (matching_record_dialog_form_always_use_value == Matching_Record_Choice_Enum.Undefined) { // Get users input Forms.Matching_Record_Dialog_Form matching_record_dialog_form = new Forms.Matching_Record_Dialog_Form(String.Format( matching_message, field, matching_record ), allow_overlay ); matching_record_dialog_form.ShowDialog(); // Did user select always answer this way? if (matching_record_dialog_form.Always_Use_Option_Flag) matching_record_dialog_form_always_use_value = matching_record_dialog_form.Selected_Option_Value; // Return the value return matching_record_dialog_form.Selected_Option_Value; } else { return matching_record_dialog_form_always_use_value; } }
protected bool Check_For_Existence_And_Save(SobekCM_Item bibPackage, DataRow currentRow, string related_file, string message, string importer_bib_source, bool preview_mode) { // reset local variables Matching_Record_Choice_Enum matching_record_dialog_form_selected_value = Matching_Record_Choice_Enum.Undefined; item_import_comments = String.Empty; bool try_to_fetch_existing_division_information = false; // clear the message collection if (currentRow != null) { currentRow["Messages"] = String.Empty; } // Does this Bibliographic record already exist in the tracking database? DataRow[] selected = null; DataTable matchingRows = SobekCM.Resource_Object.Database.SobekCM_Database.Check_For_Record_Existence(bibPackage.BibID, bibPackage.VID, bibPackage.Bib_Info.OCLC_Record, bibPackage.Bib_Info.ALEPH_Record); if ((matchingRows != null) && (matchingRows.Rows.Count > 0)) { // check if the BibID already exists if (bibPackage.BibID.Trim().Length > 0) { if (Provided_Bib_To_New_Bib.ContainsKey(bibPackage.BibID)) { bibPackage.BibID = Provided_Bib_To_New_Bib[bibPackage.BibID]; matching_record_dialog_form_selected_value = Matching_Record_Choice_Enum.Create_New_Record; } else { string vid = bibPackage.VID.PadLeft(5, '0'); selected = matchingRows.Select("BibID ='" + bibPackage.BibID.Replace("'", "''") + "' and vid = '" + vid.Replace("'", "") + "'"); // Search for an existing record that matches the provided BibID. if ((bibPackage.VID.Length > 0) && (selected.Length > 0)) { matching_record_dialog_form_selected_value = Matching_Record_Choice_Enum.Skip; } } } // Don't bother if there was already a BibID:VID match if ((matching_record_dialog_form_selected_value == Matching_Record_Choice_Enum.Undefined) && (matchingRows.Rows.Count > 0)) { // Check for both existing ALEPH and existing OCLC here in one piece of logic if (!New_Bib_IDs.Contains(matchingRows.Rows[0]["bibid"].ToString().ToUpper())) { matching_record_dialog_form_selected_value = get_matching_record_choice(message, "Aleph # " + bibPackage.Bib_Info.ALEPH_Record, matchingRows.Rows[0]["bibid"].ToString()); if (matching_record_dialog_form_selected_value == Matching_Record_Choice_Enum.Skip) { bibPackage.BibID = "(" + matchingRows.Rows[0]["bibid"].ToString() + ")"; } else if (matching_record_dialog_form_selected_value == Matching_Record_Choice_Enum.Overlay_Bib_Record) { if (bibPackage.BibID.Length == 0) { bibPackage.BibID = matchingRows.Rows[0]["bibid"].ToString().ToUpper(); } if (bibPackage.VID.Length == 0) { bibPackage.VID = matchingRows.Rows[0]["vid"].ToString().ToUpper(); } try_to_fetch_existing_division_information = true; } } else if (Importer_Type == Importer_Type_Enum.MARC) { if (bibPackage.BibID.Length == 0) { bibPackage.BibID = matchingRows.Rows[0]["bibid"].ToString().ToUpper(); } if (bibPackage.VID.Length == 0) { bibPackage.VID = matchingRows.Rows[0]["vid"].ToString().ToUpper(); } try_to_fetch_existing_division_information = true; } } } // Clear the errors this.errors.Clear(); this.warnings.Clear(); // determine how to process this row from the dialog result switch (matching_record_dialog_form_selected_value) { case Matching_Record_Choice_Enum.Overlay_Bib_Record: if ((try_to_fetch_existing_division_information)) { Resource_Object.SobekCM_Item fromTracking = SobekCM_METS_Finder.Find_UFDC_METS(bibPackage.BibID, bibPackage.VID, String.Empty, null); if (fromTracking != null) { // Copy serial hierarchy information if ((fromTracking.Bib_Info.Series_Part_Info.Enum1.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Enum1.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Enum1 = fromTracking.Bib_Info.Series_Part_Info.Enum1; } if ((fromTracking.Bib_Info.Series_Part_Info.Enum2.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Enum2.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Enum2 = fromTracking.Bib_Info.Series_Part_Info.Enum2; } if ((fromTracking.Bib_Info.Series_Part_Info.Enum3.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Enum3.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Enum3 = fromTracking.Bib_Info.Series_Part_Info.Enum3; } if ((fromTracking.Bib_Info.Series_Part_Info.Year.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Year.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Year = fromTracking.Bib_Info.Series_Part_Info.Year; } if ((fromTracking.Bib_Info.Series_Part_Info.Month.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Month.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Month = fromTracking.Bib_Info.Series_Part_Info.Month; } if ((fromTracking.Bib_Info.Series_Part_Info.Day.Length > 0) && (bibPackage.Bib_Info.Series_Part_Info.Day.Length == 0)) { bibPackage.Bib_Info.Series_Part_Info.Day = fromTracking.Bib_Info.Series_Part_Info.Day; } // Copy origin date if ((fromTracking.Bib_Info.Origin_Info.Date_Issued.Length > 0) && (bibPackage.Bib_Info.Origin_Info.Date_Issued.Length == 0)) { bibPackage.Bib_Info.Origin_Info.Date_Issued = fromTracking.Bib_Info.Origin_Info.Date_Issued; } // Check for donor if ((bibPackage.Bib_Info.Donor.ToString().ToUpper().Replace("UNKNOWN", "").Length == 0) && (fromTracking.Bib_Info.Donor.Full_Name.ToUpper().Replace("UNKNOWN", "").Length > 0)) { bibPackage.Bib_Info.Donor.Full_Name = fromTracking.Bib_Info.Donor.Full_Name; } // Check for ALEPH number if ((bibPackage.Bib_Info.ALEPH_Record.Length == 0) && (fromTracking.Bib_Info.ALEPH_Record.Length > 0)) { bibPackage.Bib_Info.Add_Identifier(fromTracking.Bib_Info.ALEPH_Record, "Aleph"); } // Copy the source and holding information bibPackage.Bib_Info.Source.Code = fromTracking.Bib_Info.Source.Code; bibPackage.Bib_Info.Source.Statement = fromTracking.Bib_Info.Source.Statement; bibPackage.Bib_Info.Location.Holding_Code = fromTracking.Bib_Info.Location.Holding_Code; bibPackage.Bib_Info.Location.Holding_Name = fromTracking.Bib_Info.Location.Holding_Name; // Copy any EAD information bibPackage.Bib_Info.Location.EAD_Name = fromTracking.Bib_Info.Location.EAD_Name; bibPackage.Bib_Info.Location.EAD_URL = fromTracking.Bib_Info.Location.EAD_URL; // Finally copy over the divisions, which also includes the files bibPackage.Divisions = fromTracking.Divisions; } } bibPackage.METS_Header.RecordStatus_Enum = METS_Record_Status.METADATA_UPDATE; add_to_database(bibPackage, importer_bib_source, preview_mode, true); if (this.errors.Count == 0) { if (preview_mode) { item_import_comments += "Existing record would have been overlayed. " + Tracking_Warnings; } else { item_import_comments += "Existing record overlayed. " + Tracking_Warnings; } report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = item_import_comments; currentRow["New Bib ID"] = bibPackage.BibID; currentRow["New VID ID"] = bibPackage.VID; } return(true); } else { item_import_comments = Error_Message; report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = Error_Message; bibPackage.VID = String.Empty; bibPackage.BibID = String.Empty; } return(false); } break; case Matching_Record_Choice_Enum.Create_New_Record: // add new bib record add_to_database(bibPackage, importer_bib_source, preview_mode, false); if (this.errors.Count == 0) { if (preview_mode) { item_import_comments += "New record would have been created. " + Tracking_Warnings; } else { item_import_comments += "New record created. " + Tracking_Warnings; } report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = item_import_comments; currentRow["New Bib ID"] = bibPackage.BibID; currentRow["New VID ID"] = bibPackage.VID; } return(true); } else { item_import_comments = Error_Message; report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = Error_Message; bibPackage.VID = String.Empty; bibPackage.BibID = String.Empty; } return(false); } break; case Matching_Record_Choice_Enum.Skip: // stop processing this record and continue to the next record if (errors.Count == 0) { item_import_comments += " Record skipped."; if (currentRow != null) { currentRow["Messages"] = "Record skipped."; } } else { item_import_comments = Error_Message; if (currentRow != null) { currentRow["Messages"] = Error_Message; } } // Add this to the result table being built report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); recordsProcessed++; recordsSkipped++; return(false); case Matching_Record_Choice_Enum.Undefined: // add this record to the database since it did not match any existing records if (!add_to_database(bibPackage, importer_bib_source, preview_mode, false)) { this.errors.Add("Unable to save to tracking"); } if (this.errors.Count == 0) { if (preview_mode) { item_import_comments += "New record would have been created. " + Tracking_Warnings; } else { item_import_comments += "New record created. " + Tracking_Warnings; } report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = item_import_comments; currentRow["New Bib ID"] = bibPackage.BibID; currentRow["New VID ID"] = bibPackage.VID; } return(true); } else { item_import_comments = Error_Message; report.Add_Item(bibPackage, related_file, item_import_comments.Trim()); if (currentRow != null) { currentRow["Messages"] = Error_Message; bibPackage.VID = String.Empty; bibPackage.BibID = String.Empty; } return(false); } break; } return(false); }