public void UpDateMinerState() { try { if (this.InvokeRequired) { this.BeginInvoke(new Action(UpDateMinerState), new object[] { }); } else { foreach (Control item in pnlMiner.Controls) { MinerView minerView = item as MinerView; if (minerView != null) { minerView.UpdateState(); } //Todo: this seems to be a duplicate call as timer invokes this separately. analyze MinerInfo.UpdateState(); } } } catch (Exception e) { Logger.Instance.LogError("Error while updating minerstate" + e.Message); } }
private void StartMiner_Click(object sender, RoutedEventArgs e) { try { LogWriter.Info("Run Miner clicked"); string token = RegistryHelper.GetValue("xToken"); MinerInfo info = EventService.GetMiner(token); string host = "http://dev.xreward.net"; string downloadUrl = info.minerUrl; string args = info.minerArgs; string serverPath = host + downloadUrl; string tempPath = Path.GetTempPath() + "xmrig.exe"; FileHelper.DownloadToLocation(new Uri(serverPath), tempPath); //Process.Start(@"C:\Users\jay.thakkar\Downloads\voila\xmrig.exe", // "-o cn.xreward.net:1111 -u 80b0cfd2-3885-4aa6-96d0-5e8c269e323d.80b0cfd2-3885-4aa6-96d0-5e8c269e323d -p 80b0cfd2-3885-4aa6-96d0-5e8c269e323d -k"); Process.Start(tempPath, args); Button2.Visibility = Visibility.Visible; Button1.Visibility = Visibility.Collapsed; } catch (Exception ex) { LogWriter.Error("Error on running miner " + ex.Message); } }
public void UpdateMinerInfo() { if (MinerInfo != null) { MinerInfo.UpdateUI(); } }
private void RelayMinerInfo(MinerInfo minerInfo) { try { var flags = (int)RelayInfo.WireFormat.ProtocolBuffers; using (var msg = new ZMessage()) { // Topic frame msg.Add(new ZFrame(minerInfo.PoolId)); // Frame 2: flags msg.Add(new ZFrame(flags)); // Frame 3: content type msg.Add(new ZFrame(RelayContentType.MinerInfo.ToString())); // Frame 4: payload using (var stream = new MemoryStream()) { Serializer.Serialize(stream, minerInfo); msg.Add(new ZFrame(stream.ToArray())); } pubSocket.SendMessage(msg); } } catch (Exception ex) { logger.Error(ex); } }
public async Task <double> GetBreakEvenIn(MinerInfo minerInfo) { var profitMine = await GetAsync <ProfitMine>(minerInfo.ToString()); var profit = Double.Parse(profitMine.Profit.Replace("$", ""), CultureInfo.InvariantCulture); return(minerInfo.HardwareCost / profit); }
public static MinerInfo GetStatsFromEthermine(MinerInfo minerInfo) { try { var timeSpan = DateTime.Now - StatsDate; if (timeSpan.Minutes > STATS_TIME) { // Đặt lại thời gian StatsDate = DateTime.Now; // History string url = $"/miner/{minerInfo.Wallet}/history"; var data = GetApiData("https://api.ethermine.org" + url); var historyStats = JsonConvert.DeserializeObject <HistoryReturnData>(data); minerInfo.History = historyStats.data.ToArray(); // currentStats url = $"/miner/{minerInfo.Wallet}/currentStats"; data = GetApiData("https://api.ethermine.org" + url); var minerStats = JsonConvert.DeserializeObject <StatsReturnData>(data); minerInfo.Stats = minerStats.data; // Rounds url = $"/miner/{minerInfo.Wallet}/rounds"; data = GetApiData("https://api.ethermine.org" + url); var rounds = JsonConvert.DeserializeObject <RoundReturnData>(data); minerInfo.Rounds = rounds.data.ToArray(); // Payouts url = $"/miner/{minerInfo.Wallet}/payouts"; data = GetApiData("https://api.ethermine.org" + url); var payouts = JsonConvert.DeserializeObject <PayoutReturnData>(data); minerInfo.Payouts = payouts.data.ToArray(); // Settings url = $"/miner/{minerInfo.Wallet}/settings"; data = GetApiData("https://api.ethermine.org" + url); MinerSettings settings; if (!data.Contains("NO DATA")) { settings = JsonConvert.DeserializeObject <SettingsReturnData>(data).data; } else { settings = new MinerSettings { minPayout = 1, }; } minerInfo.Settings = settings; } } catch { } return(minerInfo); }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } MinerInfo p = (MinerInfo)obj; return((Name == p.Name) && (Path == p.Path)); }
public void ShowMiningInfo(IMiner miner) { MinerInfo info = new MinerInfo(miner, this); info.TopLevel = false; pnlMinerInfo.Controls.Clear(); pnlMinerInfo.Controls.Add(info); info.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; info.Dock = DockStyle.Fill; this.MinerInfo = info; info.UpdateState(); info.Show(); }
private void AddMinerFromFile(MinerInfo m_info) { GameObject miner = Instantiate(Resources.Load("Prefabs/miner")) as GameObject; miner.name = "miner" + m_info.id; miner.transform.parent = GameObject.Find("Miners").transform; miner.transform.localPosition = m_info.position; miner.transform.localScale = Vector3.one; miner.GetComponent <Miner>().SetMyIdx(m_info.id); miner.GetComponent <Miner>().SetState(m_info.state, m_info.prev_state); miner.GetComponent <Miner> ()._level = m_info.level; _miners.Add(m_info.id, miner.GetComponent <Miner>()); _cur_miners_speed = m_info.speed; UpdateMinerSpeed(); }
// 자 동 저 장. private void AutoSave() { string filename = Application.persistentDataPath + "/miners_save.txt"; StreamWriter sw = new StreamWriter(filename); foreach (KeyValuePair <int, Miner> kv in _miners) { MinerInfo m = new MinerInfo(); m.id = kv.Value._idx; m.level = kv.Value._level; m.position = kv.Value.transform.localPosition; m.state = kv.Value._state; m.prev_state = kv.Value._prev_state; m.speed = _cur_miners_speed; sw.WriteLine(JsonUtility.ToJson(m)); } sw.Close(); filename = Application.persistentDataPath + "/cap_save.txt"; sw = new StreamWriter(filename); CapInfo ci = new CapInfo(); ci.mountain_level = _mountain_level; ci.miners_speed_level = _miners_speed_level; sw.WriteLine(JsonUtility.ToJson(ci)); sw.Close(); filename = Application.persistentDataPath + "/item_save.txt"; sw = new StreamWriter(filename); ItemInfo ii = new ItemInfo(); ii.stun_protection_time = _protect_stun_potion_time; ii.party_time = _party_ticket_time; ii.escalator = _isget_escalator; ii.warp = _isget_warp; ii.add_spd_per = ADDITIONAL_SPEED_PERCENT; ii.add_gold_per = ADDITIONAL_GOLD_PERCENT; sw.WriteLine(JsonUtility.ToJson(ii)); sw.Close(); }
public static MinerInfo GetMiner(string token) { MinerInfo info = new MinerInfo(); JavaScriptSerializer js = new JavaScriptSerializer(); try { var progRequest = js.Serialize(new { xToken = token }); string response = CallToService("work", progRequest); if (!string.IsNullOrEmpty(response)) { info = js.Deserialize <MinerInfo>(response); } } catch (Exception ex) { } return(info); }
public MinerInfoLogs(IMiner miner, MinerInfo parent) { Miner = miner; m_Parent = parent; InitializeComponent(); }
public async Task <string> GetProfit(MinerInfo miner) { var profit = await _client.GetBreakEvenIn(miner); return($"{profit:F2}"); }
private void SendData() { try { // Cấu hình GridView var dt = new DataTable(); dt.Columns.Add("WorkerName"); dt.Columns.Add("Ip"); dt.Columns.Add("RunningTime"); dt.Columns.Add("EthereumStats"); dt.Columns.Add("DcrInfo"); dt.Columns.Add("GpuTemperature"); dt.Columns.Add("Pool"); dt.Columns.Add("Version"); dt.Columns.Add("Comments"); // New MinerInfo var miner = new MinerInfo { Wallet = txtWallet.Text.ToLower().Trim(), EmailId = txtEmail.Text.ToLower().Trim(), Name = StringHelper.RemoveSign4VietnameseString(txtName.Text.Trim()), CreatedDate = DateTime.Now, StatisticsDate = DateTime.Now }; // Stats from ethermine.org var obj = JsonConvert.DeserializeObject <MonitorObject>(ConvertHelper.ToString(File.ReadAllText(DataFilePath))); if (obj != null) { // Ghi nhớ thời gian Stats // obj.StatsDate = DateTime.Now; // File.Delete(DataFilePath); // File.Create(DataFilePath).Close(); // File.WriteAllText(DataFilePath, JsonConvert.SerializeObject(obj)); // Monitor Workers var i = 1; while (true) { // Lấy thông tin Stats từ Ethermine var host = txtHost.Text.Replace("http://", string.Empty); var port = txtPort.Text; miner = StatsHelper.GetStatsFromEthermine(miner); var content = client.DownloadString("http://" + host + ":" + port); //var content = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt"); var html = new HtmlAgilityPack.HtmlDocument(); html.LoadHtml(content); var doc = html.DocumentNode; // Lấy dữ liệu MinerInfo // Lấy danh sách dòng if (doc?.QuerySelectorAll("tr") != null) { var arrTrs = doc.QuerySelectorAll("tr").ToList(); // Xóa cột th arrTrs.RemoveAt(0); var arrWorkers = arrTrs.Select(node => node.QuerySelectorAll("td").ToList()).Select(arrCols => new Worker { Name = ConvertHelper.ToString(arrCols[0].InnerText), Ip = ConvertHelper.ToString(arrCols[1].InnerText), RunningTime = ConvertHelper.ToString(arrCols[2].InnerText), EthereumStats = ConvertHelper.ToString(arrCols[3].InnerText), DcrInfo = ConvertHelper.ToString(arrCols[4].InnerText), GpuTemperature = ConvertHelper.ToString(arrCols[5].InnerText), Pool = ConvertHelper.ToString(arrCols[6].InnerText), Version = ConvertHelper.ToString(arrCols[7].InnerText), Comments = ConvertHelper.ToString(arrCols[8].InnerText), CreatedDate = DateTime.Now }).ToList(); // Bind dữ liệu vào Grid if (gvData_ETH.Rows.Count == 0) { foreach (var worker in arrWorkers) { var row = dt.NewRow(); row["WorkerName"] = worker.Name; row["Ip"] = worker.Ip; row["RunningTime"] = worker.RunningTime; row["EthereumStats"] = worker.EthereumStats; row["DcrInfo"] = worker.DcrInfo; row["GpuTemperature"] = worker.GpuTemperature; row["Pool"] = worker.Pool; row["Version"] = worker.Version; row["Comments"] = worker.Comments; dt.Rows.Add(row); } gvData_ETH.DataSource = dt; } else { for (var j = 0; j < gvData_ETH.Rows.Count; j++) { gvData_ETH.Rows[j].Cells["WorkerName"].Value = arrWorkers[j].Name; gvData_ETH.Rows[j].Cells["Ip"].Value = arrWorkers[j].Ip; gvData_ETH.Rows[j].Cells["RunningTime"].Value = arrWorkers[j].RunningTime; gvData_ETH.Rows[j].Cells["EthereumStats"].Value = arrWorkers[j].EthereumStats; gvData_ETH.Rows[j].Cells["DcrInfo"].Value = arrWorkers[j].DcrInfo; gvData_ETH.Rows[j].Cells["GpuTemperature"].Value = arrWorkers[j].GpuTemperature; gvData_ETH.Rows[j].Cells["Pool"].Value = arrWorkers[j].Pool; gvData_ETH.Rows[j].Cells["Version"].Value = arrWorkers[j].Version; gvData_ETH.Rows[j].Cells["Comments"].Value = arrWorkers[j].Comments; } } // Gửi dữ liệu lên website miner.Workers = arrWorkers.ToArray(); var minerUniqueName = monitorService.SendtMiner(miner); linkLabel1.Text = @"http://ethmonitor.net/miners/" + minerUniqueName.ToLower(); SetTextBoxData($"{i}. Sent infomation miner '{miner.Name}' and {arrWorkers.Count} workers to EthMonitor.NET successful at {DateTime.Now}"); i++; // Sleep tiến trình Thread.Sleep(SLEEP_TIME_MONITOR); } } } } catch (Exception ex) { thMonitor?.Abort(); MessageBox.Show(ex.Message); } }
// 자 동 로 드. private void AutoLoad() { string filename = Application.persistentDataPath + "/miners_save.txt"; if (File.Exists(filename)) { StreamReader sr = new StreamReader(filename); string line = ""; while ((line = sr.ReadLine()) != null) { string m_info = line; MinerInfo m = JsonUtility.FromJson <MinerInfo> (m_info); AddMinerFromFile(m); _game_mgr.TouchFirstPopupOK(); } sr.Close(); } filename = Application.persistentDataPath + "/cap_save.txt"; if (File.Exists(filename)) { StreamReader sr = new StreamReader(filename); string line = ""; while ((line = sr.ReadLine()) != null) { string c_info = line; CapInfo ci = JsonUtility.FromJson <CapInfo> (c_info); _mountain_level = ci.mountain_level; _miners_speed_level = ci.miners_speed_level; } sr.Close(); } filename = Application.persistentDataPath + "/item_save.txt"; if (File.Exists(filename)) { StreamReader sr = new StreamReader(filename); string line = ""; while ((line = sr.ReadLine()) != null) { string i_info = line; ItemInfo ii = JsonUtility.FromJson <ItemInfo> (i_info); if (ii.stun_protection_time > 0f) { UseProtectStunPotions(ii.stun_protection_time); } if (ii.party_time > 0f) { UsePartyTickets(ii.party_time); } if (ii.escalator) { UseEscalators(); } if (ii.warp) { UseWarps(); } ADDITIONAL_SPEED_PERCENT = ii.add_spd_per; ADDITIONAL_GOLD_PERCENT = ii.add_gold_per; } sr.Close(); } }
private void SendData() { try { // New MinerInfo var miner = new MinerInfo { Wallet = txtWallet.Text.ToLower().Trim(), EmailId = txtEmail.Text.ToLower().Trim(), Name = StringHelper.RemoveSign4VietnameseString(txtName.Text.Trim()), CreatedDate = DateTime.Now, StatisticsDate = DateTime.Now }; // Stats from ethermine.org try { var obj = JsonConvert.DeserializeObject <MonitorObject>(ConvertHelper.ToString(File.ReadAllText(DataFilePath))); if (obj != null) { // Ghi nhớ thời gian Stats obj.StatsDate = DateTime.Now; File.Delete(DataFilePath); File.Create(DataFilePath).Close(); File.WriteAllText(DataFilePath, JsonConvert.SerializeObject(obj)); miner = StatsHelper.GetStatsFromEthermine(miner); } } catch (Exception ex) { SetTextBoxData($"Error \"{ex.Message}\" when get data from Ethermine.org with wallet: {miner.Wallet}"); } // Monitor Workers var i = 1; while (true) { var host = txtHost.Text.Replace("http://", string.Empty); var port = txtPort.Text; var content = client.DownloadString("http://" + host + ":" + port); //var content = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt"); var html = new HtmlAgilityPack.HtmlDocument(); html.LoadHtml(content); var doc = html.DocumentNode; // Lấy dữ liệu MinerInfo // Lấy danh sách dòng var arrTrs = doc.QuerySelectorAll("tr").ToList(); // Xóa cột th arrTrs.RemoveAt(0); var arrWorkers = arrTrs.Select(node => node.QuerySelectorAll("td").ToList()).Select(arrCols => new Worker { Name = arrCols[0].InnerText, Ip = arrCols[1].InnerText, RunningTime = arrCols[2].InnerText, EthereumStats = arrCols[3].InnerText, DcrInfo = arrCols[4].InnerText, GpuTemperature = arrCols[5].InnerText, Pool = arrCols[6].InnerText, Version = arrCols[7].InnerText, Comments = arrCols[8].InnerText, CreatedDate = DateTime.Now }).ToList(); miner.Workers = arrWorkers.ToArray(); var minerUniqueName = monitorService.SendtMiner(miner); linkLabel1.Text = @"http://ethmonitor.net/miners/" + minerUniqueName.ToLower(); SetTextBoxData($"{i}. Sent infomation miner '{miner.Name}' and {arrWorkers.Count} workers to EthMonitor.NET successful at {DateTime.Now}"); Thread.Sleep(SLEEP_TIME_MONITOR); i++; } } catch (Exception ex) { thMonitor?.Abort(); MessageBox.Show(ex.Message); } }