示例#1
0
 private async void pulser_PulseGenerated(object sender, IEnumerable <Event> e)
 {
     foreach (var ev in e)
     {
         await _queueOperator.PushAsync(ev);
     }
 }
示例#2
0
        private async Task DoScheduleAsync(PeckSource source)
        {
            var oldTimestamp = source.Timestamp;

            try
            {
                await _eventQueueOperator.PushAsync(new Event(new PeckSourceScheduled()
                {
                    Source = source
                })
                {
                    QueueName = QueueName.FromTopicName("PeckSourceScheduled").ToString()
                });

                source.LastOffset = DateTimeOffset.UtcNow;
                await _table.ExecuteAsync(TableOperation.InsertOrMerge(source));
            }
            catch (Exception e)
            {
                source.LastOffset = oldTimestamp;
                TheTrace.TraceError("Error scheduling source {0} : {1}", source.Name, e);
                try
                {
                    _table.Execute(TableOperation.InsertOrMerge(source));
                }
                catch (Exception ex)
                {
                    TheTrace.TraceError("Error saving error (!) in table. Source {0} : {1}", source.Name, ex);
                }
            }
        }
示例#3
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.TraceInformation("BeeHive.Demo.Worker entry point called", "Information");

            while (true)
            {
                Thread.Sleep(10000);
                Trace.TraceInformation("Working", "Information");
                var order = new Order()
                {
                    CustomerId        = Guid.NewGuid().ToString("N"),
                    Id                = Guid.NewGuid().ToString("N"),
                    PaymentMethod     = "Card/Visa/4444333322221111/123",
                    ShippingAddress   = "Jabolsa",
                    TotalPrice        = 223,
                    ProductQuantities = new Dictionary <string, int>()
                    {
                        { Guid.NewGuid().ToString("N"), 1 },
                        { Guid.NewGuid().ToString("N"), 2 },
                        { Guid.NewGuid().ToString("N"), 3 },
                    }
                };

                var customer = new Customer()
                {
                    Address = "2, Korat Jingala",
                    Email   = "*****@*****.**",
                    Id      = order.CustomerId,
                    Name    = "Natsak Birat"
                };

                _customerStore.InsertAsync(customer).Wait();

                _orderStore.InsertAsync(order).Wait();
                var ev = new Event(new OrderAccepted()
                {
                    OrderId = order.Id
                })
                {
                    EventType = "OrderAccepted"
                };
                _queueOperator.PushAsync(ev).Wait();
            }
        }