public string GetString() { DateTime txTime = QtumHandler.BlockTimeToUtcTime(time); string str = string.Format("time : {0:yyyy/MM/dd HH:mm:ss}", DateTimeHandler.ToLocalTime(txTime)); str += string.Format("\n tx id : {0}", Command.ICommand.GetTxLink(txId)); str += string.Format("\n address : {0}", Command.ICommand.GetAddressLink(address)); //notifyStr += string.Format("\n category : {0}", txInfo.category); str += string.Format("\n amount : {0}", amount); str += string.Format("\n fee : {0}", fee); str += string.Format("\n label : {0}", label); str += string.Format("\n comment : {0}", comment); str += string.Format("\n"); return(str); }
static public async void RefreshTransactionInfo() { if (lastTxTime == DateTime.MaxValue) { return; } if ((DateTime.Now - lastRefreshTine).Ticks / TimeSpan.TicksPerSecond < 10) { return; } lastRefreshTine = DateTime.Now; List <QtumTxInfo> list = QtumHandler.GetTransactions(1); if (list != null && list.Count > 0) { QtumTxInfo lastInfo = list[list.Count - 1]; DateTime newLastTime = QtumHandler.BlockTimeToUtcTime(lastInfo.time); if (newLastTime > lastTxTime) { list = QtumHandler.GetTransactions(100); DateTime notiyStartTime = lastTxTime; lastTxTime = DateTime.MaxValue; await BroadcastTxNotify(notiyStartTime, SummarizeTxList(list)); lastTxTime = newLastTime; SaveLastTime(); } } }
private static async Task BroadcastTxNotify(DateTime startTime, List <QtumTxInfo> txList) { if (txList == null) { return; } if (startTime == DateTime.MinValue) { return; } await UserList.ForeachSendMsg("---------------------------------"); await UserList.ForeachSendMsg("A new transaction has occurred!\n"); for (int i = txList.Count - 1; i >= 0; --i) { QtumTxInfo txInfo = txList[i]; DateTime txTime = QtumHandler.BlockTimeToUtcTime(txInfo.time); if (txTime < startTime) { break; } string notifyStr = txInfo.GetString(); Logger.Log(notifyStr); Logger.Log(""); await UserList.ForeachSendMsg(notifyStr); } await UserList.ForeachSendMsg("---------------------------------"); }