Exemple #1
0
        public bool Activate(IActivityMonitor activityMonitor)
        {
            activityMonitor.Info($"Initializing Tcp handler (Host = {_configuration.Host}, Port = {_configuration.Port}).");

            if (_controlChannelClient == null)
            {
                _controlChannelClient = new ControlChannelClient
                                        (
                    _configuration.Host,
                    _configuration.Port,
                    _configuration.BuildAuthData(),
                    _configuration.IsSecure,
                    _configuration.RemoteCertificateValidationCallback,
                    _configuration.LocalCertificateSelectionCallback,
                    _configuration.ConnectionRetryDelayMs
                                        );
            }

            _controlChannelClient.OpenAsync(activityMonitor).GetAwaiter().GetResult();

            return(true);
        }
Exemple #2
0
        public AlertService(IOptions <TcpControlChannelConfiguration> tcpConfiguration, IOptions <DatabaseConfiguration> databaseConfiguration)
        {
            _tcpConfiguration         = tcpConfiguration.Value;
            _tcpConfiguration.AppName = typeof(AlertService).Assembly.GetName().Name;
            _tcpConfiguration.PresentEnvironmentVariables          = true;
            _tcpConfiguration.PresentMonitoringAssemblyInformation = true;
            _tcpConfiguration.HandleSystemActivityMonitorErrors    = false;

            _controlChannelClient = new ControlChannelClient(
                _tcpConfiguration.Host,
                _tcpConfiguration.Port,
                _tcpConfiguration.BuildAuthData(),
                _tcpConfiguration.IsSecure
                );

            _controlChannelClient.OpenAsync().GetAwaiter().GetResult();

            _memoryStream = new MemoryStream();
            _formatter    = new BinaryFormatter();

            _databaseConfiguration = databaseConfiguration.Value;
            _alertTableMock        = new AlertTableMock(_databaseConfiguration.Path.GetPathWithSpecialFolders());
        }