Пример #1
0
        public static IriProfile[] ParseRecord
        (
            [NotNull] IrbisRecord record
        )
        {
            if (ReferenceEquals(record, null))
            {
                throw new ArgumentNullException("record");
            }

            List <IriProfile> result = new List <IriProfile>();

            foreach (RecordField field in record.Fields
                     .GetField(IriTag))
            {
                IriProfile profile = ParseField(field);
                result.Add(profile);
            }
            return(result.ToArray());
        }
Пример #2
0
        public static IriProfile ParseField
        (
            [NotNull] RecordField field
        )
        {
            if (ReferenceEquals(field, null))
            {
                throw new ArgumentNullException("field");
            }

            IriProfile result = new IriProfile
            {
                Active      = field.GetFirstSubFieldText('a') == "1",
                ID          = field.GetFirstSubFieldText('b'),
                Title       = field.GetFirstSubFieldText('c'),
                Query       = field.GetFirstSubFieldText('d'),
                Periodicity = int.Parse(field.GetFirstSubFieldText('e')),
                LastServed  = field.GetFirstSubFieldText('f'),
                Database    = field.GetFirstSubFieldText('i')
            };

            return(result);
        }
Пример #3
0
        public static ReaderInfo Parse
        (
            [JetBrains.Annotations.NotNull] IrbisRecord record
        )
        {
            if (ReferenceEquals(record, null))
            {
                throw new ArgumentNullException("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"),
                Gender     = record.FM("23"),
                Category   = record.FM("50"),
                Address    = ReaderAddress.Parse
                             (
                    record.Fields
                    .GetField("13")
                    .FirstOrDefault()
                             ),
                Work      = record.FM("15"),
                Education = record.FM("20"),
                Email     = record.FM("32"),
                HomePhone = record.FM("17"),
                RegistrationDateString = record.FM("51"),
                Enrolment = record.Fields
                            .GetField("51")
                            .Select(ReaderRegistration.Parse)
                            .ToArray(),
                Registrations = record.Fields
                                .GetField("52")
                                .Select(ReaderRegistration.Parse)
                                .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(VisitInfo.Parse)
                                 .ToArray(),
                Profiles = IriProfile.ParseRecord(record)
            };

            foreach (ReaderRegistration registration in result.Registrations)
            {
                registration.Reader = result;
            }
            foreach (VisitInfo visit in result.Visits)
            {
                visit.Reader = result;
            }

            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);
        }