Ejemplo n.º 1
0
 public IEnumerable <MONITOR_DB> QueryMONITOR_DB()
 {
     _monitorDB        = new MONITOR_DB(this.config);
     CurrentMONITOR_DB = _monitorDB.QUERY();
     MaxSessionValue   = _monitorDB.GetMaxSessionValue();
     MaxProcessValue   = _monitorDB.GetMaxProcessValue();
     return(CurrentMONITOR_DB);
 }
Ejemplo n.º 2
0
        public string JsonChartData()
        {
            var query  = _mon.QUERY().ToList();
            var labels = query.OrderBy(x => x.Cdt).Select(x => string.Format("{0:00}d", x.Cdt.Day) + string.Format(" {0:00}h", x.Cdt.Hour)).Distinct().ToList();
            var types  = query.Select(x => x.Type).Distinct().ToList();

            //var groups = query.GroupBy(q => new { q.Type, q.Cdt.Hour });

            foreach (var label in labels)
            {
                this.labels.Add(label);
            }

            foreach (var type in types)
            {
                DatasetMonitor dm = new DatasetMonitor();
                dm.label     = type;
                dm.fillColor = (dm.label == "SESSION") ? "#FC9775" : "#5A69A6";
                dm.data      = new List <decimal>();
                var groups     = query.Where(x => x.Type == type).OrderBy(x => x.Cdt).ToList();
                var groupmondb = groups.ToList().GroupBy(q => new { q.Cdt.Hour });

                foreach (var item in groupmondb)
                {
                    var peritem = Math.Round(item.Average(x => x.Percent), 2);
                    dm.data.Add(peritem);
                }

                this.datasets.Add(dm);
            }

            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
            string json = jsonSerializer.Serialize(this);

            return(json);
        }