diff --git a/OmniLinkBridge/App.config b/OmniLinkBridge/App.config index a826409..2a2d449 100644 --- a/OmniLinkBridge/App.config +++ b/OmniLinkBridge/App.config @@ -1,6 +1,6 @@ - + diff --git a/OmniLinkBridge/Notifications/EmailNotification.cs b/OmniLinkBridge/Notifications/EmailNotification.cs index 2ab7f70..9560262 100644 --- a/OmniLinkBridge/Notifications/EmailNotification.cs +++ b/OmniLinkBridge/Notifications/EmailNotification.cs @@ -26,23 +26,21 @@ namespace OmniLinkBridge.Notifications }; mail.To.Add(address); - using (SmtpClient smtp = new SmtpClient(Global.mail_server, Global.mail_port)) + using SmtpClient smtp = new SmtpClient(Global.mail_server, Global.mail_port); + smtp.EnableSsl = Global.mail_tls; + if (!string.IsNullOrEmpty(Global.mail_username)) { - smtp.EnableSsl = Global.mail_tls; - if (!string.IsNullOrEmpty(Global.mail_username)) - { - smtp.UseDefaultCredentials = false; - smtp.Credentials = new NetworkCredential(Global.mail_username, Global.mail_password); - } + smtp.UseDefaultCredentials = false; + smtp.Credentials = new NetworkCredential(Global.mail_username, Global.mail_password); + } - try - { - smtp.Send(mail); - } - catch (Exception ex) - { - log.Error(ex, "An error occurred sending email notification"); - } + try + { + smtp.Send(mail); + } + catch (Exception ex) + { + log.Error(ex, "An error occurred sending email notification"); } } } diff --git a/OmniLinkBridge/Notifications/ProwlNotification.cs b/OmniLinkBridge/Notifications/ProwlNotification.cs index df7dc1d..1d740d8 100644 --- a/OmniLinkBridge/Notifications/ProwlNotification.cs +++ b/OmniLinkBridge/Notifications/ProwlNotification.cs @@ -25,12 +25,10 @@ namespace OmniLinkBridge.Notifications "description=" + description }; - using (WebClient client = new WebClient()) - { - client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; - client.UploadStringAsync(URI, string.Join("&", parameters.ToArray())); - client.UploadStringCompleted += Client_UploadStringCompleted; - } + using WebClient client = new WebClient(); + client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; + client.UploadStringAsync(URI, string.Join("&", parameters.ToArray())); + client.UploadStringCompleted += Client_UploadStringCompleted; } } diff --git a/OmniLinkBridge/Notifications/PushoverNotification.cs b/OmniLinkBridge/Notifications/PushoverNotification.cs index 20c7fc3..a9aaec5 100644 --- a/OmniLinkBridge/Notifications/PushoverNotification.cs +++ b/OmniLinkBridge/Notifications/PushoverNotification.cs @@ -24,11 +24,9 @@ namespace OmniLinkBridge.Notifications { "message", description } }; - using (WebClient client = new WebClient()) - { - client.UploadValues(URI, parameters); - client.UploadStringCompleted += Client_UploadStringCompleted; - } + using WebClient client = new WebClient(); + client.UploadValues(URI, parameters); + client.UploadStringCompleted += Client_UploadStringCompleted; } } diff --git a/OmniLinkBridge/OmniLinkBridge.csproj b/OmniLinkBridge/OmniLinkBridge.csproj index b2796be..69bd256 100644 --- a/OmniLinkBridge/OmniLinkBridge.csproj +++ b/OmniLinkBridge/OmniLinkBridge.csproj @@ -10,7 +10,7 @@ Properties OmniLinkBridge OmniLinkBridge - v4.5.2 + v4.7.2 512 @@ -174,7 +174,7 @@ 4.5.0 - 3.0.17 + 3.1.1 13.0.1 @@ -189,7 +189,7 @@ 1.5.0 - 4.0.0 + 4.0.1 5.0.0 diff --git a/OmniLinkBridge/WebService/MappingExtensions.cs b/OmniLinkBridge/WebService/MappingExtensions.cs index d3b8c1a..021cd79 100644 --- a/OmniLinkBridge/WebService/MappingExtensions.cs +++ b/OmniLinkBridge/WebService/MappingExtensions.cs @@ -13,14 +13,15 @@ namespace OmniLinkBridge.WebAPI public static AreaContract ToContract(this clsArea area) { - AreaContract ret = new AreaContract(); - - ret.id = (ushort)area.Number; - ret.name = area.Name; - ret.burglary = area.AreaBurglaryAlarmText; - ret.co = area.AreaGasAlarmText; - ret.fire = area.AreaFireAlarmText; - ret.water = area.AreaWaterAlarmText; + AreaContract ret = new AreaContract + { + id = (ushort)area.Number, + name = area.Name, + burglary = area.AreaBurglaryAlarmText, + co = area.AreaGasAlarmText, + fire = area.AreaFireAlarmText, + water = area.AreaWaterAlarmText + }; if (area.ExitTimer > 0) { @@ -37,12 +38,13 @@ namespace OmniLinkBridge.WebAPI public static ZoneContract ToContract(this clsZone zone) { - ZoneContract ret = new ZoneContract(); - - ret.id = (ushort)zone.Number; - ret.zonetype = zone.ZoneType; - ret.name = zone.Name; - ret.status = zone.StatusText(); + ZoneContract ret = new ZoneContract + { + id = (ushort)zone.Number, + zonetype = zone.ZoneType, + name = zone.Name, + status = zone.StatusText() + }; if (zone.IsTemperatureZone()) ret.temp = zone.TempText(); @@ -54,10 +56,11 @@ namespace OmniLinkBridge.WebAPI public static UnitContract ToContract(this clsUnit unit) { - UnitContract ret = new UnitContract(); - - ret.id = (ushort)unit.Number; - ret.name = unit.Name; + UnitContract ret = new UnitContract + { + id = (ushort)unit.Number, + name = unit.Name + }; if (unit.Status > 100) ret.level = (ushort)(unit.Status - 100); @@ -71,17 +74,16 @@ namespace OmniLinkBridge.WebAPI public static ThermostatContract ToContract(this clsThermostat unit) { - ThermostatContract ret = new ThermostatContract(); + ThermostatContract ret = new ThermostatContract + { + id = (ushort)unit.Number, + name = unit.Name + }; - ret.id = (ushort)unit.Number; - ret.name = unit.Name; - - ushort temp, heat, cool, humidity; - - ushort.TryParse(unit.TempText(), out temp); - ushort.TryParse(unit.HeatSetpointText(), out heat); - ushort.TryParse(unit.CoolSetpointText(), out cool); - ushort.TryParse(unit.HumidityText(), out humidity); + ushort.TryParse(unit.TempText(), out ushort temp); + ushort.TryParse(unit.HeatSetpointText(), out ushort heat); + ushort.TryParse(unit.CoolSetpointText(), out ushort cool); + ushort.TryParse(unit.HumidityText(), out ushort humidity); ret.temp = temp; ret.humidity = humidity; diff --git a/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj b/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj index 795bf81..11f8a7d 100644 --- a/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj +++ b/OmniLinkBridgeTest/OmniLinkBridgeTest.csproj @@ -9,7 +9,7 @@ Properties OmniLinkBridgeTest OmniLinkBridgeTest - v4.5.2 + v4.7.2 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 @@ -59,10 +59,10 @@ - 2.2.7 + 2.2.8 - 2.2.7 + 2.2.8 diff --git a/README.md b/README.md index 1a4e169..b22a878 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ You can use docker to build an image from git or download the [binary here](http ## Requirements - [Docker](https://www.docker.com/) -- .NET Framework 4.5.2 (or Mono equivalent) +- .NET Framework 4.7.2 (or Mono equivalent) ## Operation OmniLink Bridge is divided into the following modules and configurable settings. Configuration settings can also be set as environment variables by using their name in uppercase. Refer to [OmniLinkBridge.ini](https://github.com/excaliburpartners/OmniLinkBridge/blob/master/OmniLinkBridge/OmniLinkBridge.ini) for specifics.