protected void lnkSubmit_Click(object sender, EventArgs e) { string sessionCode = Cmn.Session.Get("code"); if (!sessionCode.Equals(viladCode.Value)) { Cmn.Js.ShowAlert("验证码输入错误"); return; } if (DBEntity.Tab_UserCommunity.HasEmail(this.UserEmail.Value) > 0) { Cmn.Js.ShowAlert(string.Format("邮箱账号:{0} 已经存!", this.UserEmail.Value)); return; } string strGuid = Guid.NewGuid().ToString(); DBEntity.Tab_UserCommunity ent = new DBEntity.Tab_UserCommunity(); ent.UserEmail = this.UserEmail.Value; ent.Password = this.Password.Value; ent.MobilePhone = this.MobilePhone.Value; ent.VipBool = "no"; ent.City = ""; ent.Province = ""; ent.RegViladCode = strGuid; ent.LastLoginIp = Request.UserHostAddress; ent.AddNew(ent); string SmtpServer = "mail.showone.com.cn"; string SmtpUserName = "******"; string SmtpPassword = "******"; string fromMail = "*****@*****.**"; string formName = "SisleyCommnutiy"; Cmn.Email el = new Cmn.Email(SmtpServer, SmtpUserName, SmtpPassword, fromMail, formName); el.IsBodyHtml = true; string subject = "来自希思黎社区网,用户注册验证码"; string validUrl = string.Format("{0}/EmailRegValid.aspx?validCode={1}", Cmn.WebConfig.getApp("app_WebsiteDomain"), strGuid); string body = string.Format("亲爱的{0}, <br /><br /> 恭喜您成功注册。<br / > 请点击以下链接验证邮箱 <br />{1}<br/><br/> 如果链接不能点击,请复制地址到浏览器,然后直接打开 <br /><br /> 祝好! <br /><br /> 希思黎社区 <br />{2}", this.UserEmail.Value, validUrl, Cmn.Date.ToDateTimeStr(DateTime.Now)); el.Send(this.UserEmail.Value, subject, body); Response.Redirect("register_success.aspx"); }
protected void GetSinaToken() { if (Request["code"] != null) { string client_id = Cmn.WebConfig.getApp("app_key_sina"); string client_secret = Cmn.WebConfig.getApp("app_secret_sina"); string redirect_uri = Cmn.WebConfig.getApp("app_redirectUri_sina"); string grant_type = "authorization_code"; string code = Request["code"].ToString(); string url = "https://api.weibo.com/oauth2/access_token"; string postData = string.Format("client_id={0}&client_secret={1}&grant_type={2}&code={3}&redirect_uri={4}", client_id, client_secret, grant_type, code, redirect_uri); HttpData http = new HttpData(); string responseData = http.WebRequest("post", url, postData); OathToken token = JsonHelper.ParseFormJson <OathToken>(responseData); Cmn.Cookies.Set("access_token", token.access_token, 7); Cmn.Cookies.Set("uid", token.uid, 7); //============ string strUrl = string.Format("https://api.weibo.com/2/users/show.json?access_token={0}&uid={1}", token.access_token, token.uid); string myJson = http.WebRequest("get", strUrl, string.Empty); var decodedJSON = JObject.Parse(myJson); var SinaScreen_name = decodedJSON["screen_name"].ToString() + "_sina"; var SinaProfile_image_url = decodedJSON["profile_image_url"]; var sinaId = decodedJSON["id"]; //======= //查找会员社区表中,是否已经存在 int uIdx = 0; string SinaPhotoHeader = Cmn.Date.ToDateStr2(DateTime.Now) + "_" + sinaId + ".png"; string strSql = string.Format("select count(1) from Tab_UserCommunity where SinaWeibo_Id='{0}'", sinaId); int iCount = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, strSql)); Cmn.Log.Write("strSql=" + strSql + "|iCount=" + iCount); if (iCount == 0) { //保存头像 using (WebClient wc = new WebClient()) { string photoUrl = SinaProfile_image_url.ToString(); string photoSavePath = Server.MapPath("~/upload/userHearderImg/") + SinaPhotoHeader; wc.DownloadFile(photoUrl, photoSavePath); } //添加到数据库 DBEntity.Tab_UserCommunity ent2 = new DBEntity.Tab_UserCommunity(); ent2.UserEmail = SinaScreen_name.ToString(); ent2.RealName = SinaScreen_name.ToString(); ent2.VipBool = "no"; ent2.Password = "******"; ent2.City = ""; ent2.HeadPhoto = SinaPhotoHeader; ent2.SinaWeibo_Id = sinaId.ToString(); uIdx = ent2.AddNew(ent2); } strSql = string.Format("insert into Tab_User_LoginLog (LoginName,LoginIpAddress) values('{0}','{1}')", SinaScreen_name, Request.UserHostAddress); SqlHelper.ExecuteNonQuery(CommandType.Text, strSql); DBEntity.Tab_UserCommunity ent = DBEntity.Tab_UserCommunity.GetBySinaId(sinaId.ToString()); uIdx = Convert.ToInt32(ent.Idx); int remeberDay = 7; Cmn.Cookies.Set("login_UserIdx", uIdx.ToString(), remeberDay); Cmn.Cookies.Set("login_UserEmail", ent.UserEmail, remeberDay); Cmn.Cookies.Set("login_RealName", ent.RealName, remeberDay); Cmn.Cookies.Set("login_VipBool", ent.VipBool, remeberDay); Cmn.Cookies.Set("login_HeadPhoto", string.Format("{0}/upload/userHearderImg/{1}", Cmn.WebConfig.getApp("app_WebsiteDomain"), ent.HeadPhoto), remeberDay); Cmn.Log.Write(Cmn.Cookies.Get("login_UserEmail")); //========= End Response.Redirect("index.aspx?s=" + Request["s"]); } }
protected void lnkSubmit_Click(object sender, EventArgs e) { string sessionCode = Cmn.Session.Get("code"); if (DBEntity.Tab_UserVipCardNo.ChkVipCard(this.VipCardNo.Value) <= 0) { Cmn.Js.ShowAlert("会员卡号不存在"); return; } if (DBEntity.Tab_UserVipCardNo.HasCardNo(this.VipCardNo.Value) > 0) { Cmn.Js.ShowAlert("会员卡已经被人激活"); return; } if (DBEntity.Tab_UserCommunity.HasEmail(this.UserEmail.Value) > 0) { Cmn.Js.ShowAlert(string.Format("邮箱账号:{0} 已经存!", this.UserEmail.Value)); return; } if (!sessionCode.Equals(viladCode.Value)) { Cmn.Js.ShowAlert("验证码输入错误"); return; } string strGuid = Guid.NewGuid().ToString(); DBEntity.Tab_UserCommunity ent = new DBEntity.Tab_UserCommunity(); ent.UserEmail = this.UserEmail.Value; ent.Password = this.Password.Value; ent.VipCardNo = this.VipCardNo.Value; ent.MobilePhone = this.MobilePhone.Value; ent.Province = this.Province.Items[this.Province.SelectedIndex].Value; ent.City = this.City.Value; ent.RegViladCode = strGuid; ent.VipBool = "yes"; ent.LastLoginIp = Request.UserHostAddress; ent.AddNew(ent); //修改会员卡状态 string strSql = string.Format("update Tab_UserVipCardNo set VipHasUseBool='yes',VipEditDateTime=getdate() where Idx={0}", this.VipCardNo.Value); SqlHelper.ExecuteNonQuery(CommandType.Text, strSql); Cmn.Log.Write(string.Format("VIP卡:{0} -- Yes", this.VipCardNo.Value)); //========== string SmtpServer = "mail.showone.com.cn"; string SmtpUserName = "******"; string SmtpPassword = "******"; string fromMail = "*****@*****.**"; string formName = "SisleyCommnutiy"; Cmn.Email el = new Cmn.Email(SmtpServer, SmtpUserName, SmtpPassword, fromMail, formName); el.IsBodyHtml = true; string subject = "来自希思黎社区网,用户注册验证码"; string validUrl = string.Format("{0}/EmailRegValid.aspx?validCode={1}", Cmn.WebConfig.getApp("app_WebsiteDomain"), strGuid); string body = string.Format("亲爱的{0}, <br /><br /> 恭喜您成功注册。<br / > 请点击以下链接验证邮箱 <br />{1}<br/><br/> 如果链接不能点击,请复制地址到浏览器,然后直接打开 <br /><br /> 祝好! <br /><br /> 希思黎社区 <br />{2}", this.UserEmail.Value, validUrl, Cmn.Date.ToDateTimeStr(DateTime.Now)); el.Send(this.UserEmail.Value, subject, body); Response.Redirect("register_success.aspx"); }