static void Main ( string[] args ) { if (args.Length != 3) { return; } _connectionString = args[0]; _fond = args[1]; _fileName = args[2]; string[] numbers = File.ReadAllLines(_fileName) .NonEmptyLines().ToArray(); NativeIrbisProvider.Register(); try { using (_provider = ProviderManager .GetAndConfigureProvider(_connectionString)) { foreach (string number in numbers) { _ProcessNumber(number); } } } catch (Exception exception) { Console.WriteLine(exception); } }
static int Main(string[] args) { if (args.Length != 2) { Console.WriteLine("BiblioGrinder <configurationString> <biblioDocument.json>"); return(1); } log = new TeeOutput(AbstractOutput.Console); configurationString = args[0]; documentPath = args[1]; ReadRecordCommand.ThrowOnVerify = false; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { AbstractOutput logFile = new FileOutput("grinder.log"); log.Output.Add(logFile); NativeIrbisProvider.Register(); using (provider = ProviderManager .GetAndConfigureProvider(configurationString)) { log.WriteLine ( "Connected to database {0}, max MFN={1}", provider.Database, provider.GetMaxMfn() ); document = BiblioDocument.LoadFile(documentPath); context = new BiblioContext(document, provider, log); processor = new BiblioProcessor(); processor.Initialize(context); processor.BuildDocument(context); string outputText = processor.Output.Text; // TODO implement properly outputText = Regex.Replace ( outputText, @"\s(-|–|\\u8211.)\sIS[BS]N\s[0-9XxХх-]*\.?", string.Empty ); outputText = Regex.Replace ( outputText, @"([А-Я]\.)\s([А-Я])", "$1\\~$2" ); outputText = Regex.Replace ( outputText, "\\\"([\\w])", "«$1" ); outputText = Regex.Replace ( outputText, "([\\w\\.])\\\"", "$1»" ); outputText = Regex.Replace ( outputText, "\\\"(\\.\\.\\.|\\(|\\[)", "«$1" ); outputText = Regex.Replace ( outputText, "(\\.\\.\\.|\\!|\\?|\\)|\\])\\\"", "$1»" ); outputText = outputText .Replace(" - ", " \\u8211? ") .Replace("}- ", "}\\u8211? ") .Replace(" -}", " \\u8211?}") .Replace(" -\\", " \\u8211?\\") .Replace("\\u8470? ", "\u8470?\\~") .Replace("...", "\\'85") .Replace("С. ", "С.\\~") ; File.WriteAllText ( "output.rtf", outputText, IrbisEncoding.Ansi ); stopwatch.Stop(); TimeSpan elapsed = stopwatch.Elapsed; log.WriteLine ( "Elapsed: {0}", elapsed.ToAutoString() ); log.WriteLine ( "Finished at: {0}", DateTime.Now ); } } catch (Exception exception) { log.WriteLine ( "Exception: {0}", exception ); return(1); } return(0); }
static void Test2(string[] args) { if (args.Length != 1) { Console.WriteLine("IrbisInteropTester <irbis_server.ini>"); return; } try { ServerConfiguration configuration = ServerConfiguration.FromIniFile(args[0]); using (Irbis64Dll irbis = new Irbis64Dll(configuration)) { Console.WriteLine ( "Irbis64.dll version={0}", Irbis64Dll.GetDllVersion() ); irbis.UseDatabase("ibis"); //irbis.UseDatabase("ISTU"); Console.WriteLine ( "Max MFN={0}", irbis.GetMaxMfn() ); string briefPft = irbis.GetPftPath("brief"); irbis.SetFormat("@" + briefPft); for (int mfn = 10; mfn < 20; mfn++) { irbis.ReadRecord(mfn); Console.WriteLine("Read record MFN={0}", mfn); NativeRecord record = irbis.GetRecord(); Console.WriteLine(record); string text = irbis.FormatRecord(); Console.WriteLine(text); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine ( "Record offset={0}, formatted offset={1}", irbis.Layout.Value.RecordOffset, irbis.Layout.Value.FormattedOffset ); Console.WriteLine(); TermInfo[] terms = irbis.ListTerms("K=", 50); for (int i = 0; i < terms.Length; i++) { Console.WriteLine(terms[i]); } Console.WriteLine(); terms = irbis.ExactSearchTrimEx("K=БЕТОН", 200); for (int i = 0; i < terms.Length; i++) { Console.WriteLine(terms[i]); } Console.WriteLine(); TermLink[] links = irbis.ExactSearchLinks ( "K=1 КЛАСС" ); for (int i = 0; i < links.Length; i++) { Console.WriteLine(links[i]); } Console.WriteLine(); links = irbis.ExactSearchTrimLinks ( "K=БЕТОН", 200 ); for (int i = 0; i < links.Length; i++) { Console.WriteLine(links[i]); } Console.WriteLine(); IrbisProvider provider = new NativeIrbisProvider(irbis); SearchManager manager = new SearchManager(provider); SearchContext context = new SearchContext(manager, provider); links = irbis.Search("K=БЕТОН", context); for (int i = 0; i < links.Length; i++) { Console.WriteLine(links[i]); } Console.WriteLine(); links = irbis.Search("K=БЕТОН * K=ЖЕЛЕЗО$", context); for (int i = 0; i < links.Length; i++) { Console.WriteLine(links[i]); } Console.WriteLine(); string testDatabase = Path.Combine ( Path.GetDirectoryName ( Assembly.GetEntryAssembly().Location ) .ThrowIfNull("directory is unknown"), "TestDb" ); irbis.UseStandaloneDatabase ( testDatabase, "TestDb" ); for (int i = 0; i < 10; i++) { int number = i + 1; NativeRecord record = new NativeRecord(); for (int j = 0; j < 10; j++) { NativeField field = new NativeField { Tag = 100 + j, Value = "Запись номер " + number + " поле " + (100 + j) }; record.Fields.Add(field); } irbis.NewRecord(); irbis.SetRecord(record); irbis.WriteRecord(true, false); irbis.SetFormat("v100"); string text = irbis.FormatRecord(); Console.WriteLine(text); } } } catch (Exception exception) { Console.WriteLine(exception); } }