Exemplo n.º 1
0
        public void Insert(LabMS.Model.VoteJson voteJson)
        {
            LabMS.Model.Vote voteInfo = new LabMS.Model.Vote();

            voteInfo.VoteTitle = voteJson.Title;
            voteInfo.VoteStartTime = DateTime.Now;

            voteInfo.VoteLimit = voteJson.Limit;

            voteInfo.key = base.Add(voteInfo); // Insert vote

            foreach (LabMS.Model.VoteItemJson item in voteJson.Items)
            {
                LabMS.Model.VoteItem voteItemInfo = new LabMS.Model.VoteItem();
                LabMS.BLL.VoteItem voteItem = new LabMS.BLL.VoteItem();
                voteItemInfo.VoteID = voteInfo.key;
                voteItemInfo.VoteItemContent = item.Title;

                voteItemInfo.key = voteItem.Add(voteItemInfo); // Insert Item

                foreach (LabMS.Model.VoteAnswerJson answer in item.Answers)
                {
                    LabMS.Model.VoteAnswer voteAnswerInfo = new LabMS.Model.VoteAnswer();
                    LabMS.BLL.VoteAnswer voteAnswer = new LabMS.BLL.VoteAnswer();

                    voteAnswerInfo.VoteItemID = voteItemInfo.key;
                    voteAnswerInfo.VoteAnswerContent = answer.Name;

                    voteAnswer.Add(voteAnswerInfo); // Insert answer
                }
            }
        }
Exemplo n.º 2
0
        protected string CreateCharts(LabMS.Model.Vote vi)
        {
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            System.Text.StringBuilder sbXml = new System.Text.StringBuilder();

            LabMS.BLL.Vote vote = new LabMS.BLL.Vote();
            LabMS.BLL.VoteAnswer voteAnswer = new LabMS.BLL.VoteAnswer();
            LabMS.BLL.VoteItem voteItem = new LabMS.BLL.VoteItem();
            LabMS.BLL.VoteRecordDetail voteRecordDetail = new LabMS.BLL.VoteRecordDetail();

            List<LabMS.Model.VoteItem> voteItems;
            List<LabMS.Model.VoteAnswer> voteAnswers;
            List<LabMS.Model.VoteRecordDetail> voteRecordDetails;

            string[] colors = new string[] {
                "F6BD0F",
                "8BBA00",
                "A66EDD",
                "F984A1",
                "CCCC00",
                "999999",
                "0099CC",
                "FF0000",
                "006F00",
                "0099FF",
                "FF66CC",
                "669966",
                "7C7CB4",
                "FF9933",
                "9900FF",
                "99FFCC",
                "CCCCFF",
                "669900",
                "1941A5",
                "AFD8F8"
            };

            voteItems = voteItem.GetModelList(" VoteID = " + vi.key.ToString());

            Random random = new Random();

            foreach (LabMS.Model.VoteItem vii in voteItems)
            {
                sbXml = new System.Text.StringBuilder();
                sbXml.Append("<graph caption='");
                sbXml.Append(HandleString(vii.VoteItemContent));
                sbXml.Append("' xAxisName='评价项' yAxisName='票数' decimalPrecision='0' formatNumberScale='0'>");

                voteAnswers = voteAnswer.GetModelList(" VoteItemID = " + vii.key.ToString());

                int i = Math.Abs(random.Next());
                i = random.Next(i) / colors.Length;

                foreach (LabMS.Model.VoteAnswer vai in voteAnswers)
                {
                    voteRecordDetails = voteRecordDetail.GetModelList(
                        " VoteItemID = " +
                        vii.key.ToString() +
                        " and VoteAnswerID = " +
                        vai.key.ToString()
                    );

                    sbXml.Append(string.Format("<set name='{0}' value='{1}' color='{2}' />",
                       HandleString(vai.VoteAnswerContent), voteRecordDetails.Count, colors[i++ % colors.Length]));
                }
                sbXml.Append("</graph>");

                result.Append(
                        InfoSoftGlobal.FusionCharts.RenderChartHTML("../FusionCharts/FCF_Bar2D.swf",
                            "",
                            sbXml.ToString(), "item" + vii.key, "600", "200", false)
                    );
            }

            return result.ToString();
        }