当前位置: 首页>>代码示例>>C#>>正文


C# Event.GetBody方法代码示例

本文整理汇总了C#中Event.GetBody方法的典型用法代码示例。如果您正苦于以下问题:C# Event.GetBody方法的具体用法?C# Event.GetBody怎么用?C# Event.GetBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event.GetBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var authorised = evnt.GetBody<PaymentAuthorised>();
            var order = await _ordeStore.GetAsync(authorised.OrderId);
            if (order.IsCancelled)
                return new Event[0];

            var payment = await _paymentStore.GetAsync(authorised.PaymentId);
            var customer = await _customeStore.GetAsync(order.CustomerId);
            Trace.TraceInformation("FraudCheckActor - checking order for fraud: " + order.Id);

            if (_fraudChecker.IsFradulent(payment, customer))
            {
                Trace.TraceInformation("FraudCheckActor - !! IS fraud: " + order.Id);

                return new[]
                {
                    new Event( 
                    new FraudCheckFailed()
                    {
                        OrderId = order.Id,
                        PaymentId = payment.Id
                    })
                    {
                        EventType = "FraudCheckFailed",
                        QueueName = "FraudCheckFailed"
                    }
                };
            }

            Trace.TraceInformation("FraudCheckActor - order not fraud: " + order.Id);

            return new Event[0];
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:34,代码来源:FraudCheckActor.cs

示例2: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var importRecordExtracted = evnt.GetBody<ImportRecordExtracted>();
            var elasticSearchUrl = _configurationValueProvider.GetValue(Constants.ElasticSearchUrlKey);

            var client = new HttpClient();
            var url = string.Format("{0}/import/{1}/{2}", elasticSearchUrl,
                importRecordExtracted.IndexType,
                importRecordExtracted.Id);
            var responseMessage = await client.PutAsJsonAsync(url, importRecordExtracted);

           if (!responseMessage.IsSuccessStatusCode)
            {
                throw new ApplicationException("Indexing failed. " 
                    + responseMessage.ToString());
            }

            return new[]
            {
                new Event(new NewIndexUpserted()
                {
                    IndexUrl = url
                }) 
            };
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:25,代码来源:RecordImporterActor.cs

示例3: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var newFileArrived = evnt.GetBody<NewFileArrived>();
            var blob = await _dynamoStore.GetAsync(newFileArrived.FileId);
            var reader = new StreamReader(blob.Body);
            string line = string.Empty;
            var events = new List<Event>();
            while ((line = reader.ReadLine())!= null)
            {
                var fields = line.Split(new []{','},StringSplitOptions.RemoveEmptyEntries);
                events.Add(new Event( new ImportRecordExtracted()
                {
                   Id = fields[0],
                   Content = fields[2],
                   IndexType = fields[1]
                }));
            }

            events.Add(new Event(new ImportFileProcessed()
            {
               FileId = newFileArrived.FileId
            }));

            return events;
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:25,代码来源:FileSplitterActor.cs

示例4: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var itemBackInStockForOrder = evnt.GetBody<ItemBackInStockForOrder>();
            var parkedItems =  (await _parkedOrderItemsStore.GetAsync("ProductQueuedForOrder",
                itemBackInStockForOrder.OrderId)).ToArray();
            var parkedOrderItem = parkedItems.Single(x => x.ProductId == itemBackInStockForOrder.ProductId);
            parkedOrderItem.IsItemReadyToShip = true;
            _parkedOrderItemsStore.UpdateAsync("ProductQueuedForOrder", itemBackInStockForOrder.OrderId,
                parkedOrderItem);
            if (parkedItems.Any(x => !x.IsItemReadyToShip))
            {
                Trace.TraceInformation("ItemBackInStockForOrderActor - still items remaining");
                return new Event [0];
            }
            else // ready
            {
                Trace.TraceInformation("ItemBackInStockForOrderActor - itemss all OK");

                return new[]
                {
                    new Event(new OrderInventoryCheckCompleted()
                    {
                        OrderId = itemBackInStockForOrder.OrderId
                    })
                };
            }

        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:28,代码来源:ItemBackInStockForOrderActor.cs

示例5: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var shardKeyArrived = evnt.GetBody<ShardKeyArrived>();
            TheTrace.TraceInformation("Got {0} from {1}", shardKeyArrived.ShardKey, 
                shardKeyArrived.Source.TypeName);

            var account = CloudStorageAccount.Parse(shardKeyArrived.Source.ConnectionString);
            var client = account.CreateCloudTableClient();
            var table = client.GetTableReference(shardKeyArrived.Source.DynamicProperties["TableName"].ToString());

            var entities = table.ExecuteQuery(new TableQuery().Where(
                TableQuery.GenerateFilterCondition("PartitionKey", "eq", shardKeyArrived.ShardKey)));

            bool hasAnything = false;
            foreach (var entity in entities)
            {
                await _pusher.PushAsync(entity, shardKeyArrived.Source);
                hasAnything = true;
            }

            if (hasAnything)
            {
                await _pusher.FlushAsync();
            }

            return Enumerable.Empty<Event>();
        }
开发者ID:nicolagaletti,项目名称:ConveyorBelt,代码行数:27,代码来源:ShardKeyActor.cs

示例6: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var productOutOfStock = evnt.GetBody<ProductOutOfStock>();

            Trace.TraceInformation("ProductOutOfStockActor - received");

            await Task.Delay(10*1000);

            Trace.TraceInformation("ProductOutOfStockActor - waiting to get orders from suppliers now back");

            await _stockLevelStore.IncrementAsync(Constants.InventoryCounterName,
                productOutOfStock.ProductId,
                productOutOfStock.Quantity + 2);

            return new[] { new Event(new ProductArrivedBackInStock()
            {
                ProductId = productOutOfStock.ProductId
            })
            {
                QueueName = "ProductArrivedBackInStock",
                EventType = "ProductArrivedBackInStock"
            }
            
            };

        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:26,代码来源:ProductOutOfStockActor.cs

示例7: ProcessAsync

 public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
 {
     var keywordIentified = evnt.GetBody<NewsItemContainingKeywordIentified>();
     Trace.TraceInformation("Found {0} in {1}",
         keywordIentified.Keyword, keywordIentified.Item.Url);
     return new Event[0];
 }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:7,代码来源:TraceNotificationActor.cs

示例8: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var fraudCheckFailed = evnt.GetBody<FraudCheckFailed>();
            var order = await _orderStore.GetAsync(fraudCheckFailed.OrderId);

            Trace.TraceInformation("FraudCancelOrderActor - This order must be cancelled: " + order.Id);

            if (order.IsCancelled)
                return new Event[0];

            order.IsCancelled = true;
            await _orderStore.UpsertAsync(order);
            Trace.TraceInformation("FraudCancelOrderActor - order cancelled: " + order.Id);

            return new[]
            {
                new Event(new OrderCancelled()
                {
                    OrderId = order.Id,
                    Reason = "Fraudulent payment"
                })
                {
                    EventType = "OrderCancelled",
                    QueueName = "OrderCancelled"
                }
            };
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:27,代码来源:FraudCancelOrderActor.cs

示例9: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {

            Trace.TraceInformation("ItemOutOfStockForOrderWorkflowActor");

            var outOfStockForOrder = evnt.GetBody<ItemOutOfStockForOrder>();
            if (!outOfStockForOrder.ProductRequested)
            {
                Trace.TraceInformation("ItemOutOfStockForOrderWorkflowActor - ProductRequested");

                outOfStockForOrder.ProductRequested = true;
                return new[] {new Event( outOfStockForOrder)
                {
                    QueueName = "ItemOutOfStockForOrder",
                    EventType = "ItemOutOfStockForOrder"
                }};
            }

            if (!outOfStockForOrder.ProductQueuedForOrder)
            {

                Trace.TraceInformation("ItemOutOfStockForOrderWorkflowActor - ProductQueued");

                await _parkedOrderItemStore.AddAsync("ProductQueuedForOrder",
                    outOfStockForOrder.OrderId,
                    new ParkedOrderItem()
                    {
                        ProductId = outOfStockForOrder.ProductId
                    });
                    

                outOfStockForOrder.ProductQueuedForOrder = true;
                return new[] {new Event( outOfStockForOrder)};
            }

            if (!outOfStockForOrder.OrderQueuedForProduct)
            {
                Trace.TraceInformation("ItemOutOfStockForOrderWorkflowActor - OrderQueued");

                await _orderWaitingForProductStore.AddAsync("OrderQueuedForProduct",
                    outOfStockForOrder.ProductId,
                    new OrderWaitingForProduct()
                    {
                        OrderId = outOfStockForOrder.OrderId,
                        Quantity = outOfStockForOrder.Quantity
                    });

            }

            return new Event[0];

        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:52,代码来源:ItemOutOfStockForOrderWorkflowActor.cs

示例10: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var orderShipped = evnt.GetBody<OrderShipped>();
            var order = await _orderStore.GetAsync(orderShipped.OrderId);
            var shipment = await _shipmentStore.GetAsync(orderShipped.ShipmentId);
            var customer = await _customerStore.GetAsync(order.CustomerId);

            _emailer.Send(
                customer.Email,
                string.Format("Hey {0}, your order has been shipped and expected to arrive on {1}",
                customer.Name, shipment.DeliveryExpectedDate.ToLongDateString()));

            return new Event[0];
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:14,代码来源:OrderShippedEmailActor.cs

示例11: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var productArrivedBackInStock = evnt.GetBody<ProductArrivedBackInStock>();
            var orders = await _ordersWaitingProvider.GetAsync("OrderQueuedForProduct", 
                productArrivedBackInStock.ProductId);

            _ordersWaitingProvider.RemoveAsync("OrderQueuedForProduct",
                productArrivedBackInStock.ProductId).Wait();


            return orders.Select(x => new Event(new ItemBackInStockForOrder()
            {
                ProductId = productArrivedBackInStock.ProductId,
                OrderId = x.OrderId
            }));
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:16,代码来源:ProductBackInStockActor.cs

示例12: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var importFileProcessed = evnt.GetBody<ImportFileProcessed>();
            var statusFile = importFileProcessed.FileId + Constants.StatusPostfix;

            await _dynamoStore.DeleteAsync(new SimpleBlob()
            {
                Id = importFileProcessed.FileId
            });
            await _dynamoStore.DeleteAsync(new SimpleBlob()
            {
                Id = statusFile
            });

            return new Event[0];
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:16,代码来源:FileCleanupActor.cs

示例13: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var paymentFailed = evnt.GetBody<PaymentFailed>();
            var order =  await _orderStore.GetAsync(paymentFailed.OrderId);
            order.IsCancelled = true;
            await _orderStore.UpsertAsync(order);
            Trace.TraceInformation("Order cancelled");

            return new[]
            {
                new Event(new OrderCancelled()
                {
                    OrderId = order.Id,
                    Reason = "Payment failure"
                })
            };
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:17,代码来源:PaymenyFailedActor.cs

示例14: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        { 
            var newsItemCaptured = evnt.GetBody<NewsItemCaptured>();
            if (newsItemCaptured.Item.Title.ToLower()
                .IndexOf(Keyword.ToLower()) >= 0)
            {
                return new Event[]
                {
                    new Event(new NewsItemContainingKeywordIentified()
                    {
                        Item = newsItemCaptured.Item,
                        Keyword = Keyword
                    }), 
                };
            }

            return new Event[0];
        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:18,代码来源:NewsItemKeywordActor.cs

示例15: ProcessAsync

        public async Task<IEnumerable<Event>> ProcessAsync(Event evnt)
        {
            var newsFeedPulsed = evnt.GetBody<NewsFeedPulsed>();
            var client = new HttpClient();
            var stream = await client.GetStreamAsync(newsFeedPulsed.Url);
            var feedChannel = new FeedChannel(newsFeedPulsed.Url);
            var feed = SyndicationFeed.Load(XmlReader.Create(stream));
            var offset = DateTimeOffset.MinValue;
            if (await _channelStore.ExistsAsync(feedChannel.Id))
            {
                feedChannel = await _channelStore.GetAsync(feedChannel.Id);
                offset = feedChannel.LastOffset;
            }
            feedChannel.LastOffset = feed.Items.Max(x => x.PublishDate);
             await _channelStore.UpsertAsync(feedChannel);
            return feed.Items.OrderByDescending(x => x.PublishDate)
                .TakeWhile(y => offset < y.PublishDate)
                .Select(z => new Event(new NewsItemCaptured(){Item = z.ToFeedItem()}));

        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:20,代码来源:NewsFeedPulseActor.cs


注:本文中的Event.GetBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。