コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                return;
            }

            string databasePath = args[0];

            fromNumber = args[1];
            toNumber   = args[2];

            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);

                    string savedDirectory = Directory.GetCurrentDirectory();
                    Directory.SetCurrentDirectory(systemPath);
                    try
                    {
                        irbis.UseDatabase("ibis");

                        string briefPft = irbis.GetPftPath("sbrief");
                        irbis.SetFormat("@" + briefPft);

                        NumberText currentNumber = fromNumber;
                        while (currentNumber < toNumber)
                        {
                            ProcessNumber(currentNumber.ToString());
                            currentNumber = currentNumber.Increment();
                        }
                    }
                    finally
                    {
                        Directory.SetCurrentDirectory(savedDirectory);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: fossabot/ManagedIrbis
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                return;
            }

            magazines = new CaseInsensitiveDictionary <string>();
            counter   = new DictionaryCounterInt32 <string>();
            string databasePath = args[0];

            filter = args[1];

            try
            {
                ServerConfiguration configuration
                    = ServerConfiguration.FromIniFile(databasePath);
                using (irbis = new Irbis64Dll(configuration))
                {
                    irbis.Layout = SpaceLayout.Version2014();
                    irbis.SetStandardIniFile("irbisc.ini");
                    int[] found = null;
                    irbis.UseDatabase("ibis");
                    string briefPft = irbis.GetPftPath("sbrief");
                    irbis.SetFormat("@" + briefPft);

                    found = irbis.Search(filter);
                    if (found.Length == 0)
                    {
                        Console.WriteLine("Noting found");
                        return;
                    }
                    Console.WriteLine("Found: {0}", found.Length);

                    foreach (int mfn in found)
                    {
                        ProcessRecord(mfn);
                    }

                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Всего выдач: {0}", counter.Total);
                    Console.WriteLine();

                    KeyValuePair <string, int>[] pairs = counter
                                                         .OrderByDescending(pair => pair.Value)
                                                         .ToArray();

                    foreach (KeyValuePair <string, int> pair in pairs)
                    {
                        Console.WriteLine
                        (
                            "{0}\t{1}",
                            pair.Key,
                            pair.Value
                        );
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }