static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: NetworkReaderBenchmark <path-to-MST>"); return; } string connectionString = args[0]; try { IrbisEncoding.RelaxUtf8(); Console.WriteLine("Open"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); using (IrbisConnection connection = new IrbisConnection(connectionString)) { int maxMfn = connection.GetMaxMfn(); Console.WriteLine("Max MFN={0}", maxMfn); IEnumerable <MarcRecord> batch = BatchRecordReader.WholeDatabase ( connection, connection.Database, 1000, reader => { Console.Write('.'); } ); foreach (MarcRecord record in batch) { if (record.Modified) { Console.WriteLine("Very strange!"); } } } stopwatch.Stop(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Close"); Console.WriteLine ( "Elapsed: {0} sec", stopwatch.Elapsed.ToSecondString() ); } catch (Exception exception) { Console.WriteLine(exception); } }
static void Main() { Console.CancelKeyPress += Console_CancelKeyPress; try { using (connection = new IrbisConnection()) { connection.ParseConnectionString(ConnectionString); connection.Connect(); connection.Database = DatabaseName; Console.WriteLine("Подключились"); IEnumerable <MarcRecord> records = BatchRecordReader.WholeDatabase ( connection, DatabaseName, 500 //, rdr => //{ // Console.WriteLine // ( // "{0} из {1}", // rdr.RecordsRead, // rdr.TotalRecords // ); //} ); foreach (MarcRecord record in records) { if (Cancel) { break; } if (record.Deleted) { continue; } ReaderInfo reader = ReaderInfo.Parse(record); if (reader.WorkPlace.SafeContains("ИОГУНБ")) { continue; } int age = reader.Age; int visits = reader.Visits.Count(v => v.IsVisit); if (reader.Gender.SameString("ж")) { FemaleCount++; FemaleAge.Increment(age); FemaleVisits.Augment(age, visits); } else { MaleCount++; MaleAge.Increment(age); MaleVisits.Augment(age, visits); } } } Console.WriteLine("Отключились"); Console.WriteLine(";Муж;Жен;М пос;Ж пос"); Console.WriteLine ( "Всего;{0};{1};{2};{3}", MaleCount, FemaleCount, MaleVisits.Total, FemaleVisits.Total ); for (int age = 12; age < 100; age++) { Console.WriteLine ( "{0};{1};{2};{3};{4}", age, MaleAge.GetValue(age), FemaleAge.GetValue(age), MaleVisits.GetValue(age), FemaleVisits.GetValue(age) ); } } catch (Exception exception) { Console.WriteLine(exception); } }
private void LoadReaders() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); WriteLine("Начало загрузки читателей"); IEnumerable <MarcRecord> records = BatchRecordReader.WholeDatabase ( Connection, Connection.Database, 1000 ); BatchRecordReader batch = records as BatchRecordReader; if (!ReferenceEquals(batch, null)) { batch.BatchRead += Batch_BatchRead; } records.ProcessData(ParseAndAddReader); Readers.CompleteAdding(); WriteDelimiter(); WriteLine("Распределение читателей"); string[] keys = ReadersByStatus.Keys; foreach (string key in keys) { WriteLine ( "Статус {0}: {1} читателей", key, ReadersByStatus[key].Length ); } WriteDelimiter(); DateTime today = DateTime.Today; _debtorManager = new DebtorManager(Connection) { FromDate = today.AddYears(-1), ToDate = today.AddMonths(-1) }; _debtorManager.SetupDates(); ReadersByStatus["0"].ProcessData(AnalyzeCandidate); Debtors.CompleteAdding(); WriteLine ( "Кандидатов в должники: {0}", Debtors.Count ); WriteLine("Окончание загрузки читателей"); stopwatch.Stop(); WriteLine ( "Загрузка заняла: {0}", stopwatch.Elapsed.ToAutoString() ); WriteLine("Загружено: {0}", Readers.Count); WriteDelimiter(); }
static void Main(string[] args) { if (args.Length != 2) { return; } _irbisConnectionString = args[0]; _sqlConnectionString = args[1]; try { _stopwatch = new Stopwatch(); _stopwatch.Start(); Sql2000DataProvider dataProvider = new Sql2000DataProvider(); using (_irbisConnection = new IrbisConnection(_irbisConnectionString)) using (_database = new DbManager(dataProvider, _sqlConnectionString)) { Console.WriteLine ( "Started at: {0}", DateTime.Now.ToLongUniformString() ); int maxMfn = _irbisConnection.GetMaxMfn(); Console.WriteLine("Max MFN={0}", maxMfn); _database .SetCommand("delete from [dbo].[irbisdata]") .ExecuteNonQuery(); Console.WriteLine("table truncated"); BatchRecordReader batch = (BatchRecordReader)BatchRecordReader.WholeDatabase ( _irbisConnection, _irbisConnection.Database, 500 ); foreach (MarcRecord record in batch) { try { ProcessRecord(record); } catch (Exception exception) { Console.WriteLine("Exception: {0}", exception.Message); Debug.WriteLine(exception); } } _database .SetCommand("EXECUTE [upload_done]") .ExecuteNonQuery(); _database .SetCommand("insert into [FlagTable] default values") .ExecuteNonQuery(); _stopwatch.Stop(); TimeSpan elapsed = _stopwatch.Elapsed; Console.WriteLine ( "Elapsed: {0}", elapsed.ToAutoString() ); } } catch (Exception exception) { Console.WriteLine(exception); } }