public async Task ProcessStreamItem(StreamPrice price)
        {
            StreamPrice currentPrice = null;
            bool        found        = _prices.TryGetValue(price.Id, out currentPrice);

            switch (price.Operation)
            {
            case StreamOperation.Insert:
            case StreamOperation.Update:
                if (!found || currentPrice.Compare(price) != 0)
                {
                    if (_persistenceLayer != null)
                    {
                        await _persistenceLayer.ProcessStreamItem(price);
                    }
                }
                _prices[price.Id] = price;
                break;

            case StreamOperation.Delete:
                if (found)
                {
                    if (_persistenceLayer != null)
                    {
                        await _persistenceLayer.ProcessStreamItem(price);
                    }
                    _prices.TryRemove(price.Id, out currentPrice);
                }
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        private void UpsertPriceBatch(StreamPrice price, IStreamPersisterBatch tx = null)
        {
            var batchPersister = tx as SqlBatchStreamPersister;

            var IntrumentTmp      = price.Id.Split(':')[1];
            var InstrumentIdSplit = IntrumentTmp.Split('-');
            var MarketId          = int.Parse(InstrumentIdSplit[0]);
            var SubmarketId       = int.Parse(InstrumentIdSplit[1]);
            var Id = int.Parse(InstrumentIdSplit[2]);

            batchPersister.AddRow((MarketId * 10 + SubmarketId) * 1000000 + Id, price.PriceLatest, price.PriceDate, price.Date, price.SequenceNumber);
        }
Beispiel #3
0
        private async Task UpsertPrice(StreamPrice price)
        {
            var CallSPCmd = new SqlCommand();

            await DoSqlCmd(CallSPCmd, () =>
            {
                var IntrumentTmp      = price.Id.Split(':')[1];
                var InstrumentIdSplit = IntrumentTmp.Split('-');
                var MarketId          = int.Parse(InstrumentIdSplit[0]);
                var SubmarketId       = int.Parse(InstrumentIdSplit[1]);
                var Id = int.Parse(InstrumentIdSplit[2]);

                CallSPCmd.CommandText = "exec UpsertPrice @InstrumentId, @Price, @PriceLatest, @Timestamp, @SequenceNumber";
                CallSPCmd.Parameters.Add("@InstrumentId", SqlDbType.Int).Value      = (MarketId * 10 + SubmarketId) * 1000000 + Id;
                CallSPCmd.Parameters.Add("@Price", SqlDbType.Float).Value           = price.PriceLatest;
                CallSPCmd.Parameters.Add("@Pricelatest", SqlDbType.DateTime).Value  = price.PriceDate;
                CallSPCmd.Parameters.Add("@Timestamp", SqlDbType.DateTime).Value    = price.Date;
                CallSPCmd.Parameters.Add("@SequenceNumber", SqlDbType.BigInt).Value = price.SequenceNumber;
            });
        }
 public virtual Task PriceUpdated(StreamPrice streamItem)
 {
     return(Task.CompletedTask);
 }
 public override Task PriceDeleted(StreamPrice streamItem)
 {
     return(_dataLayer.ProcessStreamItem(streamItem));
 }