Ejemplo n.º 1
0
        public Status getAll(int agendaID, out List <VoteInfo> votes)
        {
            votes = new List <VoteInfo>();

            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            VoteDAO voteDao = Factory.getInstance <VoteDAO>();

            wherelist.Add("agendaID", agendaID);
            List <VoteVO> voteVolist = voteDao.getAll <VoteVO>(wherelist);

            if (voteVolist == null)
            {
                return(Status.NONFOUND);
            }
            foreach (VoteVO voteVo in voteVolist)
            {
                wherelist.Clear();

                VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>();
                wherelist.Add("voteID", voteVo.voteID);
                List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist);

                List <String> optionList = new List <string>();
                if (voteOptionVolist != null)
                {
                    //将选项按序号排序
                    voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex);

                    foreach (VoteOptionVO voteOptionVo in voteOptionVolist)
                    {
                        optionList.Add(voteOptionVo.voteOptionName);
                    }
                }
                votes.Add(
                    new VoteInfo
                {
                    voteID          = voteVo.voteID,
                    voteName        = voteVo.voteName,
                    voteDescription = voteVo.voteDescription,
                    voteType        = voteVo.voteType,
                    optionNum       = optionList.Count,
                    options         = optionList
                });
            }

            return(Status.SUCCESS);
        }
Ejemplo n.º 2
0
        public Status getOne(int voteID, out VoteInfo vote)
        {
            vote = new VoteInfo();
            try
            {
                Dictionary <string, object> wherelist = new Dictionary <string, object>();

                VoteDAO       voteDao       = Factory.getInstance <VoteDAO>();
                VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>();

                VoteVO voteVo = voteDao.getOne <VoteVO>(voteID);
                if (voteVo == null)
                {
                    return(Status.NONFOUND);
                }
                //获取表决选项列表
                List <string> voteOptions = new List <string>();
                wherelist.Add("voteID", voteID);
                List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist);
                //将选项按序号排序
                voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex);
                //填充返回列表
                if (voteOptionVolist != null)
                {
                    foreach (VoteOptionVO voteOptionVo in voteOptionVolist)
                    {
                        voteOptions.Add(voteOptionVo.voteOptionName);
                    }
                }

                vote.agendaID        = voteVo.agendaID;
                vote.voteID          = voteVo.voteID;
                vote.voteName        = voteVo.voteName;
                vote.voteDescription = voteVo.voteDescription;
                vote.voteType        = voteVo.voteType;
                vote.optionNum       = voteOptions.Count;
                vote.options         = voteOptions;

                return(Status.SUCCESS);
            }
            catch (Exception e)
            {
                Log.LogInfo("为更新获取表决信息", e);
                return(Status.SERVER_EXCEPTION);
            }
        }