private void tsmiChangeKeystore_Click(object sender, EventArgs e) { QRCodeForm qRCodeForm = new QRCodeForm("50"); qRCodeForm.ShowDialog(); if (!isPay) { return; } bool paySuccess = false; if (userInput.Length == 0) { return; } try { // 付费记录 string apiResult = client.Get("?method=usdt.verify&hash=" + userInput + "&token=" + token); JObject json = JsonConvert.DeserializeObject <JObject>(apiResult); Block block = JsonConvert.DeserializeObject <Block>(json["data"].ToString()); //foreach (Block block in blocks) //{ if (DateTime.Compare(DateTime.Now, block.Used_at.AddHours(3)) > 0) { MessageBox.Show(resource.GetString("orderNotFound")); return; } if (toAddress.ToLower().Equals(block.To.ToLower()) && Convert.ToInt32(block.Value) - 50000000 >= -5000000)//"50000000".Equals(block.Value)) { paySuccess = true; } //} if (!paySuccess) { MessageBox.Show(resource.GetString("orderNotFound")); return; } Directory.Delete(keystoreDir, true); Directory.CreateDirectory(keystoreDir); MessageBox.Show(resource.GetString("changeKSSuccess")); RunProcess("cmd.exe", "taskkill /F /IM poc.exe"); tsmiImportKeystore.Visible = true; tsmiInstall.Visible = true; labelMsg.Text = string.Empty; } catch (WebException) { MessageBox.Show(resource.GetString("networkException")); return; } catch (Exception) { return; } }
private void tsmiPlotDir_Click(object sender, EventArgs e) { DeviceSelectForm deviceSelectForm = new DeviceSelectForm { Text = tsmiPlotDir.Text }; deviceSelectForm.ShowDialog(); if (checkedList.Count == 0) { return; } if (countDeviceSelect > 0) { QRCodeForm qRCodeForm = new QRCodeForm("10"); qRCodeForm.ShowDialog(); if (!isPay) { return; } bool paySuccess = false; if (userInput.Length == 0) { return; } try { // 付费记录 string apiResult = client.Get("?method=usdt.verify&hash=" + userInput + "&token=" + token); JObject json = JsonConvert.DeserializeObject <JObject>(apiResult); Block block = JsonConvert.DeserializeObject <Block>(json["data"].ToString()); //foreach (Block block in blocks) //{ if (DateTime.Compare(DateTime.Now, block.Used_at.AddHours(3)) > 0) { MessageBox.Show(resource.GetString("orderNotFound")); return; } if (toAddress.ToLower().Equals(block.To.ToLower()) && Convert.ToInt32(block.Value) - 10000000 >= -5000000)//"10000000".Equals(block.Value)) { paySuccess = true; } //} if (!paySuccess) { MessageBox.Show(resource.GetString("orderNotFound")); return; } } catch (WebException) { MessageBox.Show(resource.GetString("networkException")); return; } catch (Exception) { return; } } IDbConnection conn = DBHelper.CreateConnection(); Dictionary <string, object> ups; string sql = "REPLACE INTO t_plot(F_Name, F_Path, F_Uuid, F_PlotSeed, F_PlotDir, F_PlotSize, F_PlotParam, F_Status, F_CreateTime, F_ModifyTime) " + "VALUES(@Path, @Path, '', @Address, '/plotdata', '8589934592', '{\"startNonce\":0}', 1, @CreateTime, @CreateTime);"; foreach (KeyValuePair <string, string> item in checkedList) { ups = new Dictionary <string, object> { { "Path", item.Key }, { "Address", "0x" + address }, { "CreateTime", tsslDate.Text } }; if (!Directory.Exists(item.Key + "/plotdata")) { Directory.CreateDirectory(item.Key + "/plotdata"); } DBHelper.ExecuteNonQuery(conn, sql, ups); } conn.Close(); tsmiPlotDir.Enabled = false; Thread thread = new Thread(new ThreadStart(CopyPlotdata)); thread.Start(); }
private void tsmiAddPeer_Click(object sender, EventArgs e) { tsmiAddPeer.Enabled = false; AddNodeForm addNodeForm = new AddNodeForm { Text = tsmiAddPeer.Text }; addNodeForm.ShowDialog(); if (null == selectedNode) { tsmiAddPeer.Enabled = true; return; } if (0 == selectedNode.Access) { QRCodeForm qRCodeForm = new QRCodeForm("100"); qRCodeForm.ShowDialog(); if (!isPay) { tsmiAddPeer.Enabled = true; return; } bool paySuccess = false; if (userInput.Length == 0) { return; } try { //string apiResult = client.Get("api?module=block&action=getblocknobytime×tamp=" + UtcTime.GetTimeStamp() + "&closest=before&apikey=" + token); //JObject json = JsonConvert.DeserializeObject<JObject>(apiResult); //string latestBlock = json["result"].ToString(); // 付费记录 string apiResult = client.Get("?method=usdt.verify&hash=" + userInput + "&token=" + token); JObject json = JsonConvert.DeserializeObject <JObject>(apiResult); Block block = JsonConvert.DeserializeObject <Block>(json["data"].ToString()); // foreach (Block block in blocks) //{ if (DateTime.Compare(DateTime.Now, block.Used_at.AddHours(3)) > 0) { MessageBox.Show(resource.GetString("orderNotFound")); return; } if (toAddress.ToLower().Equals(block.To.ToLower()) && Convert.ToInt32(block.Value) - 100000000 >= -5000000) //"100000000".Equals(block.Value) { paySuccess = true; } //} if (!paySuccess) { MessageBox.Show(resource.GetString("orderNotFound")); return; } // 修改配置文件 //string strFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config"); //if (File.Exists(strFilePath)) //{ // string strContent = File.ReadAllText(strFilePath); // strContent = Regex.Replace(strContent, selectedNode.Id + "=False", selectedNode.Id + "=True"); // File.WriteAllText(strFilePath, strContent); //} } catch (WebException) { MessageBox.Show(resource.GetString("networkException")); return; } catch (Exception) { return; } finally { tsmiAddPeer.Enabled = true; } } tsmiAddPeer.Enabled = true; IDbConnection conn = DBHelper.CreateConnection(); string offUsedNode = "update t_node set on_used = 0;";//取消所有已选择 DBHelper.ExecuteNonQuery(conn, offUsedNode, new Dictionary <string, object>()); string updateNode = string.Empty; if (selectedNode.Access == 0) { updateNode = "update t_node set on_used = 1,access = 1 ,end_date=@date where id=@id;"; DBHelper.ExecuteNonQuery(conn, updateNode, new Dictionary <string, object>() { { "id", selectedNode.Id }, { "date", DateTime.Now.AddDays(30).ToString("yyyy-MM-dd") } }); } else { updateNode = "update t_node set on_used = 1,access = 1 where id=@id;"; DBHelper.ExecuteNonQuery(conn, updateNode, new Dictionary <string, object>() { { "id", selectedNode.Id } }); } DialogResult dr = MessageBox.Show(resource.GetString("nodeDownloadTips"), resource.GetString("tips"), MessageBoxButtons.OKCancel); if (dr == DialogResult.Cancel) { return; } RunProcess("cmd.exe", "taskkill /F /IM poc.exe"); Thread.Sleep(2000); tsmiStart.Visible = false; tsmiAdvanced.Enabled = false; if (selectedNode.Address == "sz") { string downloadUrl = client.Get("?method=mine.version&client=EHDMiner&token=" + token); JObject jsonUrl = JsonConvert.DeserializeObject <JObject>(downloadUrl); string url = jsonUrl["data"]["url"].ToString(); using (WebClient webClient = new WebClient()) { webClient.DownloadFileAsync(new Uri(url), Path.Combine(Application.StartupPath + "\\bin\\", "poc.exe")); webClient.DownloadProgressChanged += client_DownloadProgressChanged; webClient.DownloadFileCompleted += client_DownloadFileCompleted; } } else { FileUtil.ExtractResFile("EHDMiner.Resources." + poc, Application.StartupPath + "\\bin\\" + poc); MessageBox.Show(resource.GetString("addNodeMsg")); tsmiStart.Visible = true; tsmiAdvanced.Enabled = true; } //RunProcess("cmd.exe", "curl -H \"Content-Type: application/json\" --data \"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"admin_addPeer\\\",\\\"params\\\":[\\\"enode://" + selectedNode.Address + ":30303\\\"],\\\"id\\\":1}\" http://127.0.0.1:8545"); }