public void MarcRecordUtility_HaveNotField_1() { MarcRecord record = new MarcRecord(); record.AddField(200, "^aЗаглавие"); Assert.IsTrue(record.HaveNotField(700)); record.AddField(700, "^aСидоров^bС. С."); Assert.IsFalse(record.HaveNotField(700)); }
public void MarcRecordUtility_HaveField_2() { MarcRecord record = new MarcRecord(); Assert.IsFalse(record.HaveField(700, 701)); record.AddField(200, "^aЗаглавие"); record.AddField(700, "^aСидоров^bС. С."); Assert.IsTrue(record.HaveField(700, 701)); record.AddField(701, "^aКозлов^bК. К."); Assert.IsTrue(record.HaveField(700, 701)); }
public void MarcRecordUtility_SetField_6() { MarcRecord record = new MarcRecord(); record.AddField(700, "^aИванов^bИ. И."); record.AddField(700, "^aПетров^bП. П."); MarcRecord result = record.SetField(700, 1, "^aСидоров^bС. С."); Assert.AreSame(record, result); Assert.AreEqual(2, record.Fields.Count); Assert.AreEqual(2, record.Fields[0].SubFields.Count); Assert.AreEqual("Иванов", record.Fields[0].SubFields[0].Value); Assert.AreEqual(2, record.Fields[0].SubFields.Count); Assert.AreEqual("Сидоров", record.Fields[1].SubFields[0].Value); }
public void MarcRecordUtility_SetSubField_8() { MarcRecord record = new MarcRecord(); record.AddField(700, "^aИванов^bИ. И.^aСнова Иванов^bСнова И. И."); record.AddField(700, "^aПетров^bП. П.^aСнова Петров^bСнова П. П."); MarcRecord result = record.SetSubField(700, 1, 'a', 1, "Сидоров"); Assert.AreSame(record, result); Assert.AreEqual(2, record.Fields.Count); Assert.AreEqual(4, record.Fields[1].SubFields.Count); Assert.AreEqual("Петров", record.Fields[1].SubFields[0].Value); Assert.AreEqual("П. П.", record.Fields[1].SubFields[1].Value); Assert.AreEqual("Сидоров", record.Fields[1].SubFields[2].Value); Assert.AreEqual("Снова П. П.", record.Fields[1].SubFields[3].Value); }
public void MarcRecordUtility_AddField_6() { MarcRecord record = new MarcRecord(); object value = null; record.AddField(701, value); }
public void MarcRecordUtiltity_RemoveField_1() { MarcRecord record = new MarcRecord(); MarcRecord result = record.RemoveField(700); Assert.AreSame(record, result); record.AddField(700, "^aСидоров^bС. С."); result = record.RemoveField(700); Assert.AreSame(record, result); record.AddField(200, "^aЗаглавие"); record.AddField(700, "^aИванов^bИ. И."); record.AddField(700, "^aПетров^bП. П."); record.AddField(700, "^aСидоров^bС. С."); result = record.RemoveField(700); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); }
public void MarcRecordUtility_AddField_4() { MarcRecord record = new MarcRecord(); MarcRecord result = record.AddField(701, string.Empty); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); Assert.AreEqual(701, record.Fields[0].Tag); Assert.AreEqual(0, result.Fields[0].SubFields.Count); }
public void CreateIrbisRecord ( [JetBrains.Annotations.NotNull] Card card, [JetBrains.Annotations.NotNull] InventoryResult[] numbers ) { if (ReferenceEquals(card, null)) { throw new ArgumentNullException("card"); } MarcRecord record = new MarcRecord { Database = CM.AppSettings["cards-database"] }; record.AddField(920, "PAZK") .AddField(900, 't', "a", 'b', "05") .AddField(102, "RU") .AddField(101, "rus") .AddField(919, 'a', "rus", 'n', "02", 'k', "PSBO") .AddField(999, "0000000") .AddField(903, CreateRandomIndex(9)) .AddField(200, 'a', "Нет заглавия"); RecordField field = new RecordField("2020"); field.AddSubField('a', card.Id) .AddSubField('b', IdToPath(card.Id)) .AddSubField('c', "4") .AddNonEmptySubField('d', card.Operator) .AddNonEmptySubField('e', card.Remark); record.Fields.Add(field); foreach (InventoryResult number in numbers) { field = new RecordField("910"); field.AddSubField('a', "0") .AddSubField('b', number.Number) .AddSubField('c', "?"); string place = CM.AppSettings["cards-place"]; if (!string.IsNullOrEmpty(place)) { field.AddSubField('d', place); } record.Fields.Add(field); } Client.WriteRecord(record, false, true); Output.WriteLine ( "Создана ИРБИС-запись MFN {0}", record.Mfn ); }
public void MarcRecordUtility_AddField_5() { MarcRecord record = new MarcRecord(); MarcRecord result = record.AddField(701, 555); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); Assert.AreEqual(701, record.Fields[0].Tag); Assert.AreEqual(0, result.Fields[0].SubFields.Count); Assert.AreEqual(555.ToString(), result.Fields[0].Value); }
public void MarcRecordUtility_AddField_3() { MarcRecord record = new MarcRecord(); MarcRecord result = record.AddField(701, "^aСидоров^bС. С."); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); Assert.AreEqual(701, record.Fields[0].Tag); Assert.AreEqual(2, result.Fields[0].SubFields.Count); Assert.AreEqual("Сидоров", record.Fields[0].GetFirstSubFieldValue('a')); }
public void MarcRecordUtility_AddField_2() { MarcRecord record = new MarcRecord(); RecordField field = _GetField(); MarcRecord result = record.AddField(field.Tag, field); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); Assert.AreSame(field, record.Fields[0]); Assert.AreSame(record, field.Record); }
public void MarcRecordUtility_SetSubField_5() { MarcRecord record = new MarcRecord(); record.AddField(700, "^aИванов^bИ. И."); MarcRecord result = record.SetSubField(700, 1, 'a', 1, "Сидоров"); Assert.AreSame(record, result); Assert.AreEqual(1, record.Fields.Count); Assert.AreEqual(2, record.Fields[0].SubFields.Count); Assert.AreEqual("Иванов", record.Fields[0].SubFields[0].Value); }
public void MarcRecordUtility_ReplaceField_3() { MarcRecord record = new MarcRecord(); RecordField[] replacement = { new RecordField(702, "^aИванов^bИ. И."), new RecordField(702, "^aПетров^bП. П."), new RecordField(702, "^aСидоров^bС. С."), }; record.AddField(200, "^aЗаглавие"); record.AddField(700, "^aИванов^bИ. И."); record.AddField(700, "^aПетров^bП. П."); record.AddField(700, "^aСидоров^bС. С."); MarcRecord result = record.ReplaceField(700, replacement); Assert.AreSame(record, result); Assert.AreEqual(4, record.Fields.Count); Assert.IsFalse(record.HaveField(700)); Assert.IsTrue(record.HaveField(702)); }
private void GoButton_Click(object sender, RoutedEventArgs e) { _index = IndexBox.Text.Trim(); _year = YearBox.Text.Trim(); _issues = IssueBox.Text.Trim(); _month = MonthBox.Text.Trim(); _number = NumberBox.Text.Trim(); _inventory = InventoryBox.Text.Trim(); _fond = FondBox.Text.Trim(); _complect = ComplectBox.Text.Trim(); if (string.IsNullOrEmpty(_index) || string.IsNullOrEmpty(_year) || string.IsNullOrEmpty(_issues) || string.IsNullOrEmpty(_month) || string.IsNullOrEmpty(_number) || string.IsNullOrEmpty(_inventory) || string.IsNullOrEmpty(_fond) || string.IsNullOrEmpty(_complect)) { WriteLog("Empty data"); return; } var collection = NumberRangeCollection.Parse(_issues); _description = $"Подшивка N{_number} {_month} ({_issues})"; _reference = $"{_index}/{_year}/{_description}"; string connectionString = CM.AppSettings["connectionString"]; using (_connection = new IrbisConnection(connectionString)) { WriteLog("Connected"); _mainRecord = _connection.SearchReadOneRecord("\"I={0}\"", _index); if (_mainRecord == null) { WriteLog("Main record not found"); return; } MagazineInfo magazine = MagazineInfo.Parse(_mainRecord); WriteLog("Main: {0}", magazine.ExtendedTitle); foreach (NumberText number in collection) { MarcRecord issue = new MarcRecord { Database = _connection.Database }; string issueIndex = $"{_index}/{_year}/{number}"; issue .AddField(933, _index) .AddField(903, issueIndex) .AddField(934, _year) .AddField(936, number) .AddField(920, "NJP") .AddField ( new RecordField(910) .AddSubField('a', "0") .AddSubField('b', _complect) .AddSubField('c', "?") .AddSubField('d', _fond) .AddSubField('p', _reference) .AddSubField('i', _inventory) ) .AddField ( new RecordField(463) .AddSubField('w', _reference) ); _connection.WriteRecord(issue); WriteLog("Issue record created: N={0}, MFN={1}", number, issue.Mfn); } MarcRecord binding = new MarcRecord { Database = _connection.Database }; binding .AddField(933, _index) .AddField(903, _reference) .AddField(904, _year) .AddField(936, _description) .AddField(931, _issues) .AddField(920, "NJK") .AddField ( new RecordField(910) .AddSubField('a', "0") .AddSubField('b', _inventory) .AddSubField('c', "?") .AddSubField('d', _fond) ); _connection.WriteRecord(binding); WriteLog("Binding record created: MFN={0}", binding.Mfn); _mainRecord.AddField ( new RecordField(909) .AddSubField('q', _year) .AddSubField('d', _fond) .AddSubField('k', _complect) .AddSubField('h', _issues) ); _connection.WriteRecord(_mainRecord); WriteLog("Cumulation updated"); } WriteLog("Disconnected"); WriteLog("=========================================="); }