public ReturnValue <USR_CustomerShow> GetUserInfo(int uid) { USR_CustomerMod m_user = USR_CustomerBll.GetInstance().GetModel(uid); if (m_user.SysNo != -999999) { USR_CustomerShow ret = new USR_CustomerShow(); m_user.MemberwiseCopy(ret); DataTable m_dt = REL_Customer_MedalBll.GetInstance().GetMedalByCustomer(uid, 0); ret.TotalMedal = m_dt.Rows.Count; int total = 0; DataTable m_dt1 = USR_MessageBll.GetInstance().GetMessageByCustomer(uid, 1, 1, 0, 1, ref total); ret.NewMessage = total; return(ReturnValue <USR_CustomerShow> .Get200OK(ret)); } else { throw new BusinessException("用户ID错误,请重新输入!"); } }
public ReturnValue <USR_CustomerMaintain> UserLogin(string username, string password) { if (string.IsNullOrEmpty(username)) { throw new BusinessException("用户名不能为空"); } if (string.IsNullOrEmpty(password)) { throw new BusinessException("密码不能为空"); } USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckUser(username, password); if (m_user.SysNo != -999999) { USR_CustomerMaintain ret = new USR_CustomerMaintain(); m_user.MemberwiseCopy(ret); return(ReturnValue <USR_CustomerMaintain> .Get200OK(ret)); } else { throw new BusinessException("账号或密码错误,请重新输入!"); } }
public ReturnValue<USR_CustomerMaintain> Register(string email, string password, string phone, string nickname, string fatetype) { #region 验证输入 if (email!=null&&email.DoTrim() != "") { USR_CustomerMod m_userrr = USR_CustomerBll.GetInstance().CheckUser(email); if (m_userrr.SysNo != AppConst.IntNull) { throw new BusinessException("该邮箱已注册,请重新输入!"); } } else if (phone != null && phone.DoTrim() != "") { if (!Util.IsCellNumber(phone)) { throw new BusinessException("手机号格式有误,请重新输入!"); } USR_CustomerMod m_userrr = USR_CustomerBll.GetInstance().CheckPhone(phone); if (m_userrr.SysNo != AppConst.IntNull) { throw new BusinessException("该手机号已注册,请重新输入!"); } } if (CommonTools.HasForbiddenWords(nickname)) { throw new BusinessException("您的昵称中有违禁字符,请重新输入!"); } USR_CustomerMod m_userr = USR_CustomerBll.GetInstance().CheckNickName(nickname); if (m_userr.SysNo != AppConst.IntNull) { throw new BusinessException("该昵称已被占用,请尝试使用其他昵称!"); } try { int fate = int.Parse(fatetype); } catch { throw new BusinessException("请输入正确的命盘类型号!"); } #endregion #region 保存数据 USR_CustomerMod m_user = new USR_CustomerMod(); m_user.Email = email.DoTrim(); m_user.Phone = phone.DoTrim(); m_user.FateType = int.Parse(fatetype); m_user.GradeSysNo = AppConst.OriginalGrade; ; m_user.NickName = nickname.DoTrim(); m_user.Password = password.DoTrim(); m_user.RegTime = DateTime.Now; m_user.Point = AppConst.OriginalPoint; m_user.Photo = AppConst.OriginalPhoto; m_user.LastLoginTime = DateTime.Now; if (Container.ConfigService.GetAppSetting<string>("RegisterEmailCheck","false").ToLower() == "true") { m_user.Status = (int)AppEnum.State.prepare; } else { m_user.Status = (int)AppEnum.State.normal; } m_user.Credit = 0; m_user.Birth = AppConst.DateTimeNull; m_user.IsShowBirth = 1; m_user.IsStar = 0; m_user.BestAnswer = 0; m_user.TotalAnswer = 0; m_user.TotalQuest = 0; m_user.HomeTown = AppConst.IntNull; m_user.Intro = AppConst.OriginalIntro; m_user.Signature = AppConst.OriginalSign; m_user.Exp = 0; m_user.TotalReply = 0; m_user.HasNewInfo = 0; m_user.SysNo = USR_CustomerBll.GetInstance().Add(m_user); #endregion #region 发送验证邮件 if (Container.ConfigService.GetAppSetting<string>("RegisterEmailCheck","false").ToLower() == "true") { } #endregion if (m_user.SysNo != -999999) { USR_CustomerMaintain ret = new USR_CustomerMaintain(); m_user.MemberwiseCopy(ret); return ReturnValue<USR_CustomerMaintain>.Get200OK(ret); } else { throw new Exception("系统故障,注册失败"); } }
public ReturnValue<USR_CustomerMaintain> QQLogin(string code) { //QQ回调 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Container.ConfigService.GetAppSetting<string>("ThirdLoginFilePath", "")); XmlNode node = xmlDoc.SelectSingleNode("//ThirdLogin//QQ//AppID"); XmlNode node1 = xmlDoc.SelectSingleNode("//ThirdLogin//QQ//Key"); //获取Access Token System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=" + node.InnerText + "&client_secret=" + node1.InnerText + "&code=" + code + "&redirect_uri=" + Container.ConfigService.GetAppSetting<string>("HomeUrl", "") + "Passport/ThirdLogin.aspx"); System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse(); Encoding encoding = Encoding.UTF8; StreamReader reader = new StreamReader(res.GetResponseStream(), encoding); string ret = reader.ReadToEnd(); string retcode = ""; int timespan = 0; try { retcode = ret.Split(new char[] { '&' })[0].Split(new char[] { '=' })[1]; timespan = int.Parse(ret.Split(new char[] { '&' })[1].Split(new char[] { '=' })[1]); } catch (Exception ex) { throw new Exception(ex.Message); } //获取OpenID req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://graph.qq.com/oauth2.0/me?access_token=" + retcode); res = (System.Net.HttpWebResponse)req.GetResponse(); reader = new StreamReader(res.GetResponseStream(), encoding); ret = reader.ReadToEnd(); string openid = ""; try { openid = ret.Split(new char[] { '"' })[7]; } catch (Exception ex) { throw new Exception(ex.Message); } USR_CustomerMod m_customer = USR_CustomerBll.GetInstance().GetUserByThirdID(openid); if (m_customer != null && m_customer.SysNo != AppConst.IntNull) { m_customer.LastLoginTime = DateTime.Now; USR_CustomerBll.GetInstance().Update(m_customer); USR_CustomerMaintain rett = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(rett); return ReturnValue<USR_CustomerMaintain>.Get200OK(rett); } m_customer = new USR_CustomerMod(); //获取用户信息 req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(@"https://graph.qq.com/user/get_user_info?access_token=" + retcode + "&oauth_consumer_key=" + node.InnerXml + "&openid=" + openid); res = (System.Net.HttpWebResponse)req.GetResponse(); reader = new StreamReader(res.GetResponseStream(), encoding); ret = reader.ReadToEnd(); try { m_customer.NickName = ret.Split(new char[] { ':', ',' })[7].Replace(@"""", "").DoTrim(); m_customer.Photo = ret.Split(new string[] { @""":", "," }, StringSplitOptions.None)[19].Replace(@"""", "").Replace(@"\", "").DoTrim(); if (USR_CustomerBll.GetInstance().CheckNickName(m_customer.NickName).SysNo != AppConst.IntNull) { m_customer.NickName += "-"+openid.Substring(0, 6); } } catch (Exception ex) { throw new Exception(ex.Message); } #region 保存数据 USR_ThirdLoginMod m_third = new USR_ThirdLoginMod(); m_third.OpenID = openid; m_third.AccessKey = retcode; m_third.ExpireTime = DateTime.Now.AddSeconds(timespan); m_third.ThirdType = (int)AppEnum.ThirdLoginType.qq; USR_CustomerMod m_user = new USR_CustomerMod(); try { m_user.Email = ""; m_user.FateType = (int)AppEnum.FateType.astro; m_user.GradeSysNo = AppConst.OriginalGrade; ; m_user.Password = ""; m_user.RegTime = DateTime.Now; m_user.Point = AppConst.OriginalPoint; m_user.LastLoginTime = DateTime.Now; if (Container.ConfigService.GetAppSetting<string>("RegisterEmailCheck", "false").ToLower() == "true") { m_user.Status = (int)AppEnum.State.prepare; } else { m_user.Status = (int)AppEnum.State.normal; } m_user.Credit = 0; m_user.Birth = AppConst.DateTimeNull; m_user.IsShowBirth = 1; m_user.IsStar = 0; m_user.BestAnswer = 0; m_user.TotalAnswer = 0; m_user.TotalQuest = 0; m_user.HomeTown = AppConst.IntNull; m_user.Intro = AppConst.OriginalIntro; m_user.Signature = AppConst.OriginalSign; m_user.Exp = 0; m_user.TotalReply = 0; m_user.SysNo = USR_CustomerBll.GetInstance().Add(m_user); m_third.CustomerSysNo = m_user.SysNo; USR_ThirdLoginBll.GetInstance().Add(m_third); } catch (Exception ex) { throw new Exception(ex.Message); } #endregion USR_CustomerMaintain rettt = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(rettt); return ReturnValue<USR_CustomerMaintain>.Get200OK(rettt); }
public ReturnValue <USR_CustomerMaintain> QQLogin(string code) { //QQ回调 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Container.ConfigService.GetAppSetting <string>("ThirdLoginFilePath", "")); XmlNode node = xmlDoc.SelectSingleNode("//ThirdLogin//QQ//AppID"); XmlNode node1 = xmlDoc.SelectSingleNode("//ThirdLogin//QQ//Key"); //获取Access Token System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=" + node.InnerText + "&client_secret=" + node1.InnerText + "&code=" + code + "&redirect_uri=" + Container.ConfigService.GetAppSetting <string>("HomeUrl", "") + "Passport/ThirdLogin.aspx"); System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse(); Encoding encoding = Encoding.UTF8; StreamReader reader = new StreamReader(res.GetResponseStream(), encoding); string ret = reader.ReadToEnd(); string retcode = ""; int timespan = 0; try { retcode = ret.Split(new char[] { '&' })[0].Split(new char[] { '=' })[1]; timespan = int.Parse(ret.Split(new char[] { '&' })[1].Split(new char[] { '=' })[1]); } catch (Exception ex) { throw new Exception(ex.Message); } //获取OpenID req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("https://graph.qq.com/oauth2.0/me?access_token=" + retcode); res = (System.Net.HttpWebResponse)req.GetResponse(); reader = new StreamReader(res.GetResponseStream(), encoding); ret = reader.ReadToEnd(); string openid = ""; try { openid = ret.Split(new char[] { '"' })[7]; } catch (Exception ex) { throw new Exception(ex.Message); } USR_CustomerMod m_customer = USR_CustomerBll.GetInstance().GetUserByThirdID(openid); if (m_customer != null && m_customer.SysNo != AppConst.IntNull) { m_customer.LastLoginTime = DateTime.Now; USR_CustomerBll.GetInstance().Update(m_customer); USR_CustomerMaintain rett = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(rett); return(ReturnValue <USR_CustomerMaintain> .Get200OK(rett)); } m_customer = new USR_CustomerMod(); //获取用户信息 req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(@"https://graph.qq.com/user/get_user_info?access_token=" + retcode + "&oauth_consumer_key=" + node.InnerXml + "&openid=" + openid); res = (System.Net.HttpWebResponse)req.GetResponse(); reader = new StreamReader(res.GetResponseStream(), encoding); ret = reader.ReadToEnd(); try { m_customer.NickName = ret.Split(new char[] { ':', ',' })[7].Replace(@"""", "").DoTrim(); m_customer.Photo = ret.Split(new string[] { @""":", "," }, StringSplitOptions.None)[19].Replace(@"""", "").Replace(@"\", "").DoTrim(); if (USR_CustomerBll.GetInstance().CheckNickName(m_customer.NickName).SysNo != AppConst.IntNull) { m_customer.NickName += "-" + openid.Substring(0, 6); } } catch (Exception ex) { throw new Exception(ex.Message); } #region 保存数据 USR_ThirdLoginMod m_third = new USR_ThirdLoginMod(); m_third.OpenID = openid; m_third.AccessKey = retcode; m_third.ExpireTime = DateTime.Now.AddSeconds(timespan); m_third.ThirdType = (int)AppEnum.ThirdLoginType.qq; USR_CustomerMod m_user = new USR_CustomerMod(); try { m_user.Email = ""; m_user.FateType = (int)AppEnum.FateType.astro; m_user.GradeSysNo = AppConst.OriginalGrade;; m_user.Password = ""; m_user.RegTime = DateTime.Now; m_user.Point = AppConst.OriginalPoint; m_user.LastLoginTime = DateTime.Now; if (Container.ConfigService.GetAppSetting <string>("RegisterEmailCheck", "false").ToLower() == "true") { m_user.Status = (int)AppEnum.State.prepare; } else { m_user.Status = (int)AppEnum.State.normal; } m_user.Credit = 0; m_user.Birth = AppConst.DateTimeNull; m_user.IsShowBirth = 1; m_user.IsStar = 0; m_user.BestAnswer = 0; m_user.TotalAnswer = 0; m_user.TotalQuest = 0; m_user.HomeTown = AppConst.IntNull; m_user.Intro = AppConst.OriginalIntro; m_user.Signature = AppConst.OriginalSign; m_user.Exp = 0; m_user.TotalReply = 0; m_user.SysNo = USR_CustomerBll.GetInstance().Add(m_user); m_third.CustomerSysNo = m_user.SysNo; USR_ThirdLoginBll.GetInstance().Add(m_third); } catch (Exception ex) { throw new Exception(ex.Message); } #endregion USR_CustomerMaintain rettt = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(rettt); return(ReturnValue <USR_CustomerMaintain> .Get200OK(rettt)); }
public ReturnValue <USR_CustomerMaintain> WeiboLoginAlt(string token, long expires) { //新浪微博回调 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Container.ConfigService.GetAppSetting <string>("ThirdLoginFilePath", "")); XmlNode node = xmlDoc.SelectSingleNode("//ThirdLogin//WeiBo//AppID"); XmlNode node1 = xmlDoc.SelectSingleNode("//ThirdLogin//WeiBo//Key"); var oauth = new NetDimension.Weibo.OAuth(node.InnerText, node1.InnerText, Container.ConfigService.GetAppSetting <string>("HomeUrl", "") + "Passport/ThirdLogin.aspx"); var uid = ""; if (!string.IsNullOrEmpty(token)) { var Sina = new NetDimension.Weibo.Client(oauth); uid = Sina.API.Account.GetUID(); //调用API中获取UID的方法 } USR_CustomerMod m_customer = USR_CustomerBll.GetInstance().GetUserByThirdID(uid); if (m_customer != null && m_customer.SysNo != AppConst.IntNull) { m_customer.LastLoginTime = DateTime.Now; USR_CustomerBll.GetInstance().Update(m_customer); USR_CustomerMaintain ret = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(ret); return(ReturnValue <USR_CustomerMaintain> .Get200OK(ret)); } USR_ThirdLoginMod m_third = new USR_ThirdLoginMod(); m_third.OpenID = uid; m_third.AccessKey = token; m_third.ThirdType = (int)AppEnum.ThirdLoginType.weibo; USR_CustomerMod m_user = new USR_CustomerMod(); try { m_user.Email = ""; m_user.FateType = (int)AppEnum.FateType.astro; m_user.GradeSysNo = AppConst.OriginalGrade;; m_user.NickName = uid; m_user.Password = ""; m_user.RegTime = DateTime.Now; m_user.Point = AppConst.OriginalPoint; m_user.Photo = AppConst.OriginalPhoto; m_user.LastLoginTime = DateTime.Now; if (Container.ConfigService.GetAppSetting <string>("RegisterEmailCheck", "false").ToLower() == "true") { m_user.Status = (int)AppEnum.State.prepare; } else { m_user.Status = (int)AppEnum.State.normal; } m_user.Credit = 0; m_user.Birth = AppConst.DateTimeNull; m_user.IsShowBirth = 1; m_user.IsStar = 0; m_user.BestAnswer = 0; m_user.TotalAnswer = 0; m_user.TotalQuest = 0; m_user.HomeTown = AppConst.IntNull; m_user.Intro = AppConst.OriginalIntro; m_user.Signature = AppConst.OriginalSign; m_user.Exp = 0; m_user.TotalReply = 0; m_user.SysNo = USR_CustomerBll.GetInstance().Add(m_user); m_third.CustomerSysNo = m_user.SysNo; USR_ThirdLoginBll.GetInstance().Add(m_third); } catch (Exception ex) { throw new Exception(ex.Message); } USR_CustomerMaintain rett = new USR_CustomerMaintain(); m_customer.MemberwiseCopy(rett); return(ReturnValue <USR_CustomerMaintain> .Get200OK(rett)); }
public ReturnValue <USR_CustomerMaintain> Register(string email, string password, string phone, string nickname, string fatetype) { #region 验证输入 if (email != null && email.DoTrim() != "") { USR_CustomerMod m_userrr = USR_CustomerBll.GetInstance().CheckUser(email); if (m_userrr.SysNo != AppConst.IntNull) { throw new BusinessException("该邮箱已注册,请重新输入!"); } } else if (phone != null && phone.DoTrim() != "") { if (!Util.IsCellNumber(phone)) { throw new BusinessException("手机号格式有误,请重新输入!"); } USR_CustomerMod m_userrr = USR_CustomerBll.GetInstance().CheckPhone(phone); if (m_userrr.SysNo != AppConst.IntNull) { throw new BusinessException("该手机号已注册,请重新输入!"); } } if (CommonTools.HasForbiddenWords(nickname)) { throw new BusinessException("您的昵称中有违禁字符,请重新输入!"); } USR_CustomerMod m_userr = USR_CustomerBll.GetInstance().CheckNickName(nickname); if (m_userr.SysNo != AppConst.IntNull) { throw new BusinessException("该昵称已被占用,请尝试使用其他昵称!"); } try { int fate = int.Parse(fatetype); } catch { throw new BusinessException("请输入正确的命盘类型号!"); } #endregion #region 保存数据 USR_CustomerMod m_user = new USR_CustomerMod(); m_user.Email = email.DoTrim(); m_user.Phone = phone.DoTrim(); m_user.FateType = int.Parse(fatetype); m_user.GradeSysNo = AppConst.OriginalGrade;; m_user.NickName = nickname.DoTrim(); m_user.Password = password.DoTrim(); m_user.RegTime = DateTime.Now; m_user.Point = AppConst.OriginalPoint; m_user.Photo = AppConst.OriginalPhoto; m_user.LastLoginTime = DateTime.Now; if (Container.ConfigService.GetAppSetting <string>("RegisterEmailCheck", "false").ToLower() == "true") { m_user.Status = (int)AppEnum.State.prepare; } else { m_user.Status = (int)AppEnum.State.normal; } m_user.Credit = 0; m_user.Birth = AppConst.DateTimeNull; m_user.IsShowBirth = 1; m_user.IsStar = 0; m_user.BestAnswer = 0; m_user.TotalAnswer = 0; m_user.TotalQuest = 0; m_user.HomeTown = AppConst.IntNull; m_user.Intro = AppConst.OriginalIntro; m_user.Signature = AppConst.OriginalSign; m_user.Exp = 0; m_user.TotalReply = 0; m_user.HasNewInfo = 0; m_user.SysNo = USR_CustomerBll.GetInstance().Add(m_user); #endregion #region 发送验证邮件 if (Container.ConfigService.GetAppSetting <string>("RegisterEmailCheck", "false").ToLower() == "true") { } #endregion if (m_user.SysNo != -999999) { USR_CustomerMaintain ret = new USR_CustomerMaintain(); m_user.MemberwiseCopy(ret); return(ReturnValue <USR_CustomerMaintain> .Get200OK(ret)); } else { throw new Exception("系统故障,注册失败"); } }