public void SyncTokenInfo() { var tokenIds = GetTokenFolders(); var existed = _dbContext.Tokens.ToList(); var tokensToRemove = existed.Where(x => !tokenIds.Contains(x.Id)); _dbContext.RemoveRange(tokensToRemove); _dbContext.SaveChanges(); tokenIds.ForEach(x => SyncOneToken(GetTokenObj(x))); }
void UpdateRaisedSeq(string token, int seq, KyubeyContext db) { var rowId = $"incubator_{token}_seq"; var row = db.Constants.FirstOrDefault(x => x.Id == rowId); row.Value = seq.ToString(); db.SaveChanges(); }
int GetOrCreateRaisedSeq(string token, KyubeyContext db) { var rowId = $"incubator_{token}_seq"; var seqRow = db.Constants.Where(x => x.Id == rowId).FirstOrDefault(); if (seqRow == null) { var newRow = new Constant() { Id = rowId, Value = "0" }; db.Constants.Add(newRow); db.SaveChanges(); return(0); } return(Convert.ToInt32(seqRow.Value)); }
//[Invoke(Begin = "2018-06-01", Interval = 1000 * 30, SkipWhileExecuting = true)] public void PollDexActions(IConfiguration config, KyubeyContext db, ITokenRepository tokenRepository) { foreach (var x in db.Tokens .Where(x => x.HasIncubation && x.HasContractExchange) .ToList()) { var token = tokenRepository.GetOne(x.Id); if (token.Incubation.Begin_Time.HasValue && DateTime.UtcNow < TimeZoneInfo.ConvertTimeToUtc(token.Incubation.Begin_Time.Value)) { continue; } if (DateTime.UtcNow > TimeZoneInfo.ConvertTimeToUtc(token.Incubation.DeadLine)) { continue; } var depot = token.Basic.Contract.Depot ?? token.Basic.Contract.Transfer; var balance = GetBalanceAsync(depot, config).Result; x.Raised = Convert.ToDecimal(balance); db.SaveChanges(); } }