public async Task <WatchResponse> WatchAsync(WatcherParameter parameter) { using (var ping = new Ping()) { var reply = await ping.SendPingAsync(parameter.Values["Address"]); return(new WatchResponse { Successful = reply.Status == IPStatus.Success ? true : false, ShortMessage = reply.Status == IPStatus.Success ? "Successful ping" : "Failed ping" }); } }
public async Task <WatchResponse> WatchAsync(WatcherParameter parameter) { var response = new WatchResponse(); using (var connection = new NpgsqlConnection(parameter.Values["ConnectionString"])) { try { await connection.OpenAsync(); response.Successful = true; } catch (Exception ex) { response.ShortMessage = ex.Message; response.FullMessage = ex.ToString(); } } return(response); }
public async Task <WatchResponse> WatchAsync(WatcherParameter parameter) { var response = new WatchResponse(); try { using (var httpClient = new HttpClient()) { await httpClient.GetAsync(parameter.Values["Url"]); response.Successful = true; } } catch (Exception ex) { response.ShortMessage = ex.Message; response.FullMessage = ex.ToString(); } return(response); }