Exemplo n.º 1
0
        public string[] ExtractInventoryNumbers
        (
            IrbisRecord record
        )
        {
            if (record == null)
            {
                return(new string[0]);
            }

            RecordField[] allFields = record.Fields
                                      .GetField("910", "A", "0");

            RecordField[] ourFields = allFields
                                      .Where(IsOurPlace)
                                      .ToArray();

            if (allFields.Length > ourFields.Length)
            {
                return(new string[0]);
            }

            return(ourFields
                   .GetSubField('B')
                   .GetSubFieldText());
        }
Exemplo n.º 2
0
        public ReaderInfo GetReader
        (
            [NotNull] string ticket
        )
        {
            if (string.IsNullOrEmpty(ticket))
            {
                throw new ArgumentNullException("ticket");
            }

            IrbisRecord record = Client.SearchReadOneRecord
                                 (
                "{0}{1}",
                ReaderIdentifier,
                ticket
                                 );

            if (ReferenceEquals(record, null))
            {
                return(null);
            }
            ReaderInfo result = ReaderInfo.Parse(record);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Renumber the fields in the record.
        /// </summary>
        public static void RenumberFields
        (
            [NotNull] IrbisRecord record,
            [NotNull] IEnumerable <RecordField> fields
        )
        {
            List <string> seen = new List <string>();

            foreach (RecordField field in fields)
            {
                field.Record = record;
                int count = 1;
                foreach (string s in seen)
                {
                    if (s == field.Tag)
                    {
                        count++;
                    }
                }
                seen.Add(field.Tag);
                field.Repeat = count;
                foreach (SubField subField in field.SubFields)
                {
                    subField.Field = field;
                }
            }
        }
        public IrbisRecord[] ReadAllRecordVersions
        (
            int mfn
        )
        {
            List <IrbisRecord> result      = new List <IrbisRecord>();
            IrbisRecord        lastVersion = ReadRecord(mfn);

            if (lastVersion != null)
            {
                result.Add(lastVersion);
                while (true)
                {
                    long offset = lastVersion.PreviousOffset;
                    if (offset == 0)
                    {
                        break;
                    }
                    MstRecord32 mstRecord       = Mst.ReadRecord2(offset);
                    IrbisRecord previousVersion = mstRecord.DecodeRecord();
                    if (previousVersion != null)
                    {
                        result.Add(previousVersion);
                        lastVersion = previousVersion;
                    }
                }
            }

            return(result.ToArray());
        }
        /// <summary>
        /// Search and read found records.
        /// </summary>
        public IrbisRecord[] SearchReadSimple
        (
            string key
        )
        {
            int[] mfns = InvertedFile.SearchSimple(key);
            List <IrbisRecord> result = new List <IrbisRecord>();

            foreach (int mfn in mfns)
            {
                try
                {
                    XrfRecord32 xrfRecord = Xrf.ReadRecord(mfn);
                    if (!xrfRecord.Deleted)
                    {
                        MstRecord32 mstRecord = Mst.ReadRecord2(xrfRecord.AbsoluteOffset);
                        if (!mstRecord.Deleted)
                        {
                            IrbisRecord irbisRecord = mstRecord.DecodeRecord();
                            irbisRecord.Database = Database;
                            result.Add(irbisRecord);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }

            return(result.ToArray());
        }
Exemplo n.º 6
0
 private void _AddRecord
 (
     Dictionary <int, IrbisRecord> list,
     int mfn
 )
 {
     if ((mfn > 0) &&
         !list.ContainsKey(mfn))
     {
         IrbisRecord record =
             ReadRecords
                 ? Client.ReadRecord(mfn)
                 : new IrbisRecord {
             Mfn = mfn
         };
         if (!record.Deleted ||
             AllowDeleted)
         {
             list.Add
             (
                 mfn,
                 record
             );
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Разбор записи.
        /// </summary>
        public static MagazineInfo Parse
        (
            IrbisRecord record
        )
        {
            if (ReferenceEquals(record, null))
            {
                throw new ArgumentNullException("record");
            }

            MagazineInfo result = new MagazineInfo
            {
                Index        = record.FM("903"),
                Title        = record.FM("200", 'a'),
                SubTitle     = record.FM("200", 'e'),
                Cumulation   = MagazineCumulation.Parse(record),
                SeriesNumber = record.FM("923", 'h'),
                SeriesTitle  = record.FM("923", 'i'),
                Mfn          = record.Mfn
            };

            if (string.IsNullOrEmpty(result.Title) ||
                string.IsNullOrEmpty(result.Index)
                //|| string.IsNullOrEmpty(result.MagazineKind)
                //|| string.IsNullOrEmpty(result.MagazineType)
                )
            {
                return(null);
            }

            return(result);
        }
Exemplo n.º 8
0
        public static ExemplarInfo[] Parse
        (
            [JetBrains.Annotations.NotNull] IrbisRecord record,
            [JetBrains.Annotations.NotNull] string tagNumber
        )
        {
            if (ReferenceEquals(record, null))
            {
                throw new ArgumentNullException("record");
            }
            if (string.IsNullOrEmpty(tagNumber))
            {
                throw new ArgumentNullException("tagNumber");
            }

            ExemplarInfo[] result = record.Fields
                                    .GetField(tagNumber)
                                    .Select(Parse)
                                    .ToArray();

            foreach (ExemplarInfo exemplar in result)
            {
                exemplar.Mfn         = record.Mfn;
                exemplar.Description = record.Description;
            }

            return(result);
        }
Exemplo n.º 9
0
 public virtual bool ProcessRecord
 (
     IrbisRecord record
 )
 {
     // Nothing to do here
     return(true);
 }
Exemplo n.º 10
0
 protected bool ProcessBatch
 (
     BatchRecordReader batch
 )
 {
     TotalProcessed = 0;
     _stopwatch.Start();
     try
     {
         using (
             IEnumerator <IrbisRecord> enumerator =
                 batch.GetEnumerator())
         {
             while (true)
             {
                 try
                 {
                     if (!enumerator.MoveNext())
                     {
                         break;
                     }
                     IrbisRecord record = enumerator.Current;
                     bool        flag   = ProcessRecord(record);
                     TotalProcessed++;
                     flag &= ReportProgress();
                     if (!flag)
                     {
                         return(false);
                     }
                 }
                 catch (Exception exception)
                 {
                     if (!OnError(exception))
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         OnError(exception);
         return(false);
     }
     finally
     {
         _stopwatch.Stop();
         WriteLine(string.Empty);
         WriteLine
         (
             "Processed: {0}, elapsed: {1}",
             TotalProcessed,
             Elapsed
         );
     }
     return(true);
 }
Exemplo n.º 11
0
        public void WriteRequest(BookRequest request)
        {
            IrbisRecord record = request.Record;

            if (record != null)
            {
                Client.WriteRecord(record, false, true);
            }
        }
Exemplo n.º 12
0
        public static CrmEvent Parse
        (
            IrbisRecord record
        )
        {
            CrmEvent result = new CrmEvent();

            return(result);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Установка новой текущей записи.
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 public IrbisScript SetRecord
 (
     IrbisRecord record
 )
 {
     Record = record;
     SetGlobal("Record", record);
     return(this);
 }
Exemplo n.º 14
0
        public void GetAdditionalInfo(BookRequest request)
        {
            IrbisRecord record = ReadCatalog(request.BookCode);

            request.BookRecord  = record;
            request.FreeNumbers = ExtractInventoryNumbers(record);
            //request.Reader = ReadReader(request.ReaderID);
            request.MyNumbers = FilterMyNumbers(request.FreeNumbers);
        }
Exemplo n.º 15
0
 public string Format
 (
     IrbisRecord record
 )
 {
     Context.ClearAll();
     Context.Record = record;
     Program.Execute(Context);
     return(Context.Text);
 }
Exemplo n.º 16
0
 public static ExemplarInfo[] Parse
 (
     [JetBrains.Annotations.NotNull] IrbisRecord record
 )
 {
     return(Parse
            (
                record,
                ExemplarTag
            ));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Разбор записи.
 /// </summary>
 public static RevisionInfo[] Parse
 (
     IrbisRecord record
 )
 {
     return(Parse
            (
                record,
                Tag
            ));
 }
Exemplo n.º 18
0
        internal void CopyRecord(string fromMfn, string toMfn, string recordIndex)
        {
            _recordIndex = "(" + recordIndex + ") ";
            recordFrom   = client.ReadRecord(Int32.Parse(fromMfn));
            recordTo     = client.ReadRecord(Int32.Parse(toMfn));
            try
            {
                RecordField fiedl922 = new RecordField("922");
                AddSubfield(fiedl922, 'C', "200", 'A');
                AddSubfield(fiedl922, 'F', "700", 'A');
                AddSubfield(fiedl922, '?', "700", 'G');
                AddSubfield(fiedl922, '1', "700", '1');
                AddSubfield(fiedl922, 'A', "700", 'C');
                recordTo.Fields.Add(fiedl922);

                CopyField("300");
                CopyField("331");
                CopySubField("215", 'A');
                CopySubField("316", 'A');


                foreach (RecordField field210 in recordFrom.Fields.GetField("210"))
                {
                    if (!field210.ToString().Contains("^5"))
                    {
                        _recordIndex = _recordIndex.Replace(" ", "");
                    }

                    var field   = new RecordField("210");
                    var sub2105 = new SubField('5', _recordIndex + field210.GetFirstSubFieldText('5'));
                    var sub210d = new SubField('D', field210.GetFirstSubFieldText('d'));
                    field.SubFields.Add(sub210d);
                    field.SubFields.Add(sub2105);
                    logging.WriteLine(field.Text);
                    recordTo.Fields.Add(field);
                    logging.WriteLine(recordTo.FM("210"));
                }



                client.WriteRecord
                (
                    recordTo,
                    false,
                    true
                );
            }
            catch (Exception ex)
            {
                logging.WriteLine("ERROR DURING COPYING RECORD! ");
                logging.WriteLine(ex.StackTrace);
                logging.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 19
0
 public static ReaderAddress Parse
 (
     [NotNull] IrbisRecord record
 )
 {
     return(Parse
            (
                record,
                Tag
            ));
 }
Exemplo n.º 20
0
        /// <summary>
        /// Сохранение записей с помощью пула.
        /// </summary>
        public static void WriteRecord
        (
            [NotNull] this IrbisConnectionPool pool,
            [NotNull] IrbisRecord record
        )
        {
            ManagedClient64 client = pool.AcquireConnection();

            client.WriteRecord(record, false, true);
            pool.ReleaseConnection(client);
        }
 /// <summary>
 /// Разбор записи.
 /// </summary>
 public static MagazineCumulation[] Parse
 (
     IrbisRecord record
 )
 {
     return(Parse
            (
                record,
                Tag
            ));
 }
Exemplo n.º 22
0
 private static void _AddField
 (
     IrbisRecord record,
     string tag,
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         record.Fields.Add(new RecordField(tag, text));
     }
 }
Exemplo n.º 23
0
        public static IrbisRecord ReadRecord
        (
            [NotNull] this IrbisConnectionPool pool,
            int mfn
        )
        {
            ManagedClient64 client = pool.AcquireConnection();
            IrbisRecord     result = client.ReadRecord(mfn);

            pool.ReleaseConnection(client);
            return(result);
        }
Exemplo n.º 24
0
        public static IrbisRecord RenumberFields
        (
            [NotNull] IrbisRecord record
        )
        {
            RenumberFields
            (
                record,
                record.Fields
            );

            return(record);
        }
Exemplo n.º 25
0
        public static MagazineArticleInfo Parse
        (
            IrbisRecord record
        )
        {
            if (ReferenceEquals(record, null))
            {
                throw new ArgumentNullException("record");
            }

            MagazineArticleInfo result = new MagazineArticleInfo();

            return(result);
        }
Exemplo n.º 26
0
 public object ToObject
 (
     IrbisRecord record,
     object target
 )
 {
     if (ReferenceEquals(record, null))
     {
         throw new ArgumentNullException("record");
     }
     if (ReferenceEquals(target, null))
     {
         throw new ArgumentNullException("target");
     }
     return(target);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Расформатирует текст скрипта локально.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="formatSource"></param>
 /// <param name="record"></param>
 /// <returns></returns>
 public static string FormatSource
 (
     ManagedClient64 client,
     string formatSource,
     IrbisRecord record
 )
 {
     using (PftFormatter formatter = new PftFormatter(client))
     {
         string input  = formatter.ResolveInline(formatSource);
         string result = formatter
                         .ParseInput(input)
                         .Format(record);
         return(result);
     }
 }
Exemplo n.º 28
0
 // ReSharper disable ParameterTypeCanBeEnumerable.Local
 private void _SearchBySequential
 (
     Dictionary <int, IrbisRecord> result,
     string prefix,
     NumberRangeCollection ranges
 )
 {
     foreach (NumberText number in ranges)
     {
         if (ReadRecords)
         {
             IrbisRecord record = Client.SearchReadOneRecord
                                  (
                 "\"{0}{1}\"",
                 prefix,
                 number
                                  );
             if ((record != null) &&
                 !result.ContainsKey(record.Mfn))
             {
                 result.Add
                 (
                     record.Mfn,
                     record
                 );
             }
         }
         else
         {
             int[] found = Client.Search
                           (
                 "\"{0}{1}\"",
                 prefix,
                 number
                           );
             if ((found != null) &&
                 (found.Length != 0))
             {
                 _AddRecord
                 (
                     result,
                     found[0]
                 );
             }
         }
     }
 }
Exemplo n.º 29
0
        public static ReaderInfo Parse(IrbisRecord record)
        {
            ReaderInfo result = new ReaderInfo
            {
                FamilyName             = record.FM("10"),
                FirstName              = record.FM("11"),
                Patronym               = record.FM("12"),
                Birthdate              = record.FM("21"),
                Ticket                 = record.FM("30"),
                Sex                    = record.FM("23"),
                Category               = record.FM("50"),
                Address                = record.FM("13"),
                Work                   = record.FM("15"),
                Education              = record.FM("20"),
                HomePhone              = record.FM("17"),
                RegistrationDateString = record.FM("51"),
                Registrations          = record.Fields
                                         .GetField("52")
                                         .Select(field => RegistrationInfo.Parse(field))
                                         .ToArray(),
                EnabledPlaces  = record.FM("56"),
                DisabledPlaces = record.FM("57"),
                Rights         = record.FM("29"),
                Remarks        = record.FM("33"),
                PhotoFile      = record.FM("950"),
                Visits         = record.Fields
                                 .GetField("40")
                                 .Select(field => VisitInfo.Parse(field))
                                 .ToArray()
            };

            string fio = result.FamilyName;

            if (!string.IsNullOrEmpty(result.FirstName))
            {
                fio = fio + " " + result.FirstName;
            }
            if (!string.IsNullOrEmpty(result.Patronym))
            {
                fio = fio + " " + result.Patronym;
            }
            result.Fio = fio;

            return(result);
        }
Exemplo n.º 30
0
        public IrbisRecord DecodeRecord()
        {
            IrbisRecord result = new IrbisRecord
            {
                Mfn            = Leader.Mfn,
                Status         = (RecordStatus)Leader.Status,
                PreviousOffset = Leader.Previous,
                Version        = Leader.Version
            };

            foreach (MstDictionaryEntry64 entry in Dictionary)
            {
                RecordField field = DecodeField(entry);
                result.Fields.Add(field);
            }

            return(result);
        }