public async Task <WatchResponse> WatchAsync(WatcherParameter parameter)
        {
            using (var ping = new Ping())
            {
                var reply = await ping.SendPingAsync(parameter.Values["Address"]);

                return(new WatchResponse
                {
                    Success = reply.Status == IPStatus.Success ? true : false
                });
            }
        }
Example #2
0
        public async Task <WatchResponse> WatchAsync(WatcherParameter parameter)
        {
            var response = new WatchResponse();

            using (var connection = new SqlConnection(parameter.Values["ConnectionString"]))
            {
                try
                {
                    await connection.OpenAsync();

                    response.Success = true;
                }
                catch (Exception ex)
                {
                    response.Message    = ex.Message;
                    response.StackTrace = ex.ToString();
                }
            }

            return(response);
        }
Example #3
0
        public async Task <WatchResponse> WatchAsync(WatcherParameter parameter)
        {
            var response = new WatchResponse();

            try
            {
                using (var httpClient = new HttpClient())
                {
                    await httpClient.GetAsync(parameter.Values["Url"]);

                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Message    = ex.Message;
                response.StackTrace = ex.ToString();
            }

            return(response);
        }