Beispiel #1
0
        public static void Start()
        {
            IConfigurationRoot configuration;
            IHost webHost;
            bool  bMQTTTLS;

            Logging.WriteDebugLog("Service.Start() Build Date: {0}", Properties.Resources.BuildDate);

            try
            {
                configuration = new ConfigurationBuilder().AddJsonFile(_strConfigFile, false, true).Build();
            }
            catch (Exception eException)
            {
                Logging.WriteDebugLogError("Service.Start()", eException, "Unable to build configuration instance.");
                return;
            }

            bool.TryParse(configuration["RegisterZoneTemperatures"] ?? "false", out _bRegisterZoneTemperatures);
            bool.TryParse(configuration["ForwardToOriginalWebService"] ?? "false", out _bForwardToOriginalWebService);
            bool.TryParse(configuration["MQTTTLS"] ?? "false", out bMQTTTLS);

            Logging.WriteDebugLog("Service.Start() RegisterZoneTemperatures: {0}", _bRegisterZoneTemperatures);
            Logging.WriteDebugLog("Service.Start() ForwardToOriginalWebService: {0}", _bForwardToOriginalWebService);
            Logging.WriteDebugLog("Service.Start() MQTT TLS: {0}", bMQTTTLS);

            MQTT.StartMQTT(configuration["MQTTBroker"] ?? "core-mosquitto", bMQTTTLS, _strServiceName, configuration["MQTTUser"] ?? "", configuration["MQTTPassword"] ?? "", MQTTProcessor);

            AirConditioner.Configure(configuration);

            MQTTRegister();

            try
            {
                webHost = Host.CreateDefaultBuilder().ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup <ASPNETCoreStartup>().UseConfiguration(configuration).UseUrls($"http://*:80/");
                }).Build();
            }
            catch (Exception eException)
            {
                Logging.WriteDebugLogError("Service.Start()", eException, "Unable to build Kestrel instance.");
                return;
            }

            webHost.Run();
        }
Beispiel #2
0
        public static void Start()
        {
            IConfigurationRoot configuration;
            IWebHost           webHost;

            Logging.WriteDebugLog("Service.Start()");

            try
            {
                configuration = new ConfigurationBuilder().AddJsonFile(_strConfigFile, false, true).Build();
            }
            catch (Exception eException)
            {
                Logging.WriteDebugLogError("Service.Start()", eException, "Unable to build configuration instance.");
                return;
            }

            bool.TryParse(configuration["RegisterZoneTemperatures"] ?? "false", out _bRegisterZoneTemperatures);

            Logging.WriteDebugLog("Service.Start() RegisterZoneTemperatures: {0}", _bRegisterZoneTemperatures);

            MQTT.StartMQTT(configuration["MQTTBroker"] ?? "core-mosquitto", _strServiceName, configuration["MQTTUser"] ?? "", configuration["MQTTPassword"] ?? "", MQTTProcessor);

            AirConditioner.Configure(configuration);

            MQTTRegister();

            try
            {
                webHost = new WebHostBuilder().UseKestrel().UseStartup <ASPNETCoreStartup>().UseConfiguration(configuration).UseUrls($"http://*:80/").Build();
            }
            catch (Exception eException)
            {
                Logging.WriteDebugLogError("Service.Start()", eException, "Unable to build Kestrel instance.");
                return;
            }

            webHost.Run();
        }