Example #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);
        }
Example #2
0
        public override string ToString()
        {
            var sb    = new StringBuilder("VersioningTestV2(");
            int tmp87 = 0;

            if (__isset.begin_in_both)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Begin_in_both: ");
                Begin_in_both.ToString(sb);
            }
            if (__isset.newint)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newint: ");
                Newint.ToString(sb);
            }
            if (__isset.newbyte)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newbyte: ");
                Newbyte.ToString(sb);
            }
            if (__isset.newshort)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newshort: ");
                Newshort.ToString(sb);
            }
            if (__isset.newlong)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newlong: ");
                Newlong.ToString(sb);
            }
            if (__isset.newdouble)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newdouble: ");
                Newdouble.ToString(sb);
            }
            if ((Newstruct != null) && __isset.newstruct)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newstruct: ");
                Newstruct.ToString(sb);
            }
            if ((Newlist != null) && __isset.newlist)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newlist: ");
                Newlist.ToString(sb);
            }
            if ((Newset != null) && __isset.newset)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newset: ");
                Newset.ToString(sb);
            }
            if ((Newmap != null) && __isset.newmap)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newmap: ");
                Newmap.ToString(sb);
            }
            if ((Newstring != null) && __isset.newstring)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("Newstring: ");
                Newstring.ToString(sb);
            }
            if (__isset.end_in_both)
            {
                if (0 < tmp87++)
                {
                    sb.Append(", ");
                }
                sb.Append("End_in_both: ");
                End_in_both.ToString(sb);
            }
            sb.Append(')');
            return(sb.ToString());
        }
Example #3
0
        public static bool GetZhaiWuNewList(int page = 0, int rid = 20)
        {
            var  ret    = new Newlist().Download(page, 50, rid);
            bool hasNew = false;

            using (var historyCon = DBSet.GetCon(DBSet.SqliteDBName.History))
            {
                using (var con = DBSet.GetCon(DBSet.SqliteDBName.Bilibili))
                {
                    foreach (var item in ret.archives)
                    {
                        var dbItem = con.SingleById <AV>(item.aid);

                        if (dbItem == null)
                        {
                            dbItem = new AV()
                            {
                                Id   = item.aid,
                                UpId = item.owner.mid,
                                rid  = rid,
                            };

                            Console.WriteLine(item.title);
                            UpdateAVData(dbItem, item);

                            con.Insert(dbItem);
                            // 更新封面照片
                            //var imagePath = SpiderConfig.GetPath($"imgs/{dbItem.UpId}/{dbItem.Id}");

                            //var pic = new Uri(item.pic).AbsolutePath.Replace("/","_");
                            //var imageFile = Path.Combine(imagePath, pic);

                            //if (!File.Exists(imageFile))
                            //{
                            //    Console.WriteLine(imageFile);
                            //    var bytes = new WebClient().DownloadData(item.pic);
                            //    File.WriteAllBytes(imageFile, bytes);
                            //}

                            hasNew = true;
                        }
                        else
                        {
                            UpdateAVData(dbItem, item);
                            con.Update(dbItem);
                        }

                        var upItem = con.SingleById <UP>(item.owner.mid);

                        if (upItem == null)
                        {
                            var upspider = new UpSpider();
                            int mid      = item.owner.mid;
                            Console.WriteLine($"get up {mid}");

                            var info   = upspider.GetUpInfo(mid);
                            var face   = upspider.GetFaceStat(mid);
                            var upstat = upspider.GetUpStat(mid);

                            upItem = new UP
                            {
                                Id        = mid,
                                follower  = face.follower,
                                following = face.following,
                                face      = info.face,
                                jointime  = info.jointime,
                                level     = info.jointime,
                                name      = info.name,
                                rank      = info.rank,
                                sex       = info.sex,
                                sign      = info.sign,
                                views     = upstat.archive.view,
                            };

                            con.Insert(upItem);
                        }

                        var dbHistoryItem = historyCon.SingleById <AVHistory>(item.aid);

                        if (dbHistoryItem == null)
                        {
                            dbHistoryItem = new AVHistory
                            {
                                Id      = item.aid,
                                History = new List <ArchivesItem> {
                                    item
                                }
                            };
                            historyCon.Insert(dbHistoryItem);
                        }
                        else
                        {
                            dbHistoryItem.History.Add(item);
                            historyCon.Update(dbHistoryItem);
                        }
                    }
                }
            }

            return(hasNew);
        }
Example #4
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);
        }