Пример #1
0
        public async Task <StoredLatency> Commit()
        {
            var CallSPCmd = new SqlCommand();
            await _streamPersister.DoSqlCmd(CallSPCmd, () =>
            {
                CallSPCmd.CommandText = "exec UpsertPriceBatch @PriceTable, @NumRows";
                CallSPCmd.Parameters.Add("@PriceTable", SqlDbType.Structured).Value = _currentBatch;
                CallSPCmd.Parameters[0].TypeName = "[dbo].[PriceTableType]";
                CallSPCmd.Parameters.Add("@NumRows", SqlDbType.Int).Value = _currentBatch.Rows.Count;
            });

            return(new StoredLatency()
            {
                NumItems = _currentBatch.Rows.Count, Time = StreamEntityPersisterPartition.GetStoredLatency(_currentBatch)
            });
        }
Пример #2
0
        public async Task <StoredLatency> Upsert(StreamEntityBase item, IStreamPersisterBatch tx = null)
        {
            if (item.EntityType == StreamEntityType.Market)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertMarket(item as StreamMarket);
                }
            }
            else if (item.EntityType == StreamEntityType.Submarket)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertSubmarket(item as StreamSubmarket);
                }
            }
            else if (item.EntityType == StreamEntityType.Instrument)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertInstrument(item as StreamInstrument);
                }
            }
            else if (item.EntityType == StreamEntityType.Portfolio)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertPortfolio(item as StreamPortfolio);
                }
            }
            else if (item.EntityType == StreamEntityType.Position)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertPosition(item as StreamPosition);
                }
            }
            else if (item.EntityType == StreamEntityType.Rule)
            {
                if (item.Operation == StreamOperation.Insert)
                {
                    await InsertRule(item as StreamRule);
                }
            }
            else if (item.EntityType == StreamEntityType.Price)
            {
                if (tx == null)
                {
                    await UpsertPrice(item as StreamPrice);
                }
                else
                {
                    UpsertPriceBatch(item as StreamPrice, tx);
                }
            }
            else
            {
                Debugger.Break();
            }

            if (tx == null)
            {
                return(new StoredLatency()
                {
                    NumItems = 1, Time = StreamEntityPersisterPartition.GetStoredLatency(item)
                });
            }
            else
            {
                return(new StoredLatency()
                {
                    NumItems = 0, Time = 0.0
                });
            }
        }