Example #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();
        }
Example #2
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));
            }
        }
Example #3
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));
            }
        }