private static void insertBlockTime2TSDB(string mongodbConnStr, string mongodbDatabase, Aliyun_TSDB aliyun_TSDB, string netType) { long maxBloclHeight = -1; try { var maxBlock = aliyun_TSDB.TSDB_query(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(1), "max", "neo.block.height.done", JObject.Parse("{'net': '" + netType + "'}"), "2d-max"); maxBloclHeight = (long)decimal.Parse(maxBlock[0]["dps"].First.ToString().Split(":")[1]); } catch { } mongodbHelper mh = new mongodbHelper(); JArray JA = mh.GetData(mongodbConnStr, mongodbDatabase, "system_counter", "{}"); long maxBlockHeight_DB = long.Parse(JA.Children().Where(n => n["counter"].ToString() == "block").Select(n => (string)n["lastBlockindex"]).ToArray()[0]); long doBlockHeight = maxBloclHeight + 1; if (doBlockHeight <= maxBlockHeight_DB) { JArray blockJA = mh.GetData(mongodbConnStr, mongodbDatabase, "block", "{index:" + doBlockHeight + "}"); var lastBlockTime = (long)blockJA[0]["time"]; try { var a = aliyun_TSDB.TSDB_put_single(new Aliyun_TSDB.TSDB_Data("neo.block.height", lastBlockTime, doBlockHeight, JObject.Parse("{'net': '" + netType + "'}"))); var b = aliyun_TSDB.TSDB_put_single(new Aliyun_TSDB.TSDB_Data("neo.block.height.done", DateTime.Now, doBlockHeight, JObject.Parse("{'net': '" + netType + "'}"))); Console.WriteLine("写入高度:" + doBlockHeight + "块时间到TSDB"); } catch { Console.WriteLine("写入TSDB失败,重试!"); } } }