/// <summary>
        /// Initialize wrapper
        /// </summary>
        public static void Initialize()
        {
            _model = new MsSqlAuditorModel();
            _model.Initialize();

            _storage = _model.DefaultVaultProcessor.CurrentStorage;

            _serviceDataUpdateTimeout = _model.Settings.SystemSettings.ServiceDataUpdateTimeout;
            _serviceRunJobsTimeout    = _model.Settings.SystemSettings.ServiceRunJobsTimeout;
            _serviceStarted           = DateTime.Now;

            _scheduleJobProcessor    = new ScheduleJobProcessor(_storage);
            _connectionsManager      = new ConnectionsManager(_model);
            _scheduleSettingsManager = new ScheduleSettingsManager(_storage);

            _runningTasks          = new ConcurrentDictionary <string, string>();
            _databaseNodeInstances = new ConcurrentDictionary <long, NodeInstanceRow>();
            _serviceNodeInstances  = new ConcurrentDictionary <long, NodeInstanceRow>();

            _serviceSchedules  = new ConcurrentDictionary <long, ScheduleSettingsRow>();
            _databaseSchedules = new ConcurrentDictionary <long, ScheduleSettingsRow>();
            _connectionGroups  = new List <ConnectionGroupInfo>();

            LoadFromDB(true);
            log.DebugFormat(
                @"Active scheduled Instances:'{0}'  Active schedules: '{1}'",
                _serviceNodeInstances.Count,
                _serviceSchedules.Count
                );
        }
Пример #2
0
        static void Main(string[] args)
        {
            GlobalContext.Properties["LogFileName"] = CurrentAssembly.ProcessNameBase;
            log4net.Config.XmlConfigurator.Configure();

            log.Debug("Application is starting...");

            Options options = new Options();

            var result = Parser.Default.ParseArguments <Options>(args);

            log.Debug("Command line parameters have been processed.");

            switch (result.Tag)
            {
            case ParserResultType.Parsed:
                log.Debug("Command line options have been successfully parced.");
                break;

            case ParserResultType.NotParsed:
                log.Error("Error by processing command line options.");
                options.intPosX = -1;
                break;

            default:
                log.Error("Unknown status by processing command line options.");
                options.intPosX = -1;
                break;
            }

            if (AppVersionHelper.IsNotDebug())
            {
                AppDomain.CurrentDomain.UnhandledException += frmExceptionBox.CurrentDomainUnhandledException;
                Application.ThreadException += frmExceptionBox.ApplicationOnThreadException;
            }

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            TaskScheduler.UnobservedTaskException += OnUnobservedException;

            _fMain = new frmMain(
                options.intMonitor,
                options.intPosX,
                options.intPosY,
                options.intWidth,
                options.intHeight,
                options.isDisableStatusLine,
                options.isDisableMainMenu,
                options.strServerName,
                options.strTemplate,
                options.strDatabaseType,
                options.isDisableNavigationPanel
                );

            _model = new MsSqlAuditorModel();
            _fMain.SetModel(_model);

            _model.Initialize();
            _model.Settings.WarnAboutUnsignedQuery = args.All(a => a != "/!w");

            _webServer = new WebServerManager(_model);

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Model.Settings.InterfaceLanguage);

            log.Debug("Inner data model has been initialized. Main form is going to be shown...");

            Application.Run(_fMain);

            log.Debug("Application is closed...");
        }