public async Task <WatchResponse> WatchAsync(WatcherParameter parameter)
        {
            var value = await Task.Run(() =>
            {
                var response = new WatchResponse();

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

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

                        response.StackTrace = ex.StackTrace;
                    }
                }

                return(response);
            });

            return(value);
        }
        public async Task <WatchResponse> WatchAsync(WatcherParameter parameter)
        {
            var ping = new Ping();

            var reply = await ping.SendPingAsync(parameter.Values["Address"]);

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

            try
            {
                var restClient = new RestClient();

                await restClient.GetAsync(parameter.Values["Url"]);

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

            return(response);
        }