Ejemplo n.º 1
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }