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 void Main() { try { _outputBooks = ConfigurationUtility.GetBoolean("books", false); string connectionString = IrbisConnectionUtility.GetStandardConnectionString(); using (_connection = new IrbisConnection(connectionString)) { _provider = new ConnectedClient(_connection); //_provider = new SemiConnectedClient(_connection); EffectiveReport.Instance = new EffectiveReport(_provider); MenuFile menu = MenuFile.ParseLocalFile("ksu.mnu"); EffectiveStat totalStat = new EffectiveStat { Description = "Всего по всем КСУ" }; bool first = true; foreach (MenuEntry entry in menu.Entries) { if (_outputBooks) { if (!first) { EffectiveReport.AddLine(string.Empty); } first = false; string title = string.Format ( "{0} {1}", entry.Code, entry.Comment ); EffectiveReport.BoldLine(title); } EffectiveStat ksuStat = ProcessKsu(entry); ksuStat.Output(false); totalStat.Add(ksuStat); } EffectiveReport.AddLine(string.Empty); totalStat.Output(false); } ExcelDriver driver = new ExcelDriver(); string fileName = "output.xlsx"; FileUtility.DeleteIfExists(fileName); driver.OutputFile = fileName; EffectiveReport report = EffectiveReport.Instance; report.Context.SetDriver(driver); report.Render(report.Context); } catch (Exception e) { Console.WriteLine(e); throw; } }