private async Task ProcessQRCode() { stopWatch = new Stopwatch(); stopWatch.Start(); var rigID = ApplicationStateManager.RigID(); var requestBody = "{\"qrId\":\"" + _uuid + "\", \"rigId\":\"" + rigID + "\"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.PostAsync("https://api2.nicehash.com/api/v2/organization/nhmqr", content); // create qr code rect_qrCode.Fill = QrCodeHelpers.GetQRCode(_uuid, GUISettings.Instance.DisplayTheme == "Light"); while (true) { await Task.Delay(5000); if (stopWatch.ElapsedMilliseconds >= (1000 * 60 * 10)) { lbl_qr_status.Visibility = Visibility.Visible; btn_gen_qr.Visibility = Visibility.Visible; lbl_qr_status.Content = "QR Code timeout. Please generate new one."; return; } } } }
private async Task ProcessQRCode() { var rigID = ApplicationStateManager.RigID(); var requestBody = "{\"qrId\":\"" + _uuid + "\", \"rigId\":\"" + rigID + "\"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.PostAsync("https://api2.nicehash.com/api/v2/organization/nhmqr", content); } // create qr code rect_qrCode.Fill = QrCodeHelpers.GetQRCode(_uuid); }
private async Task ProcessQRCode() { var rigID = ApplicationStateManager.RigID(); var requestBody = "{\"qrId\":\"" + _uuid + "\", \"rigId\":\"" + rigID + "\"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.PostAsync("https://api2.nicehash.com/api/v2/organization/nhmqr", content); } // create qr code rect_qrCode.Fill = QrCodeHelpers.GetQRCode(_uuid); //if all ok start timer to poll while (true) { await Task.Delay(2000); try { using (var client = new HttpClient()) { var resp = await client.GetAsync($"https://api2.nicehash.com/api/v2/organization/nhmqr/{_uuid}"); if (resp.IsSuccessStatusCode) { var contentString = await resp.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(contentString)) { var btcResp = JsonConvert.DeserializeObject <BtcResponse>(contentString); if (btcResp.btc != null) { if (CredentialValidators.ValidateBitcoinAddress(btcResp.btc)) { CredentialsSettings.Instance.SetBitcoinAddress(btcResp.btc); Close(); } } } } } } catch (Exception e) { Console.WriteLine(e.Message); } } }
private void CheckBoxMode_Unchecked(object sender, RoutedEventArgs e) { GUISettings.Instance.DisplayTheme = "Light"; ThemeSetterManager.SetTheme(true); rect_qrCode.Fill = QrCodeHelpers.GetQRCode(_uuid); }
private async Task ProcessQRCode() { stopWatch = new Stopwatch(); stopWatch.Start(); var rigID = ApplicationStateManager.RigID(); var requestBody = "{\"qrId\":\"" + _uuid + "\", \"rigId\":\"" + rigID + "\"}"; var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.PostAsync("https://api2.nicehash.com/api/v2/organization/nhmqr", content); } // create qr code rect_qrCode.Fill = QrCodeHelpers.GetQRCode(_uuid, GUISettings.Instance.DisplayTheme == "Light"); //if all ok start timer to poll while (true) { await Task.Delay(2000); try { using (var client = new HttpClient()) { var resp = await client.GetAsync($"https://api2.nicehash.com/api/v2/organization/nhmqr/{_uuid}"); if (resp.IsSuccessStatusCode) { var contentString = await resp.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(contentString)) { var btcResp = JsonConvert.DeserializeObject <BtcResponse>(contentString); if (btcResp.btc != null) { if (CredentialValidators.ValidateBitcoinAddress(btcResp.btc)) { var ret = await ApplicationStateManager.SetBTCIfValidOrDifferent(btcResp.btc); if (ret == ApplicationStateManager.SetResult.CHANGED) { lbl_qr_status.Visibility = Visibility.Visible; btn_gen_qr.Visibility = Visibility.Visible; lbl_qr_status.Content = "BTC Address was changed - this code is already used."; } return; } } } } } } catch (Exception e) { Console.WriteLine(e.Message); } if (stopWatch.ElapsedMilliseconds >= (1000 * 60 * 10)) { lbl_qr_status.Visibility = Visibility.Visible; btn_gen_qr.Visibility = Visibility.Visible; lbl_qr_status.Content = "QR Code timeout. Please generate new one."; return; } } }