/// <summary> Updates the list of Z39.50 endpoints to either add this new endpoint /// or update an existing endpoint of the same name </summary> /// <param name="New_Endpoint"> New or existing endpoint to put in the collection of endpoints </param> public static void Add_Z3950_Endpoint(Z3950_Endpoint New_Endpoint) { // Look for an existing endpoint foreach (Z3950_Endpoint thisEndpoint in z3950_endpoints) { if (thisEndpoint.Name == New_Endpoint.Name) { thisEndpoint.Database_Name = New_Endpoint.Database_Name; thisEndpoint.Port = New_Endpoint.Port; thisEndpoint.URI = New_Endpoint.URI; thisEndpoint.Username = New_Endpoint.Username; if (New_Endpoint.Save_Password_Flag) { thisEndpoint.Password = New_Endpoint.Password; thisEndpoint.Save_Password_Flag = true; } else { thisEndpoint.Password = String.Empty; } return; } } // Must not be an existing endpoint, so copy this and add the copy z3950_endpoints.Add(New_Endpoint.Copy()); }
public Z3950_Import_Form() { InitializeComponent(); // Create the empty endpoint endpoint = new Z3950_Endpoint(); // Populate the combo box endpointComboBox.Items.Add(NEW); IEnumerable <string> endpoints = MetaTemplate_UserSettings.Z3950_Endpoint_Names; foreach (string thisEndpoint in endpoints) { endpointComboBox.Items.Add(thisEndpoint); } endpointComboBox.Text = NEW; // Restore last endpoint, if it exists if (MetaTemplate_UserSettings.Last_Z3950_Endpoint.Length > 0) { if (endpointComboBox.Items.Contains(MetaTemplate_UserSettings.Last_Z3950_Endpoint)) { endpointComboBox.Text = MetaTemplate_UserSettings.Last_Z3950_Endpoint; } } }
private MARC_Record GetMarcRecord(String bNumber) { var normalised = WellcomeLibraryIdentifiers.GetNormalisedBNumber(bNumber, false); var identifier = WellcomeLibraryIdentifiers.GetShortBNumber(normalised).ToString(CultureInfo.InvariantCulture); string msg; var endpoint = new Z3950_Endpoint(Z3950Name, Z3950Host, Z3950Port, Z3950DbName); return(MARC_Record_Z3950_Retriever.Get_Record_By_Primary_Identifier(identifier, endpoint, out msg)); }
private void importButton_Button_Pressed(object sender, EventArgs e) { // Check the primary key is provided if (identifierTextBox.Text.Trim().Length == 0) { MessageBox.Show("Enter the primary identifier to import the Z39.50 records. ", "Missing Primary Identifier", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check the Z39.50 endpoint if (endpoint == null) { Z3950_Endpoint_Form endpointForm = new Z3950_Endpoint_Form(); Hide(); endpointForm.ShowDialog(); Show(); endpoint = endpointForm.Endpoint; if (endpoint == null) { MessageBox.Show("Select a Z39.50 endpoint or enter information for a new or temporary endpoint. ", "Missing Endpoint", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Since this was a VALID entry, save this as the last Z39.50 endpoint used if ((endpoint.Name != NEW) && (endpoint.Name != TEMP)) { MetaTemplate_UserSettings.Last_Z3950_Endpoint = endpoint.Name; MetaTemplate_UserSettings.Save(); } string identifier = identifierTextBox.Text.Trim(); string out_message = String.Empty; MARC_Record record_from_z3950 = MARC_Record_Z3950_Retriever.Get_Record_By_Primary_Identifier(identifier, endpoint, out out_message); if (record_from_z3950 == null) { if (out_message.Length > 0) { MessageBox.Show(out_message, "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Unknown error occurred during request", "Error Encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //MessageBox.Show("Found!!\n\n" + record_from_z3950.To_Machine_Readable_Record()); Record = record_from_z3950; } Close(); }
private void save_data_to_endpoint() { if (Endpoint == null) { Endpoint = new Z3950_Endpoint(); } Endpoint.URI = uriTextBox.Text.Trim(); Endpoint.Port = UInt32.Parse(portTextBox.Text.Trim()); Endpoint.Database_Name = dbNameTextBox.Text; Endpoint.Username = usernameTextBox.Text; Endpoint.Password = passwordTextBox.Text; }
private void refresh_endpoints() { listView1.Items.Clear(); ReadOnlyCollection <string> endpoints = MetaTemplate_UserSettings.Z3950_Endpoint_Names; foreach (string thisEndpointName in endpoints) { Z3950_Endpoint thisEndpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(thisEndpointName); ListViewItem newItem = new ListViewItem(new[] { thisEndpointName, thisEndpoint.URI, thisEndpoint.Port.ToString(), thisEndpoint.Database_Name }); listView1.Items.Add(newItem); } deleteButton.Button_Enabled = false; editButton.Button_Enabled = false; }
private void endpointComboBox_SelectedIndexChanged(object sender, EventArgs e) { if ((endpointComboBox.Text != NEW) && (endpointComboBox.Text != TEMP)) { endpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(endpointComboBox.Text); if (endpoint == null) { endpointComboBox.Text = NEW; } } else if (endpointComboBox.Text == TEMP) { endpoint = temporaryEndpoint; } else if (endpointComboBox.Text == NEW) { endpoint = null; } }
private void editButton_Button_Pressed(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string name = listView1.SelectedItems[0].SubItems[0].Text; Z3950_Endpoint endpoint = MetaTemplate_UserSettings.Get_Endpoint_By_Name(name); if (endpoint != null) { Z3950_Endpoint_Form editForm = new Z3950_Endpoint_Form(endpoint, false); Hide(); editForm.ShowDialog(); Show(); if (editForm.Endpoint != null) { MetaTemplate_UserSettings.Add_Z3950_Endpoint(editForm.Endpoint); MetaTemplate_UserSettings.Save(); } } } refresh_endpoints(); }
private static void demo4() { Console.WriteLine("Performing demo4 ( z39.50 )"); try { // Create the Z39.50 endpoint Z3950_Endpoint endpoint = new Z3950_Endpoint("Moravian Library in Brno", "aleph.mzk.cz", 9991, "MZK01-UTF"); // Retrieve the record by primary identifier string out_message; MARC_Record record_from_z3950 = MARC_Record_Z3950_Retriever.Get_Record(/*7*/ 1063, "2610356038" /*"80-85609-28-2"*/, endpoint, out out_message, Record_Character_Encoding.Unicode); //MARC_Record record_from_z3950 = MARC_Record_Z3950_Retriever.Get_Record_By_Primary_Identifier("4543338", endpoint, out out_message); // Display any error message encountered if (record_from_z3950 == null) { if (out_message.Length > 0) { Console.WriteLine(out_message); } else { Console.WriteLine("Unknown error occurred during Z39.50 request"); } return; } Console.WriteLine(record_from_z3950.Get_Data_Subfield(100, 'a')); Console.WriteLine(record_from_z3950); // Write as MARCXML record_from_z3950.Save_MARC_XML("C:\\Temp\\demo4.xml"); } catch (Exception ee) { Console.WriteLine("EXCEPTION CAUGHT while performing Z39.50 demo. ( " + ee.Message + " )"); } }
private void newEditButton_Button_Pressed(object sender, EventArgs e) { Z3950_Endpoint_Form endpointForm = new Z3950_Endpoint_Form(endpoint, true); Hide(); endpointForm.ShowDialog(); // Was an item added? if (endpointForm.Endpoint != null) { if (String.Compare(endpointForm.Endpoint.Name, endpointComboBox.Text, true) != 0) { endpoint = endpointForm.Endpoint; // Now, reload the list of endpoints endpointComboBox.Items.Clear(); endpointComboBox.Items.Add(NEW); if (endpoint.Name == TEMP) { temporaryEndpoint = endpoint; endpointComboBox.Items.Add(TEMP); } IEnumerable <string> endpoints = MetaTemplate_UserSettings.Z3950_Endpoint_Names; foreach (string thisEndpoint in endpoints) { endpointComboBox.Items.Add(thisEndpoint); } // Select the selected endpointComboBox.Text = endpointForm.Endpoint.Name; } } Show(); }
public Z3950_Endpoint_Form(Z3950_Endpoint Endpoint, bool during_connection) { InitializeComponent(); if (Endpoint != null) { this.Endpoint = Endpoint; uriTextBox.Text = Endpoint.URI; portTextBox.Text = Endpoint.Port.ToString(); dbNameTextBox.Text = Endpoint.Database_Name; usernameTextBox.Text = Endpoint.Username; passwordTextBox.Text = Endpoint.Password; } else { Endpoint = new Z3950_Endpoint(); } this.during_connection = during_connection; if (!during_connection) { connectButton.Hide(); } }
// Retrieves metadata from Z39.50 server private static IList <Metadata> RetrieveMetadataByZ39(IdentifierType identifierType, string value, bool isUnion) { string z39Server = Settings.Z39ServerUrl; int z39Port = Settings.Z39Port; string z39Base = Settings.Z39Base; string z39UserName = Settings.Z39UserName; string z39Password = Settings.Z39Password; Record_Character_Encoding z39Encoding = Settings.Z39Encoding; //Set union Z39.50 if (isUnion) { z39Server = Settings.Z39UnionServerUrl; z39Port = Settings.Z39UnionPort; z39Base = Settings.Z39UnionBase; z39Encoding = Settings.Z39UnionEncoding; z39UserName = null; z39Password = null; } int identifierFieldNumber; switch (identifierType) { case IdentifierType.BARCODE: identifierFieldNumber = Settings.Z39BarcodeField; break; case IdentifierType.CNB: if (isUnion) { identifierFieldNumber = Settings.DEFAULT_NKP_CNB_FIELD; } else { identifierFieldNumber = Settings.Z39CnbField; } break; case IdentifierType.EAN: identifierFieldNumber = Settings.Z39EanField; break; case IdentifierType.ISBN: identifierFieldNumber = Settings.Z39IsbnField; break; case IdentifierType.ISSN: identifierFieldNumber = Settings.Z39IssnField; break; case IdentifierType.ISMN: identifierFieldNumber = Settings.Z39IsmnField; break; case IdentifierType.OCLC: identifierFieldNumber = Settings.Z39OclcField; break; default: identifierFieldNumber = Settings.DEFAULT_FIELD; break; } //validate string errorText = ""; if (string.IsNullOrEmpty(z39Server)) { errorText += "Z39.50 Server URL; "; } if (z39Port <= 0) { errorText += "Z39.50 Sever Port; "; } if (string.IsNullOrEmpty(z39Base)) { errorText += "Z39.50 Databáze; "; } if (identifierFieldNumber <= 0) { errorText += "Vyhledávací atribut"; } if (!string.IsNullOrEmpty(errorText)) { throw new ArgumentException("V nastaveních chybí následující údaje: " + errorText); } List <Metadata> metadataList = new List <Metadata>(); string errorMessage = ""; try { Z3950_Endpoint endpoint; if (string.IsNullOrEmpty(z39UserName)) { endpoint = new Z3950_Endpoint("Z39.50", z39Server, (uint)z39Port, z39Base); } else { endpoint = new Z3950_Endpoint("Z39.50", z39Server, (uint)z39Port, z39Base, z39UserName); endpoint.Password = z39Password ?? ""; } // Retrieve the record by primary identifier IEnumerable <MARC_Record> recordsFromZ3950 = MARC_Record_Z3950_Retriever.Get_Record( identifierFieldNumber, '"' + value + '"', endpoint, out errorMessage, z39Encoding); MARCXML_Writer marcXmlWriter = new MARCXML_Writer(System.IO.Path.Combine(Settings.TemporaryFolder, "marcxml.xml")); if (recordsFromZ3950 != null) { foreach (MARC_Record record in recordsFromZ3950) { Metadata metadata = new Metadata(); // Sysno metadata.Sysno = record.Control_Number; metadata.FixedFields = MarcGetFixedFields(record); metadata.VariableFields = MarcGetVariableFields(record); // Get identifiers list (ISBNs + 902a yearbooks) List <MetadataIdentifier> Identifiers = getIdentifiersList(metadata); metadata.Identifiers = Identifiers; // Add to list metadataList.Add(metadata); // Write to MARC XML file marcXmlWriter.AppendRecord(record); } // Finish MARC XML file marcXmlWriter.Close(); } } catch (Exception e) { throw new Z39Exception("Nastala chyba během stahování MARC záznamu pomocí Z39.50, nebo zápisu výsledného MARC záznamu na disk. Detailnější popis problému: " + e.Message); } // Display any error message encountered if (metadataList.Count == 0) { if (errorMessage.Length > 0) { if (errorMessage.Contains("No matching record found in Z39.50 endpoint")) { errorMessage = "Nenalezen vhodný záznam."; } else if (errorMessage.Contains("Connection could not be made to")) { errorMessage = "Nebylo možné navázat spojení s " + errorMessage.Substring(errorMessage.LastIndexOf(' ')); } throw new Z39Exception(errorMessage); } else { throw new Z39Exception("Nastala neznámá chyba během Z39.50 dotazu"); } } return(metadataList); }
/// <summary> Load the individual user settings </summary> public static void Load() { try { // Try to read the XML file from isolated storage Read_XML_File(SETTINGS_FILENAME); // Make sure this contains one setting. If not, set them to default if (Get_String_Setting("Settings_Version") != "1.1") { // Add the defaults First_Launch = true; Add_Setting("Language", 1); Add_Setting("Font_Face", "Arial"); Add_Setting("Font_Size", "Medium"); Add_Setting("Width", "700"); Add_Setting("Height", "500"); Add_Setting("Recent1", ""); Add_Setting("Recent2", ""); Add_Setting("Recent3", ""); Add_Setting("Recent4", ""); Add_Setting("Recent5", ""); Add_Setting("Template", ""); Add_Setting("Help_Source", 0); Add_Setting("Include_FDA", 0); Add_Setting("Include_Checksums", 0); Add_Setting("Include_SobekCM_File", 1); Add_Setting("Extension", ".mets"); Add_Setting("Show_Metadata_PostSave", "false"); Add_Setting("ImageDeriv_Create_JPEG", 1); Add_Setting("ImageDeriv_Create_JPEG2000", 1); Add_Setting("ImageDeriv_Width", DEFAULT_IMAGE_WIDTH); Add_Setting("ImageDeriv_Height", DEFAULT_IMAGE_HEIGHT); var windowsIdentity = WindowsIdentity.GetCurrent(); if (windowsIdentity != null) { Add_Setting("Individual_Creator", windowsIdentity.Name); } Add_Setting("Default_Rights_Statement", "All rights reserved by the source institution"); Add_Setting("METS_RecordStatus_List", "COMPLETE|METADATA_UPDATE|PARTIAL"); // Add the MODS types as default List <Material_Type_Setting> materialTypes = new List <Material_Type_Setting> { new Material_Type_Setting("text", "text", ""), new Material_Type_Setting("cartographic", "cartographic", ""), new Material_Type_Setting("notated music", "notated music", ""), new Material_Type_Setting("sound recording", "sound recording", ""), new Material_Type_Setting("sound recording-musical", "sound recording-musical", ""), new Material_Type_Setting("sound recording-nonmusical", "sound recording-nonmusical", ""), new Material_Type_Setting("still image", "still image", ""), new Material_Type_Setting("moving image", "moving image", ""), new Material_Type_Setting("three dimensional object", "three dimensional object", ""), new Material_Type_Setting("software, multimedia", "software, multimedia", ""), new Material_Type_Setting("mixed material", "mixed material", "") }; Material_Types_List = materialTypes; } // May not have these settings added later if (Get_String_Setting("Always_Add_Page_Images").Length == 0) { Add_Setting("Always_Add_Page_Images", "FALSE"); } // Load the list of Z39.50 endpoints if (dsSettings.Tables.Contains("Z3950_Endpoints")) { // Get information from unencrypting the passwords SecurityInfo securityInfo = new SecurityInfo(); string machine_name = (Environment.MachineName + "abcedefgh").Substring(0, 8); string user = (Environment.UserName.Replace("\\", "").Replace("//", "") + "abcedefgh").Substring(0, 8); // Step through each row in the Z39.50 endpoints foreach (DataRow thisRow in dsSettings.Tables["Z3950_Endpoints"].Rows) { // Pull out the information about this endpoint string name = thisRow["Name"].ToString(); string uri = thisRow["URI"].ToString(); uint port = 0; UInt32.TryParse(thisRow["Port"].ToString(), out port); string db_name = thisRow["Database_Name"].ToString(); string username = thisRow["UserName"].ToString(); string encrypted_password = thisRow["Password"].ToString(); string password = String.Empty; if (encrypted_password.Length > 0) { try { string unencrypted_password = securityInfo.DecryptString(encrypted_password, machine_name, user); if ((unencrypted_password.Length > 0) && (unencrypted_password[0] == 'x') && (unencrypted_password[unencrypted_password.Length - 1] == 'x')) { password = unencrypted_password.Substring(1, unencrypted_password.Length - 2); } } catch (Exception ee) { bool error = false; } } // Create the new endpoint Z3950_Endpoint endpoint = new Z3950_Endpoint(name, uri, port, db_name, username); if (password.Length > 0) { endpoint.Password = password; endpoint.Save_Password_Flag = true; } // Add this to the list of endpoints z3950_endpoints.Add(endpoint); } } else { // Just add the empty table DataTable zTable = new DataTable("Z3950_Endpoints"); zTable.Columns.Add("Name"); zTable.Columns.Add("URI"); zTable.Columns.Add("Port"); zTable.Columns.Add("Database_Name"); zTable.Columns.Add("UserName"); zTable.Columns.Add("Password"); dsSettings.Tables.Add(zTable); } } catch (Exception ee) { MessageBox.Show("ERROR CAUGHT IN META TEMPLATE SETTINGS READ: " + ee.Message + "\n\n" + ee.StackTrace); } }
private void cancelRoundButton_Button_Pressed(object sender, EventArgs e) { Endpoint = null; Close(); }
/// <summary> Get the MARC record related to an item, by specifying the primary identifier for the item in the catalog </summary> /// <param name="Primary_Identifier"> Primary identifier for the record in the catalog </param> /// <param name="Z3950_Server"> Z39.50 server endpoint information </param> /// <param name="Message"> Return message from the server </param> /// <returns> MARC record, if retrievable by primary identifier </returns> public static MARC_Record Get_Record_By_Primary_Identifier(string Primary_Identifier, Z3950_Endpoint Z3950_Server, out string Message) { // Initially set the message to empty Message = String.Empty; // http://jai-on-asp.blogspot.com/2010/01/z3950-client-in-cnet-using-zoomnet-and.html // http://www.indexdata.com/yaz/doc/tools.html#PQF // http://www.loc.gov/z3950/agency/defns/bib1.html // http://www.assembla.com/code/wasolic/subversion/nodes/ZOOM.NET // http://lists.indexdata.dk/pipermail/yazlist/2007-June/002080.html // http://fclaweb.fcla.edu/content/z3950-access-aleph const string PREFIX = "@attrset Bib-1 @attr 1=12 "; try { // allocate MARC tools MARC21_Exchange_Format_Parser parser = new MARC21_Exchange_Format_Parser(); // establish connection IConnection connection = new Connection(Z3950_Server.URI, Convert.ToInt32(Z3950_Server.Port)); connection.DatabaseName = Z3950_Server.Database_Name; // Any authentication here? if (Z3950_Server.Username.Length > 0) { connection.Username = Z3950_Server.Username; } if (Z3950_Server.Password.Length > 0) { connection.Password = Z3950_Server.Password; } // Set to USMARC connection.Syntax = RecordSyntax.USMARC; // call the Z39.50 server IPrefixQuery query = new PrefixQuery(PREFIX + Primary_Identifier); IResultSet records = connection.Search(query); // If the record count is not one, return a message if (records.Count != 1) { Message = records.Count == 0 ? "ERROR: No matching record found in Z39.50 endpoint" : "ERROR: More than one matching record found in Z39.50 endpoint by primary identifier"; return(null); } // capture the byte stream IRecord record = records[0]; MemoryStream ms = new MemoryStream(record.Content); // display while debugging //MessageBox.Show(Encoding.UTF8.GetString(record.Content)); try { // feed the record to the parser and add the 955 MARC_Record marcrec = parser.Parse(ms); parser.Close(); return(marcrec); } catch (Exception error) { Message = "ERROR: Unable to parse resulting record into the MARC Record structure!\n\n" + error.Message; return(null); //MessageBox.Show("Could not convert item " + Primary_Identifier + " to MARCXML."); //Trace.WriteLine("Could not convert item " + Primary_Identifier + " to MARCXML."); //Trace.WriteLine("Error details: " + error.Message); } } catch (Exception error) { if (error.Message.IndexOf("The type initializer for 'Zoom.Net.Yaz") >= 0) { Message = "ERROR: The Z39.50 libraries did not correctly initialize.\n\nThese libraries do not currently work in 64-bit environments."; } else { Message = "ERROR: Unable to connect and search provided Z39.50 endpoint.\n\n" + error.Message; } return(null); //MessageBox.Show("Could not convert item " + Primary_Identifier + " to MARCXML."); //Trace.WriteLine("Could not convert item " + Primary_Identifier + " to MARCXML."); //Trace.WriteLine("Error details: " + error.Message); } }
// Retrieves metadata from Z39.50 server private void RetrieveMetadataByBarcodeZ39() { string z39Server = Settings.Z39ServerUrl; int z39Port = Settings.Z39Port; string z39Base = Settings.Z39Base; string z39UserName = Settings.Z39UserName; string z39Password = Settings.Z39Password; Record_Character_Encoding z39Encoding = Settings.Z39Encoding; int z39BarcodeField = Settings.Z39BarcodeField; //validate string errorText = ""; if (string.IsNullOrEmpty(z39Server)) { errorText += "Z39.50 Server URL; "; } if (z39Port <= 0) { errorText += "Z39.50 Sever Port; "; } if (string.IsNullOrEmpty(z39Base)) { errorText += "Z39.50 Databáze; "; } if (z39BarcodeField <= 0) { errorText += "Vyhledávací atribut"; } if (!string.IsNullOrEmpty(errorText)) { throw new ArgumentException("V nastaveních chybí následující údaje: " + errorText); } string errorMessage = ""; try { Z3950_Endpoint endpoint; if (string.IsNullOrEmpty(z39UserName)) { endpoint = new Z3950_Endpoint("Z39.50", z39Server, (uint)z39Port, z39Base); } else { endpoint = new Z3950_Endpoint("Z39.50", z39Server, (uint)z39Port, z39Base, z39UserName); endpoint.Password = z39Password ?? ""; } // Retrieve the record by primary identifier MARC_Record record_from_z3950 = MARC_Record_Z3950_Retriever.Get_Record( z39BarcodeField, this.barcode, endpoint, out errorMessage, z39Encoding); if (record_from_z3950 != null) { Metadata metadata = new Metadata(); // Sysno metadata.Sysno = record_from_z3950.Control_Number; // Custom identifier if (!string.IsNullOrWhiteSpace(metadata.Sysno)) { metadata.Custom = Settings.Base + metadata.Sysno; } // Title foreach (var field in Settings.MetadataTitleFields) { if (!record_from_z3950.has_Field(field.Key)) { continue; } foreach (var subfield in field.Value) { metadata.Title += record_from_z3950.Get_Data_Subfield(field.Key, subfield).TrimEnd('/', ' ') + " "; } } // Authors string authors = ""; foreach (var field in Settings.MetadataAuthorFields) { if (!record_from_z3950.has_Field(field.Key)) { continue; } List <MARC_Field> authorFields = record_from_z3950.Fields[field.Key]; foreach (var authorField in authorFields) { foreach (var subfield in field.Value) { MARC_Subfield authorSubfield = authorField.Subfields_By_Code(subfield).FirstOrDefault(); authors += authorSubfield == null ? "" : authorSubfield.Data; authors += "@"; } authors = authors.Trim() + "|"; } } metadata.Authors = ParseAuthors(authors, '@'); // Publish year metadata.Year = GetZ39Subfields(record_from_z3950, Settings.MetadataPublishYearField.Item1, Settings.MetadataPublishYearField.Item2); // ISBN metadata.ISBN = GetNormalizedISBN(GetZ39Subfields(record_from_z3950, Settings.MetadataIsbnField.Item1, Settings.MetadataIsbnField.Item2)); if (metadata.ISBN.Contains('|')) { Warnings.Add("Záznam obsahuje více než 1 ISBN, vyberte správné, jsou oddělena zvislou čárou."); } // ISSN metadata.ISSN = GetNormalizedISSN(GetZ39Subfields(record_from_z3950, Settings.MetadataIssnField.Item1, Settings.MetadataIssnField.Item2)); if (metadata.ISSN.Contains('|')) { Warnings.Add("Záznam obsahuje více než 1 ISSN, vyberte správné, jsou oddělena zvislou čárou."); } // CNB metadata.CNB = GetZ39Subfields(record_from_z3950, Settings.MetadataCnbField.Item1, Settings.MetadataCnbField.Item2); if (metadata.CNB.Contains('|')) { Warnings.Add("Záznam obsahuje více než 1 ČNB, vyberte správné, jsou oddělena zvislou čárou."); } // OCLC metadata.OCLC = GetZ39Subfields(record_from_z3950, Settings.MetadataOclcField.Item1, Settings.MetadataOclcField.Item2); if (metadata.OCLC.Contains('|')) { Warnings.Add("Záznam obsahuje více než 1 OCLC, vyberte správné, jsou oddělena zvislou čárou."); } // EAN string ean = ""; if (record_from_z3950.has_Field(Settings.MetadataEanField.Item1)) { List <MARC_Field> eanFields = record_from_z3950.Fields[Settings.MetadataEanField.Item1]; foreach (var eanField in eanFields) { if (eanField.Indicator1 != Settings.MetadataEanField.Item3) { continue; } if (eanField.has_Subfield(Settings.MetadataEanField.Item2)) { foreach (var eanSubfield in eanField.Subfields_By_Code(Settings.MetadataEanField.Item2)) { ean += eanSubfield.Data + "|"; } } } } ean = ean.TrimEnd('|'); if (!string.IsNullOrWhiteSpace(ean)) { metadata.EAN = ean; if (metadata.EAN.Contains('|')) { this.Warnings.Add("Záznam obsahuje více než 1 EAN, vyberte správné, jsou oddělena zvislou čárou"); } } metadata.FixedFields = MarcGetFixedFields(record_from_z3950); metadata.VariableFields = MarcGetVariableFields(record_from_z3950); this.Metadata = metadata; } } catch (Exception) { throw new Z39Exception("Nastala neočekávaná chyba během Z39.50 dotazu."); } // Display any error message encountered if (this.Metadata == null) { if (errorMessage.Length > 0) { if (errorMessage.Contains("No matching record found in Z39.50 endpoint")) { errorMessage = "Nenalezen vhodný záznam."; } else if (errorMessage.Contains("Connection could not be made to")) { errorMessage = "Nebylo možné navázat spojení s " + errorMessage.Substring(errorMessage.LastIndexOf(' ')); } throw new Z39Exception(errorMessage); } else { throw new Z39Exception("Nastala neznámá chyba během Z39.50 dotazu"); } } }
public Z3950_Endpoint_Form() { InitializeComponent(); Endpoint = new Z3950_Endpoint(); }