Beispiel #1
0
        public AreaRegistryService(
            IComponentRegistryService componentService,
            IAutomationRegistryService automationService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService,
            IScriptingService scriptingService)
        {
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }

            _componentService  = componentService ?? throw new ArgumentNullException(nameof(componentService));
            _automationService = automationService ?? throw new ArgumentNullException(nameof(automationService));
            _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            apiService.ConfigurationRequested += HandleApiConfigurationRequest;

            systemInformationService.Set("Areas/Count", () => _areas.Count);

            scriptingService.RegisterScriptProxy(s => new AreaRegistryScriptProxy(this));
        }
Beispiel #2
0
        public AreaRegistryService(
            IComponentRegistryService componentService,
            IAutomationRegistryService automationService,
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            _componentService  = componentService ?? throw new ArgumentNullException(nameof(componentService));
            _automationService = automationService ?? throw new ArgumentNullException(nameof(automationService));
            _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Areas/Count", _areas.Count);
            };

            apiService.ConfigurationRequested += HandleApiConfigurationRequest;
        }
Beispiel #3
0
        public ComponentRegistryService(
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService,
            IScriptingService scriptingService,
            ILogService logService)
        {
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }

            _log             = logService.CreatePublisher(nameof(ComponentRegistryService));
            _apiService      = apiService ?? throw new ArgumentNullException(nameof(apiService));
            _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            apiService.StatusRequested += HandleApiStatusRequest;

            systemInformationService.Set("Components/Count", () => _components.Count);

            scriptingService.RegisterScriptProxy(s => new ComponentRegistryScriptProxy(this, s));
        }
Beispiel #4
0
        public NotificationService(
            IDateTimeService dateTimeService,
            IApiDispatcherService apiService,
            ISchedulerService schedulerService,
            ISettingsService settingsService,
            IStorageService storageService,
            IResourceService resourceService,
            ILogService logService)
        {
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (schedulerService == null)
            {
                throw new ArgumentNullException(nameof(schedulerService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }

            _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));
            _storageService  = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _resourceService = resourceService ?? throw new ArgumentNullException(nameof(resourceService));

            _log = logService.CreatePublisher(nameof(NotificationService));
            settingsService.CreateSettingsMonitor <NotificationServiceSettings>(s => Settings = s.NewSettings);

            apiService.StatusRequested += HandleApiStatusRequest;

            schedulerService.RegisterSchedule("NotificationCleanup", TimeSpan.FromMinutes(15), () => Cleanup());
        }
        public AutomationRegistryService(
            ISettingsService settingsService,
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService)
        {
            _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Automations/Count", _automations.Count);
            };

            apiService.StatusRequested += HandleApiStatusRequest;
        }
Beispiel #6
0
        public DaylightService(IDateTimeService dateTimeService, IApiDispatcherService apiService)
        {
            _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));

            apiService.StatusRequested += (s, e) =>
            {
                e.ApiContext.Result.Merge(JObject.FromObject(this));
            };
        }
Beispiel #7
0
        public StatusService(IComponentRegistryService componentRegistry, IApiDispatcherService apiService, ISettingsService settingsService)
        {
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            _componentRegistry = componentRegistry ?? throw new ArgumentNullException(nameof(componentRegistry));
            _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
        }
        public CloudConnectorService(IApiDispatcherService apiDispatcherService, ISettingsService settingsService, ILogService logService)
        {
            _log = logService?.CreatePublisher(nameof(CloudConnectorService)) ?? throw new ArgumentNullException(nameof(logService));
            _apiDispatcherService = apiDispatcherService ?? throw new ArgumentNullException(nameof(apiDispatcherService));

            _receiveRequestsUri = new Uri($"{BaseUri}/api/ControllerProxy/ReceiveRequests");
            _sendResponseUri    = new Uri($"{BaseUri}/api/ControllerProxy/SendResponse");

            _settings = settingsService?.GetSettings <CloudConnectorServiceSettings>() ?? throw new ArgumentNullException(nameof(settingsService));
        }
Beispiel #9
0
        public DaylightService(IDateTimeService dateTimeService, IApiDispatcherService apiService, IScriptingService scriptingService)
        {
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }
            _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));

            apiService.StatusRequested += (s, e) =>
            {
                e.ApiContext.Result.Merge(JObject.FromObject(this));
            };

            scriptingService.RegisterScriptProxy(s => new DaylightScriptProxy(this, dateTimeService));
        }
Beispiel #10
0
        public CloudConnectorService(IApiDispatcherService apiDispatcherService, ISettingsService settingsService, ISystemInformationService systemInformationService, ILogService logService)
        {
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            _log = logService?.CreatePublisher(nameof(CloudConnectorService)) ?? throw new ArgumentNullException(nameof(logService));
            _apiDispatcherService = apiDispatcherService ?? throw new ArgumentNullException(nameof(apiDispatcherService));

            _settings = settingsService?.GetSettings <CloudConnectorServiceSettings>() ?? throw new ArgumentNullException(nameof(settingsService));

            _receiveRequestsUri = $"{_settings.ServerAddress}/api/ControllerProxy/ReceiveRequests";
            _sendResponseUri    = $"{_settings.ServerAddress}/api/ControllerProxy/SendResponse";

            systemInformationService.Set("CloudConnector/IsConnected", () => _isConnected);
        }
        public ComponentRegistryService(
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService,
            ILogService logService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            _log = logService.CreatePublisher(nameof(ComponentRegistryService));

            _systemInformationService = systemInformationService ?? throw new ArgumentNullException(nameof(systemInformationService));
            _apiService      = apiService ?? throw new ArgumentNullException(nameof(apiService));
            _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            apiService.StatusRequested += HandleApiStatusRequest;
        }
Beispiel #12
0
        public AzureCloudService(IApiDispatcherService apiService, ISettingsService settingsService, ILogService logService)
        {
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (logService == null)
            {
                throw new ArgumentNullException(nameof(logService));
            }

            _apiService      = apiService;
            _settingsService = settingsService;
            _log             = logService.CreatePublisher(nameof(AzureCloudService));
        }
Beispiel #13
0
        public HttpServerService(IConfigurationService configurationService, IApiDispatcherService apiDispatcherService, ILogService logService)
        {
            if (configurationService == null)
            {
                throw new ArgumentNullException(nameof(configurationService));
            }
            if (apiDispatcherService == null)
            {
                throw new ArgumentNullException(nameof(apiDispatcherService));
            }
            _log = logService.CreatePublisher(nameof(HttpServerService)) ?? throw new ArgumentNullException(nameof(logService));

            _httpServer = new HttpServer(logService);

            _httpServer.HttpRequestReceived += OnHttpRequestReceived;
            _httpServer.WebSocketConnected  += AttachWebSocket;

            var configuration = configurationService.GetConfiguration <HttpServerServiceConfiguration>("HttpServerService");

            _httpServer.BindAsync(configuration.Port).GetAwaiter().GetResult();

            apiDispatcherService.RegisterAdapter(this);
        }
Beispiel #14
0
 public HttpServerService(IApiDispatcherService apiDispatcherService, HttpServer httpServer, ILogService logService)
 {
     _apiDispatcherService = apiDispatcherService ?? throw new ArgumentNullException(nameof(apiDispatcherService));
     _httpServer           = httpServer ?? throw new ArgumentNullException(nameof(httpServer));
     _log = logService.CreatePublisher(nameof(HttpServerService)) ?? throw new ArgumentNullException(nameof(logService));
 }