コード例 #1
0
        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)));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: RaiseJob.cs プロジェクト: LittleSound/kyubey
        //[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();
            }
        }