public static DynamicDiffstore Create(Options options, SchemaDefinition schema) { var keyType = TypeResolver.FromName(options.KeyType); var valueType = DynamicTypeBuilder.CreateFrom(schema); var builderType = typeof(DiffstoreBuilder <,>).MakeGenericType(keyType, valueType); dynamic instance = Activator.CreateInstance(builderType); switch (options.Store) { case StorageMethod.InMemory: instance.WithMemoryStorage(); break; case StorageMethod.OnDisk: instance.WithDiskStorage("storage"); break; } instance.WithFileBasedEntities(options.EntityFormat); switch (options.Snapshots) { case SnapshotStorage.LastFirst: instance.WithLastFirstOptimizedSnapshots(); break; case SnapshotStorage.SingleFile: instance.WithSingleFileSnapshots(options.SnapshotFormat); break; } var wrapperType = typeof(EmbeddedDBMS <,>) .MakeGenericType(keyType, valueType); var transactionProviderType = typeof(ConcurrentTransactionProvider <>) .MakeGenericType(keyType); var transactionPolicy = TransactionPolicy.FixedRetries( options.MaxRetries, TimeSpan.FromMilliseconds(options.RetryTimeout) ); var wrapper = Activator.CreateInstance(wrapperType, instance.Setup(), transactionPolicy, Activator.CreateInstance(transactionProviderType)); return(new DynamicDiffstore(wrapper, keyType, valueType, schema)); }
/// <summary> Mark transaction start. </summary> /// /// <remarks> Paul, 11/02/2015. </remarks> /// /// <param name="receivedTxid"> The received txid. </param> /// <param name="depositAddress"> The deposit address. </param> /// <param name="symbolPair"> The symbol pair. </param> /// <param name="orderType"> Type of the order. </param> /// <param name="amount"> The amount. </param> public void MarkTransactionStart( string receivedTxid, string depositAddress, string symbolPair, MetaOrderType orderType, MetaOrderStatus status = MetaOrderStatus.processing, TransactionPolicy policy = TransactionPolicy.INSERT) { InsertTransaction(symbolPair, depositAddress, orderType, receivedTxid, null, 0, 0, 0, status, DateTime.UtcNow, null, policy); }
public void MarkDespositAsCreditedStart(string receivedTxid, string depositAddress, string symbolPair, MetaOrderType orderType, MetaOrderStatus status = MetaOrderStatus.processing, TransactionPolicy policy = TransactionPolicy.INSERT) { MarkTransactionStart(receivedTxid, depositAddress, symbolPair, orderType, status, policy); }
// ------------------------------------------------------------------------------------------------------------ /// <summary> Inserts a transaction. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="symbolPair"> The symbol pair. </param> /// <param name="orderType"> Type of the order. </param> /// <param name="receivedTxid"> The received txid. </param> /// <param name="sentTxid"> The sent txid. </param> /// <param name="amount"> The amount. </param> /// <param name="type"> The type. </param> /// <param name="notes"> (Optional) the notes. </param> public void InsertTransaction( string symbolPair, string depositAddress, MetaOrderType orderType, string receivedTxid, string sentTxid, decimal amount, decimal price, decimal fee, MetaOrderStatus status, DateTime date, string notes = null, TransactionPolicy policy = TransactionPolicy.INSERT) { string verb; if (policy == TransactionPolicy.INSERT || policy == TransactionPolicy.REPLACE) { verb = policy.ToString(); } else if (policy == TransactionPolicy.IGNORE) { verb = "INSERT IGNORE"; } else { throw new NotImplementedException(); } m_database.Statement( verb + " INTO transactions (received_txid, deposit_address, sent_txid, symbol_pair, amount, price, fee, date, status, notes, order_type) VALUES(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k);", receivedTxid, depositAddress, sentTxid, symbolPair, amount, price, fee, date, status, notes, orderType); }
public void MarkDespositAsCreditedStart(string receivedTxid, string depositAddress, string symbolPair, MetaOrderType orderType, MetaOrderStatus status = MetaOrderStatus.processing, TransactionPolicy policy = TransactionPolicy.INSERT) { m_dataAccess.MarkDespositAsCreditedStart(receivedTxid, depositAddress, symbolPair, orderType, status, policy); }
/// <summary> Mark transaction start. </summary> /// /// <remarks> Paul, 11/02/2015. </remarks> /// /// <param name="receivedTxid"> The received txid. </param> /// <param name="depositAddress"> The deposit address. </param> /// <param name="symbolPair"> The symbol pair. </param> /// <param name="orderType"> Type of the order. </param> /// <param name="amount"> The amount. </param> public void MarkTransactionStart(string receivedTxid, string depositAddress, string symbolPair, MetaOrderType orderType, MetaOrderStatus status = MetaOrderStatus.processing, TransactionPolicy policy = TransactionPolicy.INSERT) { InsertTransaction(symbolPair, depositAddress, orderType, receivedTxid, null, 0, 0, 0, status, DateTime.UtcNow, null, policy); }
// ------------------------------------------------------------------------------------------------------------ /// <summary> Inserts a transaction. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="symbolPair"> The symbol pair. </param> /// <param name="orderType"> Type of the order. </param> /// <param name="receivedTxid"> The received txid. </param> /// <param name="sentTxid"> The sent txid. </param> /// <param name="amount"> The amount. </param> /// <param name="type"> The type. </param> /// <param name="notes"> (Optional) the notes. </param> public void InsertTransaction(string symbolPair, string depositAddress, MetaOrderType orderType, string receivedTxid, string sentTxid, decimal amount, decimal price, decimal fee, MetaOrderStatus status, DateTime date, string notes = null, TransactionPolicy policy = TransactionPolicy.INSERT) { string verb; if (policy == TransactionPolicy.INSERT || policy == TransactionPolicy.REPLACE) { verb = policy.ToString(); } else if (policy == TransactionPolicy.IGNORE) { verb = "INSERT IGNORE"; } else { throw new NotImplementedException(); } m_database.Statement(verb + " INTO transactions (received_txid, deposit_address, sent_txid, symbol_pair, amount, price, fee, date, status, notes, order_type) VALUES(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k);", receivedTxid, depositAddress, sentTxid, symbolPair, amount, price, fee, date, status, notes, orderType); }