public static SiteNode GetFilledSiteNode(string rootUri, IHttpResponseProvider httpResponseProvider)
        {
            var rootNode = new SiteNode(rootUri);

            if (UriHelper.IsMediaFile(rootUri))
            {
                try
                {
                    rootNode.Media = httpResponseProvider.RequestLinkBytes(rootUri);
                    _performanceHelper.Increment(Counters.SuccessfullHttpRequests);
                }
                catch
                {
                    rootNode.Media = new byte[0];
                    _performanceHelper.Increment(Counters.FailedHttpRequests);
                }
            }
            else
            {
                try
                {
                    rootNode.Html = httpResponseProvider.RequestHttpLayout(rootUri);
                    _performanceHelper.Increment(Counters.SuccessfullHttpRequests);
                }
                catch
                {
                    rootNode.Html = string.Empty;
                    _performanceHelper.Increment(Counters.FailedHttpRequests);
                }
            }

            NLogger.Logger.Info($"{rootUri} has been handled.");

            return(rootNode);
        }
 private void btnCounterExample_Increase_Click(object sender, EventArgs e)
 {
     if (counterHelper.Increment(MultiInstance_PerformanceCounters.CounterExample) > 0)
     {
         this.btnCounterExample_Decrease.Enabled = true;
     }
 }
Exemple #3
0
 // GET: /Home/
 public async Task <ActionResult> Index()
 {
     logger.LogDebug("Enter to Home");
     counterHelper.Increment(Counters.GoHome);
     return(View(await _storeContext.Albums
                 .OrderByDescending(a => a.OrderDetails.Count())
                 .Take(6)
                 .ToListAsync()));
 }
        // GET: /Home/
        public async Task <ActionResult> Index()
        {
            _logger.Info("Home page started");

            CounterHelper.Increment(StoreCounters.GoToHome);

            return(View(await _storeContext.Albums
                        .OrderByDescending(a => a.OrderDetails.Count())
                        .Take(6)
                        .ToListAsync()));
        }
Exemple #5
0
        // GET: /ShoppingCart/AddToCart/5
        public async Task <ActionResult> AddToCart(int id)
        {
            var cart = ShoppingCart.GetCart(_storeContext, this);

            await cart.AddToCart(await _storeContext.Albums.SingleAsync(a => a.AlbumId == id));

            await _storeContext.SaveChangesAsync();

            throw new System.Exception();  //for test
            counterHelper.Increment(Counters.AddsToCart);

            return(RedirectToAction("Index"));
        }
        // GET: /Home/
        public async Task <ActionResult> Index()
        {
            _logger.Trace("Index method started");
            _counterHelper.Increment(Counters.VisitSite);

            try
            {
                return(View(await _storeContext.Albums
                            .OrderByDescending(a => a.OrderDetails.Count)
                            .Take(6)
                            .ToListAsync()));
            }
            catch (Exception e)
            {
                _logger.Error(e.Message);
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
 public void Increment(Counters counter)
 {
     CounterHelper.Increment(counter);
 }