コード例 #1
0
ファイル: QAService.cs プロジェクト: qubianzhong/luckysign
        public QA_CommentShow MapQA_CommentShow(DataRow input)
        {
            QA_CommentShow       ret   = new QA_CommentShow();
            USR_CustomerMaintain tmpuu = new USR_CustomerMaintain();

            USR_CustomerBll.GetInstance().GetModel(int.Parse(input["CustomerSysNo"].ToString())).MemberwiseCopy(tmpuu);
            ret.Customer = tmpuu;
            if (input["AnswerSysNo"].ToString() != "")
            {
                ret.AnswerSysNo = int.Parse(input["AnswerSysNo"].ToString());
            }
            ret.Context = input["Context"].ToString();
            if (input["CustomerSysNo"].ToString() != "")
            {
                ret.CustomerSysNo = int.Parse(input["CustomerSysNo"].ToString());
            }
            if (input["DR"].ToString() != "")
            {
                ret.DR = int.Parse(input["DR"].ToString());
            }
            if (input["QuestionSysNo"].ToString() != "")
            {
                ret.QuestionSysNo = int.Parse(input["QuestionSysNo"].ToString());
            }
            if (input["SysNo"].ToString() != "")
            {
                ret.SysNo = int.Parse(input["SysNo"].ToString());
            }
            if (input["TS"].ToString() != "")
            {
                ret.TS = DateTime.Parse(input["TS"].ToString());
            }
            return(ret);
        }
コード例 #2
0
ファイル: QAService.cs プロジェクト: qubianzhong/luckysign
        public ReturnValue <PageInfo <QA_AnswerShow> > GetAnswerByQuest(int pagesize, int pageindex, int sysno)
        {
            int                      total = 0;
            DataTable                m_dt  = QA_AnswerBll.GetInstance().GetListByQuest(pagesize, pageindex, sysno, ref total);
            List <QA_AnswerShow>     ret   = new List <QA_AnswerShow>();
            PageInfo <QA_AnswerShow> rett  = new PageInfo <QA_AnswerShow>();

            if (m_dt == null || m_dt.Rows.Count == 0)
            {
                rett.List        = ret;
                rett.Total       = total;
                rett.HasNextPage = false;
                return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett));
            }

            for (int i = 0; i < m_dt.Rows.Count; i++)
            {
                QA_AnswerShow    tmp_answer = MapQA_AnswerShow(m_dt.Rows[i]);
                USR_CustomerShow tmpu       = new USR_CustomerShow();
                USR_CustomerBll.GetInstance().GetModel(tmp_answer.CustomerSysNo).MemberwiseCopy(tmpu);
                tmp_answer.Customer = tmpu;
                DataTable tmp_dt = QA_CommentBll.GetInstance().GetListByAnswer(tmp_answer.SysNo);
                if (tmp_dt != null && tmp_dt.Rows.Count > 0)
                {
                    List <QA_CommentShow> commentlist = new List <QA_CommentShow>();
                    for (int j = 0; j < tmp_dt.Rows.Count && j <= 3; j++)
                    {
                        QA_CommentShow       tmp_comment = MapQA_CommentShow(tmp_dt.Rows[j]);
                        USR_CustomerMaintain tmpuu       = new USR_CustomerMaintain();
                        USR_CustomerBll.GetInstance().GetModel(tmp_comment.CustomerSysNo).MemberwiseCopy(tmpuu);
                        tmp_comment.Customer = tmpuu;
                        commentlist.Add(tmp_comment);
                    }
                    tmp_answer.TopComments = commentlist;
                    tmp_answer.ToalComment = tmp_dt.Rows.Count;
                    if (tmp_dt.Rows.Count > 3)
                    {
                        tmp_answer.HasMoreComment = true;
                    }
                    else
                    {
                        tmp_answer.HasMoreComment = false;
                    }
                }
                ret.Add(tmp_answer);
            }

            rett.List  = ret;
            rett.Total = total;
            if (pagesize * pageindex >= total)
            {
                rett.HasNextPage = false;
            }
            else
            {
                rett.HasNextPage = true;
            }
            return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett));
        }
コード例 #3
0
        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("账号或密码错误,请重新输入!");
            }
        }
コード例 #4
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));
        }
コード例 #5
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));
        }
コード例 #6
0
        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("系统故障,注册失败");
            }
        }