public async Task <IActionResult> Index() { var json = await ClientHttp.Get("https://api.covid19api.com/summary"); var resultContent = json.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <Root>(resultContent); List <CasosAtivos> casosAtivos = new List <CasosAtivos>(); for (int i = 0; i < result.Countries.Count(); i++) { CasosAtivos obj = new CasosAtivos() { Pais = result.Countries[i].Country, TotalCasosAtivos = Convert.ToInt32(result.Countries[i].TotalConfirmed) - Convert.ToInt32(result.Countries[i].TotalRecovered) }; casosAtivos.Add(obj); } var returno = casosAtivos.OrderByDescending(c => c.TotalCasosAtivos).Take(10); return(View(returno)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Explore_Click(object sender, RoutedEventArgs e) { RemoteClient client = ((FrameworkElement)sender).Tag as RemoteClient; ClientHttp clientHttp = new ClientHttp(client); ComponentNavigator.NavigateToSectionClient(clientHttp); }
/// <summary> /// 登录 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> private void Login(string userName, string password) { if (userName == "") { PopupManager.ShowTimerPopUp("username is null"); return; } Debug.Log(userName + "," + password); byte[] result = Encoding.Default.GetBytes(password); //tbPass为输入密码的文本框 MD5 md5 = new MD5CryptoServiceProvider(); byte[] output = md5.ComputeHash(result); string pswMD5 = BitConverter.ToString(output).Replace("-", ""); //tbMd5pass为输出加密文本的文本框 Dictionary <string, string> dic = new Dictionary <string, string> { { "appID", appConfig.appID }, { "channelID", appConfig.channelID }, { "username", userName }, { "psw", pswMD5 } }; // dic.Add("email", "*****@*****.**"); StartCoroutine(ClientHttp.getInstance().POST(appConfig.asdkUrl + "/account/login", dic, LoginResult)); // wai 注册地址:http://host:port/account/register 请求方式:POST PopupManager.AddWindow(PopupWindowName.WAITING_NET); }
async Task OnSubmit() { Login login = new Login { email = this.Email, senha = this.Senha }; var respostaHttp = await ClientHttp.PostAsync("sessions", login); if (respostaHttp.statuscode.Equals(HttpStatusCode.Created)) { try { var loginResponse = ClientHttp.ObterObjeto <LoginResponse>(respostaHttp.content); ClientHttp.AplicarToken(loginResponse.token); App.Current.MainPage = new Home(); } catch (Exception) { throw; } } else { this.response = respostaHttp.message; ReturnMessage(); } }
private List <User> GetUsersFromHttp() { var client = new ClientHttp(); var response = client.GetResponse().Result; return(JsonConvert.DeserializeObject <List <User> >(response)); }
/// <summary> /// 游客登录 /// </summary> private void GuestLogin() { Dictionary <string, string> dic = new Dictionary <string, string> { { "appID", appConfig.appID }, { "channelID", appConfig.channelID } }; StartCoroutine(ClientHttp.getInstance().POST(appConfig.asdkUrl + "/account/guest", dic, GuestLoginResult)); PopupManager.AddWindow(PopupWindowName.WAITING_NET); }
public MainForm() { InitializeComponent(); clientsInfo = new List <ClientsInfo>(); clientsInfo.Add(new ClientsInfo() { clientID = CHATDIALOG, clientName = "Чат" }); chatDialogsInfo = new Dictionary <int, AllDialogsMessages>(); chatDialogsInfo.Add(CHATDIALOG, new AllDialogsMessages("Чат")); client = new Client(); httpClient = new ClientHTTP.ClientHttp(); client.ProcessReceivedMessagesEvent += ProcessReceivedMessages; }
/// <summary> /// /// </summary> /// <param name="server"></param> public PageSectionLayout(ClientHttp server) { MessageBoxs.IsBusy = true; log.Info(string.Format(CultureInfo.CurrentCulture, Local.Properties.Logs.InitializingPageWaiting, "Section Client")); // Set page variables and properties. svr = server; // Constuct page component. InitializeComponent(); AfterInitializedComponent(); log.Info(string.Format(CultureInfo.CurrentCulture, Local.Properties.Logs.InitializingPageDone, "Section Client")); MessageBoxs.IsBusy = false; }
async public Task <IHttpActionResult> Token(string username, string password, string audienceId, string grantType) { try { var client = new ClientHttp(ConfigurationManager.AppSettings["issuer"]) { Content = "username="******"&password="******"&grant_type=" + grantType, Action = "token?audienceId=" + audienceId }; await client.Post(); if (client.Response["access_token"] != null) { SwaggerConfig.AccessToken = client.Response["token_type"] + " " + client.Response["access_token"]; } if (client.Response["error"] != null) { return(Json(new { error = client.Response["error"], error_description = client.Response["error_description"] })); } return(Json(new { access_token = client.Response["access_token"], refresh_token = client.Response["refresh_token"], token_type = client.Response["token_type"], expires_in = client.Response["expires_in"], issued = Globals.Utilities.DateTime.ToLocalTime(client.Response[".issued"].ToString()), expires = Globals.Utilities.DateTime.ToLocalTime(client.Response[".expires"].ToString()), message = "" })); } catch (Exception e) { return(Json(new { result = "KO" })); } }
private void LoginCenter(string userId, string userName, string token) { if (userName == "") { PopupManager.ShowTimerPopUp("username is empty"); return; } // Debug.Log(userName + "." + userID); Dictionary <string, string> dic = new Dictionary <string, string> { { "userId", userId }, { "token", token }, { "platform", appConfig.appID }, { "channel", appConfig.channelID } }; // dic.Add("email", "*****@*****.**"); StartCoroutine(ClientHttp.getInstance().POST(appConfig.centerUrl + "/user/certify", dic, LoginCenterResult)); // waiwang 注册地址:http://host:port/account/register 请求方式:POST }
/// <summary> /// 注册 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <param name="passwordAgain"></param> private void Register(string userName, string password, string passwordAgain) { if (userName == "") { PopupManager.ShowTimerPopUp("username is null"); return; } else if (password != passwordAgain) { PopupManager.ShowTimerPopUp("password passwordAgain not same"); return; } Dictionary <string, string> dic = new Dictionary <string, string> { { "appID", appConfig.appID }, { "channelID", appConfig.channelID }, { "username", userName }, { "psw", password } }; StartCoroutine(ClientHttp.getInstance().POST(appConfig.asdkUrl + "/account/register", dic, RegisterResult)); }
async Task Register() { if (!senha.Equals(confirmarsenha)) { message = "Senhas divergentes!"; ReturnMessage(); return; } user = new User { username = this.Nome, password = this.Email, email = this.Senha }; var respostaHttp = await ClientHttp.PostAsync("users", user); if (respostaHttp.statuscode.Equals(HttpStatusCode.Created)) { try { message = "Usuário criado com sucesso!"; ReturnMessage(); App.Current.MainPage = new Home(); } catch (Exception ex) { message = ex.Message; ReturnMessage(); return; } } else { message = respostaHttp.message; ReturnMessage(); return; } }
/// <summary> /// /// </summary> /// <param name="clientHttp"></param> public static void NavigateToSectionClient(ClientHttp clientHttp) => Navigate(new Client.Section.PageSectionLayout(clientHttp));
public HttpResponseMessage ExecuteGet() { HttpResponseMessage response = ClientHttp.GetAsync(Url).Result; return(response); }