private async Task StartUpdater(string appUpdatePath) { try { Log.Information($"Update starting"); var rand = new Random(); var nextServer = rand.Next(0, ClientConstants.LoadBalancerServers.Length); var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); path = Path.Combine(path, "..\\Update.exe"); var suffix = _environment.GetClientId(); if (!string.IsNullOrEmpty(_domain)) { suffix += "." + _domain; } if (!string.IsNullOrEmpty(appUpdatePath)) { suffix += "." + appUpdatePath; } string root = $"https://{ClientConstants.LoadBalancerServers[nextServer]}:{ClientConstants.LoadBalancerServerPort}{ClientConstants.LoadBalancerFilesFolder}"; string pp = $"{root}/{ClientConstants.LoadBalancerFiles_Versions}/{suffix}"; Log.Information($"Update starting({pp}, {path})"); if (File.Exists(path)) { Process.Start(path, $"--update={pp}"); } else { Log.Warning($"Path '{path}' does not exist"); } } catch (Exception e) { Log.Error(e, "Start updater failed"); } try { if (_localSettingsService.Settings.RemovePreviousVersion < 3) { Log.Information($"Deinstalling prev Generation"); await _localSettingsService.ChangeSettingsUnconditionally(s => s.RemovePreviousVersion++); DeInstallPrevGeneration(); } } catch (Exception e) { Log.Error(e, "Start DeInstallPrevGeneration failed"); } }
public MainSettingsModel(LocalSettingsService localSettings, CoreData coreData, StreamSettingsModel streamSettings, ConnectionService connectionService, TranscodingModel transcoding) { CoreData = coreData; StreamSettings = streamSettings; Transcoding = transcoding; _connectionService = connectionService; AutoLogon.SilentValue = localSettings.Settings.AutoLogon; // TODO: what is is not registred and not save password AutoLogon.OnChange = async(o, n) => await localSettings.ChangeSettingsUnconditionally(s => s.AutoLogon = n); CurrentStreamingToCloudBehavior.Value = StreamingToCloudBehaviors.First(s => s.Value == default); CurrentEncoderType.Value = EncoderTypes.First(s => s.Value == default); CurrentEncoderQuality.Value = EncoderQualities.First(s => s.Value == default); CurrentTopMostMode.Value = TopMostModes.First(s => s.Value == TopMostMode.WhenCompact); CurrentVpnBehavior.Value = VpnBehaviors.First(s => s.Value == default); CurrentRendererType.Value = RendererTypes.First(s => s.Value == default); CurrentBlenderType.Value = BlenderTypes.First(s => s.Value == default); CurrentRecordingFormat.Value = RecordingFormats.First(s => s.Value == default); CurrentStreamingToCloudBehavior.OnChange = (o, n) => coreData.Settings.StreamingToCloud = n.Value; CurrentEncoderType.OnChange = (o, n) => coreData.Settings.EncoderType = n.Value; CurrentEncoderQuality.OnChange = (o, n) => coreData.Settings.EncoderQuality = n.Value; CurrentTopMostMode.OnChange = (o, n) => { coreData.ThisDevice.DeviceSettings.DisableTopMost = TopMostModeConverter.GetDisableTopMost(n.Value); coreData.ThisDevice.DeviceSettings.TopMostExtendedMode = TopMostModeConverter.GetTopMostExtendedMode(n.Value); }; CurrentRecordingFormat.OnChange = (o, n) => coreData.Settings.RecordingFormat = n.Value; CurrentVpnBehavior.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.VpnBehavior = n.Value; CurrentRendererType.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.RendererType = n.Value; CurrentBlenderType.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.BlenderType = n.Value; HardwareAdapter.OnChange = (o, n) => coreData.ThisDevice.DeviceSettings.RendererAdapter = n; PreferNalHdr.OnChange = (o, n) => coreData.Settings.PreferNalHdr = n; EnableQsvNv12Optimization.OnChange = (o, n) => coreData.Settings.DisableQsvNv12Optimization = !n; CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.StreamingToCloud, (s, c, p) => CurrentStreamingToCloudBehavior.SilentValue = StreamingToCloudBehaviors.FirstOrDefault(r => r.Value == CoreData.Settings.StreamingToCloud)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderType, (s, c, p) => CurrentEncoderType.SilentValue = EncoderTypes.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderType)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderQuality, (s, c, p) => CurrentEncoderQuality.SilentValue = EncoderQualities.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderQuality)); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.PreferNalHdr, (s, c, p) => PreferNalHdr.SilentValue = CoreData.Settings.PreferNalHdr); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.DisableQsvNv12Optimization, (s, c, p) => EnableQsvNv12Optimization.SilentValue = !CoreData.Settings.DisableQsvNv12Optimization); CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.RecordingFormat, (s, c, p) => CurrentRecordingFormat.SilentValue = RecordingFormats.FirstOrDefault(r => r.Value == CoreData.Settings.RecordingFormat)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.DisableTopMost, (s, c, p) => UpdateTopMost()); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.TopMostExtendedMode, (s, c, p) => UpdateTopMost()); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.VpnBehavior, (s, c, p) => CurrentVpnBehavior.SilentValue = VpnBehaviors.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.VpnBehavior)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererType, (s, c, p) => CurrentRendererType.SilentValue = RendererTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.RendererType)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.BlenderType, (s, c, p) => CurrentBlenderType.SilentValue = BlenderTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.BlenderType)); CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererAdapter, (s, c, p) => { if (HardwareAdapters != null) { HardwareAdapter.SilentValue = HardwareAdapters.Contains(CoreData.ThisDevice.DeviceSettings.RendererAdapter) ? CoreData.ThisDevice.DeviceSettings.RendererAdapter : HardwareAdapters.FirstOrDefault(); } }); }
private void ProcessNewVersion(ClientVersion[] upperVersions) { var(currentVersionInfo, currentVersionString) = ClientVersionHelper.GetCurrent(upperVersions); bool simulateUpdate = false; string custom = "4.5.0"; if (_localSettingsService.Settings.LastRunVerion != currentVersionString || simulateUpdate) { if ((_localSettingsService.Settings.NotFirstInstall || _localSettingsService.NoSettingsFileAtLoad == false) && string.IsNullOrEmpty(_appResources.AppData.Domain) || simulateUpdate) { string[] standard = string.IsNullOrWhiteSpace(currentVersionInfo?.WhatsNew) ? null : currentVersionInfo.WhatsNew.Split(';').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => "\u2022 " + s.Trim()).ToArray(); if (standard != null || currentVersionString == custom) { NewVersionModel newVersion = new NewVersionModel { WhatsNew = standard, Title = $"You are running new version {currentVersionString}", CustomView = !string.IsNullOrWhiteSpace(custom) }; if (DialogContent.Value == null) { DialogContent.Value = newVersion; IsDialogShown.Value = true; } } } TaskHelper.RunUnawaited(_localSettingsService.ChangeSettingsUnconditionally(s => { s.LastRunVerion = currentVersionString; s.NotFirstInstall = true; }), "Store LastRunVerion"); } }