internal PoDAL() { //读配置文件 MyConfiguration cfg = new MyConfiguration(false); cfg.Load(settingFile); baseUrl = cfg.ReadString("BaseUrl"); token = TokenDAL.GetToken(); }
private void FrmSystem_Load(object sender, EventArgs e) { if (File.Exists(SettingItems.settingFile)) { cfg.Load(SettingItems.settingFile); if (cfg.ContainsKey(SettingItems.baseUrl)) { txtBaseUrl.Text = cfg.ReadString(SettingItems.baseUrl); } if (cfg.ContainsKey(SettingItems.appKey)) { txtAppKey.Text = cfg.ReadString(SettingItems.appKey); } if (cfg.ContainsKey(SettingItems.appSecret)) { txtAppSecret.Text = cfg.ReadString(SettingItems.appSecret); } } }
public static Token GetToken() { string uri = "oauth2/token"; if (File.Exists(SettingItems.settingFile)) { //读配置文件 MyConfiguration cfg = new MyConfiguration(false); cfg.Load(SettingItems.settingFile); string baseUrl = cfg.ReadString("BaseUrl"); string appKey = cfg.ReadString("AppKey"); string appSecret = cfg.ReadString("AppSecret"); System.Net.HttpWebResponse response = HwApiHelper.CreateHwTokenHttpResponse(baseUrl, uri, appKey, appSecret, null); string result = HwApiHelper.GetResponseString(response); Token token = JsonConvert.DeserializeObject <Token>(result); return(token); } else { return(null); } }