public static async Task InsertIfNotExist(MySqlConnection connection, OTContract_Litigation_LitigationTimedOut model)
        {
            var count = await connection.QueryFirstOrDefaultAsync <Int32>("SELECT COUNT(*) FROM OTContract_Litigation_LitigationTimedOut WHERE TransactionHash = @hash AND BlockchainID = @blockchainID", new
            {
                hash         = model.TransactionHash,
                blockchainID = model.BlockchainID
            });

            if (count == 0)
            {
                await connection.ExecuteAsync(
                    @"INSERT INTO OTContract_Litigation_LitigationTimedOut
(TransactionHash, BlockNumber, Timestamp, OfferId, HolderIdentity, GasPrice, GasUsed, BlockchainID)
VALUES(@TransactionHash, @BlockNumber, @Timestamp, @OfferId, @HolderIdentity, @GasPrice, @GasUsed, @BlockchainID)",
                    new
                {
                    model.TransactionHash,
                    model.BlockNumber,
                    model.Timestamp,
                    model.OfferId,
                    model.HolderIdentity,
                    model.GasPrice,
                    model.GasUsed,
                    model.BlockchainID
                });

                await OTOfferHolder.UpdateLitigationStatusesForOffer(connection, model.OfferId, model.BlockchainID);
            }
        }
示例#2
0
        public static async Task FinalizeOffer(MySqlConnection connection, string offerId, UInt64 logBlockNumber,
                                               string logTransactionHash, string holder1, string holder2, string holder3, DateTime blockTimestamp, int blockchainID)
        {
            var count = await connection.ExecuteAsync(@"UPDATE OtOffer SET FinalizedBlockNumber = @logBlockNumber, FinalizedTransactionHash = @logTransactionHash, 
FinalizedTimestamp = @FinalizedTimestamp, IsFinalized = 1 WHERE OfferID = @offerId And IsFinalized = 0 AND BlockchainID = @blockchainID", new
            {
                offerId,
                logBlockNumber = logBlockNumber,
                logTransactionHash,
                FinalizedTimestamp = blockTimestamp,
                blockchainID       = blockchainID
            });

            if (count == 0)
            {
                return;
            }

            bool added = false;

            foreach (var holder in new[] { holder1, holder2, holder3 })
            {
                added = await OTOfferHolder.Insert(connection, offerId, holder, true, blockchainID);
            }
        }