コード例 #1
0
        private void _searchButton_Click
        (
            object sender,
            EventArgs e
        )
        {
            _resultBox.Clear();
            _loginBox.Clear();
            _passwordBox.Clear();

            string ticket = _ticketBox.Text.Trim();

            if (string.IsNullOrEmpty(ticket))
            {
                _resultBox.Text = Environment.NewLine
                                  + Resources.MainForm_NoIogunbTicket;

                return;
            }

            using (IrbisConnection connection = GetConnection())
            {
                string expression = string.Format
                                    (
                    "\"RI={0}\"",
                    ticket
                                    );
                int[] found = connection.Search(expression);
                if (found.Length == 0)
                {
                    _resultBox.Text = Environment.NewLine
                                      + Resources.MainForm_NoReaderFound;
                    _ticketBox.Focus();

                    return;
                }
                if (found.Length != 1)
                {
                    _resultBox.Text = Environment.NewLine
                                      + Resources.MainForm_ManyReadersFound;
                    _ticketBox.Focus();

                    return;
                }

                MarcRecord record      = connection.ReadRecord(found[0]);
                string     description = connection.FormatRecord("@brief", found[0]);
                _resultBox.Text = Environment.NewLine + description;

                RecordField litresField = record.Fields
                                          .GetFirstField(_litresTag);
                if (!ReferenceEquals(litresField, null))
                {
                    _loginBox.Text    = litresField.GetFirstSubFieldValue('a');
                    _passwordBox.Text = litresField.GetFirstSubFieldValue('b');
                }

                _loginBox.Focus();
            }
        }
コード例 #2
0
        private void _barcodeBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            _browser.DocumentText = string.Empty;
            _lines = null;

            string barcode = _barcodeBox.Text.Trim();

            if (string.IsNullOrEmpty(barcode))
            {
                return;
            }

            _barcodeBox.Clear();

            try
            {
                string connectionString = CM.AppSettings["connectionString"];
                using (IrbisConnection connection = new IrbisConnection(connectionString))
                {
                    MarcRecord record = connection.SearchReadOneRecord("\"IN={0}\"", barcode);
                    if (ReferenceEquals(record, null))
                    {
                        _browser.DocumentText = "Не найдена книга";
                        _barcodeBox.Focus();
                        return;
                    }

                    string formatted = connection.FormatRecord("@", record.Mfn);
                    _browser.DocumentText = formatted;

                    string firstLine = record.FM(906), secondLine = record.FM(908);
                    if (string.IsNullOrEmpty(firstLine))
                    {
                        _browser.DocumentText = "Не введен систематический шифр (поле 906)";
                        _barcodeBox.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(secondLine))
                    {
                        _browser.DocumentText = "Не введен авторский знак (поле 908)";
                        _barcodeBox.Focus();
                        return;
                    }

                    _lines = new[] { firstLine, secondLine };
                }
            }
            catch (Exception exception)
            {
                _browser.DocumentText = exception.ToString();
            }
        }
コード例 #3
0
        public void Format_OneRecord_Test1()
        {
            IrbisConnection connection = Connection
                                         .ThrowIfNull("Connection");

            string actual = connection.FormatRecord
                            (
                "@brief",
                1
                            );

            Write(actual);
        }
コード例 #4
0
        public void Format_Optimized()
        {
            IrbisConnection connection = Connection
                                         .ThrowIfNull("Connection");

            string actual = connection.FormatRecord
                            (
                "@",
                1
                            );

            Write(actual);
        }
コード例 #5
0
        public void Format_Verbatim()
        {
            IrbisConnection connection = Connection
                                         .ThrowIfNull("Connection");

            string actual = connection.FormatRecord
                            (
                "'Привет, мир!'",
                1
                            );

            Write(actual);
        }
コード例 #6
0
        public void Format_OneRecord_Test2()
        {
            IrbisConnection connection = Connection
                                         .ThrowIfNull("Connection");

            string actual = connection.FormatRecord
                            (
                "v200^a,/,v200^e",
                1
                            );

            Write(actual);
        }
コード例 #7
0
        /// <summary>
        /// Format reader.
        /// </summary>
        public static string FormatReader
        (
            [NotNull] ReaderInfo reader
        )
        {
            Code.NotNull(reader, "reader");

            using (IrbisConnection connection = GetIrbisConnection())
            {
                string result = connection.FormatRecord("@", reader.Mfn);

                return(result);
            }
        }
コード例 #8
0
        public void Format_VirtualRecord()
        {
            IrbisConnection connection = Connection
                                         .ThrowIfNull("Connection");

            MarcRecord record = _GetRecord();
            string     actual = connection.FormatRecord
                                (
                "@brief",
                record
                                );

            Write(actual);
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: fossabot/ManagedIrbis
        private void _ShowCurrentRecord()
        {
            _web.Navigate("about:blank");
            int mfn = CurrentMfn;

            if (mfn <= 0)
            {
                return;
            }
            string formatted = _client.FormatRecord
                               (
                _formatBox.Text,
                mfn
                               );

            _web.DocumentText = formatted;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: fossabot/ManagedIrbis
        /*========================================================*/

        public MarcRecord Execute
        (
            IrbisConnection client,
            MarcRecord record
        )
        {
            MarcRecord result = new MarcRecord();

            foreach (FstLine fstLine in Lines)
            {
                string formatted = client.FormatRecord
                                   (
                    fstLine.Code,
                    record
                                   );
                if (!string.IsNullOrEmpty(formatted))
                {
                    formatted = formatted.Trim();
                    if (!string.IsNullOrEmpty(formatted))
                    {
                        formatted = formatted.Replace("\r", string.Empty);
                        string[] parts = formatted.Split
                                         (
                            new[] { '\n' },
                            StringSplitOptions.RemoveEmptyEntries
                                         );
                        foreach (string part in parts)
                        {
                            string trimmed = part.Trim();
                            if (!string.IsNullOrEmpty(trimmed))
                            {
                                RecordField field = RecordFieldUtility.Parse
                                                    (
                                    fstLine.Tag,
                                    trimmed
                                                    );
                                result.Fields.Add(field);
                            }
                        }
                    }
                }
            }

            return(result);
        }
コード例 #11
0
        public Form5()
        {
            InitializeComponent();

            string connectionString = CM.AppSettings["connectionString"];

            Connection = new IrbisConnection();
            Connection.ParseConnectionString(connectionString);
            Connection.Connect();

            Grid = new SiberianFoundGrid
            {
                Dock = DockStyle.Fill
            };
            Controls.Add(Grid);

            List <FoundLine> lines = new List <FoundLine>();

            for (int i = 1; i < 100; i++)
            {
                try
                {
                    string    description = Connection.FormatRecord("@brief", i);
                    FoundLine line        = new FoundLine
                    {
                        Mfn          = i,
                        Materialized = true,
                        Description  = description
                    };
                    lines.Add(line);
                }
                catch
                {
                    // Nothing to do
                }
            }

            Connection.Dispose();

            Grid.Load(lines.ToArray());

            //FormClosed += _FormClosed;
        }
コード例 #12
0
        static void ProcessRecord
        (
            [NotNull] MarcRecord record
        )
        {
            string index = record.FM(903);

            if (string.IsNullOrEmpty(index))
            {
                return;
            }

            string description = _irbisConnection.FormatRecord("@sbrief_istu", record.Mfn);

            //string description = _GetDescription(record);

            if (string.IsNullOrEmpty(description))
            {
                return;
            }

            description = description.Limit(500);

            IrbisData data = new IrbisData
            {
                Index       = index.Limit(32),
                Description = description,
                Heading     = _GetHeading(record),
                Title       = _GetTitle(record),
                Author      = _GetAuthors(record),
                Count       = _GetExemplars(record),
                Year        = _GetYear(record),
                Link        = _GetLink(record),
                Type        = _GetType(record)
            };

            _database.Insert(data);
            Console.WriteLine("[{0}] {1}", record.Mfn, data.Description);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: fossabot/ManagedIrbis
        private static void Main()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                string connectionString = ConfigurationUtility
                                          .GetString("connectionString")
                                          .ThrowIfNull("connectionString not set");

                int delay = ConfigurationUtility
                            .GetInt32("delay");

                DateTime threshold = DateTime.Today
                                     .AddMonths(-delay);

                using (IrbisConnection connection
                           = new IrbisConnection(connectionString))
                {
                    DatabaseInfo[] databases
                        = connection.ListDatabases();

                    DebtorManager manager
                        = new DebtorManager(connection)
                        {
                        ToDate = threshold
                        };
                    manager.BatchRead += (sender, args) =>
                    {
                        Console.Write(".");
                    };
                    DebtorInfo[] debtors = manager.GetDebtors
                                           (
                        connection.Search("RB=$")
                                           );
                    debtors = debtors.Where
                              (
                        debtor => !debtor.WorkPlace
                        .SafeContains(LibraryName)
                              )
                              .ToArray();
                    Console.WriteLine();
                    Console.WriteLine
                    (
                        "Debtors: {0}",
                        debtors.Length
                    );

                    VisitInfo[] allDebt = debtors.SelectMany
                                          (
                        debtor => debtor.Debt
                                          )
                                          .ToArray();
                    Console.WriteLine
                    (
                        "Books in debt: {0}",
                        allDebt.Length
                    );


                    Workbook workbook = new Workbook();
                    workbook.CreateNewDocument();
                    Worksheet worksheet = workbook.Worksheets[0];

                    int row = 0;

                    worksheet.Cells[row, 0].Value = "ФИО";
                    worksheet.Cells[row, 1].Value = "Билет";
                    worksheet.Cells[row, 2].Value = "Краткое описание";
                    worksheet.Cells[row, 3].Value = "Год";
                    worksheet.Cells[row, 4].Value = "Номер";
                    worksheet.Cells[row, 5].Value = "Цена";
                    worksheet.Cells[row, 6].Value = "Хранение";
                    worksheet.Cells[row, 7].Value = "Дата";
                    worksheet.Cells[row, 8].Value = "Отдел";

                    row++;

                    for (int i = 0; i < allDebt.Length; i++)
                    {
                        if (i % 100 == 0)
                        {
                            Console.Write(".");
                        }

                        VisitInfo debt = allDebt[i];

                        string description = debt.Description;
                        string inventory   = debt.Inventory;
                        string database    = debt.Database;
                        string year        = string.Empty;
                        string index       = debt.Index;
                        string price       = string.Empty;

                        if (!string.IsNullOrEmpty(index) &&
                            !string.IsNullOrEmpty(database))
                        {
                            if (databases.FirstOrDefault
                                (
                                    db => db.Name.SameString(database)
                                )
                                == null)
                            {
                                continue;
                            }

                            try
                            {
                                connection.Database = database;
                                MarcRecord record
                                    = connection.SearchReadOneRecord
                                      (
                                          "\"I={0}\"",
                                          index
                                      );
                                if (!ReferenceEquals(record, null))
                                {
                                    description = connection.FormatRecord
                                                  (
                                        FormatName,
                                        record.Mfn
                                                  );
                                    year  = GetYear(record);
                                    price = GetPrice(debt, record);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }

                        worksheet.Cells[row, 0].Value = debt.Reader.FullName;
                        worksheet.Cells[row, 1].Value = debt.Reader.Ticket;
                        worksheet.Cells[row, 2].Value = description;
                        worksheet.Cells[row, 3].Value = year;
                        worksheet.Cells[row, 4].Value = inventory;
                        worksheet.Cells[row, 5].Value = price;
                        worksheet.Cells[row, 6].Value = debt.Sigla;
                        worksheet.Cells[row, 7].Value = debt.DateExpectedString;
                        worksheet.Cells[row, 8].Value = debt.Department;

                        for (int j = 0; j <= 6; j++)
                        {
                            Cell cell = worksheet.Cells[row, j];
                            cell.Borders.SetAllBorders
                            (
                                Color.Black,
                                BorderLineStyle.Hair
                            );
                        }

                        row++;
                    }

                    workbook.SaveDocument(OutputFile);

                    Console.WriteLine("All done");

                    stopwatch.Stop();
                    TimeSpan elapsed = stopwatch.Elapsed;
                    Console.WriteLine("Elapsed: {0}", elapsed);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #14
0
        private InventoryResult _CheckInventory
        (
            IrbisConnection client,
            string number
        )
        {
            if (string.IsNullOrEmpty(number))
            {
                throw new ArgumentNullException("number");
            }

            InventoryResult result = new InventoryResult
            {
                Number = number
            };

            int[] found = client.Search
                          (
                "\"IN={0}\"",
                number
                          );

            bool writtenOff = CheckWrittenOff(number);

            if (writtenOff)
            {
                if (found.Length != 0)
                {
                    result.Status = InventoryStatus.Problem;
                    result.Text   = "проблема: то ли списан, то ли нет";
                }
                else
                {
                    result.Status = InventoryStatus.WrittenOff;
                    result.Text   = "списан";
                }
            }
            else
            {
                switch (found.Length)
                {
                case 0:
                    result.Status = InventoryStatus.NotFound;
                    result.Text   = "не найден";
                    break;

                case 1:
                    string format      = CM.AppSettings["format"];
                    string description = client.FormatRecord
                                         (
                        format,
                        found[0]
                                         );
                    if (!string.IsNullOrEmpty(description))
                    {
                        description = description.Trim();
                    }
                    result.Status = InventoryStatus.Found;
                    result.Text   = string.Format
                                    (
                        "найден: {0}",
                        description
                                    );
                    break;

                default:
                    result.Status = InventoryStatus.Problem;
                    result.Text   =
                        "проблема: много найдено";
                    break;
                }
            }

            return(result);
        }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: fossabot/ManagedIrbis
        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} =&gt; <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
            //        );
            //}
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: fossabot/ManagedIrbis
        static void Main(string[] args)
        {
            string connectionString = ConnectionString;

            if (args.Length != 0)
            {
                connectionString = args[0];
            }

            try
            {
                //IrbisEncoding.RelaxUtf8();
                using (Connection = new IrbisConnection())
                {
                    Connection.ParseConnectionString(connectionString);
                    Connection.Connect();

                    BatchRecordReader batch
                        = (BatchRecordReader)BatchRecordReader.Search
                          (
                              Connection,
                              Connection.Database,
                              //@"V=KN * G=201$",
                              @"V=KN",
                              1000
                          );
                    batch.BatchRead += (sender, eventArgs) =>
                    {
                        Console.Write(".");
                    };

                    //BatchRecordReader batch = records as BatchRecordReader;
                    //if (!ReferenceEquals(batch, null))
                    //{
                    //    Console.WriteLine("Found: {0}", batch.TotalRecords);
                    //    batch.BatchRead += (sender, args)
                    //        => Console.WriteLine(batch.RecordsRead);
                    //}

                    foreach (MarcRecord record in batch)
                    {
                        ProcessRecord(record);
                    }

                    Console.WriteLine();

                    Pair <int, int>[] top = list.OrderByDescending
                                            (
                        pair => pair.Second
                                            )
                                            .Take(100)
                                            .ToArray();

                    foreach (Pair <int, int> pair in top)
                    {
                        string description = EnhanceText
                                             (
                            Connection.FormatRecord
                            (
                                "@sbrief",
                                pair.First
                            )
                                             );

                        Console.WriteLine("{0}\t{1}", description, pair.Second);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }