private void CheckField ( [NotNull] RecordField field ) { ExemplarInfo exemplar = ExemplarInfo.Parse(field); if (!CheckForMenu(_statusMenu, exemplar.Status)) { AddDefect ( field, 10, "Статус экземпляра не из словаря" ); } if (!CheckForMenu(_placeMenu, exemplar.Place)) { AddDefect ( field, 10, "Место хранения не из словаря" ); } if (string.IsNullOrEmpty(exemplar.Number)) { AddDefect ( field, 10, "Не задан номер экземпляра" ); } }
// ReSharper restore ParameterTypeCanBeEnumerable.Local private bool _SelectByMfn ( ExemplarInfo exemplar ) { return(true); }
private bool _SelectByDictionary ( ExemplarInfo exemplar ) { throw new NotImplementedException(); }
public ExemplarInfo GetExemplarInfoByIdData(int IDDATA) { string connectionString = ConfigurationManager.ConnectionStrings["BookStatusConnection"].ConnectionString; string queryText = new BJExemplarQueries(this.BaseName).GET_EXEMPLAR_BY_IDDATA; DataTable result = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(queryText, connectionString); da.SelectCommand.Parameters.Add("IDDATA", SqlDbType.Int).Value = IDDATA; da.Fill(result); ExemplarInfo ei = new ExemplarInfo(IDDATA); string fieldCode; foreach (DataRow row in result.Rows) { fieldCode = row["MNFIELD"].ToString() + row["MSFIELD"].ToString(); switch (fieldCode)//пока только автор заглавие { case "899$a": ei.Location = row["PLAIN"].ToString(); break; case "899$p": ei.InventoryNumber = row["PLAIN"].ToString(); break; case "899$w": ei.Barcode = row["PLAIN"].ToString(); break; } } return(ei); }
public BookInfo GetBJBookByID(int iDMAIN) { string connectionString = ConfigurationManager.ConnectionStrings["BookStatusConnection"].ConnectionString; string queryText = new BJBookQueries(this.BaseName).GET_BOOK_BY_IDMAIN; DataTable result = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(queryText, connectionString); da.SelectCommand.Parameters.Add("IDMAIN", SqlDbType.Int).Value = iDMAIN; da.Fill(result); BookInfo bi = new BookInfo(); string fieldCode; List <int> ExemplarIdDataList = new List <int>(); int currentIDDATA = (int)result.Rows[0]["IDDATA"]; foreach (DataRow row in result.Rows) { fieldCode = row["MNFIELD"].ToString() + row["MSFIELD"].ToString(); if (((int)row["IDBLOCK"] == 260) && (currentIDDATA != (int)row["IDDATA"])) { ExemplarIdDataList.Add((int)row["IDDATA"]); //собираем IDDATA всех экземпляров } switch (fieldCode) //пока только автор заглавие { case "200$a": bi.Title = row["PLAIN"].ToString(); break; case "700$a": case "701$a": bi.Author.Add(row["PLAIN"].ToString()); break; case "330$a": bi.Annotation.Add(row["PLAIN"].ToString()); break; } currentIDDATA = (int)row["IDDATA"]; } ExemplarLoader loader = new ExemplarLoader(this._baseName); foreach (int iddata in ExemplarIdDataList) { ExemplarInfo ei = loader.GetExemplarInfoByIdData(iddata); bi.Exemplars.Add(ei); } //проверим есть ли электронный экземпляр. если есть, то добавим его. пока только так можно определить электронный экземпляр. когда они проинвентаризируются, будет создаваться сам в предыдущем цикле queryText = new BJBookQueries(this.BaseName).IS_HYPERLINK_EXISTS; result = new DataTable(); da = new SqlDataAdapter(queryText, connectionString); da.SelectCommand.Parameters.Add("IDMAIN", SqlDbType.Int).Value = iDMAIN; int IsHyperlinkExists = da.Fill(result); if (IsHyperlinkExists > 0) { ExemplarInfo ei = new ExemplarInfo(-1);//пока для всех электронных будет -1 ei = loader.GetElectronicExemplarInfo(this._baseName + "_" + iDMAIN.ToString()); bi.Exemplars.Add(ei); } return(bi); }
private bool _SelectByQuery ( string prefix, NumberRangeCollection ranges, ExemplarInfo exemplar ) { return(false); }
private bool _SelectByDeep ( string prefix, NumberRangeCollection ranges, ExemplarInfo exemplar ) { throw new NotImplementedException(); }
public static List <ExemplarInfo> GetExemplars ( [NotNull] string ksu ) { Code.NotNullNorEmpty(ksu, "ksu"); List <ExemplarInfo> result; using (IrbisConnection connection = GetIrbisConnection()) { ExemplarManager manager = new ExemplarManager(connection, Output) { Format = Format }; string expression = string.Format ( "\"{0}{1}\"", Prefix, ksu ); result = BatchRecordReader.Search ( connection, connection.Database, expression, 500 ) .SelectMany ( x => ExemplarInfo.Parse(x) ) .Where ( exemplar => exemplar.KsuNumber1.SameString(ksu) ) .Select ( exemplar => manager.Extend(exemplar, null) ) .ToList(); result.Sort(_ExemplarComparison); } return(result); }
private void _badButton_Click ( object sender, EventArgs e ) { if (_currentRecord == null || _currentExemplar == null) { XtraMessageBox.Show ( "Нечего откладывать!" ); return; } string processing = CM.AppSettings["processing"]; RecordField field = _currentExemplar.Field; if (field == null) { return; } field.SetSubField('a', "5"); field.SetSubField('d', processing); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _client.WriteRecord ( _currentRecord, false, true ); stopwatch.Stop(); _logBox.Output.WriteLine ( "Отложен номер {0}: {1} ({2})", _currentExemplar.Number, _currentRecord.UserData, stopwatch.Elapsed ); _SetHtml(string.Empty); _currentRecord = null; _currentExemplar = null; }
private static string GetPrice ( [NotNull] VisitInfo debt, [NotNull] MarcRecord bookRecord ) { Code.NotNull(debt, "debt"); string inventory = debt.Inventory; string barcode = debt.Barcode; RecordField[] fields = bookRecord.Fields .GetField("910"); string result = null; foreach (RecordField field in fields) { ExemplarInfo exemplar = ExemplarInfo.Parse(field); if (!string.IsNullOrEmpty(inventory)) { if (exemplar.Number.SameString(inventory)) { if (!string.IsNullOrEmpty(barcode)) { if (exemplar.Barcode.SameString(barcode)) { result = exemplar.Price; break; } } else { result = exemplar.Price; break; } } } } if (string.IsNullOrEmpty(result)) { result = bookRecord.FM("10", 'd'); } return(result); }
private void _fixPlaceButton_Click ( object sender, EventArgs e ) { if (_currentRecord == null || _currentExemplar == null) { XtraMessageBox.Show ( "Нечего исправлять!" ); return; } RecordField field = _currentExemplar.Field; if (field == null) { return; } field.SetSubField('a', "0"); field.SetSubField('d', CurrentFond); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _client.WriteRecord ( _currentRecord, false, true ); stopwatch.Stop(); _logBox.Output.WriteLine ( "Исправлено место/статус для номера {0}: {1} ({2})", _currentExemplar.Number, _currentRecord.UserData, stopwatch.Elapsed ); _SetHtml(string.Empty); _currentRecord = null; _currentExemplar = null; }
private void CheckBarcode ( [NotNull] string barcode ) { Code.NotNullNorEmpty(barcode, "barcode"); List <ExemplarInfo> exemplars = ControlCenter.Exemplars; if (ReferenceEquals(exemplars, null)) { return; } ExemplarInfo current = exemplars.FirstOrDefault ( exemplar => exemplar.Barcode.SameString(barcode) ); if (ReferenceEquals(current, null)) { WriteLine ( "Метка не входит в партию: {0}", barcode ); return; } current.Marked = true; WriteLine ( "Подтверждён экземпляр {0}: {1}", current, current.Description ); UpdateTop(); _bookGrid.ResetBindings(); _bookGrid.Invalidate(); }
private static int _ExemplarComparison ( ExemplarInfo left, ExemplarInfo right ) { int result = NumberText.Compare ( left.Number, right.Number ); if (result == 0) { result = NumberText.Compare ( left.Description, right.Description ); } return(result); }
private void _okButton_Click ( object sender, EventArgs e ) { if (_currentRecord == null || _currentExemplar == null) { XtraMessageBox.Show ( "Невозможно подтвердить книгу" ); return; } RecordField field = _currentExemplar.Field; if (field == null) { return; } field.SetSubField('!', CurrentFond); field.SetSubField('s', CurrentDate); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _client.WriteRecord ( _currentRecord, false, true ); stopwatch.Stop(); _logBox.Output.WriteLine ( "Подтвержден номер {0}: {1} ({2})", _currentExemplar.Number, _currentRecord.UserData, stopwatch.Elapsed ); BookInfo book = new BookInfo { Number = _currentExemplar.Number, Description = (string)_currentRecord.UserData }; ConfirmedBooks.Add(book); _counterLabel.Text = string.Format ( "Подтверждено: {0}", ConfirmedBooks.Count ); _SetHtml(string.Empty); _currentRecord = null; _currentExemplar = null; if (_numberBox.Enabled) { _numberBox.Focus(); } }
private void _addButton_Click ( object sender, EventArgs e ) { UniversalForm mainForm = MainForm; if (ReferenceEquals(mainForm, null) || !mainForm.Active) { WriteLine("Приложение не активно"); return; } string number = _numberBox.Text.Trim(); if (string.IsNullOrEmpty(number)) { return; } _numberBox.Clear(); _numberBox.Focus(); Application.DoEvents(); if (AlreadyHave(number)) { WriteLine("Уже есть экземпляр: {0}", number); return; } ExemplarInfo exemplar = null; Manager.Format = ((ListFormat)_formatBox.SelectedItem) .Format .ThrowIfNull("Manager.Format"); try { Run ( () => { exemplar = Manager.ReadExtend(number); } ); } catch (Exception exception) { WriteLine("Ошибка: {0}", exception.Message); return; } if (ReferenceEquals(exemplar, null)) { WriteLine("Не удалось найти экземпляр: {0}", number); return; } if (!string.IsNullOrEmpty(exemplar.Description)) { exemplar.Description = exemplar.Description.Replace ( "[Текст] ", string.Empty ); } MarcRecord record = exemplar.Record.ThrowIfNull("exemplar.Record"); RecordField field = exemplar.Field.ThrowIfNull("exemplar.Field"); if (_statusBox.Checked && exemplar.Status != "0") { exemplar.Status = "0"; field.SetSubField('A', "0"); WriteLine("Статус экземпляра {0} изменён на 0", number); } if (_exhibitionBox.Checked) { field.SetSubField('9', "Выставка новых поступлений"); WriteLine("Экземпляр {0} передан на выставку", number); } if (record.Modified) { Run ( () => { MainForm.Provider.WriteRecord(record); WriteLine("Изменения сохранены на сервере"); } ); } ExemplarList.Add(exemplar); _bindingSource.Position = ExemplarList.Count - 1; SaveExemplars(); _numberBox.Focus(); WriteLine ( "Добавлено: {0} {1}", exemplar.Number, exemplar.Description.ToVisibleString() ); }
private void _fixShelfButton_Click ( object sender, EventArgs e ) { if (_currentRecord == null || _currentExemplar == null) { XtraMessageBox.Show ( "Нечего исправлять!" ); return; } string currentShelf = CurrentShelf; if (string.IsNullOrEmpty(currentShelf)) { XtraMessageBox.Show ( "Не задан раздел!" ); return; } if (currentShelf.ContainsAnySymbol ( ' ', ',', ';' )) { XtraMessageBox.Show ( "Раздел содержит недопустимые символы!" ); return; } string shelf = _currentRecord.FM(906); if (!string.IsNullOrEmpty(shelf)) { XtraMessageBox.Show ( "В записи уже установлен " + "систематический шифр, " + "его нельзя менять!" ); return; } _currentRecord.SetField ( 906, currentShelf ); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _client.WriteRecord ( _currentRecord, false, true ); stopwatch.Stop(); _logBox.Output.WriteLine ( "Исправлен раздел для метки {0}: {1} ({2})", _currentExemplar.Barcode, _currentRecord.UserData, stopwatch.Elapsed ); _SetHtml(string.Empty); _currentRecord = null; _currentExemplar = null; }
private void _HandleNumber ( [CanBeNull] string number ) { _currentRecord = null; _currentExemplar = null; _SetHtml(string.Empty); if (string.IsNullOrEmpty(number)) { return; } _logBox.Output.WriteLine ( "Введен номер: {0}", number ); string prefix = CM.AppSettings["prefix"]; int[] found = _client.Search ( "\"{0}{1}\"", prefix, number ); if (found.Length == 0) { _SetHtml ( "Не найден номер {0}", number ); return; } if (found.Length != 1) { _SetHtml ( "Много записей для номера {0}", number ); return; } MarcRecord record = _client.ReadRecord(found[0]); RecordField[] fields = record.Fields .GetField(910) .GetField('b', number); if (fields.Length == 0) { _SetHtml ( "Не найдено поле с номером {0}", number ); return; } if (fields.Length != 1) { _SetHtml ( "Много полей с номером {0}", number ); return; } ExemplarInfo exemplar = ExemplarInfo.Parse(fields[0]); StringBuilder diagnosis = new StringBuilder(); diagnosis.AppendFormat ( "<b>{0}</b><br/>", 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 currentCollection = CurrentCollection; if (!string.IsNullOrEmpty(currentCollection)) { string collection = exemplar.Collection; if (currentCollection != collection) { if (string.IsNullOrEmpty(collection)) { diagnosis.AppendFormat ( "<font color='red'>Для книги не указана " + "коллекция" ); } else { diagnosis.AppendFormat ( "<font color='red'>Неверная коллекция: " + "</font><b>{0}</b><br/>", collection ); } } } 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; }
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 // ); //} }