public void UpdateServerWithPreferredMineAndCredential() { if (isGateway) { return; } try { bot.Refresh(); //1. 优先查看 MineProfile 的配置 var cma = MineProfile.FindByBot(bot.Id); if (cma != null && cma.MineId > 0 && !string.IsNullOrWhiteSpace(cma.CustomAccount) && !string.IsNullOrWhiteSpace(cma.CustomPassword)) { var m = Mine.Find(cma.MineId); if (m != null) { server = BitServer.Create(m.Address, cma.CustomAccount, cma.CustomPassword); mine = m; return; } } //2. 其次查看 SystemPreferred var preferred = systemPreferred.Peek(); preferred.Refresh(); //2.5 如果有绑定信息的话 if (bot.Account != null) { var pma = MineProfile.FindByAccountMine(bot.Account.Id, preferred.Id); if (pma != null && !string.IsNullOrWhiteSpace(pma.CustomAccount) && !string.IsNullOrWhiteSpace(pma.CustomPassword)) { var m = Mine.Find(pma.MineId); if (m != null) { server = BitServer.Create(preferred.Address, pma.CustomAccount, pma.CustomPassword); mine = m; return; } } } //3. 最后使用系统自带的 server = BitServer.Create(preferred.Address, preferred.DefaultAccount, preferred.DefaultPassword); mine = preferred; } catch (Exception error) { logger.Error("UpdateServerWithPreferredMineAndCredential", error); } }
public ComputeManager() { this.isGateway = true; this.server = BitServer.Create(systemGateway.Address, systemGateway.DefaultAccount, systemGateway.DefaultPassword); logger.InfoFormat("Create ComputeManager Gateway {0} {1} {2}", systemGateway.Address, systemGateway.DefaultAccount, systemGateway.DefaultPassword); }