Пример #1
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        public BatchRecordFormatter
        (
            [NotNull] ManagedClient64 client,
            int batchSize,
            [NotNull] string format
        )
        {
            if (ReferenceEquals(client, null))
            {
                throw new ArgumentNullException("client");
            }
            if (batchSize < 1)
            {
                throw new ArgumentOutOfRangeException("batchSize");
            }
            if (string.IsNullOrEmpty(format))
            {
                throw new ArgumentNullException("format");
            }
            Client    = client;
            BatchSize = batchSize;
            Format    = format;
            IEnumerable <int> range = Enumerable.Range(1, Client.GetMaxMfn());

            _InitializePackages(range);
        }
Пример #2
0
        public static List <ReaderInfo> LoadReaders
        (
            [NotNull] ManagedClient64 client,
            [NotNull] List <ReaderInfo> readers,
            [NotNull] string dbName
        )
        {
            if (ReferenceEquals(client, null))
            {
                throw new ArgumentNullException("client");
            }
            if (ReferenceEquals(readers, null))
            {
                throw new ArgumentNullException("readers");
            }
            if (string.IsNullOrEmpty(dbName))
            {
                throw new ArgumentNullException("dbName");
            }

            try
            {
                client.PushDatabase(dbName);
                readers.Capacity += client.GetMaxMfn();

                BatchRecordReader batch = new BatchRecordReader
                                          (
                    client,
                    1500
                                          );

                Parallel.ForEach
                (
                    batch,
                    record =>
                {
                    if (!record.Deleted)
                    {
                        ReaderInfo reader
                            = ReaderInfo.Parse(record);
                        lock (readers)
                        {
                            readers.Add(reader);
                        }
                    }
                }
                );
            }
            finally
            {
                client.PopDatabase();
            }

            return(readers);
        }
Пример #3
0
        public BatchRecordReader
        (
            ManagedClient64 client,
            int batchSize
        )
        {
            if (ReferenceEquals(client, null))
            {
                throw new ArgumentNullException("client");
            }
            if (batchSize < 1)
            {
                throw new ArgumentOutOfRangeException("batchSize");
            }
            Client    = client;
            BatchSize = batchSize;
            IEnumerable <int> range = Enumerable.Range(1, Client.GetMaxMfn());

            _InitializePackages(range);
        }
Пример #4
0
        private int[] _GetMfnList
        (
            string connectionString
        )
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }

            using (ManagedClient64 client = new ManagedClient64())
            {
                client.ParseConnectionString(connectionString);
                client.Connect();
                int maxMfn = client.GetMaxMfn() - 1;
                if (maxMfn <= 0)
                {
                    throw new ApplicationException("MaxMFN=0");
                }
                int[] result = Enumerable.Range(1, maxMfn).ToArray();
                return(result);
            }
        }
Пример #5
0
 internal int GetMaxMfn()
 {
     return(client.GetMaxMfn());
 }