static void Main(string[] args) { if (args.Length != 2) { return; } string iniPath = args[0]; string database = args[1]; using (IniFile iniFile = new IniFile ( iniPath, IrbisEncoding.Ansi, false )) { ServerIniFile serverIniFile = new ServerIniFile(iniFile); ServerConfiguration configuration = ServerConfiguration.FromIniFile(serverIniFile); using (Irbis64Dll irbis = new Irbis64Dll(configuration)) { irbis.Layout = SpaceLayout.Version2014(); irbis.UseDatabase(database); int maxMfn = irbis.GetMaxMfn(); Console.WriteLine("Max MFN={0}", maxMfn); for (int mfn = 1; mfn < maxMfn; mfn++) { NativeRecord record; try { irbis.ReadRecord(mfn); record = irbis.GetRecord(); } catch { continue; } NativeField[] fields = record.Fields .Where(field => field.Tag < 4) .ToArray(); foreach (NativeField field in fields) { record.Fields.Remove(field); } if (fields.Length != 0) { Console.WriteLine(mfn); irbis.SetRecord(record); irbis.WriteRecord(true, false); } } } } }
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); } }