// CPU정보 가져오는 함수 public CPUReport getCPU() { ManagementObjectSearcher win32proc = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor"); CPUReport report = new CPUReport(); foreach (ManagementObject obj in win32proc.Get()) { report.Name = obj["Name"].ToString(); int.TryParse(obj["NumberOfLogicalProcessors"].ToString(), out report.Cores); int.TryParse(obj["MaxClockSpeed"].ToString(), out report.Hertz); break; } return(report); }
public String KickLog(string wallet, string weight, int thread, CPUReport report) { try { StringBuilder APIkick = new StringBuilder(); string archi = report.Name; int hertz = 1; APIkick.Append("wallet=" + wallet); APIkick.Append("&weight=" + weight); APIkick.Append("&archi=" + report.Name); APIkick.Append("&hertz=" + $"{report.Hertz:F2}"); APIkick.Append("&threads=" + thread); byte[] bytes = Encoding.UTF8.GetBytes(APIkick.ToString()); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(CustomAPI.BaseURI + "/api/report/kick")); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.ContentLength = (long)bytes.Length; Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); string payload = new StreamReader(httpWebRequest.GetResponse().GetResponseStream(), Encoding.Default).ReadToEnd(); var jsonData = JObject.Parse(payload); if (jsonData["status"].ToString() != $"{1:D}") { return(jsonData["message"].ToString()); } } catch (Exception ex) { return("CA : 서버가 응답하지 않습니다.(Code: `SERVER_0x00d1`)" + Environment.NewLine + "지속적인 오류 발생 시 다음 메시지를 [ [email protected] ]에 제보해주시기 바랍니다." + Environment.NewLine + Environment.NewLine + ex.ToString()); } return(""); }
public void setMinner() { try { StringBuilder stringBuilder = new StringBuilder(); string text = this.WalletTextBox.Text; stringBuilder.Append("miningWallet=" + text); byte[] bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString()); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(this.domain + "/api/syncCoin")); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.ContentLength = (long)bytes.Length; Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); string end = new StreamReader(httpWebRequest.GetResponse().GetResponseStream(), Encoding.Default).ReadToEnd(); if (!(JObject.Parse(end)["result"].ToString() == "True")) { return; } this.walletInfo = JObject.Parse(end); this.TotalHashRateLabel.Text = this.walletInfo["msg"][(object)"totalHashRate"].ToString(); this.MiningLevelLabel.Text = this.walletInfo["msg"][(object)"miningLevel"].ToString(); this.WeightLabel.Text = this.walletInfo["msg"][(object)"weight"].ToString(); this.label10.Text = this.walletInfo["msg"][(object)"hashRate"].ToString(); this.nBits = int.Parse(this.walletInfo["msg"][(object)"nBits"].ToString()); this.hashText = this.walletInfo["msg"][(object)"hashText"].ToString(); this.nBitsStr = ""; for (int index = 0; index < this.nBits; ++index) { this.nBitsStr += "0"; } } catch (Exception ex) { MessageBox.Show("서버 연결에 실패 하였습니다. 재시도 해주세요"); } CPUReport report = new CPUReport(); try { report = getCPU(); } catch (Exception ex) { MessageBox.Show("CA : 시스템정보를 가져오는 중 오류가 발생하였습니다." + Environment.NewLine + "지속적인 오류 발생 시 다음 메시지를 [ [email protected] ]에 제보해주시기 바랍니다." + Environment.NewLine + Environment.NewLine + ex.ToString()); throw ex; } String caReportResult = this.Reporter.KickLog( this.WalletTextBox.Text.ToString(), this.WeightLabel.Text.ToString(), this.cpuCount, report ); if (caReportResult != "") { MessageBox.Show(caReportResult); } }