Ejemplo n.º 1
0
        public ActionResult d3()
        {
            using (var context = new ElmahDashboardContext())
            {
                var model           = context.CountByTypeError();
                List <DataModel> ls = new List <DataModel>();
                var types           = context.ListTypes(14);
                foreach (var item in types)
                {
                    var line = model.Where(p => p.Type == item).OrderBy(p => p.Date).Select(p => new XY(1, p.Counts, p.Date)).ToList();
                    var dt   = new DataModel();
                    var i    = 0;
                    foreach (var _i in line)
                    {
                        line[i].x = i;
                        i++;
                    }
                    dt.key    = item;
                    dt.values = line;

                    ls.Add(dt);
                }
                var s = JsonConvert.SerializeObject(ls);
                ViewBag.chartData = s;
                return(View(ls));
            }

            //return View();
        }
Ejemplo n.º 2
0
 public ActionResult Items(int?offset, int?length, string application, string host, string source, string type, string search, int?truncValueLength)
 {
     using (var context = new ElmahDashboardContext())
     {
         var where = "([Application] LIKE @p0) AND ([Host] LIKE @p1) AND ([Source] LIKE @p2) AND ([Type] LIKE @p3) AND ([AllXml] LIKE @p4)";
         var parameters = new object[] { application.IfNullOrWhiteSpace("%"), host.IfNullOrWhiteSpace("%"), source.IfNullOrWhiteSpace("%"), type.IfNullOrWhiteSpace("%"), "%" + search + "%" };
         var orderBy    = (String)null;
         var model      = new ItemsModel();
         model.Items = context.ListErrors(offset ?? 0, length ?? 10, where, orderBy, false, parameters).ToArray();
         if (truncValueLength.HasValue)
         {
             foreach (var item in model.Items)
             {
                 if (item.Type != null && item.Type.Length > truncValueLength)
                 {
                     item.Type = item.Type.Substring(0, truncValueLength.Value) + "...";
                 }
                 if (item.Source != null && item.Source.Length > truncValueLength)
                 {
                     item.Source = item.Source.Substring(0, truncValueLength.Value) + "...";
                 }
                 if (item.Message != null && item.Message.Length > truncValueLength)
                 {
                     item.Message = item.Message.Substring(0, truncValueLength.Value) + "...";
                 }
             }
         }
         return(View("ItemsPart", model));
     }
 }
Ejemplo n.º 3
0
        public ActionResult AllXml(Guid id)
        {
            using (var context = new ElmahDashboardContext())
            {
                var item = context.GetError(id);

                Response.ContentType     = "text/xml";
                Response.ContentEncoding = Encoding.UTF8;
                return(Content(item.AllXml.ToString()));
            }
        }
Ejemplo n.º 4
0
        public ActionResult ItemDetails(Guid id)
        {
            using (var context = new ElmahDashboardContext())
            {
                var model = new ItemDetailsModel();
                model.Item = context.GetError(id);
                model.UserAgentInfoProvider     = UserAgentInfoProvider;
                model.RemoteAddressInfoProvider = RemoteAddressInfoProvider;

                return(View("ItemDetailsPart", model));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Index(int?offset, int?length)
        {
            using (var context = new ElmahDashboardContext())
            {
                var model = new IndexModel();
                model.Applications = context.ListApplications().ToArray();
                model.Hosts        = context.ListHosts().ToArray();
                model.Sources      = context.ListSource().ToArray();
                model.Types        = context.ListTypes().ToArray();

                return(View(model));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Delete(PrevNextRequest input)
        {
            using (var context = new ElmahDashboardContext())
            {
                var id = input.Sequence;
                if (context.Delete(id))
                {
                    //return View();
                }
                else
                {
                    // return View();
                }

                return(null);
            }
        }
Ejemplo n.º 7
0
        public void UpdateCache(ElmahDashboardContext context)
        {
            // Skip cache updating if not older than 10 seconds:
            if (LastCacheUpdateTime.AddSeconds(10) > DateTime.Now)
            {
                return;
            }

            lock (this)
            {
                // Flush old items out of cache:
                var minDate = DateTime.UtcNow - MaxCacheAge;
                CachedItems.RemoveAll(i => i.TimeUtc < minDate);

                // Retrieve new items:
                var minSequence = CachedItems.Select(i => i.Sequence).DefaultIfEmpty(-1).Max();
                CachedItems.AddRange(context.ListErrorItems(minDate, minSequence));
            }
        }
Ejemplo n.º 8
0
        public ActionResult PreviousItemDetails(PrevNextRequest input)
        {
            using (var context = new ElmahDashboardContext())
            {
                var where = "([Application] LIKE @p0) AND ([Host] LIKE @p1) AND ([Source] LIKE @p2) AND ([Type] LIKE @p3) AND ([AllXml] LIKE @p4) AND ([Sequence] < @p5)";
                var parameters = new object[] { input.Application.IfNullOrWhiteSpace("%"), input.Host.IfNullOrWhiteSpace("%"), input.Source.IfNullOrWhiteSpace("%"), input.Type.IfNullOrWhiteSpace("%"), "%" + input.Search + "%", input.Sequence };
                var orderBy    = "[Sequence] DESC";

                var model = new ItemDetailsModel();
                model.Item = context.ListErrors(0, 1, where, orderBy, true, parameters).SingleOrDefault();
                model.UserAgentInfoProvider     = UserAgentInfoProvider;
                model.RemoteAddressInfoProvider = RemoteAddressInfoProvider;

                if (model.Item != null)
                {
                    return(View("ItemDetailsPart", model));
                }
                else
                {
                    return(this.HttpNotFound());
                }
            }
        }
        public ActionResult DailyStats()
        {
            using (var context = new ElmahDashboardContext())
            {
                EECounters.UpdateCache(context);

                var now   = DateTime.UtcNow;
                var model = new DailyStatsModel();
                model.Timestamp      = now;
                model.RangeEnd       = now.TruncToDays().AddDays(1);
                model.RangeStart     = model.RangeEnd.AddDays(-14);
                model.DailyCounters  = EECounters.GetDailyCounters(model.RangeStart, model.RangeEnd);
                model.LastDayErrors  = EECounters.GetErrors(now.AddDays(-1), now);
                model.SampleLogCount = Int32.Parse(ConfigurationManager.AppSettings["MvcElmahDashboardLogCount"].IfNullOrWhiteSpace("3"));
                foreach (var app in EECounters.GetErrors(now.AddDays(-4), now).Select(i => i.Application).Distinct())
                {
                    var appvar = app;
                    model.AppDailyCounters[appvar] = EECounters.GetDailyCounters(model.RangeEnd.AddDays(-4), model.RangeEnd, item => item.Application == appvar);
                }

                return(View(model));
            }
        }
Ejemplo n.º 10
0
        public ActionResult DailyStats()
        {
            using (var context = new ElmahDashboardContext())
            {
                EECounters.UpdateCache(context);

                var now   = DateTime.UtcNow;
                var model = new DailyStatsModel();
                model.Timestamp      = now;
                model.RangeEnd       = now.TruncToDays().AddDays(1);
                model.RangeStart     = model.RangeEnd.AddDays(-14);
                model.DailyCounters  = EECounters.GetDailyCounters(model.RangeStart, model.RangeEnd);
                model.LastDayErrors  = EECounters.GetErrors(now.AddDays(-1), now);
                model.SampleLogCount = Int32.Parse(ConfigurationManager.AppSettings["MvcElmahDashboardLogCount"].IfNullOrWhiteSpace("3"));
                foreach (var app in EECounters.GetErrors(now.AddDays(-4), now).Select(i => i.Application).Distinct())
                {
                    var appvar = app;
                    model.AppDailyCounters[appvar] = EECounters.GetDailyCounters(model.RangeEnd.AddDays(-4), model.RangeEnd, item => item.Application == appvar);
                }

                //chart line with focus
                int day             = Int32.Parse(ConfigurationManager.AppSettings["MvcElmahDashboardDayChart"].IfNullOrWhiteSpace("14"));
                var _model          = context.CountByTypeError(day);
                List <DataModel> ls = new List <DataModel>();
                var types           = context.ListTypes(day);
                foreach (var item in types)
                {
                    var line = _model.Where(p => p.Type == item).OrderBy(p => p.Date).Select(p => new XY(1, p.Counts, p.Date)).ToList();
                    var dt   = new DataModel();
                    var i    = 0;
                    foreach (var _i in line)
                    {
                        line[i].x = i;
                        i++;
                    }
                    dt.key    = item;
                    dt.values = line;

                    ls.Add(dt);
                }
                var s = JsonConvert.SerializeObject(ls);
                ViewBag.chartData = s;
                ViewBag.DayChart  = day;

                //chart pie
                var _pie = _model.GroupBy(p => p.Type).Select(g => new { label = g.Key, value = g.Sum(i => i.Counts) }).OrderByDescending(x => x.value).Take(5).ToList(); //from prop in _model
                if (types.Count() > 5)
                {
                    var _other = _model.GroupBy(p => p.Type).Select(g => new { label = g.Key, value = g.Sum(i => i.Counts) }).OrderByDescending(x => x.value).Skip(5).Sum(v => v.value);
                    _pie.Add(new { label = "Other", value = _other });
                }
                ViewBag.pieData = JsonConvert.SerializeObject(_pie);

                //user error
                var _userdata = context.ListUserByDay(day);
                ViewBag.UersError = _userdata;
                var _userpie = _userdata.Select(g => new { label = g.User, value = g.Counts }).OrderByDescending(x => x.value).Take(5).ToList();
                if (_userdata.Count() > 5)
                {
                    var _other = _userdata.Select(g => new { label = g.User, value = g.Counts }).OrderByDescending(x => x.value).Skip(5).Sum(v => v.value);
                    _userpie.Add(new { label = "Other", value = _other });
                }
                ViewBag.userChart = JsonConvert.SerializeObject(_userpie);

                return(View(model));
            }
        }