/// <summary> /// Initializes a new instance of the <see cref="SettingsViewModel"/> class. /// </summary> internal SettingsViewModel() { this.GetFolderCommand = new RelayCommand(this.OnGetFolder); var settings = BrowserSettingsHelper.Load(); if (settings != null) { this.BrowserSettings = settings; } var outputFolder = this.BrowserSettings.OutputFolder; this.OutputFolder = string.IsNullOrEmpty(outputFolder) || !Directory.Exists(outputFolder) ? AppEnvironment.UserVideoFolder : outputFolder; }
internal override async Task <bool> OnPreUpdate(SafeDictionary <string, object> keys) { ReportProgress("Identifying..."); int tries = 0; while (await TerminalIdentificationManager.GetIdentificationInfoAsync() == null && tries < 10) { tries++; await TerminalIdentificationManager.IdentifyAsync(); if (await TerminalIdentificationManager.GetIdentificationInfoAsync() == null) { await Task.Delay(30000); } } if (await TerminalIdentificationManager.GetIdentificationInfoAsync() == null) { App.ShutdownSafe(); return(false); } keys["server"] = _server = (await PanaceaRegistry.GetServerInformation(false)).ManagementServer; if (string.IsNullOrEmpty(_server)) { ReportProgress("Please add a terminal server in registry..."); await Task.Delay(4000); App.ShutdownSafe(); return(false); } //we can allow a failure to access TS if HS server is stored locally BrowserSettingsHelper.UpdateSettings(new[] { "WebBrowser.SubProcess.exe", "Panacea.exe" }); ServerResponse <GetHospitalServersResponse> getHospitalServerResponse = null; try { getHospitalServerResponse = await ServerRequestHelper.GetObjectFromServerAsync <GetHospitalServersResponse>(_server, "get_hospital_servers/"); } catch { getHospitalServerResponse = (await PanaceaRegistry.GetServerInformation(false)).ManagementServerResponse; } if (getHospitalServerResponse == null) { throw new Exception("Terminal Server unreachable and no information stored in registry..."); } if (!getHospitalServerResponse.Success) { if (getHospitalServerResponse.Error != "self destruct") { ReportProgress(getHospitalServerResponse.Error); await Task.Delay(4000); ProcessHelper.StartRegistrator(_server); App.ShutdownSafe(); return(false); } var path = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\..\\"); foreach (var directory in Directory.GetDirectories(path)) { try { if (!directory.EndsWith("\\Updater")) { Directory.Delete(directory, true); } } catch { // ignored } } foreach (var directory in Directory.GetFiles(path)) { try { File.Delete(directory); } catch { // ignored } } App.ShutdownSafe(); return(false); } if (!await UpdateRegistry(getHospitalServerResponse)) { return(false); } keys["hospitalserver"] = _hospitalServer = getHospitalServerResponse.Result.HospitalServers[0]; if (string.IsNullOrEmpty(getHospitalServerResponse.Result.Crutch)) { return(true); } _crutch = getHospitalServerResponse.Result.Crutch; ReportProgress("Waiting for traffic controller... Please wait..."); var req = BuildHttpRequest( new Uri(new Uri(_crutch), "api/" + Common.GetMacAddress() + "/requestAccessLock/") .ToString()); try { var resp = await req.GetHttpResponseAsync(120000); if (resp.StatusCode != HttpStatusCode.Conflict && resp.StatusCode != HttpStatusCode.OK) { throw new WebException("Not conflict"); } } catch (WebException) { ReportProgress("Traffic controller unreachable... Please wait..."); await Task.Delay(new Random().Next(10000, 60000)); App.Restart(); return(false); } return(true); }