예제 #1
0
 public void TestPricePrecision()
 {
     var cli = new CheckpointClient(Url, Token);
     var res = cli.PreviewPromoOffers(new ApplyPromoOffersRequest
     {
         Order = new Order
         {
             PosCode    = "MAIN",
             Name       = "order1",
             ExternalId = "1",
             DateStart  = DateTime.Today,
             DateEnd    = null,
             Items      = new []
             {
                 new OrderItem
                 {
                     Date   = DateTime.Today,
                     Code   = "123",
                     Name   = "Text",
                     Amount = 10,
                     AmountBeforeDiscount = 10.123456m
                 }
             }
         }
     });
 }
예제 #2
0
        protected virtual async Task ProcessInitializingHandler(PartitionInitializingEventArgs initArgs)
        {
            var partitionId = initArgs.PartitionId;

            Logger.LogTrace($"Initializing partition {partitionId}");

            if (initArgs.CancellationToken.IsCancellationRequested)
            {
                // Log the condition where the initialization handler is called, an the PartitionInitializingEventArgs contains a cancellation request.
                Logger.LogTrace($"PartitionInitializingEventArgs contain a cancellation request {partitionId}");
            }

            try
            {
                var checkpoint = await CheckpointClient.GetCheckpointForPartitionAsync(partitionId, initArgs.CancellationToken);

                initArgs.DefaultStartingPosition = EventPosition.FromEnqueuedTime(checkpoint.LastProcessed);
                Logger.LogTrace($"Starting to read partition {partitionId} from checkpoint {checkpoint.LastProcessed}");
                Logger.LogMetric(EventMetrics.EventHubPartitionInitialized(partitionId), 1);
            }
#pragma warning disable CA1031
            catch (Exception ex)
#pragma warning restore CA1031
            {
                Logger.LogTrace($"Failed to initialize partition {partitionId} from checkpoint");

                EventHubExceptionProcessor.ProcessException(ex, Logger, errorMetricName: EventHubErrorCode.EventHubPartitionInitFailed.ToString());
            }
        }
예제 #3
0
        public override async Task RunAsync(CancellationToken ct)
        {
            // Reset previous checkpoints corresponding to an older source event hub (i.e. applicable if the source event hub changes)
            await CheckpointClient.ResetCheckpointsAsync(ct);

            EventProcessorClient.ProcessEventAsync          += ProcessEventHandler;
            EventProcessorClient.ProcessErrorAsync          += ProcessErrorHandler;
            EventProcessorClient.PartitionInitializingAsync += ProcessInitializingHandler;

            try
            {
                Console.WriteLine($"Starting event hub processor at {DateTime.UtcNow}");
                await EventProcessorClient.StartProcessingAsync(ct);

                // Wait indefinitely until cancellation is requested
                ct.WaitHandle.WaitOne();

                await EventProcessorClient.StopProcessingAsync();
            }
            finally
            {
                EventProcessorClient.ProcessEventAsync          -= ProcessEventHandler;
                EventProcessorClient.ProcessErrorAsync          -= ProcessErrorHandler;
                EventProcessorClient.PartitionInitializingAsync -= ProcessInitializingHandler;
            }
        }
예제 #4
0
        public void TestConnection()
        {
            Assert.IsNotNull(Token, "Token is undefined!");
            var cli = new CheckpointClient(Url, Token);
            var res = cli.FindPointOfSales(new PointOfSaleFilter());

            Assert.Greater(res.Count, 0);
        }
예제 #5
0
        public void TestCustomerSearch()
        {
            var cli       = new CheckpointClient(Url, Token);
            var customers = cli.FindCustomers(new CustomerFilter
            {
                ExternalId = "1b057f36-5f15-4148-b907-54e9c1cccaf0"
            });

            Assert.Greater(customers.Count, 1);
        }
예제 #6
0
        public void TestCardsList()
        {
            var cli   = new CheckpointClient(Url, Token);
            var cards = cli.FindCards(new CardFilter
            {
                Limit = 10
            });

            Assert.Greater(cards.Count, 0);
        }
예제 #7
0
        public void TestCustomerSearch()
        {
            var cli       = new CheckpointClient(Url, Token);
            var customers = cli.FindCustomers(new CustomerFilter
            {
                BirthDate = new DateTime(2020, 1, 1)
            });

            Assert.Greater(customers.Count, 0);
        }
예제 #8
0
        public void TestTiersSearch()
        {
            var cli   = new CheckpointClient(Url, Token);
            var tiers = cli.GetTiers();

            Assert.Greater(tiers.Count, 0);
            foreach (var tier in tiers.Results)
            {
                Assert.Greater(tier.Id, 0);
            }
        }
예제 #9
0
        public void TestCardsList()
        {
            var cli   = new CheckpointClient(Url, Token);
            var cards = cli.FindCards(new CardFilter
            {
                CardNo = "8760c21e-0da8-4e54-a21f-2f037c3ed3ab",
                Limit  = 1
            });

            Assert.Greater(cards.Count, 0);
        }
예제 #10
0
        public void TestOrderSearch()
        {
            var cli    = new CheckpointClient(Url, Token);
            var orders = cli.FindOrders(new OrderFilter());

            Assert.Greater(orders.Count, 0);
            Assert.IsNotNull(orders.Results);
            foreach (var order in orders.Results)
            {
                Assert.Greater(order.Id, 0);
                var ord = cli.GetOrder(order.Id);
                Assert.IsNotNull(ord);
            }
        }
예제 #11
0
        public void TestCustomerAndAccountOperations()
        {
            var cli = new CheckpointClient(Url, Token);

            var order = new Order
            {
                ExternalId = Guid.NewGuid().ToString(),
                DateStart  = DateTime.Today.AddDays(-1),
                DateEnd    = DateTime.Today,
                Name       = "Reservation",
                PosCode    = "MAIN",
                Customer   = new Customer
                {
                    ExternalId = Guid.NewGuid().ToString(),
                    FirstName  = "Serg",
                    LastName   = "Zhi",
                    Email      = "*****@*****.**",
                    Phone      = "+7999112244",
                    BirthDate  = new DateTime(1981, 12, 11)
                }
            };

            order = cli.CreateUpdateOrder("MAIN", order.ExternalId, order);

            var customers = cli.FindCustomers(new CustomerFilter());

            Assert.Greater(customers.Count, 0);
            var customer = cli.GetCustomer(customers.Results[0].Id);

            Assert.IsNotNull(customer.Cards);
            Assert.Greater(customer.Cards.Length, 0);
            var card           = customer.Cards[0];
            var pointOperation = cli.ChargePoints(new ChargePointsRequest("Points test", "MAIN", order.ExternalId, card.Account.Id, 10, "test user"));

            Assert.IsNotNull(pointOperation);
            Assert.Greater(pointOperation.Id, 0);

            cli.ChargedPointsDelete(new DeleteAccountOperationRequest
            {
                AccountOperationId = pointOperation.Id
            });

            cli.DeleteOrder(order.Id);
        }
예제 #12
0
 public void TestBonusCharge()
 {
     var cli   = new CheckpointClient(Url, Token);
     var cards = cli.ChargePoints(new ChargePointsRequest("8760c21e-0da8-4e54-a21f-2f037c3ed3ab", "Тест", 10));
 }