static void ProcessNumber ( string number ) { int[] found = irbis.ExactSearch(string.Format ( "IN={0}", number )); if (found.Length == 0) { return; } int mfn = found[0]; irbis.ReadRecord(mfn); NativeRecord native = irbis.GetRecord(); MarcRecord record = native.ToMarcRecord(); string description = irbis.FormatRecord(mfn); int count = record.FM(999).SafeToInt32(); Console.WriteLine ( "{0}\t{1}\t{2}", number, count, description ); }
static void ProcessRecord ( int mfn ) { irbis.ReadRecord(mfn); NativeRecord record = irbis.GetRecord(); NativeField v933 = record.GetFirstField(933); if (ReferenceEquals(v933, null)) { return; } string index = v933.Value; string description; if (!magazines.ContainsKey(index)) { int[] found = irbis.ExactSearch("I=" + index); if (found.Length == 0) { return; } description = irbis.FormatRecord(found[0]); magazines.Add(index, description); } description = magazines[index]; NativeField v999 = record.GetFirstField(999); int count = ReferenceEquals(v999, null) ? 0 : v999.Value.SafeToInt32(); Console.WriteLine ( "{0}: {1}", irbis.FormatRecord(mfn), count ); counter.Augment(description, count); }
static void Main(string[] args) { if (args.Length < 2) { return; } string databasePath = args[0]; searchExpression = args[1]; try { ServerConfiguration configuration = ServerConfiguration.FromIniFile(databasePath); using (irbis = new Irbis64Dll(configuration)) { irbis.Layout = SpaceLayout.Version2014(); string systemPath = irbis.Configuration.SystemPath; string mainIni = Path.GetFullPath ( Path.Combine ( systemPath, "irbisc.ini" ) ); Irbis65Dll.IrbisMainIniInit(mainIni); irbis.UseDatabase("ibis"); Console.WriteLine("Max MFN={0}", irbis.GetMaxMfn()); string briefPft = irbis.GetPftPath("sbrief"); irbis.SetFormat("@" + briefPft); int[] found = irbis.Search(searchExpression); Console.WriteLine("Found: {0}", found.Length); Console.WriteLine(); foreach (int mfn in found) { string formatted = irbis.FormatRecord(mfn); Console.WriteLine ( "{0}: {1}", mfn, formatted ); } } } catch (Exception exception) { Console.WriteLine(exception); } }
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); } }