private void updateR2(JToken[] rr, long blockindex, Dictionary <string, long> blockindexDict) {// changeAuctionState foreach (JToken jt in rr) { string auctionId = jt["auctionId"].ToString(); string domain = jt["domain"].ToString(); string parenthash = jt["parenthash"].ToString(); //string domainTTL = jt["domainTTL"].ToString(); long startBlockSelling = long.Parse(jt["startBlockSelling"].ToString()); long endBlock = long.Parse(jt["endBlock"].ToString()); decimal maxPrice = decimal.Parse(jt["maxPrice"].ToString()); string maxBuyer = jt["maxBuyer"].ToString(); long lastBlock = long.Parse(jt["lastBlock"].ToString()); string txid = jt["txid"].ToString(); AuctionTx at = queryAuctionTx(auctionId); if (at == null) { // 没有竞拍信息,报错停止处理 error(auctionId); return; } if (format(at.maxPrice) > maxPrice) { continue; } at.domain = domain; at.parenthash = parenthash; //at.domainTTL = domainTTL; if (endBlock != 0) { at.endTime = new AuctionTime { blockindex = endBlock, blocktime = blockindexDict.GetValueOrDefault(endBlock + ""), txid = txid }; } if (at.startTime == null || at.startTime.blockindex == 0) { at.startTime = new AuctionTime { blockindex = startBlockSelling, blocktime = blockindexDict.GetValueOrDefault(startBlockSelling + ""), txid = txid }; } if (at.ttl == 0) { at.ttl = at.startTime.blocktime + TimeConst.getTimeSetter(at.fulldomain.Substring(at.fulldomain.IndexOf("."))).ONE_YEAR_SECONDS; } at.maxPrice = format(maxPrice); at.maxBuyer = maxBuyer; replaceAuctionTx(at, auctionId); } }
private void initConfig() { JToken cfg = config["TaskList"].Where(p => p["taskName"].ToString() == name()).ToArray()[0]["taskInfo"]; auctionStateColl = cfg["auctionStateColl"].ToString(); batchSize = int.Parse(cfg["batchSize"].ToString()); batchInterval = int.Parse(cfg["batchInterval"].ToString()); root = cfg["root"].ToString(); timeSetter = TimeConst.getTimeSetter(root); // db info localDbConnInfo = Config.localDbConnInfo; blockDbConnInfo = Config.blockDbConnInfo; // initSuccFlag = true; }
private JArray format(JArray res) { TimeSetter timeSetter = TimeConst.getTimeSetter(".test"); return(new JArray() { res.Select(p => { string fulldomain = p["fulldomain"].ToString(); if (fulldomain.EndsWith(".test")) { JObject jo = (JObject)p; long starttime = long.Parse(jo["startTime"]["blocktime"].ToString()); jo.Remove("ttl"); jo.Add("ttl", starttime + timeSetter.ONE_YEAR_SECONDS); return jo; } return p; }) }); }
private JArray format(JArray res) { if (res == null || res.Count == 0) { return(new JArray() { }); } return(new JArray() { res.Select(p => { JObject jo = (JObject)p; string fulldoamin = p["fulldomain"].ToString(); TimeSetter timeSetter = TimeConst.getTimeSetter(fulldoamin.Substring(fulldoamin.LastIndexOf("."))); if (fulldoamin.EndsWith(".test")) { long starttime = long.Parse(jo["startTime"]["blocktime"].ToString()); jo.Remove("ttl"); jo.Add("ttl", starttime + timeSetter.ONE_YEAR_SECONDS); } long st = long.Parse(jo["startTime"]["blocktime"].ToString()); long ed = long.Parse(jo["endTime"]["blocktime"].ToString()); if (ed > 0) { jo.Remove("lastTime"); return jo; } string auctionState = p["auctionState"].ToString(); long expireSeconds = 0; if (auctionState == "0201") { expireSeconds = st + timeSetter.THREE_DAY_SECONDS; } else if (auctionState == "0301") { expireSeconds = st + timeSetter.FIVE_DAY_SECONDS; } else if (auctionState == "0401") { long lt = long.Parse(jo["lastTime"]["blocktime"].ToString()); if (st + timeSetter.TWO_DAY_SECONDS >= lt) { expireSeconds = st + timeSetter.THREE_DAY_SECONDS; } else { expireSeconds = st + timeSetter.FIVE_DAY_SECONDS; } } if (expireSeconds > 0) { // 预计结束时间 JObject ep = (JObject)jo["endTime"]; long blocktime = long.Parse(ep["blocktime"].ToString()); long endBlockTime = blocktime + expireSeconds; ep.Remove("blocktime"); jo.Remove("endTime"); ep.Add("blocktime", endBlockTime); jo.Add("endTime", ep); // jo.Remove("lastTime"); } string value = jo["maxPrice"].ToString(); value = NumberDecimalHelper.formatDecimal(value); jo.Remove("maxPrice"); jo.Add("maxPrice", value); return jo; }) }); }
public Attack() { CastTime = TimeConst.Seconds(3); Name = "Attack"; }
public Rend() { Name = "Rend"; CastTime = TimeConst.Seconds(1); }
public void Execute(Character self, Character target) { target.Buffs.Add(Buffs.Bleeding(self.Snapshot(), TimeConst.Seconds(1), TimeConst.Seconds(5), 1)); }
private JArray format(JArray res, bool isSearch = false) { if (res == null || res.Count == 0) { return(new JArray() { }); } long nowtime = TimeHelper.GetTimeStamp(); return(new JArray() { res.Select(p => { JObject jo = (JObject)p; // 格式转换 string value = jo["maxPrice"].ToString(); value = NumberDecimalHelper.formatDecimal(value); jo.Remove("maxPrice"); jo.Add("maxPrice", value); // 获取ttl string fulldoamin = p["fulldomain"].ToString(); long ttl = 0; if (isSearch) { var rr = getDomainInfo(fulldoamin); if (rr != null && rr.Count > 0) { if (p["auctionState"].ToString() == "0401" || p["auctionState"].ToString() == "0601") { JObject resJo = new JObject() { { "auctionId", p["auctionId"] }, { "fulldomain", p["fulldomain"] }, { "owner", rr[0]["owner"] }, { "ttl", rr[0]["TTL"] } }; string price; if (hasNNfixedSelling(p["fulldomain"].ToString(), long.Parse(p["startTime"]["blockindex"].ToString()), out price)) { resJo.Remove("auctionState"); resJo.Add("auctionState", "0901"); resJo.Add("price", price); return resJo; } resJo.Add("price", "0"); return resJo; /* * return new JObject() { * {"auctionId", p["auctionId"] }, * {"fulldomain", p["fulldomain"] }, * {"owner", rr[0]["owner"] }, * {"ttl", rr[0]["TTL"] } * }; */ } ttl = long.Parse(rr[0]["TTL"].ToString()); jo.Remove("ttl"); jo.Add("ttl", ttl); if (ttl > nowtime) { // 过期域名续约后状态需更新为0401 jo.Remove("auctionState"); jo.Add("auctionState", "0401"); } } } // 触发结束 long now = TimeHelper.GetTimeStamp(); long st = long.Parse(jo["startTime"]["blocktime"].ToString()); long ed = long.Parse(jo["endTime"]["blocktime"].ToString()); if (ed > 0) { jo.Remove("lastTime"); if (now >= ed && now <= ttl) { jo.Remove("auctionState"); jo.Add("auctionState", "0401"); } return jo; } // 计算预计结束时间 TimeSetter timeSetter = TimeConst.getTimeSetter(fulldoamin.Substring(fulldoamin.LastIndexOf("."))); string auctionState = p["auctionState"].ToString(); long expireSeconds = 0; if (auctionState == "0201") { expireSeconds = st + timeSetter.THREE_DAY_SECONDS; } else if (auctionState == "0301") { expireSeconds = st + timeSetter.FIVE_DAY_SECONDS; } else if (auctionState == "0401") { long lt = long.Parse(jo["lastTime"]["blocktime"].ToString()); if (st + timeSetter.TWO_DAY_SECONDS >= lt) { expireSeconds = st + timeSetter.THREE_DAY_SECONDS; } else { expireSeconds = st + timeSetter.FIVE_DAY_SECONDS; } } if (expireSeconds > 0) { JObject ep = (JObject)jo["endTime"]; long blocktime = long.Parse(ep["blocktime"].ToString()); long endBlockTime = blocktime + expireSeconds; ep.Remove("blocktime"); jo.Remove("endTime"); ep.Add("blocktime", endBlockTime); jo.Add("endTime", ep); // jo.Remove("lastTime"); } if (now >= expireSeconds && now <= ttl && auctionState == "0601") { jo.Remove("auctionState"); jo.Add("auctionState", "0401"); } return jo; }) }); }