private static void UpdateAsync() { Task.Factory.StartNew(() => { try { byte[] htmlData = GetHtmlAsync("https://www.f2pool.com/").Result; if (htmlData != null && htmlData.Length != 0) { Console.WriteLine($"{DateTime.Now} - 鱼池首页html获取成功"); string html = Encoding.UTF8.GetString(htmlData); double usdCny = PickUsdCny(html); Console.WriteLine($"usdCny={usdCny}"); List <IncomeItem> incomeItems = PickIncomeItems(html); Console.WriteLine($"鱼池首页有{incomeItems.Count}个币种"); FillCny(incomeItems, usdCny); NeatenSpeedUnit(incomeItems); if (incomeItems != null && incomeItems.Count != 0) { Login(); DataResponse <List <CalcConfigData> > response = OfficialServer.GetCalcConfigs(); Console.WriteLine($"NTMiner有{response.Data.Count}个币种"); HashSet <string> coinCodes = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (CalcConfigData calcConfigData in response.Data) { IncomeItem incomeItem = incomeItems.FirstOrDefault(a => string.Equals(a.CoinCode, calcConfigData.CoinCode, StringComparison.OrdinalIgnoreCase)); if (incomeItem != null) { coinCodes.Add(calcConfigData.CoinCode); calcConfigData.Speed = incomeItem.Speed; calcConfigData.SpeedUnit = incomeItem.SpeedUnit; calcConfigData.IncomePerDay = incomeItem.IncomeCoin; calcConfigData.IncomeUsdPerDay = incomeItem.IncomeUsd; calcConfigData.IncomeCnyPerDay = incomeItem.IncomeCny; calcConfigData.ModifiedOn = DateTime.Now; } } OfficialServer.SaveCalcConfigsAsync(response.Data, null); foreach (IncomeItem incomeItem in incomeItems) { if (coinCodes.Contains(incomeItem.CoinCode)) { continue; } Console.WriteLine(incomeItem.ToString()); } Console.ForegroundColor = ConsoleColor.Green; foreach (var incomeItem in incomeItems) { if (!coinCodes.Contains(incomeItem.CoinCode)) { continue; } Console.WriteLine(incomeItem.ToString()); } Console.ResetColor(); Console.WriteLine($"更新了{coinCodes.Count}个币种:{string.Join(",", coinCodes)}"); int unUpdatedCount = response.Data.Count - coinCodes.Count; Console.WriteLine($"{unUpdatedCount}个币种未更新{(unUpdatedCount == 0 ? string.Empty: ":" + string.Join(",", response.Data.Select(a => a.CoinCode).Except(coinCodes)))}"); } } } catch (Exception e) { PrintError(e); } }); }