/// <summary> Adds this bib id to the SobekCM database. </summary> /// <param name="bibPackage"> Digital resource object to save to teh database </param> /// <param name="source"> String indicates the source of this new item </param> /// <param name="preview_mode"> Flag indicates this is preview mode </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> If the save is successful, the new BibID, VID, ItemID, and GroupID are /// added to the digital resource object. </remarks> protected bool add_to_database(SobekCM_Item bibPackage, string source, bool preview_mode, bool existing ) { bool new_item_flag = false; try { // Is there a valid material type? if ((bibPackage.Bib_Info.SobekCM_Type_String == "UNDETERMINED") || (bibPackage.Bib_Info.SobekCM_Type_String.Length == 0)) { if (default_material_type.Length > 0) { bibPackage.Bib_Info.SobekCM_Type_String = default_material_type; } else { Forms.Select_Material_Type_Form selectMaterialType = new Forms.Select_Material_Type_Form(bibPackage.Bib_Info.OCLC_Record, bibPackage.Bib_Info.ALEPH_Record, bibPackage.Bib_Info.Main_Title.ToString(), bibPackage.BibID); if ( selectMaterialType.ShowDialog() == System.Windows.Forms.DialogResult.OK ) { bibPackage.Bib_Info.SobekCM_Type_String = selectMaterialType.Material_Type; if ( selectMaterialType.Always_Use_This_Answer ) { default_material_type = selectMaterialType.Material_Type; } } } } // Set a value for the VID_Source and Last_Modified_User variables string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; bibPackage.Tracking.VID_Source = source + ":" + System.Security.Principal.WindowsIdentity.GetCurrent().Name; // If the bibid is not in bibid format, then clear it and save it now string original_bibid = bibPackage.BibID; if (!SobekCM.Resource_Object.Database.SobekCM_Database.is_bibid_format(original_bibid)) { if (Provided_Bib_To_New_Bib.ContainsKey(bibPackage.BibID)) { bibPackage.BibID = Provided_Bib_To_New_Bib[bibPackage.BibID]; } else { bibPackage.BibID = "AA"; } } else { original_bibid = String.Empty; } // Set some values based on the TYPE if (bibPackage.Bib_Info.SobekCM_Type_String.ToUpper().IndexOf("NEWSPAPER") >= 0) { bibPackage.Tracking.Large_Format = true; bibPackage.Tracking.Track_By_Month = true; } // Save this Bib oject to the database warnings.Clear(); if (!preview_mode) { if (!existing) { if (!SobekCM.Resource_Object.Database.SobekCM_Database.Save_New_Digital_Resource(bibPackage, false, false, username, source, -1)) { //this.errors.Add("Error saving " + bibPackage.BibID + ":" + bibPackage.VID + " to the database."); errorCnt++; recordsProcessed++; // exit without saving the Bib item return false; } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } else { if (SobekCM.Resource_Object.Database.SobekCM_Database.Save_Digital_Resource(bibPackage) < 0) { //this.errors.Add("Error saving " + bibPackage.BibID + ":" + bibPackage.VID + " to the database."); errorCnt++; recordsProcessed++; // exit without saving the Bib item return false; } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } } else { if (!Preview_Duplicate_Save_To_Database(bibPackage, errors, warnings, true, new_item_flag)) { errorCnt++; recordsProcessed++; // exit without saving the Bib item return false; } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } // If the original value for BibID was not a valid BibID include the mapping // from that term to the new BibID if ((original_bibid.Length > 0) && ( bibPackage.BibID.Length > 0 ) && ( !Provided_Bib_To_New_Bib.ContainsKey( original_bibid ))) { Provided_Bib_To_New_Bib[original_bibid] = bibPackage.BibID; } } catch (Exception e) { DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); } // increment the recordsProcessed counter recordsProcessed++; // Return this Bib item return true; }
/// <summary> Adds this bib id to the SobekCM database. </summary> /// <param name="bibPackage"> Digital resource object to save to teh database </param> /// <param name="source"> String indicates the source of this new item </param> /// <param name="preview_mode"> Flag indicates this is preview mode </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> If the save is successful, the new BibID, VID, ItemID, and GroupID are /// added to the digital resource object. </remarks> protected bool add_to_database(SobekCM_Item bibPackage, string source, bool preview_mode, bool existing) { bool new_item_flag = false; try { // Is there a valid material type? if ((bibPackage.Bib_Info.SobekCM_Type_String == "UNDETERMINED") || (bibPackage.Bib_Info.SobekCM_Type_String.Length == 0)) { if (default_material_type.Length > 0) { bibPackage.Bib_Info.SobekCM_Type_String = default_material_type; } else { Forms.Select_Material_Type_Form selectMaterialType = new Forms.Select_Material_Type_Form(bibPackage.Bib_Info.OCLC_Record, bibPackage.Bib_Info.ALEPH_Record, bibPackage.Bib_Info.Main_Title.ToString(), bibPackage.BibID); if (selectMaterialType.ShowDialog() == System.Windows.Forms.DialogResult.OK) { bibPackage.Bib_Info.SobekCM_Type_String = selectMaterialType.Material_Type; if (selectMaterialType.Always_Use_This_Answer) { default_material_type = selectMaterialType.Material_Type; } } } } // Set a value for the VID_Source and Last_Modified_User variables string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; bibPackage.Tracking.VID_Source = source + ":" + System.Security.Principal.WindowsIdentity.GetCurrent().Name; // If the bibid is not in bibid format, then clear it and save it now string original_bibid = bibPackage.BibID; if (!SobekCM.Resource_Object.Database.SobekCM_Database.is_bibid_format(original_bibid)) { if (Provided_Bib_To_New_Bib.ContainsKey(bibPackage.BibID)) { bibPackage.BibID = Provided_Bib_To_New_Bib[bibPackage.BibID]; } else { bibPackage.BibID = "AA"; } } else { original_bibid = String.Empty; } // Set some values based on the TYPE if (bibPackage.Bib_Info.SobekCM_Type_String.ToUpper().IndexOf("NEWSPAPER") >= 0) { bibPackage.Tracking.Large_Format = true; bibPackage.Tracking.Track_By_Month = true; } // Save this Bib oject to the database warnings.Clear(); if (!preview_mode) { if (!existing) { if (!SobekCM.Resource_Object.Database.SobekCM_Database.Save_New_Digital_Resource(bibPackage, false, false, username, source, -1)) { //this.errors.Add("Error saving " + bibPackage.BibID + ":" + bibPackage.VID + " to the database."); errorCnt++; recordsProcessed++; // exit without saving the Bib item return(false); } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) { New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } } else { if (SobekCM.Resource_Object.Database.SobekCM_Database.Save_Digital_Resource(bibPackage) < 0) { //this.errors.Add("Error saving " + bibPackage.BibID + ":" + bibPackage.VID + " to the database."); errorCnt++; recordsProcessed++; // exit without saving the Bib item return(false); } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) { New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } } } else { if (!Preview_Duplicate_Save_To_Database(bibPackage, errors, warnings, true, new_item_flag)) { errorCnt++; recordsProcessed++; // exit without saving the Bib item return(false); } else { string original_id = bibPackage.BibID + ":" + bibPackage.VID; // increment the recordsSavedToDB counter recordsSavedToDB++; // Save this as a new bib id if (!New_Bib_IDs.Contains(bibPackage.BibID.ToUpper())) { New_Bib_IDs.Add(bibPackage.BibID.ToUpper()); } } } // If the original value for BibID was not a valid BibID include the mapping // from that term to the new BibID if ((original_bibid.Length > 0) && (bibPackage.BibID.Length > 0) && (!Provided_Bib_To_New_Bib.ContainsKey(original_bibid))) { Provided_Bib_To_New_Bib[original_bibid] = bibPackage.BibID; } } catch (Exception e) { DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while processing!\n\n" + e.Message, "DLC Importer Error", e); } // increment the recordsProcessed counter recordsProcessed++; // Return this Bib item return(true); }