Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //int uid = Convert.ToInt32(Request.QueryString["state"]);
                M_UserInfo   mu       = buser.GetLogin();//注意域名不要子域名跳过来
                M_User_Token tokenMod = tokenbll.SelModelByUid(mu.UserID);
                if (tokenMod == null)
                {
                    tokenMod = new M_User_Token();
                }
                switch (Request.QueryString["s"])
                {
                case "qq":    //使用JS SDK
                    break;

                default:    //Sina
                    string code = Request.QueryString["code"];
                    if (!string.IsNullOrEmpty(code))
                    {
                        M_Third_Info appmod  = thirdBll.SelModelByName("Sina");
                        SinaHelper   sinaBll = new SinaHelper(null);
                        tokenMod.uid       = mu.UserID;
                        tokenMod.SinaToken = sinaBll.GetTokenByCode(code);
                        tokenbll.InsertORUpdate(tokenMod);
                    }
                    Response.Redirect("/Plat/UpCenter.aspx?Set=1");
                    break;
                }
            }
        }
Exemple #2
0
 private void showViboIcons(int uid)
 {
     tokenMod = tokenbll.SelModelByUid(uid);
     if (tokenMod == null)
     {
         return;
     }
     if (!string.IsNullOrEmpty(tokenMod.SinaToken))
     {
         SinaHelper sina = new SinaHelper(tokenMod.SinaToken);
         if (sina.CheckToken())
         {
             JObject uinfo = sina.GetUserState(sina.GetUid());
             sinaStatu_D.InnerText = "(已绑定)";//" + uinfo["screen_name"].ToString() + "
             sinaimg.Style.Add("color", "rgb(10, 164, 231)");
             Sina_Btn.Text = "修改绑定";
         }
         else
         {
             sinaStatu_D.InnerText = "(已过期)";
         }
     }
     if (!string.IsNullOrEmpty(tokenMod.QQToken))
     {
         QQHelper qqhelper = new QQHelper(tokenMod.QQToken, tokenMod.QQOpenID);
         if (qqhelper.TokenIsValid())
         {
             QQStatus_Div.InnerText = "(已绑定:" + tokenMod.QQUName + ")";
             qqimg.Style.Add("color", "rgb(10, 164, 231)");
             QQSPan.InnerText = "修改绑定";
         }
         else
         {
             QQStatus_Div.InnerText = "(已过期:" + tokenMod.QQUName + ")";
         }
     }
 }
Exemple #3
0
        //新浪社会化登录(跳转链接)
        public void Login_Sina()
        {
            B_User_Token tokenBll = new B_User_Token();
            M_User_Token tokenMod = tokenBll.SelModelByUid(buser.GetLogin().UserID);

            if (tokenMod != null)//已存有用户信息,则直接登录
            {
                SinaHelper sinaBll = new SinaHelper(tokenMod.SinaToken);
                Response.Redirect(sinaBll.GetAuthUrl()); return;
            }
            else
            {
                SinaHelper sinaBll = new SinaHelper("");
                Response.Redirect(sinaBll.GetAuthUrl()); return;
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region AJAX请求
            //正数为消息,负数为贴吧
            if (function.isAjax())
            {
                string action = Request["action"];
                string result = "";
                int    id     = DataConvert.CLng(Regex.Split(Request["value"] ?? "", ":::")[0]);
                //思路,信息都存在贴吧中,ID为负数
                switch (action)
                {
                case "add":
                {
                    string puremsg = "";
                    msgMod = FillMsg(Request.Form["MsgContent_T"], out puremsg);
                    result = msgBll.Insert(msgMod).ToString();
                    #region  步至微博
                    if (!string.IsNullOrWhiteSpace(Request.Form["sync_chk"]))
                    {
                        puremsg = StringHelper.SubStr(puremsg, 140, "");
                        string       sync     = Request.Form["sync_chk"];
                        M_UserInfo   mu       = buser.GetLogin();
                        M_User_Token tokenMod = tokenBll.SelModelByUid(mu.UserID);
                        if (tokenMod != null)
                        {
                            try
                            {
                                if (sync.Contains("qqblog") && !string.IsNullOrWhiteSpace(tokenMod.QQToken))
                                {
                                    qqBll = new QQHelper(tokenMod.QQToken, tokenMod.QQOpenID);
                                    if (!string.IsNullOrEmpty(msgMod.Attach))
                                    {
                                        qqBll.AddBlog(puremsg, msgMod.Attach.Split('|')[0]);
                                    }
                                    else
                                    {
                                        qqBll.AddBlog(puremsg);
                                    }
                                }
                                if (sync.Contains("sina") && !string.IsNullOrWhiteSpace(tokenMod.SinaToken))
                                {
                                    sinaBll = new SinaHelper(tokenMod.SinaToken);
                                    string err = sinaBll.PostStatus(puremsg, (msgMod.Attach ?? "").Split('|')[0]);
                                    ZLLog.L(err);
                                }
                            }
                            catch (Exception ex) { ZLLog.L("[" + sync + "]同步失败,用户[" + mu.UserName + "]原因:" + ex.Message); }
                        }
                    }
                    #endregion
                }
                break;

                case "addvote":
                {
                    msgMod            = FillMsg(Request.Form["MsgContent_T"]);
                    msgMod.MsgType    = 2;
                    msgMod.Title      = HttpUtility.HtmlEncode(VoteTitle_T.Text);
                    msgMod.VoteOP     = Request.Form["VoteOption_T1"] + "," + Request.Form["VoteOption_T"];    //为Jquery验证
                    msgMod.VoteOP     = HttpUtility.HtmlEncode(msgMod.VoteOP);
                    msgMod.VoteResult = "";
                    msgMod.EndTime    = DateTime.Parse(EndDate_T.Text);
                    result            = msgBll.Insert(msgMod).ToString();
                }
                break;

                case "addarticle":    //里面包含html|图片|附件,暂不同步微博
                {
                    string   msg      = Request.Form["msg"];
                    UEHelper ueHelper = new UEHelper();
                    msgMod            = FillMsg("");
                    msgMod.MsgContent = msg;
                    msgMod.MsgType    = 3;
                    msgMod.Title      = ueHelper.GetSubTitle(msgMod.MsgContent);
                    result            = msgBll.Insert(msgMod).ToString();
                }
                break;

                case "AddReply":
                case "AddReply2":
                    if (id == 0)
                    {
                        throw new Exception("传入的ID不正确");
                    }
                    result = PlatAJAX();
                    break;

                case "UserVote":
                    result = PlatAJAX();
                    break;

                default:
                    if (id == 0)
                    {
                        throw new Exception("信息ID不正确");
                    }
                    if (id > 0)
                    {
                        result = PlatAJAX();
                    }
                    else
                    {
                        result = BarAJAX();
                    }
                    break;
                }
                Response.Write(result); Response.Flush(); Response.End();
            }
            #endregion
            if (!IsPostBack)
            {
                MyBind();
            }
        }
Exemple #5
0
        public ContentResult Blog_API()
        {
            //正数为plat,负数为bar
            string action = GetParam("action");
            string result = "";
            int    id     = DataConvert.CLng(Regex.Split(GetParam("value"), ":::")[0]);

            //思路,信息都存在贴吧中,ID为负数
            switch (action)
            {
            case "add":
            {
                string puremsg = "";
                msgMod = FillMsg(Request.Form["MsgContent_T"], out puremsg);
                result = msgBll.Insert(msgMod).ToString();
                #region  步至微博
                if (!string.IsNullOrWhiteSpace(Request.Form["sync_chk"]))
                {
                    puremsg = StringHelper.SubStr(puremsg, 140, "");
                    string       sync     = Request.Form["sync_chk"];
                    M_User_Token tokenMod = tokenBll.SelModelByUid(mu.UserID);
                    if (tokenMod != null)
                    {
                        try
                        {
                            if (sync.Contains("sina") && !string.IsNullOrWhiteSpace(tokenMod.SinaToken))
                            {
                                //sinaBll = new SinaHelper(tokenMod.SinaToken);
                                //string err = sinaBll.PostStatus(puremsg, (msgMod.Attach ?? "").Split('|')[0]);
                                //ZLLog.L(err);
                            }
                        }
                        catch (Exception ex) { ZLLog.L("[" + sync + "]同步失败,用户[" + mu.UserName + "]原因:" + ex.Message); }
                    }
                }
                #endregion
            }
            break;

            case "addvote":
            {
                msgMod            = FillMsg(Request.Form["MsgContent_T"]);
                msgMod.MsgType    = 2;
                msgMod.Title      = HttpUtility.HtmlEncode(GetParam("VoteTitle_T"));
                msgMod.VoteOP     = Request.Form["VoteOption_T1"] + "," + Request.Form["VoteOption_T"];    //为Jquery验证
                msgMod.VoteOP     = HttpUtility.HtmlEncode(msgMod.VoteOP);
                msgMod.VoteResult = "";
                msgMod.EndTime    = DateTime.Parse(GetParam("EndDate_T"));
                result            = msgBll.Insert(msgMod).ToString();
            }
            break;

            case "addarticle":    //里面包含html|图片|附件,暂不同步微博
            {
                string   msg      = GetParam("msg");
                UEHelper ueHelper = new UEHelper();
                msgMod            = FillMsg("");
                msgMod.MsgContent = msg;
                msgMod.MsgType    = 3;
                msgMod.Title      = ueHelper.GetSubTitle(msgMod.MsgContent);
                result            = msgBll.Insert(msgMod).ToString();
            }
            break;

            case "AddReply":
            case "AddReply2":
                if (id == 0)
                {
                    throw new Exception("传入的ID不正确");
                }
                result = PlatAJAX();
                break;

            case "UserVote":
                result = PlatAJAX();
                break;

            default:
                if (id == 0)
                {
                    throw new Exception("信息ID不正确");
                }
                if (id > 0)
                {
                    result = PlatAJAX();
                }
                else
                {
                    result = BarAJAX();
                }
                break;
            }
            return(Content(result));
        }