/// <summary> Executes the push transactions action. </summary> /// /// <remarks> Paul, 20/02/2015. </remarks> /// /// <param name="newTrans"> The new transaction. </param> /// <param name="database"> The database. </param> void OnPushTransactions(List <TransactionsRow> newTrans, MySqlData database) { Dictionary <string, uint> lastSeen = new Dictionary <string, uint>(); try { database.BeginTransaction(); foreach (TransactionsRow r in newTrans) { // this may have problems with partial transactions database.InsertTransaction(r.symbol_pair, r.deposit_address, r.order_type, r.received_txid, r.sent_txid, r.amount, r.price, r.fee, r.status, r.date, r.notes, TransactionPolicy.REPLACE); if (lastSeen.ContainsKey(r.symbol_pair)) { lastSeen[r.symbol_pair] = Math.Max(r.uid, lastSeen[r.symbol_pair]); } else { lastSeen[r.symbol_pair] = r.uid; } } // keep the site upto date with last seen transastion uids foreach (KeyValuePair <string, uint> kvp in lastSeen) { database.UpdateLastSeenTransactionForSite(kvp.Key, kvp.Value); } database.EndTransaction(); } catch (Exception) { database.RollbackTransaction(); throw; } }