static void Main(string[] args) { string sourcePath = @"D:\Temp45\1-31973.MRC"; string outputPath = @"D:\Temp45\1-31973.txt"; int counter = 0; using (IsoReader reader = new IsoReader(sourcePath, IrbisEncoding.Oem)) using (TextWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8)) { foreach (MarcRecord record in reader) { if (record == null) { continue; } PlainText.WriteRecord(writer, record); Console.Write('.'); counter++; } } Console.WriteLine(); Console.WriteLine(counter); Console.WriteLine(); }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Need two arguments"); return; } string inputFileName = args[0]; string outputFileName = args[1]; try { FoundRecord[] found = MstRecover64 .FindRecords(inputFileName) .Where(record => (record.Flags & (int)RecordStatus.LogicallyDeleted) == 0) .ToArray(); Console.WriteLine("Records found: {0}", found.Length); using (StreamWriter output = File.CreateText(outputFileName)) using (MstFile64 input = new MstFile64(inputFileName, DirectAccessMode.ReadOnly)) { foreach (FoundRecord info in found) { Console.WriteLine ( "MFN {0}: ver {1} status {2}", info.Mfn, info.Version, info.Flags ); MstRecord64 mstRecord = input.ReadRecord(info.Position); MarcRecord marcRecord = mstRecord.DecodeRecord(); PlainText.WriteRecord(output, marcRecord); } } } catch (Exception exception) { Console.WriteLine(exception); } }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Need two arguments"); return; } string inputFileName = args[0]; string outputFileName = args[1]; try { // Сначала прочитаем уже имеющиеся записи if (File.Exists(outputFileName)) { using (StreamReader stringReader = File.OpenText(outputFileName)) { MarcRecord marcRecord; while ((marcRecord = PlainText.ReadRecord(stringReader)) != null) { ReaderInfo readerInfo = ReaderInfo.Parse(marcRecord); DepersonalizedReader depersonalized = DepersonalizedReader.FromReaderInfo(readerInfo); string ticket = depersonalized.Ticket.ThrowIfNull(); readers.Add(ticket, depersonalized); } } } // Теперь будем вычитывать данные и объединять их с уже имеющимися string ext = Path.GetExtension(inputFileName); if (ext.SameString(".mst")) { ProcessOneDatabase(inputFileName); } else { string[] inputFiles = File.ReadAllLines(inputFileName); foreach (string inputFile in inputFiles) { ProcessOneDatabase(inputFile); } } // Сохраняем результат Console.WriteLine("Writing "); using (StreamWriter writer = File.CreateText(outputFileName)) { var allReaders = readers.Values; foreach (DepersonalizedReader reader in allReaders) { MarcRecord record = reader.ToMarcRecord(); PlainText.WriteRecord(writer, record); } } Console.WriteLine("DONE"); } catch (Exception exception) { Console.WriteLine(exception); } }