// ========================================================== static void DumpTerm ( [NotNull] string term ) { MarcRecord[] records = connection.SearchRead("\"" + term + "\""); Console.WriteLine ( "{0} MFN={1}", term, StringUtility.Join(", ", records.Select(r => r.Mfn)) ); if (records.Length > 1) { DoubleCount++; } for (int i = 1; i < records.Length; i++) { FieldDifference[] diff = RecordComparator.FindDifference2 ( records[0], records[i], ResiduaryTags ) .ToArray(); FieldDifference[] modified = diff .Where(line => line.State != FieldState.Unchanged) .ToArray(); if (modified.Length == 0) { Console.WriteLine("No difference found"); FullDoubleCount++; if (DeleteDoubles) { connection.DeleteRecord(records[i].Mfn); Console.WriteLine("Deleted"); } } foreach (FieldDifference line in diff) { Console.WriteLine(line.ToString()); } Console.WriteLine(); } Console.WriteLine(new string('=', 70)); Console.WriteLine(); }
public void Search_Read() { IrbisConnection connection = Connection .ThrowIfNull("Connection"); MarcRecord[] records = connection.SearchRead("T=ABA$"); int[] mfns = records.Select(r => r.Mfn).ToArray(); bool ok = true; int count = Math.Min(10, records.Length); for (int i = 0; i < count; i++) { MarcRecord record = connection.ReadRecord ( records[i].Mfn ); string diagnostic = string.Format ( "MFN={0}, Version={1}, Version={2} Fields={3}{4}", record.Mfn, record.Version, record.Version, record.Fields.Count, Environment.NewLine ); Write(diagnostic); ok = ok && records[i].Version == record.Version; } if (!ok) { throw new IrbisException("SearchRead -> wrong version!"); } }
private void _HandleRfid ( string rfid ) { _currentRecord = null; _currentExemplar = null; _SetHtml(string.Empty); _logBox.Output.WriteLine ( "Считана метка: {0}", rfid ); string prefix = CM.AppSettings["prefix"]; MarcRecord[] found = _client.SearchRead ( "\"{0}{1}\"", prefix, rfid ); if (found.Length == 0) { _SetHtml ( "Не найдена метка {0}", rfid ); return; } if (found.Length != 1) { _SetHtml ( "Много записей для метки {0}", rfid ); return; } MarcRecord record = found[0]; RecordField[] fields = record.Fields .GetField(910) .GetField('h', rfid); if (fields.Length == 0) { _SetHtml ( "Не найдено поле с меткой {0}", rfid ); return; } if (fields.Length != 1) { _SetHtml ( "Много полей с меткой {0}", rfid ); return; } ExemplarInfo exemplar = ExemplarInfo.Parse(fields[0]); exemplar.UserData = fields[0]; StringBuilder diagnosis = new StringBuilder(); diagnosis.AppendFormat ( "{0} => <b>{1}</b><br/>", rfid, exemplar.Number ); if (!string.IsNullOrEmpty(exemplar.RealPlace)) { diagnosis.AppendFormat ( "<font color='red'>Экземпляр уже был проверен " + "в фонде</font> <b>{0}</b> ({1})<br/>", exemplar.RealPlace, exemplar.CheckedDate ); } if (exemplar.Status != "0") { diagnosis.AppendFormat ( "<font color='red'>Неверный статус " + "экземпляра: </font><b>{0}</b><br/>", exemplar.Status ); } if (!exemplar.Place.SameString(CurrentFond)) { diagnosis.AppendFormat ( "<font color='red'>Неверное место хранения " + "экземпляра: </font><b>{0}</b><br/>", exemplar.Place ); } string currentShelf = CurrentShelf; if (!string.IsNullOrEmpty(currentShelf)) { string[] items = currentShelf .Split(',', ';') .Select(item => item.Trim()) .NonEmptyLines() .Select(item => item.ToUpperInvariant()) .ToArray(); string shelf = record.FM(906); if (string.IsNullOrEmpty(shelf)) { diagnosis.AppendFormat ( "<font color='red'>Для книги не указан " + "расстановочный шифр</font><br/>" ); } else if (items.Length != 0) { shelf = shelf.ToUpperInvariant(); bool good = false; foreach (string item in items) { if (shelf.StartsWith(item)) { good = true; break; } } if (!good) { diagnosis.AppendFormat ( "<font color='red'>Неверный шифр: " + "</font><b>{0}</b><br/>", shelf ); } } } string fromNumber = FromNumber, toNumber = ToNumber; if (!string.IsNullOrEmpty(fromNumber) && !string.IsNullOrEmpty(toNumber)) { string number = exemplar.Number; if (!string.IsNullOrEmpty(number)) { NumberText fn = fromNumber, tn = toNumber, n = number; if (fn > n || tn < n) { diagnosis.AppendFormat ( "<font color='red'>Номер за пределами " + "интервала</font>: <b>{0}</b><br/>", number ); } } } diagnosis.AppendLine("<br/>"); string cardFormat = CM.AppSettings["card-format"]; string briefDescription = _client.FormatRecord ( cardFormat, record.Mfn ).Trim(); diagnosis.Append(briefDescription); record.UserData = briefDescription; _SetHtml ( "{0}", diagnosis.ToString() ); _currentRecord = record; _currentExemplar = exemplar; //if (_emulation != null) //{ // _okButton_Click // ( // this, // EventArgs.Empty // ); //} }