private async void Run(object sender, RoutedEventArgs e) { progressbar.Text = "Running code"; progressbar.ShowAsync(); var edContent = await webv.InvokeScriptAsync("getContent", new List <string>()); var bytes = Encoding.UTF8.GetBytes(edContent); var base64 = System.Uri.EscapeUriString(Convert.ToBase64String(bytes)).Replace("+", "%2B").Replace("=", "%3D"); Debug.WriteLine(base64); var cts = new CancellationTokenSource(); var client = new HttpClient(); try { cts.CancelAfter(7500); var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/api/run?Content=" + base64 + "&Input=" + inpbox.Text)); var result = await response.Content.ReadAsStringAsync(); outbox.Text = result; } catch { outbox.Text = "Timeout"; } progressbar.HideAsync(); CodeHub.ScrollToSection(HubInOut); }
private async void Verify(object sender, RoutedEventArgs e) { progressbar.Text = "Verifying code"; progressbar.ShowAsync(); var edContent = await webv.InvokeScriptAsync("getContent", new List <string>()); var bytes = Encoding.UTF8.GetBytes(edContent); var base64 = System.Uri.EscapeUriString(Convert.ToBase64String(bytes)).Replace("+", "%2B").Replace("=", "%3D"); Debug.WriteLine(base64); var cts = new CancellationTokenSource(); var client = new HttpClient(); if (!localSettings.Containers.ContainsKey("userInfo")) { MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu."); await msgbox.ShowAsync(); return; } var username_basic = localSettings.Containers["userInfo"].Values["userName"].ToString(); var username = System.Uri.EscapeUriString(username_basic).Replace("+", "%2B").Replace("=", "%3D"); try { cts.CancelAfter(7500); var uri = new Uri("http://codeinn-acecoders.rhcloud.com:8000/api/verify?Content=" + base64 + "&Id=" + displayedObject.Id + "&Table=" + tableName + "&username="******"Timeout. Try again later."; } progressbar.HideAsync(); CodeHub.ScrollToSection(HubInOut); }