/// <summary> /// 加载所有服务器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Grid_Loaded(object sender, RoutedEventArgs e) { HttpAdapter adapter = new HttpAdapter(); bool bValid = await adapter.KeyValidAsync(); List <ServerInfo> infoRes = null; if (bValid) { //加载 infoRes = await adapter.GetServerList(); int cnt = 0; foreach (ServerInfo item in infoRes) { item.Num = ++cnt; this.Recordings.Add(item); } loadGrid.Visibility = Visibility.Collapsed; } else { loadBlock.Text = "加载失败,请检查网络是否正常连接以及密钥配置是否正确。"; } }
/// <summary> /// 测试ApiKey的有效性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Test_key_Click(object sender, RoutedEventArgs e) { test_key.IsEnabled = false; HttpAdapter adapter = new HttpAdapter(); bool ret = await adapter.KeyValidAsync(); if (ret) { await MessageAdapter.ShowMsgDlgAsync("ApiKey有效"); } else { await MessageAdapter.ShowMsgDlgAsync("ApiKey无效"); } test_key.IsEnabled = true; }
private async void Grid_Loaded(object sender, RoutedEventArgs e) { HttpAdapter adapter = new HttpAdapter(); bool bValid = await adapter.KeyValidAsync(); if (bValid) { AccountInfo infoRes = await adapter.GetAccountInfo(); email.Text = infoRes.Email; name.Text = infoRes.Name; balance.Text = infoRes.Balance; pending.Text = infoRes.Pending; pdate.Text = infoRes.PayDate; pamount.Text = infoRes.PayAmount; } }