/// <summary> /// The poll_ item command. /// </summary> /// <param name="source"> /// The object source. /// </param> /// <param name="e"> /// The RepeaterCommandEventArgs e. /// </param> protected void Poll_ItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e) { if (e.CommandName != "vote") { return; } if (!this.CanVote) { this.PageContext.AddLoadMessage(this.GetText("WARN_ALREADY_VOTED")); return; } if (this.IsLocked) { this.PageContext.AddLoadMessage(this.GetText("WARN_TOPIC_LOCKED")); return; } if (this.IsClosed) { this.PageContext.AddLoadMessage(this.GetText("WARN_POLL_CLOSED")); return; } object userID = null; object remoteIP = null; if (this.PageContext.BoardSettings.PollVoteTiedToIP) { remoteIP = IPHelper.IPStrToLong(this.Request.ServerVariables["REMOTE_ADDR"]).ToString(); } if (!this.PageContext.IsGuest) { userID = this.PageContext.PageUserID; } LegacyDb.choice_vote(e.CommandArgument, userID, remoteIP); // save the voting cookie... string cookieCurrent = String.Empty; // We check whether is a vote for an option if (this.Request.Cookies[VotingCookieName(Convert.ToInt32(this.PollId))] != null) { // Add the voted option to cookie value string cookieCurrent = "{0},".FormatWith(this.Request.Cookies[VotingCookieName(Convert.ToInt32(this.PollId))].Value); this.Request.Cookies.Remove(VotingCookieName(Convert.ToInt32(this.PollId))); } var c = new HttpCookie( VotingCookieName(this.PollId), "{0}{1}".FormatWith(cookieCurrent, e.CommandArgument.ToString())) { Expires = DateTime.UtcNow.AddYears(1) }; this.Response.Cookies.Add(c); // show an info that the user is voted string msg = this.GetText("INFO_VOTED"); this.BindData(); // Initialize bubble event to update parent control. if (this.ChoiceVoted != null) { this.ChoiceVoted(source, e); } // show the notification window to user this.PageContext.AddLoadMessage(msg); }