示例#1
0
        private static async Task ProcessItem(QueueItem item)
        {
            try
            {
                var url           = $"http://localhost:5007/api/values/{item.Id}";
                var stringContent = item.Value == null ? null : new StringContent("\"" + item.Value + "\"", Encoding.UTF8, "application/json");
                HttpResponseMessage response;


                switch (item.Verb)
                {
                case Verb.Get:
                    response = await http.GetAsync(url);

                    break;

                case Verb.Create:
                    response = await http.PostAsync(url, stringContent);

                    break;

                case Verb.AddOrUpdate:
                    response = await http.PutAsync(url, stringContent);

                    break;

                default:
                    throw new NotImplementedException();
                }

                response.EnsureSuccessStatusCode();

                var responseValue = await response.Content.ReadAsStringAsync();
            }
            catch (Exception e)
            {
                logger.Warning.Write(FormattedMessageBuilder.Formatted("Ignoring exception and continuing."), e);
            }
        }
示例#2
0
 public static void HelloWorld()
 {
     LogSource.Get().Debug.Write(FormattedMessageBuilder.Formatted("It seems logging is enabled."));
 }