Exemplo n.º 1
0
        private void spd_Scroll(object sender, EventArgs e)
        {
            TrackBar trackBar = sender as TrackBar;
            int      val      = trackBar.Value;

            redisConfigInfo._AddKey <int>(trackBar.Name, val);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取Token
        /// </summary>
        /// <param name="para_API_key"></param>
        /// <param name="para_API_secret_key"></param>
        /// <returns></returns>
        private string getTokon()
        {
            string token = redisConfig._GetKey <string>("baidu_token");

            if (string.IsNullOrEmpty(token))
            {
                WebClient webClient = new WebClient();
                webClient.BaseAddress = "https://openapi.baidu.com";
                string result = webClient.DownloadString($"https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id={API_key}&client_secret={API_secret_key}");
                webClient.Dispose();

                dynamic json = JToken.Parse(result);
                token = json.access_token;
                long expires_in = json.expires_in;
                redisConfig._AddKey <string>("baidu_token", token, new TimeSpan(expires_in * 1000 * 1000 * 10));
            }
            return(token);
        }