public bool Validate() { AppConfig appConfig = _provider.FindAppConfig(); if (appConfig.MaxDaysAgo <= 0) { return(false); } if (appConfig.BackupDirectory == null || appConfig.BackupDirectory == "") { return(false); } if (string.IsNullOrEmpty(appConfig.AccessCode)) { return(false); } if (string.IsNullOrEmpty(appConfig.SlackChannel)) { return(false); } if (string.IsNullOrEmpty(appConfig.Environment)) { return(false); } if (string.IsNullOrEmpty(appConfig.FileSystemLoggingDirectory)) { return(false); } if (string.IsNullOrEmpty(appConfig.WebhookCode)) { return(false); } return(true); }
public async Task Send(string message) { string webhookCode = _appConfig.FindAppConfig().WebhookCode; RestClient client = new RestClient("https://hooks.slack.com/"); RestRequest request = new RestRequest($"services/{webhookCode}", Method.POST) { RequestFormat = DataFormat.Json }; string value = JsonSerializer.Serialize(new { text = message }); request.AddParameter("application/json", value, ParameterType.RequestBody); IRestResponse restResponse = await client.ExecuteAsync(request, Method.POST); }
public string GetDirectory() { //GetAppConfig appConfig = new GetAppConfig(); return(_appConfigProvider.FindAppConfig().FileSystemLoggingDirectory); }