static void Main(string[] args) { RequestAPI request = new RequestAPI(); ResultApi resultado = new ResultApi(); decimal valor, resultadoconversao; string op; Console.WriteLine("Digite o tipo de moeda que deseja converter"); Console.WriteLine("\nUSD Dolar"); op = Console.ReadLine(); Console.WriteLine("Digite o valor em Reais"); valor = decimal.Parse(Console.ReadLine()); switch (op) { case "USD": resultado = request.Request($"all/{op}", Method.GET); resultadoconversao = decimal.Parse(resultado.USD.Cotacao) * valor; Console.WriteLine($"O Resultado é :R$ {resultadoconversao:N2} na data de : {resultado.USD.DataCotacao.ToString("dd/MM/yyyy HH:mm")}"); break; default: break; } }
void LoadContact(string allPhones, int count) { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion if (count < 1000) { //Формируем запрос allPhones = "phones=" + allPhones; string fields = "fields=photo_rec,photo_medium_rec"; string access_token = "access_token=" + MyUserData.access_token;//данные в MyUserData заносятся из словаря string adr = RequestAPI.Request("friends.getByPhones", allPhones, fields, access_token); WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadContactsCompleted); client.DownloadStringAsync(new Uri(adr)); } else { //реализовать разбиение на запросы MessageBox.Show("To big size of contact list. Sorry."); } }
void LoadDialog() { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion //Формируем запрос string uid = "uid=" + myApp.Uid; //string count = "count=10"; // string rev = "rev=1"; string access_token = "access_token=" + MyUserData.access_token; ///смещение, необходимое для выборки определенного подмножества сообщений. //string offset = "offset="; ///идентификатор сообщения, начиная с которго необходимо получить последующие сообщения. //string start_mid="start_mid="; string adr = RequestAPI.Request("messages.getHistory", uid, access_token); //Отправляем запрос, получаем ответ. Запускаем событие обработки. WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadDialogCompleted); client.DownloadStringAsync(new Uri(adr)); }
void SendMessage() { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion //Формируем запрос string uid = "uid=" + myApp.Uid; messageSent = new Message() { Body = textSend.Text }; string message = "message=" + textSend.Text;//настроить форматирование!!! Проверка на длинну! string access_token = "access_token=" + MyUserData.access_token; ///смещение, необходимое для выборки определенного подмножества сообщений. //string offset = "offset="; ///идентификатор сообщения, начиная с которго необходимо получить последующие сообщения. //string start_mid="start_mid="; string adr = RequestAPI.Request("messages.send", uid, message, access_token); //Отправляем запрос, получаем ответ. Запускаем событие обработки. WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_SendMessageCompleted); client.DownloadStringAsync(new Uri(adr)); }
private void phonenumBox_LostFocus(object sender, RoutedEventArgs e) { //Проверка номера телефона методами API Вконтакте //Формируем запрос string phone = "phone=" + phonenumBox.Text; string adr = RequestAPI.Request("auth.checkPhone.xml", phone, ApplicationSettings.client_id, ApplicationSettings.client_secret); //Создаем клиент для передачи данных WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); client.DownloadStringAsync(new Uri(adr)); }
private void buttonConfirm_Click(object sender, RoutedEventArgs e) { //Формируем запрос string phone = "phone=" + phoneConfirmBox.Text; string code = "code=" + CodeBox.Text; string test_mode = "test_mode=0"; string password = "******" + passwordBox.Password; string adr = RequestAPI.Request("auth.confirm", phone, code, password, ApplicationSettings.client_id, ApplicationSettings.client_secret, test_mode); //Создаем клиент для передачи данных WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_authConfirm); client.DownloadStringAsync(new Uri(adr)); }
private void buttonRegistration_Click(object sender, RoutedEventArgs e) { //Формируем запрос string phone = "phone=" + phonenumBox.Text; string firstname = "first_name=" + firstnameBox.Text; string lastname = "last_name=" + lastnameBox.Text; string test_mode = "test_mode=0"; string adr = RequestAPI.Request("auth.signup", phone, firstname, lastname, ApplicationSettings.client_id, ApplicationSettings.client_secret, test_mode); //Создаем клиент для передачи данных WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_signupCompleted); client.DownloadStringAsync(new Uri(adr)); MessageBox.Show("Данны для регистрации отправлены! Дождитесь прихода SMS с кодом и введите его в окне подтверждения, для завершения регистрации"); }
void DeleteFromFriends(int uid) { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion //Формируем запрос string s_uid = "uid=" + uid; string access_token = "access_token=" + MyUserData.access_token; string adr = RequestAPI.Request("friends.delete", s_uid, access_token); //Отправляем запрос, получаем ответ. Запускаем событие обработки. WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DeleteFriendsCompleted); client.DownloadStringAsync(new Uri(adr)); }
private void UpdateMessage() { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion short size = 20; //Формируем запрос string count = "count=" + size; string access_token = "access_token=" + MyUserData.access_token;//данные в MyUserData заносятся из словаря string adr = RequestAPI.Request("messages.get", count, access_token); WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_UpdateMessagesCompleted); client.DownloadStringAsync(new Uri(adr)); }
private void UpdateFriends() { #region Progress ON prog.IsVisible = true; prog.IsIndeterminate = true; SystemTray.SetProgressIndicator(this, prog); #endregion //Формируем запрос string fields = "fields=uid,first_name,last_name,photo_rec,photo_medium_rec,photo_big,online"; string access_token = "access_token=" + MyUserData.access_token; string order = "order=name"; string adr = RequestAPI.Request("friends.get", fields, order, access_token); //Отправляем запрос, получаем ответ. Запускаем событие обработки. WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_UpdateFriendsCompleted); client.DownloadStringAsync(new Uri(adr)); }
private void phonenumBox_LostFocus(object sender, RoutedEventArgs e) { //Проверка номера телефона методами API Вконтакте if (phonenumBox.Text != "") { //Формируем запрос string phone = "phone=" + phonenumBox.Text; string adr = RequestAPI.Request("auth.checkPhone", phone, ApplicationSettings.client_id, ApplicationSettings.client_secret); //Создаем клиент для передачи данных WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); client.DownloadStringAsync(new Uri(adr)); } else if (phonenumBox.Text == "") { phoneBlock.Opacity = 0.6; phoneBlock.Foreground = (Brush)Resources["PhoneForegroundBrush"]; } }