public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    NpcInfo[] infos = db.GetAllNPCInfo();
                    foreach (NpcInfo info in infos)
                    {
                        result.Add(FlashUtils.CreatNPCInfo(info));
                    }

                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("Load NPCInfoList is fail!", ex);
            }

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

            return csFunction.CreateCompressXml(context, result, "NPCInfoList", true);
        }
Beispiel #2
0
        private static Dictionary<int, NpcInfo> LoadFromDatabase()
        {
            Dictionary<int, NpcInfo> list = new Dictionary<int, NpcInfo>();

            using (ProduceBussiness db = new ProduceBussiness())
            {
                NpcInfo[] infos = db.GetAllNPCInfo();

                foreach (NpcInfo info in infos)
                {
                    if (!list.ContainsKey(info.ID))
                    {
                        list.Add(info.ID, info);
                    }
                }
            }

            return list;
        }