Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            //Мигрируем настройки отчетов с offdc на fms
            var connectionString = "Database=usersettings;Data Source=sql2.analit.net;Port=3306;User Id=ReportsSystem;Password=samepass;pooling=false;default command timeout=0; Allow user variables=true;convert zero datetime=yes;";

            ActiveRecordInitialize.Init("release", typeof(Report).Assembly, typeof(ContactGroup).Assembly);
        }
Ejemplo n.º 2
0
        public static int Main(string[] args)
        {
            try {
                XmlConfigurator.Configure();
                GlobalContext.Properties["Version"]          = Assembly.GetExecutingAssembly().GetName().Version;
                ConnectionHelper.DefaultConnectionStringName = "production";
                ActiveRecordInitialize.Init("production", typeof(Job).Assembly);
                var config = new Config();
                ConfigReader.LoadSettings(config);

                var runner = new JobRunner();
                runner.Jobs.Add(new CalculatorJob(config));

                var cmd = args.FirstOrDefault();

                if (cmd.Match("uninstall"))
                {
                    CommandService.Uninstall();
                    return(0);
                }

                if (cmd.Match("install"))
                {
                    CommandService.Install();
                    return(0);
                }
                if (cmd.Match("console"))
                {
                    runner.Start();
                    if (Console.IsInputRedirected)
                    {
                        Console.WriteLine("Для завершения нажмите ctrl-c");
                        Console.CancelKeyPress += (e, a) => runner.Stop();
                        runner.Cancellation.WaitHandle.WaitOne();
                    }
                    else
                    {
                        Console.WriteLine("Для завершения нажмите любую клавишу");
                        Console.ReadLine();
                        runner.Stop();
                    }
                    runner.Join();
                    return(0);
                }

                ServiceBase.Run(new CommandService(runner));
                return(0);
            }
            catch (Exception e) {
                log.Error("Ошибка при запуске приложения", e);
                return(1);
            }
        }
Ejemplo n.º 3
0
        public static int Main(string[] args)
        {
            var appArgs = new AppArgs();

            try {
                XmlConfigurator.Configure();
                GlobalContext.Properties["Version"] = Assembly.GetExecutingAssembly().GetName().Version;

                if (Parse(args, appArgs))
                {
                    return(0);
                }

                ConnectionHelper.DefaultConnectionStringName = "local";
                if (!ActiveRecordStarter.IsInitialized)
                {
                    ActiveRecordInitialize.Init(ConnectionHelper.GetConnectionName(),
                                                typeof(ReportExecuteLog).Assembly, typeof(ContactGroup).Assembly);

                    HbmSerializer.Default.HbmAutoImport = false;
                    foreach (var cfg in ActiveRecordMediator.GetSessionFactoryHolder().GetAllConfigurations())
                    {
                        cfg.AddInputStream(HbmSerializer.Default.Serialize(Assembly.Load("Common.Models")));
                    }
                }
                GeneralReport.Factory = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof(ActiveRecordBase));

                if (appArgs.ReportId == -1)
                {
                    throw new Exception("Не указан код отчета для запуска в параметре gr.");
                }

                if (ProcessReport(appArgs.ReportId, appArgs.Manual, appArgs.Interval, appArgs.From, appArgs.To))
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            catch (Exception ex) {
                _log.Error($"Ошибка при запуске отчета {appArgs.ReportId}, параметры {String.Join("  ", Environment.GetCommandLineArgs())}", ex);
                Mailer.MailGlobalErr(ex);
                return(1);
            }
        }