public string abStatistics1() { var start = DateTime.Now.AddYears(-100); var end = DateTime.Now; var onhtml = string.Empty; var hiscount = 0; var allreq = 0; var usecount = 0; var users = 0; try { using (var abdb = new mvc104.abm.studyinContext()) { users = abdb.User.Count(c => c.Inspect == "1" && c.Drugrelated == "0"); hiscount = abdb.History.Count(a => a.Finishdate.CompareTo(start) >= 0 && a.Finishdate.CompareTo(end) <= 0); allreq = abdb.Request.Count(a => a.Time.CompareTo(start) >= 0 && a.Time.CompareTo(end) <= 0); usecount = abdb.Request.Count(a => !a.Method.Contains("LoginAndQuery") && a.Time.CompareTo(start) >= 0 && a.Time.CompareTo(end) <= 0); } } catch (Exception ex) { } onhtml += "<li>学习完成量: " + hiscount + "</li>"; onhtml += "<li>访问量: " + allreq + "</li>"; onhtml += "<li>使用量: " + usecount + "</li>"; onhtml += "<li>今日可学习用户数: " + users + "</li>"; Response.ContentType = "text/event-stream"; return("data:" + onhtml + "\n\n"); }
public aballresponse AbUsageAmount() { var ret = new aballresponse { status = 0, values = new List <values>(), labels = new List <labels>() }; try { using (var abdb = new mvc104.abm.studyinContext()) { var ah = abdb.Request.Where(a => a.Method.Contains("InspectPostStudyStatus")).Select(b => b.Time).ToList(); var aaaaa = from one in ah group one by one.ToString("yyyy-MM-dd") into onegroup select new aaa { day = onegroup.Key, count = onegroup.Count() }; foreach (var cc in aaaaa) { ret.labels.Add(new labels { label = cc.day }); ret.values.Add(new values { value = cc.count.ToString() }); } } } catch (Exception ex) { ret.content += ex.Message; } return(ret); }
public aballresponse AbOkDailyCount() { var ret = new aballresponse { status = 0, values = new List <values>(), labels = new List <labels>() }; try { using (var abdb = new mvc104.abm.studyinContext()) { var ah = abdb.History.Select(ab => ab.Finishdate).ToList(); var aaaaa = from one in ah group one by one.ToString("yyyy-MM-dd") into onegroup select new aaa { day = onegroup.Key, count = onegroup.Count() }; // var memday=DateTime.Parse( aaaaa.First().day); foreach (var cc in aaaaa) { // if(DateTime.Parse(cc.day).AddDays(-1).CompareTo(memday)>0){ // } ret.labels.Add(new labels { label = cc.day }); ret.values.Add(new values { value = cc.count.ToString() }); } //using (var command = abdb.Database.GetDbConnection().CreateCommand()) //{ // command.CommandText = "SELECT distinct(date( finishdate)),count(*) FROM studyin.history group by date( finishdate);"; // command.CommandText = "SELECT finishdate FROM studyin.history"; // command.CommandType = CommandType.Text; // abdb.Database.OpenConnection(); // using (var result = command.ExecuteReader()) // { // while (result.Read()) // { // var aa = new aaa(); // aa.count = 1; // aa.day = result.GetData(0).ToString(); // a.Add(aa); // } // } //} } } catch (Exception ex) { ret.content += ex.Message; } return(ret); }
public abssresponse abStatistics(string startdate, string enddate) { var start = DateTime.Now.AddYears(-100); var end = DateTime.Now; if (!DateTime.TryParse(startdate, out start)) { return(new abssresponse { status = responseStatus.startdateerror, content = responseStatus.startdateerror.ToString() }); } if (!DateTime.TryParse(enddate, out end)) { return(new abssresponse { status = responseStatus.enddateerror, content = responseStatus.enddateerror.ToString() }); } var ret = new abssresponse { status = 0 }; var onhtml = string.Empty; var hiscount = 0; var allreq = 0; var usecount = 0; var users = 0; try { using (var abdb = new mvc104.abm.studyinContext()) { users = abdb.User.Count(c => c.Inspect == "1" && c.Drugrelated == "0"); hiscount = abdb.History.Count(a => a.Finishdate.CompareTo(start) >= 0 && a.Finishdate.CompareTo(end) <= 0); allreq = abdb.Request.Count(a => a.Time.CompareTo(start) >= 0 && a.Time.CompareTo(end) <= 0); usecount = abdb.Request.Count(a => !a.Method.Contains("LoginAndQuery") && a.Time.CompareTo(start) >= 0 && a.Time.CompareTo(end) <= 0); } } catch (Exception ex) { ret.content += ex.Message; } onhtml += "<li>学习完成量: " + hiscount + "</li>"; onhtml += "<li>访问量: " + allreq + "</li>"; onhtml += "<li>使用量: " + usecount + "</li>"; onhtml += "<li>今日可学习用户数: " + users + "</li>"; ret.onhtml = onhtml; try { var he = Request.Host.ToString(); foreach (var a in Request.Headers) { he += "--" + a.Key + "=" + a.Value; } Task.Run(() => highlevel.LogRequest(he + startdate + enddate, "abStatistics", Request.HttpContext.Connection.RemoteIpAddress.ToString())); } catch (Exception ex) { _log.LogError("dblog error:", ex); } return(ret); }
public aballresponse AbOkDailyCount() { var ret = new aballresponse { status = 0, values = new List <values>(), labels = new List <labels>() }; try { using (var abdb = new mvc104.abm.studyinContext()) { var ah = abdb.History.Select(ab => ab.Finishdate).ToList(); var aaaaa = from one in ah group one by one.ToString("yyyy-MM-dd") into onegroup orderby onegroup.Key descending select new aaa { day = onegroup.Key, count = onegroup.Count() }; // var memday=DateTime.Parse( aaaaa.First().day); foreach (var cc in aaaaa) { // if(DateTime.Parse(cc.day).AddDays(-1).CompareTo(memday)>0){ // } ret.labels.Add(new labels { label = cc.day }); ret.values.Add(new values { value = cc.count.ToString() }); } } } catch (Exception ex) { ret.content += ex.Message; } return(ret); }