Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            Guid id = Guid.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]))
            {
                id = new Guid(context.Request.QueryString["ID"]);
            }
            int top = 5;

            if (!string.IsNullOrEmpty(context.Request.QueryString["topcount"]))
            {
                top = int.Parse(context.Request.QueryString["topcount"]);
            }
            string Newtype = "self";

            if (!string.IsNullOrEmpty(context.Request.QueryString["NewType"]))
            {
                Newtype = context.Request.QueryString["NewType"];
            }
            List <ClassNewInfo> Newlist;

            switch (Newtype)
            {
            case "classtea":
                Newlist = GetNewInfoByClassTea(id, top);
                break;

            case "classstu":
                Newlist = GetNewInfoByClassStu(id, top);
                break;

            default:
                Newlist = GetNewInfoByClassTea(id, top);
                Newlist.AddRange(GetNewInfoByClassStu(id, top));
                break;
            }

            string Newjson = "";
            string split   = string.Empty;

            foreach (ClassNewInfo item in Newlist)
            {
                Newjson += string.Format("{3}{{\"newuser\":\"{0}\",\"newcontent\":\"{1}\",\"newdate\":\"{2}\"}}", item.NewUser,
                                         item.Newcontent, item.NewDate, split);
                split = ",";
            }
            Newjson = string.Format("[{0}]", Newjson);
            context.Response.ContentType = "text/plain";
            context.Response.Write(Newjson);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            Guid id = Guid.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]))
            {
                id = new Guid(context.Request.QueryString["ID"]);
            }
            int top = 5;

            if (!string.IsNullOrEmpty(context.Request.QueryString["topcount"]))
            {
                top = int.Parse(context.Request.QueryString["topcount"]);
            }
            string Newtype = "self";

            if (!string.IsNullOrEmpty(context.Request.QueryString["NewType"]))
            {
                Newtype = context.Request.QueryString["NewType"];
            }
            List <NewInfo> Newlist;

            switch (Newtype)
            {
            case "self":
                Newlist = GetNewInfoBySelf(id, top);
                break;

            case "classtea":
                Newlist = GetNewInfoByClassTea(id, top);
                break;

            case "classstu":
                Newlist = GetNewInfoByClassStu(id, top);
                break;

            case "classes":
                Newlist = GetArtileInfoByClassTea(id, top);

                break;

            case "hotclasses":
                Newlist = GetHotInfoByClassTea(id, top);
                break;

            default:
                Newlist = GetNewInfoByClassTea(id, top);
                Newlist.AddRange(GetNewInfoByClassStu(id, top));
                break;
            }

            string Newjson = "";
            string split   = string.Empty;

            foreach (NewInfo item in Newlist)
            {
                Newjson += string.Format("{0}{{\"newsuser\":\"{1}\",\"newscontent\":\"{2}\",\"newsdate\":\"{3}\",\"writefrom\":\"{4}\",\"pid\":\"{5}\",\"title\":\"{6}\"}}", split, item.NewUser,
                                         UCHome_BaseOper.EncodeBase64(item.Newcontent), item.NewDate.ToShortDateString(), item.writefrom, item.pid, item.title);
                split = ",";
            }
            Newjson = string.Format("[{0}]", Newjson);
            context.Response.ContentType = "text/plain";
            context.Response.Write(Newjson);
        }