Пример #1
0
        public async Task <HttpResponseMessage> PostServiceEnvironmentStatusLog(ServiceStatusLogRequest request)
        {
            var url = Url
                      .Controller("Administration")
                      .Action("ServiceEnvironmentStatusLog")
                      .ToString();

            return(await Client.PostAsync(url, ContentHelper.GetStringContent(request)));
        }
Пример #2
0
        public async Task ProcessAsync(ServiceWatchItem item)
        {
            while (true)
            {
                try
                {
                    Logger?.LogTrace("{0} - Watching '{1}' for '{2}' environment", DateTime.Now, item.ServiceName, item.Environment);

                    var watchResponse = await Watcher.WatchAsync(new WatcherParameter(item.ToDictionary()));

                    if (watchResponse.Success)
                    {
                        Logger?.LogInformation(" Success watch for '{0}' in '{1}' environment", item.ServiceName, item.Environment);
                    }
                    else
                    {
                        Logger?.LogError(" Failed watch for '{0}' in '{1}' environment", item.ServiceName, item.Environment);
                    }

                    var serviceStatusLog = new ServiceStatusLogRequest
                    {
                        ServiceID            = item.ServiceID,
                        ServiceEnvironmentID = item.ServiceEnvironmentID,
                        Target     = item.ServiceName,
                        ActionName = Watcher.ActionName,
                        Success    = watchResponse.Success,
                        Message    = watchResponse.Message,
                        StackTrace = watchResponse.StackTrace
                    };

                    try
                    {
                        await Client.PostServiceEnvironmentStatusLog(serviceStatusLog);
                    }
                    catch (Exception ex)
                    {
                        Logger?.LogCritical(" Error on saving watch response ({0}): '{1}'", item.ServiceName, ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    Logger?.LogCritical(" Error watching service: '{0}': '{1}'", item.ServiceName, ex.Message);
                }

                Thread.Sleep(item.Interval ?? AppSettings.DelayTime);
            }
        }