/// <summary> /// createtime expiresetime不用传。 /// </summary> /// <param name="PubConn"></param> /// <param name="model"></param> /// <param name="tokentype"></param> /// <returns></returns> public virtual bool Add(DbConn PubConn, DbModels.tb_token model, Models.DbModels.TokenType tokentype) { DateTime nowtime = PubConn.GetServerDate(); model.createtime = nowtime; model.expires = nowtime.AddMinutes(GetExpiresminutes(tokentype)); List <ProcedureParameter> Par = new List <ProcedureParameter>() { // new ProcedureParameter("@token", model.token), // new ProcedureParameter("@userid", model.userid), new ProcedureParameter("@id", model.id), // new ProcedureParameter("@username", model.username), // new ProcedureParameter("@appid", model.appid), // new ProcedureParameter("@createtime", model.createtime), // new ProcedureParameter("@expires", model.expires) }; int rev = PubConn.ExecuteSql("insert into " + tokentype.ToString() + " (token,userid,id,username,appid,createtime,expires)" + " values(@token,@userid,@id,@username,@appid,@createtime,@expires)", Par); return(rev == 1); }
public JsonResult deletetoken(string id, Models.DbModels.TokenType tokentype) { using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn()) { PubConn.Open(); bool r = Models.TokenDal.Instance.Delete(PubConn, id, tokentype); Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this); log.opecontent = "删除token。tokentype=" + tokentype.ToString() + " result=" + r; Models.CertCenterLogDal.Instance.Add(PubConn, log); if (r) { return(Json(new { code = 1 })); } else { return(Json(new { code = -905, msg = "删除失败,token不存在或存已被删除。" })); } } }