コード例 #1
0
ファイル: csFunction.cs プロジェクト: vancourt/BaseGunnyII
        public static string BuildCelebUsers(string file, int order, string fileNotCompress)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                int page = 1;
                int size = 50;
                //int order = 5;
                int userID = -1;
                int total = 0;
                bool resultValue = false;

                using (PlayerBussiness db = new PlayerBussiness())
                {
                    PlayerInfo[] infos = db.GetPlayerPage(page, size, ref total, order, userID, ref resultValue);
                    if (resultValue)
                    {
                        foreach (PlayerInfo info in infos)
                        {
                            result.Add(FlashUtils.CreateCelebInfo(info));
                        }
                        value = true;
                        message = "Success!";
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(file + " is fail!", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));
            result.Add(new XAttribute("date", System.DateTime.Today.ToString("yyyy-MM-dd")));

            //csFunction.CreateCompressXml(result, "CelebForUsers", false);
            if (!string.IsNullOrEmpty(fileNotCompress))
            {
                csFunction.CreateCompressXml(result, fileNotCompress, false);
            }

            return csFunction.CreateCompressXml(result, file, true);
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
                bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");
            int total = 0;

            try
            {
                int page = 1;//int.Parse(context.Request["page"]);
                int size = 10;//int.Parse(context.Request["size"]);
                int order = int.Parse(context.Request["order"]);
                int userID = -1;// int.Parse(context.Request["state"]);
                bool resultValue = false;

                using (PlayerBussiness db = new PlayerBussiness())
                {
                    PlayerInfo[] infos = db.GetPlayerPage(page, size, ref total, order, userID, ref resultValue);
                    if (resultValue)
                    {
                        foreach (PlayerInfo info in infos)
                        {
                            XElement node = new XElement("Item", new XAttribute("ID", info.ID),
                           new XAttribute("NickName", info.NickName == null ? "" : info.NickName),
                           new XAttribute("Grade", info.Grade),
                           new XAttribute("Colors", info.Colors == null ? "" : info.Colors),
                           new XAttribute("Skin", info.Skin == null ? "" : info.Skin),
                           new XAttribute("Sex", info.Sex),
                           new XAttribute("Style", info.Style == null ? "" : info.Style),
                           new XAttribute("ConsortiaName", info.ConsortiaName == null ? "" : info.ConsortiaName),
                           new XAttribute("Hide", info.Hide),
                           new XAttribute("Offer", info.Offer),
                           new XAttribute("ReputeOffer", info.ReputeOffer),
                           new XAttribute("ConsortiaHonor", info.ConsortiaHonor),
                           new XAttribute("ConsortiaLevel", info.ConsortiaLevel),
                           new XAttribute("ConsortiaRepute", info.ConsortiaRepute),
                           new XAttribute("WinCount", info.Win),
                           new XAttribute("TotalCount", info.Total),
                           new XAttribute("EscapeCount", info.Escape),
                           new XAttribute("Repute", info.Repute),
                           new XAttribute("GP", info.GP));

                            result.Add(node);
                        }

                        value = true;
                        message = "Success!";
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("LoadUsersSort", ex);
            }

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

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));
        

        }