public static List <ExemplarInfo> GetExemplars ( [NotNull] string ksu ) { Code.NotNullNorEmpty(ksu, "ksu"); List <ExemplarInfo> result; using (IrbisConnection connection = GetIrbisConnection()) { ExemplarManager manager = new ExemplarManager(connection, Output) { Format = Format }; string expression = string.Format ( "\"{0}{1}\"", Prefix, ksu ); result = BatchRecordReader.Search ( connection, connection.Database, expression, 500 ) .SelectMany ( x => ExemplarInfo.Parse(x) ) .Where ( exemplar => exemplar.KsuNumber1.SameString(ksu) ) .Select ( exemplar => manager.Extend(exemplar, null) ) .ToList(); result.Sort(_ExemplarComparison); } return(result); }
static EffectiveStat ProcessKsu ( [NotNull] MenuEntry entry ) { Code.NotNull(entry, "entry"); string ksu = entry.Code.ThrowIfNull("entry.Code"); if (_outputBooks) { Console.WriteLine(); Console.WriteLine("КСУ {0} {1}", ksu, entry.Comment); Console.WriteLine(); } EffectiveStat result = new EffectiveStat { Description = string.Format ( _outputBooks ? "Итого по КСУ {0}" : "{0} {1}", ksu, entry.Comment ) }; string expression = string.Format("\"NKSU={0}\"", ksu); IEnumerable <MarcRecord> batch = BatchRecordReader.Search ( _connection, _connection.Database, expression, 500 ); foreach (MarcRecord record in batch) { EffectiveStat bookStat = ProcessBook(record, ksu); if (_outputBooks) { bookStat.Output(false); } result.Add(bookStat); } return(result); }
static int Main(string[] arguments) { try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string connectionString = CM.AppSettings["connectionString"]; if (string.IsNullOrEmpty(connectionString)) { Console.WriteLine("Connection string not specified"); return(1); } CommandLineParser parser = new CommandLineParser(); ParsedCommandLine parsed = parser.Parse(arguments); if (parsed.PositionalArguments.Count != 0) { connectionString = parsed.PositionalArguments[0]; } using (IrbisConnection connection = new IrbisConnection(connectionString)) { int maxMfn = connection.GetMaxMfn(); string expression = RequestPrefixes.Unfulfilled /* I=0 */ + " + " + RequestPrefixes.Reserved; /* I=2 */ if (parsed.HaveSwitch("expression")) { expression = parsed.GetSwitch("expression") .ThrowIfNull() .Value; } expression = expression.ThrowIfNull("expression"); Console.Write("Reading good records "); MarcRecord[] goodRecords = BatchRecordReader.Search ( connection, connection.Database, expression, 1000, batch => Console.Write(".") ) .ToArray(); Console.WriteLine(); Console.WriteLine ( "Good records loaded: {0}", goodRecords.Length ); if (goodRecords.Length == maxMfn) { Console.WriteLine("No truncation needed, exiting"); return(0); } connection.TruncateDatabase(connection.Database); Console.WriteLine("Database truncated"); using (BatchRecordWriter writer = new BatchRecordWriter ( connection, connection.Database, 500 )) { foreach (MarcRecord record in goodRecords) { record.Version = 0; record.Mfn = 0; writer.Append(record); } } Console.WriteLine("Good records restored"); stopwatch.Stop(); Console.WriteLine ( "Elapsed: {0}", stopwatch.Elapsed.ToAutoString() ); } } catch (Exception ex) { Console.WriteLine(ex); return(1); } return(0); }
static int Main(string[] arguments) { try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string connectionString = ConfigurationManager.AppSettings["connectionString"]; if (string.IsNullOrEmpty(connectionString)) { Console.WriteLine("Connection string not specified"); return(1); } CommandLineParser parser = new CommandLineParser(); ParsedCommandLine parsed = parser.Parse(arguments); if (parsed.PositionalArguments.Count != 0) { connectionString = parsed.PositionalArguments[0]; } string searchExpression = "V=01 + V=02"; string filterExpression = null; if (parsed.HaveSwitch("search")) { searchExpression = parsed.GetSwitch("search") .ThrowIfNull().Value; } searchExpression = searchExpression.ThrowIfNull(); if (parsed.HaveSwitch("filter")) { filterExpression = parsed.GetSwitch("filter") .ThrowIfNull().Value; } using (IrbisConnection connection = new IrbisConnection(connectionString)) { IEnumerable <MarcRecord> allRecords = BatchRecordReader.Search ( connection, connection.Database, searchExpression, 500, batch => Console.Write(".") ); } stopwatch.Stop(); Console.WriteLine ( "Elapsed: {0}", stopwatch.Elapsed.ToAutoString() ); } catch (Exception exception) { Console.WriteLine(exception); return(1); } return(0); }
static void Main() { Console.WriteLine(new string('=', 80)); Console.WriteLine("Start: {0}", DateTime.Now); deadline = DateTime.Today.AddDays(-1.0); try { string baseUri = CM.AppSettings["baseUri"]; string apiID = CM.AppSettings["apiID"]; string apiKey = CM.AppSettings["apiKey"]; string connectionString = CM.AppSettings["connectionString"]; string messageText = CM.AppSettings["message"]; client = new OsmiCardsClient ( baseUri, apiID, apiKey ); Console.WriteLine("PING:"); JObject ping = client.Ping(); Console.WriteLine(ping); string[] cards = client.GetCardList(); Console.Write("CARDS: {0}", cards.Length); List <string> recipients = new List <string>(); using (connection = new IrbisConnection(connectionString)) { IEnumerable <MarcRecord> batch = BatchRecordReader.Search ( connection, "RDR", "RB=$", 1000 ); foreach (MarcRecord record in batch) { ReaderInfo reader = ReaderInfo.Parse(record); string ticket = reader.Ticket; if (!ticket.OneOf(cards)) { continue; } VisitInfo[] outdated = reader.Visits .Where(v => !v.IsVisit) .Where(v => !v.IsReturned) .Where(v => v.DateExpected < deadline) .ToArray(); if (outdated.Length != 0) { Console.WriteLine ( "[{0}] {1}: {2} book(s)", reader.Ticket, reader.FullName, outdated.Length ); recipients.Add(reader.Ticket); } } } Console.WriteLine(); Console.WriteLine("Total recipient(s): {0}", recipients.Count); if (recipients.Count != 0) { client.SendPushMessage ( recipients.ToArray(), messageText ); Console.WriteLine("Send OK"); } Console.WriteLine("Finish: {0}", DateTime.Now); Console.WriteLine(new string('=', 80)); Console.WriteLine(); } catch (Exception exception) { Console.WriteLine(exception); } }
static void Main(string[] args) { string connectionString = ConnectionString; if (args.Length != 0) { connectionString = args[0]; } try { //IrbisEncoding.RelaxUtf8(); using (Connection = new IrbisConnection()) { Connection.ParseConnectionString(connectionString); Connection.Connect(); BatchRecordReader batch = (BatchRecordReader)BatchRecordReader.Search ( Connection, Connection.Database, //@"V=KN * G=201$", @"V=KN", 1000 ); batch.BatchRead += (sender, eventArgs) => { Console.Write("."); }; //BatchRecordReader batch = records as BatchRecordReader; //if (!ReferenceEquals(batch, null)) //{ // Console.WriteLine("Found: {0}", batch.TotalRecords); // batch.BatchRead += (sender, args) // => Console.WriteLine(batch.RecordsRead); //} foreach (MarcRecord record in batch) { ProcessRecord(record); } Console.WriteLine(); Pair <int, int>[] top = list.OrderByDescending ( pair => pair.Second ) .Take(100) .ToArray(); foreach (Pair <int, int> pair in top) { string description = EnhanceText ( Connection.FormatRecord ( "@sbrief", pair.First ) ); Console.WriteLine("{0}\t{1}", description, pair.Second); } } } catch (Exception exception) { Console.WriteLine(exception); } }