diff --git a/.vs/hass-workstation-service/v16/.suo b/.vs/hass-workstation-service/v16/.suo index 8d790af..e8ad257 100644 Binary files a/.vs/hass-workstation-service/v16/.suo and b/.vs/hass-workstation-service/v16/.suo differ diff --git a/README.md b/README.md index ffdee86..d5ba8a0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ It will try to futher accomplish this goal in the future by: - Being easy to configure - Using secure communication -## Deployments +## Installation -1. \ No newline at end of file +You can get the installer from [here](https://hassworkstationstorage.z6.web.core.windows.net/publish/setup.exe). When using the installer, the application checks for updates on startup. +Note: You'll get a Windows Smartscreen warning because the code was self signed. You can click "More info" and then "Run anyway" to proceed with installing. + +Alternatively, you can find releases on GitHub [here](https://github.com/sleevezipper/hass-workstation-service/releases). diff --git a/UserInterface/Program.cs b/UserInterface/Program.cs index bef6f96..c5040c9 100644 --- a/UserInterface/Program.cs +++ b/UserInterface/Program.cs @@ -6,7 +6,7 @@ using System; namespace UserInterface { - class Program + public class Program { // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized @@ -20,5 +20,6 @@ namespace UserInterface .UsePlatformDetect() .LogToDebug() .UseReactiveUI(); + } } diff --git a/UserInterface/Properties/PublishProfiles/FolderProfile.pubxml b/UserInterface/Properties/PublishProfiles/FolderProfile.pubxml index bac3ebc..6642b42 100644 --- a/UserInterface/Properties/PublishProfiles/FolderProfile.pubxml +++ b/UserInterface/Properties/PublishProfiles/FolderProfile.pubxml @@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Release Any CPU - bin\Release\netcoreapp3.1\publish\ + ..\hass-workstation-service\ FileSystem netcoreapp3.1 win-x64 diff --git a/UserInterface/Views/MainWindow.axaml.cs b/UserInterface/Views/MainWindow.axaml.cs index 55de57f..6c2592e 100644 --- a/UserInterface/Views/MainWindow.axaml.cs +++ b/UserInterface/Views/MainWindow.axaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using MangaReader.Avalonia.Platform.Win; namespace UserInterface.Views { @@ -12,6 +13,7 @@ namespace UserInterface.Views #if DEBUG this.AttachDevTools(); #endif + WindowsTrayIcon icon = new WindowsTrayIcon(); } private void InitializeComponent() diff --git a/hass-workstation-service/.gitignore b/hass-workstation-service/.gitignore index 2bbc24e..dcc03d4 100644 --- a/hass-workstation-service/.gitignore +++ b/hass-workstation-service/.gitignore @@ -22,4 +22,7 @@ obj/ # End of https://www.toptal.com/developers/gitignore/api/vscode,dotnetcore # ignore logs -logs/ \ No newline at end of file +logs/ + +# ignore debugging symbols +*.pdb \ No newline at end of file diff --git a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs index 2c3414e..97fff4a 100644 --- a/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs +++ b/hass-workstation-service/Communication/InterProcesCommunication/InterProcessApi.cs @@ -31,7 +31,7 @@ namespace hass_workstation_service.Communication.InterProcesCommunication /// /// You can use this to check if the application responds. - /// + /// /// /// public string Ping(string str) diff --git a/hass-workstation-service/Communication/MQTT/AutoDiscoveryConfigModel.cs b/hass-workstation-service/Communication/MQTT/AutoDiscoveryConfigModel.cs index 46a0a5a..4a9ae66 100644 --- a/hass-workstation-service/Communication/MQTT/AutoDiscoveryConfigModel.cs +++ b/hass-workstation-service/Communication/MQTT/AutoDiscoveryConfigModel.cs @@ -89,6 +89,9 @@ namespace hass_workstation_service.Communication public string Value_template { get; set; } } + /// + /// This information will be used when announcing this device on the mqtt topic + /// public class DeviceConfigModel { /// diff --git a/hass-workstation-service/Communication/MQTT/MqttPublisher.cs b/hass-workstation-service/Communication/MQTT/MqttPublisher.cs index 4ae21fb..87d2fa0 100644 --- a/hass-workstation-service/Communication/MQTT/MqttPublisher.cs +++ b/hass-workstation-service/Communication/MQTT/MqttPublisher.cs @@ -53,8 +53,16 @@ namespace hass_workstation_service.Communication var factory = new MqttFactory(); this._mqttClient = factory.CreateMqttClient(); - this._mqttClient.ConnectAsync(options); - + if (options != null) + { + this._mqttClient.ConnectAsync(options); + this._mqttClientMessage = "Connecting..."; + } + else + { + this._mqttClientMessage = "Not configured"; + } + this._mqttClient.UseConnectedHandler(e => { this._mqttClientMessage = "All good"; }); diff --git a/hass-workstation-service/Data/ConfigurationService.cs b/hass-workstation-service/Data/ConfigurationService.cs index df04c03..07dab17 100644 --- a/hass-workstation-service/Data/ConfigurationService.cs +++ b/hass-workstation-service/Data/ConfigurationService.cs @@ -78,12 +78,8 @@ namespace hass_workstation_service.Data } else { - //for now we return defaults until we can actually configure this - return new MqttClientOptionsBuilder() - .WithTcpServer("192.168.2.6") - // .WithTls() - .WithCredentials("tester", "tester") - .Build(); + Program.StartUI(); + return null; } } diff --git a/hass-workstation-service/Program.cs b/hass-workstation-service/Program.cs index 6178520..4d40bb3 100644 --- a/hass-workstation-service/Program.cs +++ b/hass-workstation-service/Program.cs @@ -31,29 +31,37 @@ namespace hass_workstation_service .WriteTo.Console() .WriteTo.File(new RenderedCompactJsonFormatter(), "logs/log.ndjson") .CreateLogger(); - - - try + // We do it this way because there is currently no way to pass an argument to a dotnet core app when using clickonce + if (Process.GetProcessesByName("hass-workstation-service").Count() > 1) //bg service running + { + StartUI(); + } + else { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + try { - await CreateHostBuilder(args).RunConsoleAsync(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + await CreateHostBuilder(args).RunConsoleAsync(); + } + else + { + // we only support MS Windows for now + throw new NotImplementedException("Your platform is not yet supported"); + } } - else + catch (Exception ex) { - // we only support MS Windows for now - throw new NotImplementedException("Your platform is not yet supported"); + Log.Fatal(ex, "Application start-up failed"); + } + finally + { + Log.CloseAndFlush(); } } - catch (Exception ex) - { - Log.Fatal(ex, "Application start-up failed"); - } - finally - { - Log.CloseAndFlush(); - } + + } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) @@ -87,5 +95,11 @@ namespace hass_workstation_service return "Debug"; } + + public static void StartUI() + { + Log.Logger.Information(Environment.CurrentDirectory + "\\UserInterface.exe"); + Process.Start(Environment.CurrentDirectory + "\\UserInterface.exe"); + } } } diff --git a/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml new file mode 100644 index 0000000..93ac6ec --- /dev/null +++ b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml @@ -0,0 +1,47 @@ + + + + + 15 + 1.0.0.* + True + Release + True + https://github.com/sleevezipper/hass-workstation-service/issues + True + true + Web + https://hassworkstationstorage.z6.web.core.windows.net/publish/ + True + True + 820B7EDF3E26E24BB4C25B177A05B3D0C77BF73A + hass-workstation-service_TemporaryKey.pfx + true + false + Any CPU + Hass Workstation Service + bin\publish\ + bin\publish\ + Sleevezipper + ClickOnce + False + False + win-x64 + False + sha256RSA + True + https://github.com/sleevezipper/hass-workstation-service/issues + netcoreapp3.1 + True + True + Foreground + + + + true + .NET Core Runtime 3.1.10 (x64) + + + \ No newline at end of file diff --git a/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml.user b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml.user new file mode 100644 index 0000000..a32fee2 --- /dev/null +++ b/hass-workstation-service/Properties/PublishProfiles/AzureHosted.pubxml.user @@ -0,0 +1,6 @@ + + + + diff --git a/hass-workstation-service/Properties/PublishProfiles/ClickOnceProfile.pubxml b/hass-workstation-service/Properties/PublishProfiles/ClickOnceProfile.pubxml index 9a49144..7744d22 100644 --- a/hass-workstation-service/Properties/PublishProfiles/ClickOnceProfile.pubxml +++ b/hass-workstation-service/Properties/PublishProfiles/ClickOnceProfile.pubxml @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 34 + 35 1.0.0.* True Release diff --git a/hass-workstation-service/UserInterface.exe b/hass-workstation-service/UserInterface.exe new file mode 100644 index 0000000..5352119 Binary files /dev/null and b/hass-workstation-service/UserInterface.exe differ diff --git a/hass-workstation-service/hass-workstation-service.csproj b/hass-workstation-service/hass-workstation-service.csproj index f61dee6..daa1c59 100644 --- a/hass-workstation-service/hass-workstation-service.csproj +++ b/hass-workstation-service/hass-workstation-service.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 dotnet-hass_workstation_service-C65C2EBE-1977-4C24-AC6B-6921877E1390 hass_workstation_service - Exe + WinExe Sleevezipper https://github.com/sleevezipper/hass-workstation-service false @@ -23,6 +23,17 @@ + + + + + + + + PreserveNewest + + + Never diff --git a/hass-workstation-service/hass-workstation-service.csproj.user b/hass-workstation-service/hass-workstation-service.csproj.user index 77a891c..958055e 100644 --- a/hass-workstation-service/hass-workstation-service.csproj.user +++ b/hass-workstation-service/hass-workstation-service.csproj.user @@ -1,7 +1,7 @@  - <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\hass-workstation-service\Properties\PublishProfiles\ClickOnceProfile.pubxml + <_LastSelectedProfileId>C:\Users\Maurits\Documents\Repo\hass-desktop-service\hass-workstation-service\Properties\PublishProfiles\AzureHosted.pubxml true \ No newline at end of file