// [Route("salt")] // [HttpGet] // public GetLearnerInfoResponse salt(string token) // { // try // { // // var aa= Request.Headers["Content-Type"]; // if (string.IsNullOrEmpty(token)) // { // return new GetLearnerInfoResponse // { // StatusCode = Global.Status[responseCode.TokenError].StatusCode, // Description = Global.Status[responseCode.TokenError].Description // }; // } // var key = "2cff5601e52f4747bfb9e271fe45042a"; // var salt = "d31beaac47b44b45b1c6066712d49ff6"; // var original_value = token; // var encrypted_value = CryptographyHelpers.Encrypt(key, salt, original_value); // var target = CryptographyHelpers.Decrypt(key, salt, encrypted_value); // return new GetLearnerInfoResponse // { // Name = encrypted_value, // // Identity = encrypted_value.Length.ToString(), // StatusCode = encrypted_value.Length.ToString(), // Description = target, // }; // } // catch (Exception ex) // { // return new GetLearnerInfoResponse // { // StatusCode = Global.Status[responseCode.ProgramError].StatusCode, // Description = Global.Status[responseCode.ProgramError].Description + ex.Message // }; // } // } private async void LogRequest(string content, string method = null, string ip = null) { try { var dbtext = string.Empty; var dbmethod = string.Empty; var dbip = string.Empty; var contentlenth = 150; var shortlength = 44; if (!string.IsNullOrEmpty(content)) { var lenth = content.Length; dbtext = lenth > contentlenth?content.Substring(0, contentlenth) : content; } if (!string.IsNullOrEmpty(method)) { dbmethod = method.Length > shortlength?method.Substring(0, shortlength) : method; } if (!string.IsNullOrEmpty(ip)) { dbip = ip.Length > shortlength?ip.Substring(0, shortlength) : ip; } var id = string.Format(", {0}-{1}-{2}", dbip, dbmethod, dbtext); Log.Information("LogRequest,{0},from ip={1}", "begin" + id, Request.HttpContext.Connection.RemoteIpAddress); await Task.Run(() => { using (var logdb = new studyinContext()) { logdb.Request.Add(new Request { Content = dbtext, Ip = dbip, Method = dbmethod, Time = DateTime.Now }); logdb.SaveChanges(); } }); Log.Information("LogRequest,{0},from ip={1}", "end" + id, Request.HttpContext.Connection.RemoteIpAddress); } catch (Exception ex) { Log.Information("LogRequest error,{0},from ip={1}", ex.Message, Request.HttpContext.Connection.RemoteIpAddress); } }
public aballresponse CheckRequestAb() { var ret = new aballresponse { status = 0, values = new List <values>(), labels = new List <labels>() }; try { using (var driverdb = new studyinContext()) { var ah = driverdb.Request.Where(ab => ab.Time.CompareTo(DateTime.Now.AddDays(-1)) >= 0).Select(a => a.Time); var aaaaa = from one in ah group one by one.ToString("yyyy-MM-dd HH") + "点" into onegroup orderby onegroup.Key descending 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); }