Example #1
0
        public JObject  QQUserLogion(JObject json)
        {
            JObject job    = new JObject();
            var     result = 0;

            using (var db = new RepositoryBase(DBFactory.Bayetech).BeginTrans())
            {
                QQUserModel order  = JsonConvert.DeserializeObject <QQUserModel>(json.First.Path);
                User        entity = db.FindEntity <User>(t => t.Name == order.nickname);
                if (entity == null)
                {
                    User user = new User();
                    user.Id        = Core.Common.CreatUser("P");
                    user.Name      = order.nickname;
                    user.NameAlias = order.nickname;
                    user.AddTime   = DateTime.Now;
                    db.Insert(user);
                    result = db.Commit();
                    if (result == 1)
                    {
                        job.Add(ResultInfo.Result, JToken.FromObject(true));
                        job.Add(ResultInfo.Data, JToken.FromObject(false));
                    }
                    else
                    {
                        job.Add(ResultInfo.Result, JToken.FromObject(false));
                        job.Add(ResultInfo.Data, JToken.FromObject(false));
                    }
                }
                else
                {
                    entity.UpdateTime = DateTime.Now;
                    db.Update(entity);
                    result = db.Commit();
                    if (result == 1)
                    {
                        if (entity.Phone == "" || entity.Phone == null)
                        {
                            job.Add(ResultInfo.Result, JToken.FromObject(true));
                            job.Add(ResultInfo.Data, JToken.FromObject(false));
                        }
                        else
                        {
                            job.Add(ResultInfo.Result, JToken.FromObject(true));
                            job.Add(ResultInfo.Data, JToken.FromObject(true));
                        }
                    }
                    else
                    {
                        job.Add(ResultInfo.Result, JToken.FromObject(false));
                        job.Add(ResultInfo.Data, JToken.FromObject(false));
                    }
                }
            }

            //MallOrder goodInfo = JsonConvert.DeserializeObject<MallOrder>(json.First.Path);

            return(job);
        }
Example #2
0
        public JsonResult AddFeedback(string openid, string editorContent, string fromcity, string browserName)
        {
            QQUserModel userModel = qqUserService.GetQQUserByOpenId(openid);

            if (userModel == null)
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "非法提交,Openid不存在"
                }));
            }
            if (!userModel.Status.Value)
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "QQ用户已被锁定,无法留言"
                }));
            }
            WebSiteInfo siteInfo         = new WebSiteInfo();
            int         maxFeedbackNum   = Convert.ToInt32(siteInfo.GetWebSiteInfo().MaxFeedbackNum);
            int         todayFeedbackNum = service.GetTodayFeedbackNum(openid);

            if (todayFeedbackNum >= maxFeedbackNum)
            {
                //锁定QQ用户
                userModel.Status = false;
                qqUserService.UpdateQQUser(userModel);
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "留言提交失败,已超出每日最大提交数量"
                }));
            }
            FeedbackModel model = new FeedbackModel()
            {
                SendId   = userModel.Id,
                AcceptId = 0,
                Content  = XSS.FilterXSS(editorContent),
                ParentId = 0,
                City     = fromcity,
                Equip    = browserName,
                CreateOn = DateTime.Now
            };
            bool result = service.CreateModel(model);

            if (result)
            {
                return(Json(new AjaxResult {
                    state = ResultType.success.ToString(), message = "留言提交成功"
                }));
            }
            else
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "留言提交失败"
                }));
            }
        }
Example #3
0
        public JsonResult ReplyComment(string openid, string remarkId, string targetUserId, string articleid, string editorContent)
        {
            QQUserModel userModel = qqUserService.GetQQUserByOpenId(openid);

            if (userModel == null)
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "非法提交,Openid不存在"
                }));
            }
            if (!userModel.Status.Value)
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "QQ用户已被锁定,无法评论"
                }));
            }
            WebSiteInfo siteInfo        = new WebSiteInfo();
            int         maxCommentNum   = Convert.ToInt32(siteInfo.GetWebSiteInfo().MaxCommentNum);
            int         todayCommentNum = service.GetTodayCommentNum(openid);

            if (todayCommentNum >= maxCommentNum)
            {
                //锁定QQ用户
                userModel.Status = false;
                qqUserService.UpdateQQUser(userModel);
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "评论提交失败,已超出每日最大提交数量"
                }));
            }
            CommentModel model = new CommentModel()
            {
                SendId    = userModel.Id,
                AcceptId  = Convert.ToInt32(targetUserId),
                Content   = XSS.FilterXSS(editorContent),
                Status    = true,
                ParentId  = Convert.ToInt32(remarkId),
                ArticleId = Convert.ToInt32(articleid),
                CreateOn  = DateTime.Now
            };
            bool result = service.CreateModel(model);

            if (result)
            {
                return(Json(new AjaxResult {
                    state = ResultType.success.ToString(), message = "评论回复成功"
                }));
            }
            else
            {
                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = "评论回复失败"
                }));
            }
        }
Example #4
0
        public ActionResult Edit(QQUserModel model)
        {
            var result = qqUserService.UpdateModel(model) ? SuccessTip() : ErrorTip();

            return(Json(result));
        }
Example #5
0
        public JsonResult List(QQUserModel filter, PageInfo pageInfo)
        {
            var result = qqUserService.GetListByFilter(filter, pageInfo);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CallBack()
        {
            string backState = Request.QueryString["state"];
            string code      = Request.QueryString["code"];

            if (null != backState && null != code && null != Session["QQLoginState"] && backState == Session["QQLoginState"].ToString())
            {
                Session["QQLoginState"] = null;
                //调获取AccessToken的接口
                string access_token = QQLoginHelper.GetAccessToken(code);
                //调获取OpenID的接口
                string openid = QQLoginHelper.GetOpenId(access_token);
                //调获取用户信息的接口
                QQUserInfo qqUserInfo = QQLoginHelper.GetQQUserInfo(access_token, openid);
                if (qqUserInfo.ret == 0 && string.IsNullOrEmpty(qqUserInfo.msg))
                {
                    QQUserModel userModel = service.GetByWhere("WHERE OpenId='" + openid + "'").FirstOrDefault();
                    if (userModel != null)
                    {
                        //更新QQ用户信息
                        userModel.NickName  = qqUserInfo.nickname;
                        userModel.Gender    = qqUserInfo.gender == "男" ? 1 : 0;
                        userModel.HeadShot  = qqUserInfo.figureurl_qq;
                        userModel.LastLogin = DateTime.Now;
                        service.UpdateModel(userModel);
                    }
                    else
                    {
                        userModel = new QQUserModel();
                        //添加QQ用户
                        userModel.OpenId    = openid;
                        userModel.NickName  = qqUserInfo.nickname;
                        userModel.Gender    = qqUserInfo.gender == "男"?1:0;
                        userModel.HeadShot  = qqUserInfo.figureurl_qq;
                        userModel.Email     = "";
                        userModel.Status    = true;
                        userModel.LastLogin = DateTime.Now;
                        userModel.CreateOn  = DateTime.Now;
                        service.CreateModel(userModel);
                    }
                    Response.Cookies["openid"].Value         = openid;
                    Response.Cookies["openid"].Expires       = DateTime.Now.AddDays(3);
                    Response.Cookies["nickname"].Value       = qqUserInfo.nickname;
                    Response.Cookies["nickname"].Expires     = DateTime.Now.AddDays(3);
                    Response.Cookies["figureurl_qq"].Value   = qqUserInfo.figureurl_qq;
                    Response.Cookies["figureurl_qq"].Expires = DateTime.Now.AddDays(3);
                }
                else
                {
                    //获取用户失败
                    throw new ApplicationException(qqUserInfo.msg);
                }
                if (Session["BeforeLoginUrl"] != null)
                {
                    return(Redirect(Session["BeforeLoginUrl"].ToString())); //返回登陆之前的URL
                }
                else
                {
                    throw new Exception("登录之前的路由丢失");
                }
            }
            else
            {
                throw new Exception("登录State已丢失或不正确");
            }
        }