示例#1
0
        public override void Process(CmdTrigger <IrcCmdArgs> trigger)
        {
            var  chan     = trigger.Args.Channel;
            var  voteChan = trigger.Text.NextWord();
            Vote vote;

            // If we have a channel given in the argument list
            if (voteChan.Length > 0)
            {
                vote = Vote.GetVote(trigger.Args.IrcClient.GetChannel(voteChan));
            }
            vote = Vote.GetVote(chan);

            if (vote != null)
            {
                trigger.Reply("The vote has ended!");
                trigger.Reply(VoteMgr.Mgr.Stats(vote));
                trigger.Reply(VoteMgr.Mgr.Result(vote));
                VoteMgr.Mgr.EndVote(vote);
                return;
            }


            else
            {
                Vote[] votesArray = new Vote[VoteMgr.Votes.Values.Count];
                VoteMgr.Votes.Values.CopyTo(votesArray, 0);
                foreach (var vte in votesArray)
                {
                    VoteMgr.Mgr.EndVote(vte);
                }
                trigger.Reply("Disposed of {0} vote[s].", votesArray.Length);
            }
        }
示例#2
0
        /// <summary>
        /// 获取投票结果详情
        /// </summary>
        /// <returns></returns>
        public ActionResult VoteResult()
        {
            int id = GetRouteInt("id");

            if (id == 0)
            {
                id = WebHelper.GetQueryInt("id");
            }

            VoteInfo voteInfo = Vote.GetVote(id);

            if (voteInfo == null)
            {
                return(PromptView("/", "您访问的页面不存在"));
            }

            List <VoteResultInfo> voteResultInfo = Vote.GetVoteResultsList(id);

            VoteResultModel model = new VoteResultModel
            {
                ResultsList = voteResultInfo,
                Id          = voteInfo.Id,
                Title       = voteInfo.Title,
                State       = voteInfo.State,
                Type        = voteInfo.Type
            };

            return(View(model));
        }
示例#3
0
    protected void BindVote()
    {
        Vote bll = new Vote();

        RepeaterVote.DataSource = bll.GetVote();
        RepeaterVote.DataBind();
    }
示例#4
0
    protected void BindMyVote()
    {
        Vote bll = new Vote();

        MyRadioButtonList.DataSource     = bll.GetVote();
        MyRadioButtonList.DataTextField  = "VoteName";
        MyRadioButtonList.DataValueField = "VoteId";
        MyRadioButtonList.DataBind();
    }
示例#5
0
    public void BindVote()
    {
        Vote bll = new Vote();

        RadioVoteList.DataSource     = bll.GetVote();
        RadioVoteList.DataTextField  = "VoteName";
        RadioVoteList.DataValueField = "VoteId";
        RadioVoteList.DataBind();
    }
示例#6
0
        public override void Process(CmdTrigger <IrcCmdArgs> trigger)
        {
            var chan = trigger.Args.Channel;
            var vote = Vote.GetVote(chan);

            if (vote != null)
            {
                trigger.Reply("Current vote: \"{0}\"", vote.VoteQuestion);
                trigger.Reply("There are a total of '{0}' votes, '{1}' positive, '{2}' negative.", vote.TotalVotes, vote.PositiveCount, vote.NegativeCount);
                trigger.Reply("The vote has ran for {0}.", vote.RunTimeString);
                return;
            }

            trigger.Reply("This channel has no open votes.");
        }
示例#7
0
        public ActionResult EditVote(int Id = -1)
        {
            VoteInfo voteInfo = Vote.GetVote(Id);

            if (voteInfo == null)
            {
                return(PromptView("投票信息不存在"));
            }

            VoteModel model = new VoteModel
            {
                Title     = voteInfo.Title,
                StartTime = voteInfo.StartTime,
                EndTime   = voteInfo.EndTime,
                State     = voteInfo.State,
                Type      = voteInfo.Type
            };

            ViewData["referer"] = SiteUtils.GetAdminRefererCookie();

            return(View(model));
        }
示例#8
0
        public ActionResult EditVote(VoteModel model, int Id = -1)
        {
            VoteInfo voteInfo = Vote.GetVote(Id);

            if (voteInfo == null)
            {
                return(PromptView("投票信息不存在"));
            }

            if (ModelState.IsValid)
            {
                voteInfo.Title     = model.Title;
                voteInfo.StartTime = model.StartTime;
                voteInfo.EndTime   = model.EndTime;
                voteInfo.State     = model.State;
                voteInfo.Type      = model.Type;

                Vote.UpdateVote(voteInfo);
                return(PromptView("投票信息修改成功"));
            }
            ViewData["referer"] = SiteUtils.GetAdminRefererCookie();
            return(View(model));
        }
示例#9
0
    private bool IsConvergentVote(Vote vote, Process process, string votingType)
    {
        if (votingType.Equals("Quality"))
        {
            if ((vote.GetVote() && (process.posVotes > process.negVotes)) ||
                (!vote.GetVote() && (process.posVotes < process.negVotes)))
                return true;
        }
        else
        {
            if ((vote.GetVote() && (process.posDuplicationVotes > process.negDuplicationVotes)) ||
                (!vote.GetVote() && (process.posDuplicationVotes < process.negDuplicationVotes)))
                return true;
        }

        return false;
    }