Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(USR_ThirdLoginMod model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into USR_ThirdLogin(");
            strSql.Append("CustomerSysNo,OpenID,AccessKey,ExpireTime,ThirdType)");
            strSql.Append(" values (");
            strSql.Append("@CustomerSysNo,@OpenID,@AccessKey,@ExpireTime,@ThirdType)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());
            SqlParameter[] parameters = {
                 new SqlParameter("@CustomerSysNo",SqlDbType.Int,4),
                 new SqlParameter("@OpenID",SqlDbType.VarChar,100),
                 new SqlParameter("@AccessKey",SqlDbType.VarChar,100),
                 new SqlParameter("@ExpireTime",SqlDbType.DateTime),
                 new SqlParameter("@ThirdType",SqlDbType.Int,4),
             };
            if (model.CustomerSysNo != AppConst.IntNull)
                parameters[0].Value = model.CustomerSysNo;
            else
                parameters[0].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[0]);
            if (model.OpenID != AppConst.StringNull)
                parameters[1].Value = model.OpenID;
            else
                parameters[1].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[1]);
            if (model.AccessKey != AppConst.StringNull)
                parameters[2].Value = model.AccessKey;
            else
                parameters[2].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[2]);
            if (model.ExpireTime != AppConst.DateTimeNull)
                parameters[3].Value = model.ExpireTime;
            else
                parameters[3].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[3]);
            if (model.ThirdType != AppConst.IntNull)
                parameters[4].Value = model.ThirdType;
            else
                parameters[4].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[4]);

            return SqlHelper.ExecuteNonQuery(cmd, parameters);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>

        public USR_ThirdLoginMod GetModel(int SysNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SysNo, CustomerSysNo, OpenID, AccessKey, ExpireTime, ThirdType from  USR_ThirdLogin");
            strSql.Append(" where SysNo=@SysNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo", SqlDbType.Int, 4)
            };
            parameters[0].Value = SysNo;
            USR_ThirdLoginMod model = new USR_ThirdLoginMod();
            DataSet           ds    = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
                {
                    model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CustomerSysNo"].ToString() != "")
                {
                    model.CustomerSysNo = int.Parse(ds.Tables[0].Rows[0]["CustomerSysNo"].ToString());
                }
                model.OpenID    = ds.Tables[0].Rows[0]["OpenID"].ToString();
                model.AccessKey = ds.Tables[0].Rows[0]["AccessKey"].ToString();
                if (ds.Tables[0].Rows[0]["ExpireTime"].ToString() != "")
                {
                    model.ExpireTime = DateTime.Parse(ds.Tables[0].Rows[0]["ExpireTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ThirdType"].ToString() != "")
                {
                    model.ThirdType = int.Parse(ds.Tables[0].Rows[0]["ThirdType"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(USR_ThirdLoginMod model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("update USR_ThirdLogin set ");
     strSql.Append("CustomerSysNo=@CustomerSysNo,");
     strSql.Append("OpenID=@OpenID,");
     strSql.Append("AccessKey=@AccessKey,");
     strSql.Append("ExpireTime=@ExpireTime,");
     strSql.Append("ThirdType=@ThirdType");
     strSql.Append(" where SysNo=@SysNo ");
     SqlCommand cmd = new SqlCommand(strSql.ToString());
     SqlParameter[] parameters = {
          new SqlParameter("@SysNo",SqlDbType.Int,4),
          new SqlParameter("@CustomerSysNo",SqlDbType.Int,4),
          new SqlParameter("@OpenID",SqlDbType.VarChar,100),
          new SqlParameter("@AccessKey",SqlDbType.VarChar,100),
          new SqlParameter("@ExpireTime",SqlDbType.DateTime),
          new SqlParameter("@ThirdType",SqlDbType.Int,4)
      };
     if (model.SysNo != AppConst.IntNull)
         parameters[0].Value = model.SysNo;
     else
         parameters[0].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[0]);
     if (model.CustomerSysNo != AppConst.IntNull)
         parameters[1].Value = model.CustomerSysNo;
     else
         parameters[1].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[1]);
     if (model.OpenID != AppConst.StringNull)
         parameters[2].Value = model.OpenID;
     else
         parameters[2].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[2]);
     if (model.AccessKey != AppConst.StringNull)
         parameters[3].Value = model.AccessKey;
     else
         parameters[3].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[3]);
     if (model.ExpireTime != AppConst.DateTimeNull)
         parameters[4].Value = model.ExpireTime;
     else
         parameters[4].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[4]);
     if (model.ThirdType != AppConst.IntNull)
         parameters[5].Value = model.ThirdType;
     else
         parameters[5].Value = System.DBNull.Value;
     cmd.Parameters.Add(parameters[5]);
     return SqlHelper.ExecuteNonQuery(cmd,parameters);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public USR_ThirdLoginMod GetModel(int SysNo)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select SysNo, CustomerSysNo, OpenID, AccessKey, ExpireTime, ThirdType from  USR_ThirdLogin");
     strSql.Append(" where SysNo=@SysNo ");
     SqlParameter[] parameters = {
     new SqlParameter("@SysNo", SqlDbType.Int,4 )
      		};
     parameters[0].Value = SysNo;
     USR_ThirdLoginMod model = new USR_ThirdLoginMod();
     DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
         {
             model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CustomerSysNo"].ToString() != "")
         {
             model.CustomerSysNo = int.Parse(ds.Tables[0].Rows[0]["CustomerSysNo"].ToString());
         }
         model.OpenID = ds.Tables[0].Rows[0]["OpenID"].ToString();
         model.AccessKey = ds.Tables[0].Rows[0]["AccessKey"].ToString();
         if (ds.Tables[0].Rows[0]["ExpireTime"].ToString() != "")
         {
             model.ExpireTime = DateTime.Parse(ds.Tables[0].Rows[0]["ExpireTime"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ThirdType"].ToString() != "")
         {
             model.ThirdType = int.Parse(ds.Tables[0].Rows[0]["ThirdType"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 5
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //if (!ValidateEmail())
            //{
            //    return;
            //}
            if (!ValidateNickName())
            {
                return;
            }

            #region 获取用户第三方数据
            USR_ThirdLoginMod m_third = new USR_ThirdLoginMod();
            switch (ViewState["type"].ToString())
            {
                case "qq":
                    m_third.OpenID = ViewState["openid"].ToString();
                    m_third.AccessKey = ViewState["code"].ToString();
                    m_third.ExpireTime = DateTime.Now.AddSeconds(int.Parse(ViewState["expire"].ToString()));
                    m_third.ThirdType = (int)AppEnum.ThirdLoginType.qq;
                    break;
                case "weibo":
                    m_third.OpenID = ViewState["openid"].ToString();
                    m_third.AccessKey = ViewState["code"].ToString();
                    m_third.ThirdType = (int)AppEnum.ThirdLoginType.weibo;
                    break;
                default:
                    ShowError("系统故障,请联系管理员");
                    break;
            }
            #endregion

            #region 保存数据
            USR_CustomerMod m_user = new USR_CustomerMod();
            try
            {
                m_user.Email = "";
                m_user.FateType = int.Parse(drpType.SelectedValue);
                m_user.GradeSysNo = AppConst.OriginalGrade; ;
                m_user.NickName = ViewState["nickname"].ToString();
                m_user.Password = "";
                m_user.RegTime = DateTime.Now;
                m_user.Point = AppConst.OriginalPoint;
                m_user.Photo = ViewState["photo"].ToString();
                m_user.LastLoginTime = DateTime.Now;
                if (AppConfig.RegisterEmailCheck.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)
            {
                LogManagement.getInstance().WriteException(ex, "WebForMain.Register", Request.UserHostAddress);
                return;
            }
            #endregion

            #region 登陆状态设置
            if (!(AppConfig.RegisterEmailCheck.ToLower() == "true"))
            {
                SessionInfo m_session = new SessionInfo();
                m_session.CustomerEntity = m_user;
                m_session.GradeEntity = USR_GradeBll.GetInstance().GetModel(m_user.SysNo);
                Session[AppConfig.CustomerSession] = m_session;
            }
            #endregion
            if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
            {
                Response.Redirect("RegisterSucc.aspx?url=" + Request.QueryString["url"]);
            }
            else
            {
                Response.Redirect("RegisterSucc.aspx");
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(USR_ThirdLoginMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into USR_ThirdLogin(");
            strSql.Append("CustomerSysNo,OpenID,AccessKey,ExpireTime,ThirdType)");
            strSql.Append(" values (");
            strSql.Append("@CustomerSysNo,@OpenID,@AccessKey,@ExpireTime,@ThirdType)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@CustomerSysNo", SqlDbType.Int,         4),
                new SqlParameter("@OpenID",        SqlDbType.VarChar,   100),
                new SqlParameter("@AccessKey",     SqlDbType.VarChar,   100),
                new SqlParameter("@ExpireTime",    SqlDbType.DateTime),
                new SqlParameter("@ThirdType",     SqlDbType.Int,         4),
            };
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                parameters[0].Value = model.CustomerSysNo;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.OpenID != AppConst.StringNull)
            {
                parameters[1].Value = model.OpenID;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.AccessKey != AppConst.StringNull)
            {
                parameters[2].Value = model.AccessKey;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.ExpireTime != AppConst.DateTimeNull)
            {
                parameters[3].Value = model.ExpireTime;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);
            if (model.ThirdType != AppConst.IntNull)
            {
                parameters[4].Value = model.ThirdType;
            }
            else
            {
                parameters[4].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[4]);

            return(SqlHelper.ExecuteNonQuery(cmd, parameters));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public int Update(USR_ThirdLoginMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USR_ThirdLogin set ");
            strSql.Append("CustomerSysNo=@CustomerSysNo,");
            strSql.Append("OpenID=@OpenID,");
            strSql.Append("AccessKey=@AccessKey,");
            strSql.Append("ExpireTime=@ExpireTime,");
            strSql.Append("ThirdType=@ThirdType");
            strSql.Append(" where SysNo=@SysNo ");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo",         SqlDbType.Int,         4),
                new SqlParameter("@CustomerSysNo", SqlDbType.Int,         4),
                new SqlParameter("@OpenID",        SqlDbType.VarChar,   100),
                new SqlParameter("@AccessKey",     SqlDbType.VarChar,   100),
                new SqlParameter("@ExpireTime",    SqlDbType.DateTime),
                new SqlParameter("@ThirdType",     SqlDbType.Int, 4)
            };
            if (model.SysNo != AppConst.IntNull)
            {
                parameters[0].Value = model.SysNo;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                parameters[1].Value = model.CustomerSysNo;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.OpenID != AppConst.StringNull)
            {
                parameters[2].Value = model.OpenID;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.AccessKey != AppConst.StringNull)
            {
                parameters[3].Value = model.AccessKey;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);
            if (model.ExpireTime != AppConst.DateTimeNull)
            {
                parameters[4].Value = model.ExpireTime;
            }
            else
            {
                parameters[4].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[4]);
            if (model.ThirdType != AppConst.IntNull)
            {
                parameters[5].Value = model.ThirdType;
            }
            else
            {
                parameters[5].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[5]);
            return(SqlHelper.ExecuteNonQuery(cmd, parameters));
        }
Exemplo n.º 12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(USR_ThirdLoginMod model)
 {
     dal.Update(model);
 }
Exemplo n.º 13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(USR_ThirdLoginMod model)
 {
     return dal.Add(model);
 }
Exemplo n.º 14
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //if (!ValidateEmail())
            //{
            //    return;
            //}
            if (!ValidateNickName())
            {
                return;
            }

            #region 获取用户第三方数据
            USR_ThirdLoginMod m_third = new USR_ThirdLoginMod();
            switch (ViewState["type"].ToString())
            {
            case "qq":
                m_third.OpenID     = ViewState["openid"].ToString();
                m_third.AccessKey  = ViewState["code"].ToString();
                m_third.ExpireTime = DateTime.Now.AddSeconds(int.Parse(ViewState["expire"].ToString()));
                m_third.ThirdType  = (int)AppEnum.ThirdLoginType.qq;
                break;

            case "weibo":
                m_third.OpenID    = ViewState["openid"].ToString();
                m_third.AccessKey = ViewState["code"].ToString();
                m_third.ThirdType = (int)AppEnum.ThirdLoginType.weibo;
                break;

            default:
                ShowError("系统故障,请联系管理员");
                break;
            }
            #endregion

            #region 保存数据
            USR_CustomerMod m_user = new USR_CustomerMod();
            try
            {
                m_user.Email         = "";
                m_user.FateType      = int.Parse(drpType.SelectedValue);
                m_user.GradeSysNo    = AppConst.OriginalGrade;;
                m_user.NickName      = ViewState["nickname"].ToString();
                m_user.Password      = "";
                m_user.RegTime       = DateTime.Now;
                m_user.Point         = AppConst.OriginalPoint;
                m_user.Photo         = ViewState["photo"].ToString();
                m_user.LastLoginTime = DateTime.Now;
                if (AppConfig.RegisterEmailCheck.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)
            {
                LogManagement.getInstance().WriteException(ex, "WebForMain.Register", Request.UserHostAddress);
                return;
            }
            #endregion

            #region 登陆状态设置
            if (!(AppConfig.RegisterEmailCheck.ToLower() == "true"))
            {
                SessionInfo m_session = new SessionInfo();
                m_session.CustomerEntity           = m_user;
                m_session.GradeEntity              = USR_GradeBll.GetInstance().GetModel(m_user.SysNo);
                Session[AppConfig.CustomerSession] = m_session;
            }
            #endregion
            if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
            {
                Response.Redirect("RegisterSucc.aspx?url=" + Request.QueryString["url"]);
            }
            else
            {
                Response.Redirect("RegisterSucc.aspx");
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public void Update(USR_ThirdLoginMod model)
        {
            dal.Update(model);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(USR_ThirdLoginMod model)
        {
            return(dal.Add(model));
        }