public object GetValue(string SettingName) { try { object retValue = null; if (this.DefaultSettings.Settings.ContainsKey(SettingName)) { retValue = this.DefaultSettings.Settings[SettingName]; } foreach (var env in Environments.Values) { foreach (var HostToCheck in env.Host) { if ((Url.ToLower().isWildCardMatch(HostToCheck.ToLower())) || (HostName.ToLower().isWildCardMatch(HostToCheck.ToLower()))) { if (env.Settings.ContainsKey(SettingName)) { retValue = env.Settings[SettingName]; } break; } } } return(retValue); } catch (Exception) { return(null); } }
public void SetValue(string SettingName, object Val) { try { var isSet = false; foreach (var env in Environments.Values) { foreach (var HostToCheck in env.Host) { if ((Url.ToLower().isWildCardMatch(HostToCheck.ToLower())) || (HostName.ToLower().isWildCardMatch(HostToCheck.ToLower()))) { if (env.Settings.ContainsKey(SettingName)) { env.Settings[SettingName] = Val; } isSet = true; break; } } } if ((!isSet) && (this.DefaultSettings.Settings.ContainsKey(SettingName))) { this.DefaultSettings.Settings[SettingName] = Val; } } catch (Exception) { } }
private async Task CheckHost(HostToCheck host) { try { var result = await HttpRequestClient.GetRequestAsync(host.Url); string version = null; try { var model = result.DeserializeJson <AmIAliveModel>(); version = model?.Version; if (!string.IsNullOrEmpty(model?.Error)) { await SendNotification( SlackMonitorChannel, $":exclamation: {_appName} {_appVersion}: {host.ServiceName}: {model.Error}"); } } catch { // ignored //not all system support version yet } await _serviceMonitoringRepository.UpdateOrCreate( MonitoringRecord.Create(host.ServiceName, DateTime.UtcNow, version)); } catch (WebException ex) { using (var receiveStream = ex.Response.GetResponseStream()) { using (var sr = new StreamReader(receiveStream)) { var content = await sr.ReadToEndAsync(); await _log.WriteErrorAsync("CheckAllServices", "CheckHost", content, ex); } } } }