Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1 ||
                args.Length > 2)
            {
                Console.WriteLine
                (
                    "Usage: ReaderKiller <readerList>"
                );

                return;
            }

            string fileName = args[0];

            doDelete = ConfigurationUtility.GetBoolean
                       (
                "delete",
                false
                       );
            databases = ConfigurationUtility.GetString
                        (
                "databases",
                null
                        )
                        .ThrowIfNull("Databases not specified")
                        .Split
                        (
                new[] { ';', ',', ' ' },
                StringSplitOptions.RemoveEmptyEntries
                        );
            if (databases.Length == 0)
            {
                throw new Exception("Empty database list");
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                string connectionString = args.Length > 1
                    ? args[2]
                    : CM.AppSettings["connectionString"];

                string[] tickets = File.ReadAllLines
                                   (
                    fileName,
                    Encoding.UTF8
                                   );
                Console.WriteLine
                (
                    "Tickets loaded: {0}",
                    tickets.Length
                );

                using (connection = new IrbisConnection())
                {
                    connection.SetRetry(10, ExceptionResolver);

                    connection.ParseConnectionString
                    (
                        connectionString
                    );
                    connection.Connect();

                    Console.WriteLine("Connected");

                    for (int i = 0; i < tickets.Length; i++)
                    {
                        string ticket = tickets[i];
                        ProcessReader(i, ticket);
                    }
                }

                Console.WriteLine("Disconnected");

                stopwatch.Stop();
                Console.WriteLine
                (
                    "Time elapsed: {0}",
                    stopwatch.Elapsed.ToAutoString()
                );
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }