public bool sendCodeToPhone(string phoneNumber, LoginDALController loginDAL) { bool sendOk = false; string phoneCode = getrandom.Next(100000, 999999).ToString(); int row = loginDAL.InsertPhoneCode(phoneNumber, phoneCode, GetIp()); if (row == 1) { #region 由云片网发送短信到手机上 string RptAppKey = ConfigurationManager.AppSettings["RptAppKey"].ToString(); string RptAppSecret = ConfigurationManager.AppSettings["RptAppSecret"].ToString(); string SendMessageUrl = ConfigurationManager.AppSettings["SendMessageUrl"].ToString(); string timestamp = GetTimeStamp(); string innerJson = "{'appKey':'" + RptAppKey + "','timestamp':" + timestamp + ",'appSecret':'" + (RptAppSecret + timestamp).GetMD5String() + "','data':{'templateCode':'DLYZ','mobile':'" + phoneNumber + "','params':{'code':'" + phoneCode + "','minute':120}}}"; YPResultSet result = ReqPost.PostSendMicroMessage(innerJson, SendMessageUrl); if (result.code == "0") { sendOk = true; } else { sendOk = false; } #endregion } return(sendOk); }
public IHttpActionResult getPosts(ReqPost rp) { results res = new results(); int perpage = 20; if (rp.index <= 0) { rp.index = 1; } using (var db = new oucfreetalkEntities()) { if (rp.pclass != -1 && db.postc.FirstOrDefault(a => a.id == rp.pclass) == null) { res.result = 0; return(Ok(res)); } if (rp.pclass == -1) { var search_post = (from it in db.posts join itb in db.students on it.owner equals itb.id where it.state == true orderby it.updatetime descending select new { it.id, it.ownclass, it.owner, it.realbody, it.title, it.contenttext, it.createtime, ownername = itb.nikename, ownerpic = itb.pic }).ToList(); int allcount = search_post.Count; int allpage = allcount / perpage; if (allcount % perpage != 0) { allpage++; } var search = search_post.Skip((rp.index - 1) * perpage).Take(perpage); return(Ok(new { search, allpage })); } else { var search_post = (from it in db.posts join itb in db.students on it.owner equals itb.id where it.ownclass == rp.pclass orderby it.updatetime descending select new { it.id, it.ownclass, it.owner, it.realbody, it.title, it.contenttext, it.body, it.createtime, ownername = itb.nikename, ownerpic = itb.pic }).ToList(); int allcount = search_post.Count; int allpage = allcount / perpage; if (allcount % perpage != 0) { allpage++; } var search = search_post.Skip((rp.index - 1) * perpage).Take(perpage); return(Ok(new { search, allpage })); } } }