Esempio n. 1
0
        private void Form1Load(object sender, EventArgs e)
        {
            // create loggers
            _loggerRef = Reference <ILogger> .Create(new TextBoxLogger(txtMainLog));

            // create client factory and client
            _clientFactory = new CoreClientFactory(_loggerRef);
            _clientFactory.SetEnv(BuildConst.BuildEnv);
            _clientFactory.SetApplication(Assembly.GetExecutingAssembly());
            _client = _clientFactory.Create();
            // - form title
            WinFormHelper.SetAppFormTitle(this, EnvHelper.EnvName(BuildEnv));
            // setup the AlertRule view
            _alertRuleViewHelper = new AlertRuleViewHelper();
            _alertRuleDataHelper = new AlertRuleDataHelper();
            _alertRuleFilters    = new ComboxBoxFilterGroup(
                panelAlertRule, _alertRuleViewHelper, AlertRuleSelectionChanged);
            _alertRuleSelecter = new AlertRuleSelecter(
                _alertRuleFilters, _alertRuleViewHelper, _alertRuleDataHelper);
            _alertRuleView = new ListViewManager <AlertRule>(
                _loggerRef.Target, lvAlertRule, _alertRuleViewHelper,
                _alertRuleSelecter, _alertRuleFilters, new AlertRuleSorter(), _alertRuleDataHelper);

            ICoreCache alertRuleCache = _client.CreateCache(
                update => _alertRuleView.UpdateData(new ViewChangeNotification <AlertRule>
            {
                Change  = update.Change,
                OldData =
                    (AlertRule)update.OldItem?.Data,
                NewData =
                    (AlertRule)update.NewItem?.Data
            }), SynchronizationContext.Current);

            alertRuleCache.SubscribeNoWait <AlertRule>(Expr.ALL, null, null);
            // setup the AlertSignal view
            _alertSignalViewHelper = new AlertSignalViewHelper();
            _alertSignalDataHelper = new AlertSignalDataHelper();
            _alertSignalFilters    = new ComboxBoxFilterGroup(
                panelAlertSignal, _alertSignalViewHelper, AlertSignalSelectionChanged);
            _alertSignalSelecter = new AlertSignalSelecter(
                _alertSignalFilters, _alertSignalViewHelper, _alertSignalDataHelper);
            _alertSignalView = new ListViewManager <AlertSignal>(
                _loggerRef.Target, lvAlertSignal, _alertSignalViewHelper,
                _alertSignalSelecter, _alertSignalFilters, new AlertSignalSorter(), _alertSignalDataHelper);
            ICoreCache alertSignalCache = _client.CreateCache(
                update => _alertSignalView.UpdateData(new ViewChangeNotification <AlertSignal>
            {
                Change  = update.Change,
                OldData =
                    (AlertSignal)update.OldItem?.Data,
                NewData =
                    (AlertSignal)update.NewItem?.Data
            }), SynchronizationContext.Current);

            alertSignalCache.SubscribeNoWait <AlertSignal>(Expr.ALL, null, null);
            // setup the LogEvent view
            _logEventViewHelper = new LogEventViewHelper();
            _logEventDataHelper = new LogEventDataHelper();
            _logEventFilters    = new ComboxBoxFilterGroup(
                panelLogEvent, _logEventViewHelper, LogEventSelectionChanged);
            _logEventSelecter = new LogEventSelecter(
                _logEventFilters, _logEventViewHelper, _logEventDataHelper);
            _logEventView = new ListViewManager <DebugLogEvent>(
                _loggerRef.Target, lvLogEvent, _logEventViewHelper,
                _logEventSelecter, _logEventFilters, new LogEventSorter(), _logEventDataHelper);
            ICoreCache logEventCache = _client.CreateCache(
                update => _logEventView.UpdateData(new ViewChangeNotification <DebugLogEvent>
            {
                Change  = update.Change,
                OldData =
                    (DebugLogEvent)update.OldItem?.Data,
                NewData =
                    (DebugLogEvent)update.NewItem?.Data
            }), SynchronizationContext.Current);

            logEventCache.SubscribeNoWait <DebugLogEvent>(Expr.ALL, null, null);
            // init controls
            // server 0
            _serverAddress[0] = txtServer0Address;
            _ping[0]          = chkServer0Ping;
            _lastChecked[0]   = txtServer0LastChecked;
            _lastReplied[0]   = txtServer0LastReplied;
            _serverStatus[0]  = txtServer0Status;
            _serverReason[0]  = txtServer0OtherInfo;
            // server 1
            _serverAddress[1] = txtServer1Address;
            _ping[1]          = chkServer1Ping;
            _lastChecked[1]   = txtServer1LastChecked;
            _lastReplied[1]   = txtServer1LastReplied;
            _serverStatus[1]  = txtServer1Status;
            _serverReason[1]  = txtServer1OtherInfo;
            // server 2
            _serverAddress[2] = txtServer2Address;
            _ping[2]          = chkServer2Ping;
            _lastChecked[2]   = txtServer2LastChecked;
            _lastReplied[2]   = txtServer2LastReplied;
            _serverStatus[2]  = txtServer2Status;
            _serverReason[2]  = txtServer2OtherInfo;
            // server 3
            _serverAddress[3] = txtServer3Address;
            _ping[3]          = chkServer3Ping;
            _lastChecked[3]   = txtServer3LastChecked;
            _lastReplied[3]   = txtServer3LastReplied;
            _serverStatus[3]  = txtServer3Status;
            _serverReason[3]  = txtServer3OtherInfo;
            // server 4
            _serverAddress[4] = txtServer4Address;
            _ping[4]          = chkServer4Ping;
            _lastChecked[4]   = txtServer4LastChecked;
            _lastReplied[4]   = txtServer4LastReplied;
            _serverStatus[4]  = txtServer4Status;
            _serverReason[4]  = txtServer4OtherInfo;
            // server 5
            _serverAddress[5] = txtServer5Address;
            _ping[5]          = chkServer5Ping;
            _lastChecked[5]   = txtServer5LastChecked;
            _lastReplied[5]   = txtServer5LastReplied;
            _serverStatus[5]  = txtServer5Status;
            _serverReason[5]  = txtServer5OtherInfo;
            for (int i = 0; i < NServers; i++)
            {
                _lastChecked[i].BackColor  = Color.FromKnownColor(KnownColor.Window);
                _lastReplied[i].BackColor  = Color.FromKnownColor(KnownColor.Window);
                _serverStatus[i].BackColor = Color.FromKnownColor(KnownColor.Window);
                _serverReason[i].BackColor = Color.FromKnownColor(KnownColor.Window);
            }
        }