protected string ProcessedSubstitutions(string raw, AlgorithmEntry algo) { if (string.IsNullOrWhiteSpace(raw)) { return(null); } raw = raw .Replace("_ACCOUNT_", _account) .Replace("_WORKER_", _worker); return(ProcessCommon(raw, algo)); }
private string ProcessCommon(string raw, AlgorithmEntry algo) { return(raw .Replace("_PARAM1_", _param1) .Replace("_PARAM2_", _param2) .Replace("_PARAM3_", _param3) .Replace("_SPARAM1_", _param1) .Replace("_SPARAM2_", _param2) .Replace("_SPARAM3_", _param3) .Replace("_APARAM1_", algo.Param1) .Replace("_APARAM2_", algo.Param2) .Replace("_APARAM3_", algo.Param3)); }
protected TEntry CreateEntry(Dictionary <string, object> item) { string algoName = item.GetString("algo"); AlgorithmEntry algo = MiningEngine.AlgorithmEntries.Single(o => o.Name == algoName); TEntry entry = new TEntry { MiningEngine = MiningEngine, ServiceEntry = this, AlgoName = algoName, Name = algo.Display, PriceId = item.GetString("priceid"), MinProfit = _minProfit, Hashrate = algo.Hashrate, Power = algo.Power, Priority = algo.Priority, Affinity = algo.Affinity, Weight = _weight, Folder = ProcessedSubstitutions(item.GetString("folder"), algo) ?? string.Empty, Command = ProcessedSubstitutions(item.GetString("command"), algo), Arguments = ProcessedSubstitutions(item.GetString("arguments"), algo) ?? string.Empty }; if (item.ContainsKey("usewindow")) { entry.UseWindow = bool.Parse(item["usewindow"].ToString()); } if (!string.IsNullOrWhiteSpace(DonationAccount)) { entry.DonationFolder = ProcessedDonationSubstitutions(item.GetString("folder"), algo) ?? string.Empty; entry.DonationCommand = ProcessedDonationSubstitutions(item.GetString("command"), algo); entry.DonationArguments = ProcessedDonationSubstitutions(item.GetString("arguments"), algo) ?? string.Empty; } return(entry); }
protected TEntry CreateEntry(Dictionary <string, object> item) { string algoName = item.GetString("algo"); AlgorithmEntry algo = MiningEngine.AlgorithmEntries.Single(o => o.Name == algoName); TEntry entry = new TEntry { MiningEngine = MiningEngine, ServiceEntry = this, AlgoName = algoName, Name = algo.Display, CoinName = item.GetString("cname") ?? string.Empty, ApiKey = item.GetString("apikey") ?? _apikey, UserId = item.GetString("userid") ?? _userid, PriceId = item.GetString("priceid") ?? string.Empty, Enabled = item.ContainsKey("active") ? (bool)item["active"] : true, Tag = item.GetString("tag") ?? string.Empty, CWeight = item.ContainsKey("cweight") ? item["cweight"].ExtractDecimal() : 1m, MinProfit = _minProfit, Hashrate = algo.Hashrate, MU = algo.MU, DevFee = algo.DevFee.ExtractDecimal(), Power = algo.Power, Priority = algo.Priority, Affinity = algo.Affinity, Weight = _weight, UseWindow = item.ContainsKey("usewindow") ? (bool)item["usewindow"] : MiningEngine._usewindow, Folder = ProcessedSubstitutions(item.GetString("folder"), algo) ?? string.Empty, Command = ProcessedSubstitutions(item.GetString("command"), algo), Arguments = ProcessedSubstitutions(item.GetString("arguments"), algo) ?? string.Empty }; if (item.ContainsKey("fee")) { _fee = item["fee"].ExtractDecimal(); } if (!string.IsNullOrWhiteSpace(entry.CoinName)) { entry.CoinName = entry.CoinName[0].ToString().ToUpper() + entry.CoinName.Substring(1, entry.CoinName.Length - 1); } if (!string.IsNullOrWhiteSpace(entry.Tag)) { entry.Name = entry.Name + "_" + entry.Tag.ToUpper(); } entry.FeePercent = 1 - (1 - _fee / 100) * (1 - _BtcFee / 100); entry.Fees = 1 - (1 - entry.DevFee / 100) * (1 - _fee / 100) * (1 - _BtcFee / 100); if (!string.IsNullOrWhiteSpace(DonationAccount)) { entry.DonationFolder = ProcessedDonationSubstitutions(item.GetString("folder"), algo) ?? string.Empty; entry.DonationCommand = ProcessedDonationSubstitutions(item.GetString("command"), algo); entry.DonationArguments = ProcessedDonationSubstitutions(item.GetString("arguments"), algo) ?? string.Empty; } if (item.ContainsKey("wallet") && !string.IsNullOrWhiteSpace(item["wallet"].ToString())) { entry.Wallet = item["wallet"].ToString(); string Donation = Substitute(entry.Tag); entry.Arguments = entry.Arguments.Replace(_account, entry.Wallet); entry.DonationArguments = entry.DonationArguments.Replace(DonationAccount, Donation); } return(entry); }