示例#1
0
 private void Vote(VoteInfo vote)
 {
     System.Web.HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies[this.voteId.ToString()];
     if (httpCookie == null)
     {
         if (this.Page.Request.Params["VoteItemId"] != null)
         {
             string text = this.Page.Request.Params["VoteItemId"];
             if (!string.IsNullOrEmpty(text))
             {
                 string[] array = text.Split(new char[]
                 {
                     ','
                 });
                 for (int i = 0; i < array.Length; i++)
                 {
                     if (!string.IsNullOrEmpty(array[i]) && i + 1 <= vote.MaxCheck)
                     {
                         long         voteItemId   = System.Convert.ToInt64(array[i]);
                         VoteItemInfo voteItemById = CommentBrowser.GetVoteItemById(voteItemId);
                         if (vote.VoteId == voteItemById.VoteId)
                         {
                             CommentBrowser.Vote(voteItemId);
                         }
                     }
                 }
                 httpCookie         = new System.Web.HttpCookie(this.voteId.ToString());
                 httpCookie.Expires = System.DateTime.Now.AddYears(100);
                 httpCookie.Value   = this.voteId.ToString();
                 HiContext.Current.Context.Response.Cookies.Add(httpCookie);
                 this.ShowMessage("投票成功", true);
                 return;
             }
         }
     }
     else
     {
         if (httpCookie != null && !string.IsNullOrEmpty(this.Page.Request.QueryString["VoteItemId"].ToString()))
         {
             this.ShowMessage("该用户已经投过票了", false);
         }
     }
 }
示例#2
0
        void Vote(VoteInfo vote)
        {
            HttpCookie cookie = HiContext.Current.Context.Request.Cookies[this.voteId.ToString()];

            if (cookie == null)
            {
                if (this.Page.Request.Params["VoteItemId"] != null)
                {
                    string str = this.Page.Request.Params["VoteItemId"];
                    if (!string.IsNullOrEmpty(str))
                    {
                        string[] strArray = str.Split(new char[] { ',' });
                        for (int i = 0; i < strArray.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(strArray[i]) && ((i + 1) <= vote.MaxCheck))
                            {
                                long         voteItemId   = Convert.ToInt64(strArray[i]);
                                VoteItemInfo voteItemById = CommentBrowser.GetVoteItemById(voteItemId);
                                if (vote.VoteId == voteItemById.VoteId)
                                {
                                    CommentBrowser.Vote(voteItemId);
                                }
                            }
                        }
                        cookie         = new HttpCookie(this.voteId.ToString());
                        cookie.Expires = DateTime.Now.AddYears(100);
                        cookie.Value   = this.voteId.ToString();
                        HiContext.Current.Context.Response.Cookies.Add(cookie);
                        this.ShowMessage("投票成功", true);
                    }
                }
            }
            else if ((cookie != null) && !string.IsNullOrEmpty(this.Page.Request.QueryString["VoteItemId"].ToString()))
            {
                this.ShowMessage("该用户已经投过票了", false);
            }
        }