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); } }
// // GET: /Work/DeleteProfile public ActionResult DeleteProfile(string id) { try { var profile = MineProfile.Find(int.Parse(id)); if (profile != null) { var account = Account.FindBy(WebSecurity.CurrentUserId); var mp = MineProfile.FindByAccountMine(account.Id, profile.MineId); mp.Delete(); } } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(RedirectToAction("Index", "Work")); }