/// <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); }
private void FormSetting_Load(object sender, EventArgs e) { //初始化语音库 List <PerInfo> perInfos = new List <PerInfo>(); perInfos.Add(new PerInfo() { Val = 0, Display = "度小美" }); perInfos.Add(new PerInfo() { Val = 1, Display = "度小宇" }); perInfos.Add(new PerInfo() { Val = 3, Display = "度逍遥" }); perInfos.Add(new PerInfo() { Val = 4, Display = "度丫丫" }); perInfos.Add(new PerInfo() { Val = 106, Display = "度博文" }); perInfos.Add(new PerInfo() { Val = 110, Display = "度小童" }); perInfos.Add(new PerInfo() { Val = 111, Display = "度小萌" }); perInfos.Add(new PerInfo() { Val = 103, Display = "度米朵" }); perInfos.Add(new PerInfo() { Val = 5, Display = "度小娇" }); per.DataSource = perInfos; per.DisplayMember = "Display"; per.ValueMember = "Val"; //初始化设置Redis foreach (Control ctl in groupBox1.Controls) { string key = ctl.Name; int val = redisConfigInfo._GetKey <int>(key); if (ctl.GetType() == typeof(TrackBar)) { TrackBar trackBar = ctl as TrackBar; if (val == default(int)) { val = 5; } trackBar.Value = val; } else if (ctl.GetType() == typeof(ComboBox)) { ComboBox comboBox = ctl as ComboBox; if (val == default(int)) { val = 0; } comboBox.SelectedValue = val; } } }