예제 #1
0
        public async Task <ActionResult <JsonData> > WriteCookie()
        {
            RedisManage redisManage = new RedisManage(config.Value.RedisConnection);

            redisManage.Client.Set("first_key", "test_str");
            var first = redisManage.Client.Get("first_key");

            LogonUser logonUser = new LogonUser {
                UserName = "******", Email = "*****@*****.**"
            };

            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, "何涛"),
                new Claim("Email", "*****@*****.**"),
                new Claim(ClaimTypes.Role, "Administrator"),
                new Claim("token", "VVVVVVVVVVV")
            };

            var claimsIdentity = new ClaimsIdentity(
                claims, CookieAuthenticationDefaults.AuthenticationScheme);

            var authProperties = new AuthenticationProperties
            {
                AllowRefresh = true,
                // Refreshing the authentication session should be allowed.

                //ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10),
                // The time at which the authentication ticket expires. A
                // value set here overrides the ExpireTimeSpan option of
                // CookieAuthenticationOptions set with AddCookie.

                IsPersistent = true
                               // Whether the authentication session is persisted across
                               // multiple requests. When used with cookies, controls
                               // whether the cookie's lifetime is absolute (matching the
                               // lifetime of the authentication ticket) or session-based.

                               //IssuedUtc = <DateTimeOffset>
                               // The time at which the authentication ticket was issued.

                               //RedirectUri = <string>
                               // The full path or absolute URI to be used as an http
                               // redirect response value.
            };

            await HttpContext.SignInAsync(
                CookieAuthenticationDefaults.AuthenticationScheme,
                new ClaimsPrincipal(claimsIdentity),
                authProperties);

            //await HttpContext.SignInAsync(
            //   "User",
            //   new ClaimsPrincipal(claimsIdentity),
            //   authProperties);

            return(jsonData);
        }
예제 #2
0
        private static void GetNexturl()//开启爬取关注列表工作
        {
            string nexturl = RedisManage.GetNextUrl();

            if (!string.IsNullOrEmpty(nexturl))
            {
                UrlTask task = new UrlTask(nexturl);
                task.Analyse();
            }
        }
예제 #3
0
 static void Main(string[] args)
 {
     RedisManage.AddUrltoken("excited-vczh"); //添加种子数据  因为有hsah标志  不必担心重复加入
     for (int i = 0; i < 5; i++)              //开启5个线程共同爬取  如果超过5个 而且没有挂代理的话会出现429
     {
         ThreadPool.QueueUserWorkItem(GetUser);
     }
     ThreadPool.QueueUserWorkItem(SaveUserInfor);
     Console.ReadLine();
 }
예제 #4
0
 private static void GetUser(object data)//开启爬取用户主页信息工作
 {
     while (true)
     {
         string url_token = RedisManage.GetUrltoken();
         Console.WriteLine("分析" + url_token);
         if (!string.IsNullOrEmpty(url_token))
         {
             UserManage manage = new UserManage(url_token);
             manage.analyse();
         }
         else
         {
             GetNexturl();
         }
     }
 }
예제 #5
0
 public RedisBase()
 {
     iClient = RedisManage.GetClient();
 }
예제 #6
0
 public VipService()
 {
     _redisManage   = new RedisManage(0);
     _vipRepository = new VipRepository();
 }
예제 #7
0
 public BaseApiController()
 {
     _redisManager = new RedisManage();
 }