Example #1
0
        public static string BuildCelebConsortia(string file, int order, string fileNotCompress)
        {
            bool     value   = false;
            string   message = "Fail!";
            XElement result  = new XElement("Result");
            int      total   = 0;

            try
            {
                int page = 1;
                int size = 50;
                //int order = 10;
                int    consortiaID = -1;
                string name        = "";
                int    level       = -1;

                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    ConsortiaInfo[] infos = db.GetConsortiaPage(page, size, ref total, order, name, consortiaID, level, -1);
                    foreach (ConsortiaInfo info in infos)
                    {
                        XElement node = FlashUtils.CreateConsortiaInfo(info);

                        if (info.ChairmanID != 0)
                        {
                            using (PlayerBussiness pb = new PlayerBussiness())
                            {
                                PlayerInfo player = pb.GetUserSingleByUserID(info.ChairmanID);
                                if (player != null)
                                {
                                    node.Add(FlashUtils.CreateCelebInfo(player));
                                }
                            }
                        }
                        result.Add(node);
                    }

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

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

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

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

            try
            {
                //page=1&
                //level=%2D1&
                //ConsortiaID=4&
                //openApply=%2D1&
                //size=1&
                //name=&
                //key=f231292ae606ad5b61fafa816805f47c&
                //order=%2D1&
                //selfid=5&
                //rnd=0%2E6236354559659958
                int    page        = int.Parse(context.Request["page"]);
                int    size        = int.Parse(context.Request["size"]);
                int    order       = int.Parse(context.Request["order"]);
                int    consortiaID = int.Parse(context.Request["consortiaID"]);
                string name        = csFunction.ConvertSql(HttpUtility.UrlDecode(context.Request["name"]));
                int    level       = int.Parse(context.Request["level"]);
                //-1表示全部,1开启的,0关闭的。
                int openApply = int.Parse(context.Request["openApply"]);

                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    ConsortiaInfo[] infos = db.GetConsortiaPage(page, size, ref total, order, name, consortiaID, level, openApply);
                    foreach (ConsortiaInfo info in infos)
                    {
                        result.Add(FlashUtils.CreateConsortiaInfo(info));
                    }

                    value   = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("ConsortiaList", 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.BinaryWrite(StaticFunction.Compress(result.ToString(false)));
        }
Example #3
0
        public static void Process(IHttpRequest Request, IHttpResponse Response)
        {
            bool     value   = false;
            string   message = "Fail!";
            XElement result  = new XElement("Result");
            int      total   = 0;
            int      systemConsortiaCount = 0;

            try
            {
                int    page        = int.Parse(Request.Uri.QueryString["page"]);
                int    size        = int.Parse(Request.Uri.QueryString["size"]);
                int    order       = int.Parse(Request.Uri.QueryString["order"]);
                int    consortiaID = int.Parse(Request.Uri.QueryString["consortiaID"]);
                string name        = csFunction.ConvertSql(HttpUtility.UrlDecode(Request.Uri.QueryString["name"]));
                int    level       = int.Parse(Request.Uri.QueryString["level"]);
                int    openApply   = int.Parse(Request.Uri.QueryString["openApply"]);
                if (name == "" && consortiaID == -1 && level == -1)
                {
                    using (ConsortiaBussiness db = new ConsortiaBussiness())
                    {
                        List <ConsortiaInfo> systemConsortia       = db.GetAllSystemConsortia().ToList <ConsortiaInfo>();
                        List <ConsortiaInfo> activeSystemConsortia = new List <ConsortiaInfo>();
                        if (page <= 3)
                        {
                            systemConsortiaCount = 3;
                        }
                        else
                        {
                            systemConsortiaCount = 2;
                        }
                        if (systemConsortia.Count <= systemConsortiaCount)
                        {
                            foreach (ConsortiaInfo info in systemConsortia)
                            {
                                result.Add(FlashUtils.CreateConsortiaInfo(info));
                            }
                            systemConsortiaCount = systemConsortia.Count;
                        }
                        else
                        {
                            ThreadSafeRandom random = new ThreadSafeRandom();
                            foreach (ConsortiaInfo info in systemConsortia)
                            {
                                if (info.IsActive)
                                {
                                    activeSystemConsortia.Add(info);
                                }
                            }
                            if (activeSystemConsortia.Count > systemConsortiaCount)
                            {
                                for (int i = 0; i < systemConsortiaCount; i++)
                                {
                                    int index = random.Next(activeSystemConsortia.Count);
                                    result.Add(FlashUtils.CreateConsortiaInfo(activeSystemConsortia.ElementAt(index)));
                                    activeSystemConsortia.RemoveAt(index);
                                }
                            }
                            else
                            {
                                int otherConsortia = systemConsortiaCount - activeSystemConsortia.Count;
                                foreach (ConsortiaInfo info in activeSystemConsortia)
                                {
                                    result.Add(FlashUtils.CreateConsortiaInfo(info));
                                }
                                while (otherConsortia > 0)
                                {
                                    int index = random.Next(systemConsortia.Count);
                                    if (!activeSystemConsortia.Contains(systemConsortia[index]))
                                    {
                                        result.Add(FlashUtils.CreateConsortiaInfo(systemConsortia.ElementAt(index)));
                                        systemConsortia.RemoveAt(index);
                                        otherConsortia--;
                                    }
                                }
                            }
                        }
                        size -= systemConsortiaCount;
                        if (size < 0)
                        {
                            size = 0;
                        }
                        consortiaID = -2;
                    }
                }
                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    ConsortiaInfo[] infos = db.GetConsortiaPage(page, size, ref total, order, name, consortiaID, level, openApply);
                    ConsortiaInfo[] array = infos;
                    for (int j = 0; j < array.Length; j++)
                    {
                        ConsortiaInfo info = array[j];
                        result.Add(FlashUtils.CreateConsortiaInfo(info));
                    }
                    value   = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
            }
            result.Add(new XAttribute("total", total));
            result.Add(new XAttribute("vaule", value));
            result.Add(new XAttribute("message", message));
            Response.Write(csFunction.Compress(result.ToString(false)));
        }