public List <TransactionComment> SelectByTransactionHash(string txHash) { const string SQL_STATEMENT = "SELECT * " + "FROM TransactionComments " + "WHERE TransactionHash = @TransactionHash;"; List <TransactionComment> result = new List <TransactionComment>(); using (SqliteConnection con = new SqliteConnection(base.CacheConnectionString)) using (SqliteCommand cmd = new SqliteCommand(SQL_STATEMENT, con)) { cmd.Parameters.AddWithValue("@TransactionHash", txHash); cmd.Connection.Open(); using (SqliteDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { var tc = new TransactionComment(); tc.Id = GetDataValue <long>(dr, "Id"); tc.TransactionHash = GetDataValue <string>(dr, "TransactionHash"); tc.OutputIndex = GetDataValue <int>(dr, "OutputIndex"); tc.Comment = GetDataValue <string>(dr, "Comment"); tc.Timestamp = GetDataValue <long>(dr, "Timestamp"); result.Add(tc); } } return(result); } }
public TransactionComment SelectByTransactionHashAndIndex(string txHash, int outputIndex) { const string SQL_STATEMENT = "SELECT * " + "FROM TransactionComments " + "WHERE TransactionHash = @TransactionHash AND OutputIndex = @OutputIndex"; TransactionComment tc = null; using (SqliteConnection con = new SqliteConnection(base.CacheConnectionString)) using (SqliteCommand cmd = new SqliteCommand(SQL_STATEMENT, con)) { cmd.Parameters.AddWithValue("@TransactionHash", txHash); cmd.Parameters.AddWithValue("@OutputIndex", outputIndex); cmd.Connection.Open(); using (SqliteDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { tc = new TransactionComment(); tc.Id = GetDataValue <long>(dr, "Id"); tc.TransactionHash = GetDataValue <string>(dr, "TransactionHash"); tc.OutputIndex = GetDataValue <int>(dr, "OutputIndex"); tc.Comment = GetDataValue <string>(dr, "Comment"); tc.Timestamp = GetDataValue <long>(dr, "Timestamp"); } } return(tc); } }
public long Insert(TransactionComment comment) { const string SQL_STATEMENT = "INSERT INTO TransactionComments " + "(TransactionHash, OutputIndex, Comment, Timestamp) " + "VALUES (@TransactionHash, @OutputIndex, @Comment, @Timestamp);" + "SELECT LAST_INSERT_ROWID() newid;"; using (SqliteConnection con = new SqliteConnection(base.CacheConnectionString)) using (SqliteCommand cmd = new SqliteCommand(SQL_STATEMENT, con)) { cmd.Parameters.AddWithValue("@TransactionHash", comment.TransactionHash); cmd.Parameters.AddWithValue("@OutputIndex", comment.OutputIndex); cmd.Parameters.AddWithValue("@Timestamp", comment.Timestamp); if (string.IsNullOrWhiteSpace(comment.Comment)) { cmd.Parameters.AddWithValue("@Comment", DBNull.Value); } else { cmd.Parameters.AddWithValue("@Comment", comment.Comment); } cmd.Connection.Open(); return(Convert.ToInt64(cmd.ExecuteScalar())); } }
public void Save(TransactionComment comment) { var key = GetKey(UserTables.TxComment, $"{comment.TransactionHash}_{comment.OutputIndex}"); if (!CommentBook.Contains(key)) { CommentBook.Add(key); UserDomain.Put(key, comment); } }
public long Add(string txHash, int outputIndex, string comment) { var item = new TransactionComment(); item.TransactionHash = txHash; item.OutputIndex = outputIndex; item.Comment = comment; item.Timestamp = Time.EpochTime; return(new TransactionCommentDac().Insert(item)); }
public void Add(string txHash, int outputIndex, string comment) { var item = new TransactionComment(); item.TransactionHash = txHash; item.OutputIndex = outputIndex; item.Comment = comment; item.Timestamp = Time.EpochTime; var result = 0L; TransactionCommentDac.Default.Save(item); }