public async Task ProcessStreamItem(StreamPortfolio portfolio)
        {
            StreamPortfolio currentPortfolio = null;
            bool            found            = _portfolios.TryGetValue(portfolio.Id, out currentPortfolio);

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

            case StreamOperation.Delete:
                if (found)
                {
                    if (_persistenceLayer != null)
                    {
                        await _persistenceLayer.ProcessStreamItem(portfolio);
                    }
                    _portfolios.TryRemove(portfolio.Id, out currentPortfolio);
                }
                break;

            default:
                break;
            }
        }
Example #2
0
        private async Task InsertPortfolio(StreamPortfolio portfolio)
        {
            var CallSPCmd = new SqlCommand();

            await DoSqlCmd(CallSPCmd, () =>
            {
                var Id = int.Parse(portfolio.Id.Split(':')[1]);
                CallSPCmd.CommandText = "exec InsertPortfolio @Id, @Name, @Balance, @CheckRules, @Timestamp";
                CallSPCmd.Parameters.Add("@Id", SqlDbType.Int).Value             = Id;
                CallSPCmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value      = portfolio.Name;
                CallSPCmd.Parameters.Add("@Balance", SqlDbType.Float).Value      = portfolio.Balance;
                CallSPCmd.Parameters.Add("@CheckRules", SqlDbType.Bit).Value     = portfolio.CheckRules;
                CallSPCmd.Parameters.Add("@Timestamp", SqlDbType.DateTime).Value = portfolio.Date;
            });
        }
 public virtual Task PortfolioUpdated(StreamPortfolio streamItem)
 {
     return(Task.CompletedTask);
 }
 public override Task PortfolioUpdated(StreamPortfolio streamItem)
 {
     return(_dataLayer.ProcessStreamItem(streamItem));
 }