コード例 #1
0
        public void  Analyse()
        {
            try
            {
                if (GetHtml())
                {
                    Stopwatch watch = new Stopwatch();
                    watch.Start();

                    followerResult result = SerializeHelper.DeserializeToObject <followerResult>(JSONstring);
                    if (!result.paging.is_end)
                    {
                        RedisManage.AddNextUrl(result.paging.next);
                    }
                    foreach (var item in result.data)
                    {
                        RedisManage.AddUrltoken(item.url_token);
                    }
                    watch.Stop();
                    Console.WriteLine("解析json用了{0}毫秒", watch.ElapsedMilliseconds.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
ファイル: server.cs プロジェクト: zxfgithub12/ZhiHu
 /// <summary>
 /// 将队列中的用户信息持久化
 /// </summary>
 public void SaveUser()
 {
     using (ZhihuEntity Entity = new ZhihuEntity())
     {
         string json = RedisManage.GetUserInfo();
         User   user = SerializeHelper.DeserializeToObject <User>(json);
         Entity.user.Add(user);
         try
         {
             Entity.SaveChanges();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }