Ejemplo n.º 1
0
        private void _Worker
        (
            object state
        )
        {
            int[] chunk = (int[])state;
            //foreach (int mfn in chunk)
            //{
            //    IrbisRecord record = new IrbisRecord{Mfn = mfn};
            //    _PutRecord(record);
            //}
            //_event.Set();

            using (ManagedClient64 client = new ManagedClient64())
            {
                client.ParseConnectionString(ConnectionString);
                client.Connect();
                BatchRecordReader batch = new BatchRecordReader
                                          (
                    client,
                    chunk
                                          );
                foreach (IrbisRecord record in batch)
                {
                    _PutRecord(record);
                }
            }
            _event.Set();
        }
Ejemplo n.º 2
0
        public string Get
        (
            string name,
            ManagedClient64 client
        )
        {
            string result;

            if (!_dictionary.TryGetValue(name, out result))
            {
                if (client != null)
                {
                    result = client.ReadTextFile(name);
                }
            }

            if (string.IsNullOrEmpty(result))
            {
                result = null;
            }

            if (result == null)
            {
                _dictionary.Remove(name);
            }
            else
            {
                _dictionary[name] = result;
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void _Worker
        (
            object state
        )
        {
            int[] chunk = (int[])state;

            using (ManagedClient64 client = new ManagedClient64())
            {
                client.ParseConnectionString(ConnectionString);
                client.Connect();

                BatchRecordFormatter batch = new BatchRecordFormatter
                                             (
                    client,
                    chunk,
                    Format
                                             );
                foreach (string line in batch)
                {
                    _PutLine(line);
                }
            }
            _event.Set();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Disconnect.
 /// </summary>
 public static void DisconnectRetry
 (
     this ManagedClient64 client
 )
 {
     Try(client.Dispose);
 }
        public static IrbisUpperCaseTable FromServer
        (
            [NotNull] ManagedClient64 connection,
            [NotNull] string fileName
        )
        {
            string text = connection.ReadTextFile
                          (
                IrbisPath.System,
                fileName
                          );

            if (string.IsNullOrEmpty(text))
            {
                throw new IrbisException
                      (
                          "No file " + fileName
                      );
            }

            IrbisUpperCaseTable result = ParseText
                                         (
                IrbisEncoding.Ansi,
                text
                                         );

            return(result);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 public RecordExtractor
 (
     ManagedClient64 client
 )
     : this(client, null)
 {
 }
Ejemplo n.º 7
0
        public static ChairInfo[] Read
        (
            [NotNull] ManagedClient64 client,
            [NotNull] string fileName
        )
        {
            if (ReferenceEquals(client, null))
            {
                throw new ArgumentNullException("client");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            string chairText = client.ReadTextFile
                               (
                IrbisPath.MasterFile,
                fileName
                               );

            ChairInfo[] result = Parse(chairText);

            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Contructor.
        /// </summary>
        public MorphologyEngine
        (
            [NotNull] ManagedClient64 client,
            [NotNull] string prefix,
            [NotNull] string database
        )
        {
            if (ReferenceEquals(client, null))
            {
                throw new ArgumentNullException("client");
            }
            if (string.IsNullOrEmpty(prefix))
            {
                throw new ArgumentNullException("prefix");
            }
            if (string.IsNullOrEmpty(database))
            {
                throw new ArgumentNullException("database");
            }

            _client   = client;
            _provider = new IrbisMorphologyProvider
                        (
                prefix,
                database,
                client
                        );
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RecordBuffer" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 public RecordBuffer
 (
     ManagedClient64 client
 )
     : this(client, 10)
 {
 }
        /// <inheritdoc cref="MorphologyProvider.FindWord"/>
        public override MorphologyEntry[] FindWord
        (
            string word
        )
        {
            ManagedClient64 client   = Client.ThrowIfNull("Client");
            string          database = Database.ThrowIfNull("Database");


            client.PushDatabase(database);
            try
            {
                IrbisRecord[] records = client.SearchRead
                                        (
                    "\"K={0}\"",
                    word
                                        );
                MorphologyEntry[] result = records
                                           .Select(r => MorphologyEntry.Parse(r))
                                           .ToArray();

                return(result);
            }
            finally
            {
                client.PopDatabase();
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// No operation.
 /// </summary>
 public static void NopRetry
 (
     this ManagedClient64 client
 )
 {
     Try(client.NoOp);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 public BatchRecordFormatter
 (
     [NotNull] ManagedClient64 client,
     int batchSize,
     [NotNull] IEnumerable <int> range,
     [NotNull] string format
 )
 {
     if (ReferenceEquals(client, null))
     {
         throw new ArgumentNullException("client");
     }
     if (batchSize < 1)
     {
         throw new ArgumentOutOfRangeException("batchSize");
     }
     if (ReferenceEquals(range, null))
     {
         throw new ArgumentNullException("range");
     }
     if (string.IsNullOrEmpty(format))
     {
         throw new ArgumentNullException("format");
     }
     Client    = client;
     BatchSize = batchSize;
     Format    = format;
     _InitializePackages(range);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 public BatchRecordFormatter
 (
     [NotNull] ManagedClient64 client,
     [NotNull] string format,
     [NotNull] string query,
     params object[] args
 )
 {
     if (ReferenceEquals(client, null))
     {
         throw new ArgumentNullException("client");
     }
     if (string.IsNullOrEmpty(format))
     {
         throw new ArgumentNullException("format");
     }
     if (string.IsNullOrEmpty(query))
     {
         throw new ArgumentNullException("query");
     }
     Client    = client;
     BatchSize = DefaultBatchSize;
     Format    = format;
     int[] found = Client.Search(query, args);
     _InitializePackages(found);
 }
Ejemplo n.º 14
0
        public static bool TryLogin2
        (
            this ManagedClient64 client,
            IWin32Window owner
        )
        {
            while (Login2(client, owner))
            {
                try
                {
                    client.Connect();
                    if (client.Connected)
                    {
                        return(true);
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public IrbisAlphabetTable
 (
     ManagedClient64 client
 )
     : this(client, FileName)
 {
 }
Ejemplo n.º 16
0
 public GlobalCorrector
 (
     ManagedClient64 client
 )
     : this()
 {
     Client = client;
 }
Ejemplo n.º 17
0
 public PftCache
 (
     ManagedClient64 client
 )
     : this()
 {
     Client = client;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GblBuilder
 (
     [NotNull] ManagedClient64 client
 )
     : this()
 {
     Client = client;
 }
Ejemplo n.º 19
0
 public GblBuilder
 (
     ManagedClient64 client
 )
     : this()
 {
     Client = client;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="IrbisCommadEventArgs" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 public IrbisCommadEventArgs
 (
     ManagedClient64 client
 )
 {
     Client     = client;
     RetryCount = client.RetryCount;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Connect to the server.
        /// </summary>
        public static void ConnectRetry
        (
            this ManagedClient64 client
        )
        {
            Action action = client.Connect;

            Try(action);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Get max MFN.
        /// </summary>
        public static int GetMaxMfnRetry
        (
            this ManagedClient64 client
        )
        {
            Func <int> func = client.GetMaxMfn;

            return(Try(func));
        }
Ejemplo n.º 23
0
        public static IrbisExecutive FromConnectionString
        (
            string connectionString
        )
        {
            ManagedClient64 client = new ManagedClient64();

            client.ParseConnectionString(connectionString);
            return(new IrbisExecutive(client));
        }
Ejemplo n.º 24
0
 public GblBuilder
 (
     ManagedClient64 client,
     string database
 )
     : this()
 {
     Client   = client;
     Database = database;
 }
Ejemplo n.º 25
0
        public static IrbisMenu Read
        (
            ManagedClient64 client,
            string name
        )
        {
            string text = client.ReadTextFile(name);

            return(ParseText(text));
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="IrbisCommadEventArgs" /> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="exception">The exception.</param>
 public IrbisCommadEventArgs
 (
     ManagedClient64 client,
     IrbisException exception
 )
 {
     Client     = client;
     RetryCount = client.RetryCount;
     Exception  = exception;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Write the record.
        /// </summary>
        public static void WriteRecordRetry
        (
            this ManagedClient64 client,
            IrbisRecord record
        )
        {
            Action <IrbisRecord, bool, bool> action = client.WriteRecord;

            Try(action, record, false, true);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Search.
        /// </summary>
        public static int[] SearchRetry
        (
            this ManagedClient64 client,
            string expression
        )
        {
            Func <string, object[], int[]> func = client.Search;

            return(Try(func, expression, new object[0]));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Read text file.
        /// </summary>
        public static string ReadTextFileRetry
        (
            this ManagedClient64 client,
            string specification
        )
        {
            Func <string, string> func = client.ReadTextFile;

            return(Try(func, specification));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Read record from server.
        /// </summary>
        public static IrbisRecord ReadRecordRetry
        (
            this ManagedClient64 client,
            int mfn
        )
        {
            Func <int, IrbisRecord> func = client.ReadRecord;

            return(Try(func, mfn));
        }