Esempio n. 1
0
        public void FstProcessor_Rusmarc()
        {
            IrbisConnection connection = Connection.ThrowIfNull();
            IrbisProvider   provider   = new ConnectedClient(connection);

            FileSpecification specification = new FileSpecification
                                              (
                IrbisPath.MasterFile,
                "IBIS",
                "rmarci.fst"
                                              );
            FstProcessor processor = new FstProcessor(provider, specification);

            MarcRecord record;
            string     fileName = Path.Combine
                                  (
                DataPath.ThrowIfNull("DataPath"),
                "TEST1.ISO"
                                  );

            using (Stream stream = File.OpenRead(fileName))
            {
                record = Iso2709.ReadRecord
                         (
                    stream,
                    IrbisEncoding.Ansi
                         )
                         .ThrowIfNull("Iso2709.ReadRecord");
            }
            MarcRecord transformed = processor.TransformRecord
                                     (
                record,
                processor.File
                                     );

            Write(transformed);
        }
Esempio n. 2
0
        static void ProcessFile
        (
            int index,
            string fullName
        )
        {
            string fileName = Path.GetFileNameWithoutExtension(fullName);

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

            WriteLog
            (
                "{0}) ФАЙЛ {1}: ",
                index,
                fileName
            );

            Match match = NameRegex.Match(fileName);

            if (!match.Success)
            {
                WriteLogLine("неподдерживаемое имя файла, пропускаем");
                return;
            }

            WriteLogLine(string.Empty);

            using (FileStream stream = File.OpenRead(fullName))
            {
                while (GoOn)
                {
                    MarcRecord sourceRecord;

                    try
                    {
                        sourceRecord = Iso2709.ReadRecord
                                       (
                            stream,
                            Encoding.Default
                                       );
                    }
                    catch (Exception ex)
                    {
                        WriteLogLine("EXCEPTION: {0}", ex);
                        WriteLogLine("пропускаем файл");
                        continue;
                    }
                    if (sourceRecord == null)
                    {
                        break;
                    }

                    if (!ProcessRecord
                        (
                            sourceRecord
                        ))
                    {
                        break;
                    }
                    WriteLogLine(string.Empty);
                } // while

                FileCount++;
            } // using
        }