public MainViewModel() { try { _business = ServiceLocator.Current.GetInstance <IBusiness>(); _mailService = ServiceLocator.Current.GetInstance <IMailService>(); _monitorService = ServiceLocator.Current.GetInstance <IMonitorService>(); _watchdogService = ServiceLocator.Current.GetInstance <IWatchdogService>(); _faxService = ServiceLocator.Current.GetInstance <IFaxService>(); if (_faxService != null) { _faxService.EinsatzCreated += (sender, e) => DispatcherHelper.CheckBeginInvokeOnUI(() => { faxService_EinsatzCreated(sender, e); }); } _decoderService = ServiceLocator.Current.GetInstance <IDecoderService>(); if (_decoderService != null) { _decoderService.StatusChanged += (sender, e) => DispatcherHelper.CheckBeginInvokeOnUI(() => { switch (e.Number) { case 1: DecoderStatus1 = Settings.Default.Decoder1_Mode + (Settings.Default.Decoder1_Mode == DecoderMode.OFF ? "" : $"[{e.Status}]"); break; case 2: DecoderStatus2 = Settings.Default.Decoder2_Mode + (Settings.Default.Decoder2_Mode == DecoderMode.OFF ? "" : $"[{e.Status}]"); break; } }); } #if DEBUG IsAdminMode = true; #endif } catch (Exception ex) { Logger.WriteError(MethodBase.GetCurrentMethod(), ex); } }
public OrderbookAggregatorService(ISettingsService settingsService, IRabbitMqService rabbitMqService, ISystem system, IReloadingManager <MarginTradingOrderbookAggregatorSettings> settings, IAlertService alertService, IBestPricesService bestPricesService, IWatchdogService watchdogService, IOrderbooksStatusService orderbooksStatusService) { _settingsService = settingsService; _system = system; _alertService = alertService; _bestPricesService = bestPricesService; _watchdogService = watchdogService; _orderbooksStatusService = orderbooksStatusService; _messageProducer = CreateRabbitMqMessageProducer(settings, rabbitMqService); }
/// <summary> /// HealthCheckOperations constructor. /// </summary> /// <param name="svc">Reference to WatchdogService stateless service instance.</param> /// <param name="telemetry">Reference to the WatchdogService ReportMetrics instance.</param> /// <param name="interval">TimeSpan of the reporting interval.</param> /// <param name="token">CancellationToken instance.</param> /// <param name="timeout">Default fabric operation timeout value.</param> public HealthCheckOperations( IWatchdogService svc, IWatchdogTelemetry telemetry, TimeSpan interval, CancellationToken token, TimeSpan timeout = default(TimeSpan)) { if (null == svc) { throw new ArgumentNullException("Argument 'svc' is null."); } if (null == telemetry) { throw new ArgumentNullException("Argument 'telemetry' is null."); } ServiceEventSource.Current.ServiceMessage(svc.Context, "HealthCheckOperations.Constructor"); this._token = token; this._service = svc; this._timeout = (default(TimeSpan) == timeout) ? TimeSpan.FromSeconds(5) : timeout; this._telemetry = telemetry; this._http = new HttpClient(); // Create a timer that calls the local method every 30 seconds starting 1 minute from now. this._healthCheckTimer = new Timer( async(o) => { try { await this.EnumerateHealthChecksAsync(); } catch (Exception ex) { this._healthState = HealthState.Error; ServiceEventSource.Current.ServiceMessage(this._service.Context, "Exception {0} in {1}", ex.Message, "HealthCheckTimer method"); } }, this._token, interval, interval.Add(TimeSpan.FromSeconds(30))); }