Пример #1
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    QuestInfo[] quests = db.GetALlQuest();
                    QuestAwardInfo[] questgoods = db.GetAllQuestGoods();
                    QuestConditionInfo[] questcondiction = db.GetAllQuestCondiction();
                    QuestRateInfo[] questrate = db.GetAllQuestRate();
                    foreach (QuestInfo quest in quests)
                    {
                        //添加任务模板
                        XElement temp_xml = FlashUtils.CreateQuestInfo(quest);

                        //添加任何条件
                        IEnumerable temp_questcondiction = questcondiction.Where(s => s.QuestID == quest.ID);
                        foreach (QuestConditionInfo item1 in temp_questcondiction)
                        {
                            temp_xml.Add(FlashUtils.CreateQuestCondiction(item1));
                        }

                        //添加任务奖励
                        IEnumerable temp_questgoods = questgoods.Where(s => s.QuestID == quest.ID);
                        foreach (QuestAwardInfo item2 in temp_questgoods)
                        {
                            temp_xml.Add(FlashUtils.CreateQuestGoods(item2));
                        }
                        //<Rate BindMoneyRate="1|1|1|1" ExpRate="1.5|2|2.5|3" GoldRate="1.5|2|2.5|3" ExploitRate="1.5|2|2.5|3" CanOneKeyFinishTime="3" />
                        result.Add(temp_xml);
                    }
                    foreach (QuestRateInfo quest in questrate)
                    {
                        XElement temp_xml1 = FlashUtils.CreateQuestRate(quest);
                        result.Add(temp_xml1);
                    }
                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("QuestList", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            //return result.ToString(false);
            return csFunction.CreateCompressXml(context, result, "QuestList", true);
        }