コード例 #1
0
ファイル: Reoffer.cs プロジェクト: sportradar/MtsSdkNet
        private void HandleTicketResponse(ITicketResponse ticketResponse)
        {
            _log.Info($"Ticket '{ticketResponse.TicketId}' response is {ticketResponse.Status}. Reason={ticketResponse.Reason?.Message}");
            if (ticketResponse.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticketResponse.Acknowledge();

                // handle ticket response

                //if for some reason we want to cancel ticket, this is how we can do it
                var ticketCancel = _factory.CreateTicketCancelBuilder().SetTicketId(ticketResponse.TicketId).SetCode(TicketCancellationReason.BookmakerTechnicalIssue).BuildTicket();
                _mtsSdk.SendTicket(ticketCancel);
            }
            else
            {
                // if the ticket was declined and response has reoffer, the reoffer or reoffer cancellation can be send
                // the reoffer or reoffer cancellation must be send before predefined timeout, or is automatically canceled
                if (ticketResponse.BetDetails.Any(a => a.Reoffer != null))
                {
                    if (ReofferShouldBeAccepted())
                    {
                        // ReSharper disable once RedundantArgumentDefaultValue
                        var reofferTicket = _factory.CreateTicketReofferBuilder().Set(_originalTicket, ticketResponse, null).BuildTicket();
                        _mtsSdk.SendTicket(reofferTicket);
                    }
                    else
                    {
                        var reofferCancel = _factory.CreateTicketReofferCancelBuilder().SetTicketId(ticketResponse.TicketId).BuildTicket();
                        _mtsSdk.SendTicket(reofferCancel);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Basic.cs プロジェクト: sportradar/MtsSdkNet
        private void HandleTicketResponse(ITicketResponse ticket)
        {
            _log.Info($"Ticket '{ticket.TicketId}' response is {ticket.Status}. Reason={ticket.Reason?.Message}");

            if (ticket.BetDetails != null && ticket.BetDetails.Any())
            {
                foreach (var betDetail in ticket.BetDetails)
                {
                    _log.Info($"Bet decline reason: '{betDetail.Reason?.Message}'.");
                    if (betDetail.SelectionDetails != null && betDetail.SelectionDetails.Any())
                    {
                        foreach (var selectionDetail in betDetail.SelectionDetails)
                        {
                            _log.Info($"Selection decline reason: '{selectionDetail.Reason?.Message}'.");
                        }
                    }
                }
            }

            if (ticket.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticket.Acknowledge();

                // handle ticket response

                //if for some reason we want to cancel ticket, this is how we can do it
                var ticketCancel = _factory.CreateTicketCancelBuilder().SetTicketId(ticket.TicketId).SetCode(TicketCancellationReason.BookmakerTechnicalIssue).BuildTicket();
                _mtsSdk.SendTicket(ticketCancel);
            }
        }
コード例 #3
0
 public void SendNewTickets(List <Ticket> tickets)
 {
     foreach (var ticket in tickets)
     {
         try
         {
             //ITicket mtsTicket = _ticketGenerator.GenerateNewTicket(ticket);
             mtsTicket = _ticketGenerator.GenerateNewTicket(ticket);
             _mtsSdk.SendTicket(mtsTicket);
             //int stat = (int)BetStatus.s;
             //int stat = (int)TicketStatus.waiting;
             //_ticketService.UpdateTicketStatus(ticket.ticketId, stat.ToString());
             _log.Info($"The ticket : {mtsTicket.TicketId} sent successfully.");
             _log.Info($"The ticket JSon: { mtsTicket.ToJson() }");
         }
         catch (Exception ex)
         {
             _log.Error($"Error in sending ticket, dbTicketId = {ticket.ticketId}", ex);
         }
     }
 }
コード例 #4
0
        private void HandleTicketResponse(ITicketResponse ticketResponse)
        {
            _log.LogInformation($"Ticket '{ticketResponse.TicketId}' response is {ticketResponse.Status}. Reason={ticketResponse.Reason?.Message}");
            if (ticketResponse.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticketResponse.Acknowledge();

                // handle ticket response

                //if for some reason we want to cashout ticket, this is how we can do it
                var ticketCashout = _factory.CreateTicketCashoutBuilder().SetTicketId(ticketResponse.TicketId).SetCashoutStake(12932).BuildTicket();
                _mtsSdk.SendTicket(ticketCashout);
            }
        }
コード例 #5
0
        public void Run()
        {
            _log.LogInformation("Running the MTS SDK cashout example");

            _log.LogInformation("Retrieving configuration from application configuration file");
            var config = MtsSdk.GetConfiguration();

            _log.LogInformation("Creating root MTS SDK instance");
            _mtsSdk = new MtsSdk(config, _loggerFactory);

            _log.LogInformation("Attaching to events");
            AttachToFeedEvents(_mtsSdk);

            _log.LogInformation("Opening the sdk instance (creating and opening connection to the AMPQ broker)");
            _mtsSdk.Open();
            _factory = _mtsSdk.BuilderFactory;

            // create ticket (in order to be accepted, correct values must be entered)
            // values below are just for demonstration purposes and will not be accepted

            //cashout ticket is available only for live events
            var r = new Random();

            _originalTicket = _factory.CreateTicketBuilder()
                              .SetTicketId("ticketId-" + r.Next())
                              .SetSender(_factory.CreateSenderBuilder()
                                         .SetCurrency("EUR")
                                         .SetEndCustomer(_factory.CreateEndCustomerBuilder()
                                                         .SetId("customerClientId-" + r.Next())
                                                         .SetConfidence(1)
                                                         .SetIp(IPAddress.Loopback)
                                                         .SetLanguageId("en")
                                                         .SetDeviceId("UsersDevice-" + r.Next())
                                                         .Build())
                                         .Build())
                              .AddBet(_factory.CreateBetBuilder()
                                      .SetBetId("betId-" + r.Next())
                                      .SetBetBonus(1)
                                      .SetStake(123450000, StakeType.Total)
                                      .AddSelectedSystem(1)
                                      .AddSelection(_factory.CreateSelectionBuilder()
                                                    .SetEventId("1")
                                                    .SetIdUof(1, $"sr:match:{r.Next()}", 1, "1", string.Empty, null)
                                                    .SetOdds(11000)
                                                    .Build())
                                      .Build())
                              .BuildTicket();

            // send ticket to the MTS. Since this is a non-blocking way of sending, the response will raise the event TicketResponseReceived
            _log.LogInformation("Send ticket to the MTS.");
            _mtsSdk.SendTicket(_originalTicket);

            _log.LogInformation("Example successfully executed. Hit <enter> to quit");
            Console.WriteLine(string.Empty);
            Console.ReadLine();

            _log.LogInformation("Detaching from events");
            DetachFromFeedEvents(_mtsSdk);

            _log.LogInformation("Closing the connection and disposing the instance");
            _mtsSdk.Close();

            _log.LogInformation("Example stopped");
        }
コード例 #6
0
ファイル: Basic.cs プロジェクト: sportradar/MtsSdkNet
        public void Run()
        {
            _log.Info("Running the MTS SDK Basic example");

            _log.Info("Retrieving configuration from application configuration file");
            var config = MtsSdk.GetConfiguration();

            _log.Info("Creating root MTS SDK instance");
            _mtsSdk = new MtsSdk(config);

            _log.Info("Attaching to events");
            AttachToFeedEvents(_mtsSdk);

            _log.Info("Opening the sdk instance (creating and opening connection to the AMPQ broker)");
            _mtsSdk.Open();
            _factory = _mtsSdk.BuilderFactory;

            // create ticket (in order to be accepted, correct values must be entered)
            // values below are just for demonstration purposes and will not be accepted
            var r   = new Random();
            var bet = _factory.CreateBetBuilder()
                      .SetBetId("betId-" + r.Next())
                      .SetBetBonus(1)
                      .SetStake(11200, StakeType.Total)
                      .AddSelectedSystem(1)
                      .AddSelection(_factory.CreateSelectionBuilder()
                                    .SetEventId("1")
                                    .SetIdUof(3, $"sr:match:{r.Next()}", 12, "1", string.Empty, null) // only one of the following is required to set selectionId (if you use this method, config property 'accessToken' must be provided)
                                    .SetIdLo(1, 1, "1:1", "1")
                                    .SetIdLcoo(1, 1, "1:1", "1")
                                    .SetId("lcoo:409/1/*/YES")
                                    .SetOdds(11000)
                                    .Build())
                      .Build();
            var endCustomer = _factory.CreateEndCustomerBuilder()
                              .SetId("customerClientId-" + r.Next())
                              .SetConfidence(1)
                              .SetIp(IPAddress.Loopback)
                              .SetLanguageId("en")
                              .SetDeviceId("UsersDevice-" + r.Next())
                              .Build();
            var ticket = _factory.CreateTicketBuilder()
                         .SetTicketId("ticketId-" + r.Next())
                         .SetSender(_factory.CreateSenderBuilder()
                                    .SetCurrency("EUR")
                                    .SetEndCustomer(endCustomer)
                                    .Build())
                         .AddBet(bet)
                         .BuildTicket();

            // send ticket to the MTS. Since this is a non-blocking way of sending, the response will come on the event TicketResponseReceived
            _log.Info("Send ticket to the MTS.");
            _log.Info(ticket.ToJson());
            _mtsSdk.SendTicket(ticket);

            _log.Info("Example successfully executed. Hit <enter> to quit");
            Console.WriteLine(string.Empty);
            Console.ReadLine();

            _log.Info("Detaching from events");
            DetachFromFeedEvents(_mtsSdk);

            _log.Info("Closing the connection and disposing the instance");
            _mtsSdk.Close();

            _log.Info("Example stopped");
        }
コード例 #7
0
ファイル: Examples.cs プロジェクト: sportradar/MtsSdkNetCore
        public void Run()
        {
            _log.LogInformation("Running the MTS SDK ticket integration examples");

            _log.LogInformation("Retrieving configuration from application configuration file");
            var config = MtsSdk.GetConfiguration();

            _log.LogInformation("Creating root MTS SDK instance");
            _mtsSdk = new MtsSdk(config, _loggerFactory);

            _log.LogInformation("Attaching to events");
            AttachToFeedEvents(_mtsSdk);

            _log.LogInformation("Opening the sdk instance (creating and opening connection to the AMPQ broker)");
            _mtsSdk.Open();

            var ticketExamples = new TicketExamples(_mtsSdk.BuilderFactory);

            _factory = _mtsSdk.BuilderFactory;

            _log.LogInformation("Example 1");
            _mtsSdk.SendTicket(ticketExamples.Example1());
            _log.LogInformation("Example 2");
            _mtsSdk.SendTicket(ticketExamples.Example2());
            _log.LogInformation("Example 3");
            _mtsSdk.SendTicket(ticketExamples.Example3());
            _log.LogInformation("Example 4");
            _mtsSdk.SendTicket(ticketExamples.Example4());
            _log.LogInformation("Example 5");
            _mtsSdk.SendTicket(ticketExamples.Example5());
            _log.LogInformation("Example 6");
            _mtsSdk.SendTicket(ticketExamples.Example6());
            _log.LogInformation("Example 7");
            _mtsSdk.SendTicket(ticketExamples.Example7());
            _log.LogInformation("Example 8");
            _mtsSdk.SendTicket(ticketExamples.Example8());
            _log.LogInformation("Example 9");
            _mtsSdk.SendTicket(ticketExamples.Example9());
            _log.LogInformation("Example 10");
            _mtsSdk.SendTicket(ticketExamples.Example10());
            _log.LogInformation("Example 11");
            _mtsSdk.SendTicket(ticketExamples.Example11());
            _log.LogInformation("Example 12");
            _mtsSdk.SendTicket(ticketExamples.Example12());
            _log.LogInformation("Example 13");
            _mtsSdk.SendTicket(ticketExamples.Example13());
            _log.LogInformation("Example 14");
            _mtsSdk.SendTicket(ticketExamples.Example14());

            _log.LogInformation("Examples successfully executed. Hit <enter> to quit");
            Console.WriteLine(string.Empty);
            Console.ReadLine();

            _log.LogInformation("Detaching from events");
            DetachFromFeedEvents(_mtsSdk);

            _log.LogInformation("Closing the connection and disposing the instance");
            _mtsSdk.Close();

            _log.LogInformation("Example stopped");
        }