Exemplo n.º 1
0
        public void when_creating_conference_and_seat_then_publishes_seat_created_on_publish()
        {
            var conference = new ConferenceInfo
            {
                OwnerEmail  = "*****@*****.**",
                OwnerName   = "test owner",
                AccessCode  = "qwerty",
                Name        = "test conference",
                Description = "test conference description",
                Location    = "redmond",
                Slug        = "test",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
            };

            service.CreateConference(conference);

            var seat = new SeatType {
                Name = "seat", Description = "description", Price = 100, Quantity = 100
            };

            service.CreateSeat(conference.Id, seat);

            service.Publish(conference.Id);

            var e = busEvents.OfType <SeatCreated>().FirstOrDefault();

            Assert.NotNull(e);
            Assert.Equal(e.SourceId, seat.Id);
        }
        public async Task <List <Ticket> > Add(int id, string st, int count, int discount, User user)
        {
            var      discountEntity = this._discountsService.GetById(discount);
            SeatType seatType       = (SeatType)Enum.Parse(typeof(SeatType), st);
            var      tickets        = new List <Ticket>();

            for (int i = 0; i < count; i++)
            {
                var seat   = this._tripsService.GetById(id).Transport.Seats.FirstOrDefault(s => s.Type == seatType);
                var ticket = new Ticket
                {
                    Price = discountEntity.Percent * seat.Price,
                    Seat  = seat,
                    Buyer = user
                };
                await this._ticketRepository.AddAsync(ticket);

                tickets.Add(ticket);
                user.Tickets.Add(ticket);

                this._tripsService.DropSeat(id, seat, count);
            }
            await this._ticketRepository.SaveChangesAsync();

            return(tickets);
        }
Exemplo n.º 3
0
        public bool IsSeatTypeAvailable(SeatType seatType)
        {
            bool isAvailable  = false;
            int  orderedSeats = GetOrderedSeatsNumber(seatType);

            switch (seatType)
            {
            case SeatType.Basic:
            {
                isAvailable = Auditorium.BasicSeatsCapacity > orderedSeats;
                break;
            }

            case SeatType.Silver:
            {
                isAvailable = Auditorium.SilverSeatsCapacity > orderedSeats;
                break;
            }

            case SeatType.Gold:
            {
                isAvailable = Auditorium.BasicSeatsCapacity > orderedSeats;
                break;
            }
            }

            return(isAvailable);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 将铺位/座位号枚举转化成字符串
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string ToString(SeatType type)
        {
            switch (type)
            {
            case SeatType.A1: return(SEAT_TYPE_YZ);

            case SeatType.A2: return(SEAT_TYPE_RZ);

            case SeatType.A3: return(SEAT_TYPE_YW);

            case SeatType.A4: return(SEAT_TYPE_RW);

            case SeatType.A6: return(SEAT_TYPE_GJRW);

            case SeatType.A9: return(SEAT_TYPE_SW);

            case SeatType.M: return(SEAT_TYPE_1D);

            case SeatType.MIN: return(SEAT_TYPE_ORDER);

            case SeatType.O: return(SEAT_TYPE_2D);

            case SeatType.P: return(SEAT_TYPE_TD);

            case SeatType.WZ: return(SEAT_TYPE_WZ);

            default: return(string.Empty);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Static seat price calculator.
        /// </summary>
        /// <param name="baseSeatPrice">Base seat price - corresponds to SeatType.Upper</param>
        /// <param name="inSeatType">Type of the seat.</param>
        /// <returns>Seat price</returns>
        public static float CalculateSeatPrice(float baseSeatPrice, SeatType inSeatType)
        {
            float seatPrice;

            try
            {
                //Convert.ToDouble(baseSeatPrice); IF DOESNT WORK, TRY THIS
                switch (inSeatType)
                {
                case SeatType.Dress:
                    seatPrice = (float)Math.Round((baseSeatPrice * 1.2f), 2);
                    return(seatPrice);

                case SeatType.Stall:
                    seatPrice = (float)Math.Round((baseSeatPrice * 0.8f), 2);
                    return(seatPrice);

                case SeatType.Upper:
                    seatPrice = (float)baseSeatPrice;
                    return(seatPrice);

                default:
                    throw new Exception("seatType was not set when used in static CalculateSeatPrice method in Seat class.");
                }
            }
            catch
            {
                throw new Exception("Could not CalculateSeatPrice in Seat class. Probably float-related error.");
            }
        }
        private SeatType ParseSeatTypeObsolete(string[] handLines)
        {
            int numPlayers = 0;

            for (int i = 2; i < handLines.Length; i++)
            {
                if (handLines[i].StartsWithFast("***"))
                {
                    numPlayers = i - 2;
                    break;
                }
            }

            if (numPlayers <= 2)
            {
                return(SeatType.FromMaxPlayers(2));
            }
            if (numPlayers <= 6)
            {
                return(SeatType.FromMaxPlayers(6));
            }
            if (numPlayers <= 9)
            {
                return(SeatType.FromMaxPlayers(9));
            }

            return(SeatType.FromMaxPlayers(10));
        }
        protected override SeatType ParseSeatType(string[] handLines)
        {
            foreach (var line in handLines)
            {
                switch (line.ToLower())
                {
                case string a when
                    a.Contains("hu") ||
                    a.Contains("2-max") ||
                    a.Contains("heads up") ||
                    a.Contains("headsup") ||
                    a.Contains("heads-up"):
                    return(SeatType.FromMaxPlayers(2));

                case string a when a.Contains("3-max"):
                    return(SeatType.FromMaxPlayers(3));

                case string a when a.Contains("5-max"):
                    return(SeatType.FromMaxPlayers(5));

                case string a when a.Contains("6-max"):
                    return(SeatType.FromMaxPlayers(6));

                case string a when a.Contains("9-max"):
                    return(SeatType.FromMaxPlayers(9));

                case string a when a.StartsWithFast("***"):
                    goto end_loop;
                }
            }
            end_loop : return(ParseSeatTypeObsolete(handLines));
        }
        public void BulkDeleteSeats(int numberOfSeats, SeatType type, int venueId)
        {
            using (SqlConnection sourceConnection = new SqlConnection(connectionString))
            {
                sourceConnection.Open();

                try
                {
                    numberOfSeats = Math.Abs(numberOfSeats);
                    int typeInt            = (int)type;
                    var numberOfSeatsParam = new SqlParameter("@numberOfSeats", numberOfSeats);
                    var seatTypeParam      = new SqlParameter("@seatType", typeInt);
                    var venueIdParam       = new SqlParameter("@venueId", venueId);
                    Context.Database.ExecuteSqlCommand("dbo.BulkDeleteSeats @numberOfSeats, @seatType, @venueId", numberOfSeatsParam, seatTypeParam, venueIdParam);
                    Console.WriteLine("Seats successfully deleted.");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    sourceConnection.Close();
                }
            }
        }
Exemplo n.º 9
0
        public byte GetSeatNumber(SeatType seatType)
        {
            byte seatNumber = 0;

            // seats are positioned as such that gold seats have the lowest numbers and basic seats have the highest seat numbers.
            switch (seatType)
            {
            case SeatType.Gold:
            {
                seatNumber = (byte)(GetOrderedSeatsNumber(seatType) + 1);
                break;
            }

            case SeatType.Silver:
            {
                seatNumber = (byte)(GetOrderedSeatsNumber(seatType) + Auditorium.GoldSeatsCapacity + 1);
                break;
            }

            case SeatType.Basic:
            {
                seatNumber = (byte)(GetOrderedSeatsNumber(seatType) + Auditorium.GoldSeatsCapacity + Auditorium.SilverSeatsCapacity + 1);
                break;
            }
            }
            return(seatNumber);
        }
Exemplo n.º 10
0
        public void when_creating_conference_and_seat_then_does_not_publish_seat_created()
        {
            var conference = new ConferenceInfo
            {
                OwnerEmail  = "*****@*****.**",
                OwnerName   = "test owner",
                AccessCode  = "qwerty",
                Name        = "test conference",
                Description = "test conference description",
                Location    = "redmond",
                Slug        = "test",
                StartDate   = DateTime.UtcNow,
                EndDate     = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
            };

            service.CreateConference(conference);

            var seat = new SeatType {
                Name = "seat", Description = "description", Price = 100, Quantity = 100
            };

            service.CreateSeat(conference.Id, seat);

            Assert.Empty(busEvents.OfType <SeatCreated>());
        }
Exemplo n.º 11
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            // Full Tilt Poker Game #26862468195: Table Adornment (6 max, shallow) - $0.50/$1 - No Limit Hold'em - 16:09:19 ET - 2010/12/31

            string handLine = handLines[0];

            string [] seatInfo = handLine.Split('(');

            // No ( means its full ring
            if (seatInfo.Length == 1)
            {
                return(SeatType.FromMaxPlayers(9));
            }

            if (seatInfo[1].StartsWith("6 max"))
            {
                return(SeatType.FromMaxPlayers(6));
            }
            else if (seatInfo[1].StartsWith("heads"))
            {
                return(SeatType.FromMaxPlayers(2));
            }

            return(SeatType.FromMaxPlayers(9));
        }
 public void SetUp()
 {
     _handHistory = new HandHistory()
     {
         ComumnityCards =
             BoardCards.ForFlop(Card.GetCardFromIntValue(5), Card.GetCardFromIntValue(14),
                                Card.GetCardFromIntValue(40)),
         DateOfHandUtc        = new DateTime(2012, 3, 20, 12, 30, 44),
         DealerButtonPosition = 5,
         FullHandHistoryText  = "some hand text",
         GameDescription      =
             new GameDescriptor(PokerFormat.CashGame,
                                SiteName.PartyPoker,
                                GameType.NoLimitHoldem,
                                Limit.FromSmallBlindBigBlind(10, 20, Currency.USD),
                                TableType.FromTableTypeDescriptions(TableTypeDescription.Regular),
                                SeatType.FromMaxPlayers(6)),
         HandActions = new List <HandAction>()
         {
             new HandAction("Player1", HandActionType.POSTS, 0.25m, Street.Preflop)
         },
         HandId           = 141234124,
         NumPlayersSeated = 2,
         Players          = new PlayerList()
         {
             new Player("Player1", 1000, 1),
             new Player("Player2", 300, 5),
         },
         TableName = "Test Table",
     };
 }
Exemplo n.º 13
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            // Line 5 onward is:
            //  Players in round: 3
            //  Seat 8: Max Power s ($8.96)
            //  Seat 9: EvilJihnny99 ($24.73)
            //  Seat 10: huda22 ($21.50)

            //When Hero is playing there is one extra line
            //User: ONG_Hero
            //Button: seat 9
            //Players in round: 4 (6)
            //Seat 1: Opponent1 ($200)
            //Seat 2: ONG_Hero ($200)

            int numPlayers = ParseNumberOfPlayers(handLines);

            if (numPlayers <= 2)
            {
                return(SeatType.FromMaxPlayers(2));
            }
            if (numPlayers <= 6)
            {
                return(SeatType.FromMaxPlayers(6));
            }
            if (numPlayers <= 9)
            {
                return(SeatType.FromMaxPlayers(9));
            }

            return(SeatType.FromMaxPlayers(10));
        }
        protected override SeatType ParseSeatType(List <string> header)
        {
            var line       = header[1];
            var maxPlayers = FastInt.Parse(line, line.IndexOf(' '));

            return(SeatType.FromMaxPlayers(maxPlayers));
        }
Exemplo n.º 15
0
        public void Handle(SeatCreated @event)
        {
            using (var repository = contextFactory.Invoke()) {
                var dto = repository.Find <SeatType>(@event.SourceId);
                if (dto != null)
                {
                    Trace.TraceWarning(
                        "Ignoring SeatCreated event for seat type with ID {0} as it was already created.",
                        @event.SourceId);
                }
                else
                {
                    dto = new SeatType(
                        @event.SourceId,
                        @event.ConferenceId,
                        @event.Name,
                        @event.Description,
                        @event.Price,
                        @event.Quantity);

                    bus.Send(
                        new AddSeats {
                        ConferenceId = @event.ConferenceId,
                        SeatType     = @event.SourceId,
                        Quantity     = @event.Quantity
                    });

                    repository.Save(dto);
                }
            }
        }
Exemplo n.º 16
0
 public ChooseForm(List <Flight> flights, Flight flight, SeatType type)
 {
     this.flights = flights;
     this.flight  = flight;
     this.type    = type;
     InitializeComponent();
 }
Exemplo n.º 17
0
 public static Seat FindFirstAvailableSeat(IEnumerable <Seat> seats, SeatType seatType)
 {
     //seats are arranged front to back, left to right
     return(seats
            .FirstOrDefault(s => s.Type == seatType &&
                            s.Guest == null));
 }
        public async Task <IActionResult> Edit(string id, [Bind("Name,Description,RelativeQuality")] SeatType seatType)
        {
            if (id != seatType.Name)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(seatType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeatTypeExists(seatType.Name))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(seatType));
        }
Exemplo n.º 19
0
        //todo:need to refactor and has grouping bag
        public IEnumerable <PlayerSummary> GetPlayerSummariesByName(string name)
        {
            if (!OponentNames.Contains(name))
            {
                throw new Exception(string.Format("Player with name {0} is not found!", name));
            }
            var playerGames = _context.Games.GetGamesForPlayer(name).ToList(); //* 2 qs
            var limits      = playerGames.GetDistinctLimits();                 //* 1qs

            foreach (var limit in limits)
            {
                SeatType l = limit;
                var      limitPlayerGames = playerGames.GetGamesForLimit(l);
                var      handsWon         = _context.HandActions.GetWonActionsCountForPlayer(name);

                var sessionGroups = from lg in limitPlayerGames
                                    group lg by new { lg.TableName, lg.DateOfHand.Date };

                var playerSummary = new PlayerSummary
                {
                    Name     = name,
                    Limit    = limit,
                    Hands    = limitPlayerGames.Count(),
                    HandsWon = handsWon,
                    Sessions = sessionGroups.Count()
                };
                playerSummary.HandsWonPercent =
                    decimal.Round((decimal)playerSummary.HandsWon / (decimal)playerSummary.Hands * 100, 2);
                yield return(playerSummary);
            }
        }
Exemplo n.º 20
0
        //todo:need to refactor
        public IEnumerable <PlayerStatistics> GetPlayerStatisticsByName(string name)
        {
            if (!OponentNames.Contains(name))
            {
                throw new Exception(string.Format("Player with name {0} is not found!", name));
            }
            var playerGames = _context.Games.GetGamesForPlayer(name).ToList();
            var limits      = playerGames.GetDistinctLimits();

            foreach (var l in limits)
            {
                SeatType limit             = l;
                var      limitGames        = playerGames.GetGamesForLimit(limit).ToList();
                var      limitGameCount    = limitGames.Count();
                var      valPutCount       = limitGames.VPIPCountForPlayer(name);
                var      preflopRaiseCount = limitGames.PFRCountForPlayer(name);
                var      atsPercent        = limitGames.GetATSPercentForPlayer(name);
                var      afpfPercent       = limitGames.GetAFPercentForPlayer(name);
                var      playerStatistics  = new PlayerStatistics
                {
                    Name  = name,
                    Limit = l,
                    VPIP  = decimal.Round((decimal)valPutCount / (decimal)limitGameCount * 100, 2),
                    PFR   = decimal.Round((decimal)preflopRaiseCount / (decimal)limitGameCount * 100, 2),
                    ATS   = decimal.Round((decimal)atsPercent, 2),
                    AF    = decimal.Round((decimal)afpfPercent, 2)
                };
                yield return(playerStatistics);
            }
        }
Exemplo n.º 21
0
        public void DrawCard(SeatType seatType)
        {
            if (!Game.IsGameStarted)
            {
                return;
            }
            var hand     = GetPlayerHand(seatType);
            var handSize = hand.Cards.Count;

            if (handSize >= hand.MaxHandSize)
            {
                return;
            }

            var data                  = Game.Library.GetRandomData();
            var card                  = new CardHand(data);
            var actionPoints          = Parameters.Amounts.ActionPointsConsume;
            var inventory             = GetInventory(seatType);
            var hasEnoughActionPoints = inventory.GetAmount(Inventory.ActionPointItem) >= actionPoints;

            if (!hasEnoughActionPoints)
            {
                return;
            }

            inventory.RemoveItem(Inventory.ActionPointItem, actionPoints);
            hand.Add(card);
            OnDrawCard(seatType, card);
        }
Exemplo n.º 22
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            // line 4 onward has all seated player
            // Seat 1: ovechkin08 (2000€)
            // Seat 4: R.BAGGIO (2000€)
            // *** ANTE/BLINDS ***

            int numPlayers = 0;

            for (int i = 3; i < handLines.Length; i++)
            {
                if (handLines[i].StartsWith("***"))
                {
                    numPlayers = i - 3;
                    break;
                }
            }

            if (numPlayers <= 2)
            {
                return(SeatType.FromMaxPlayers(2));
            }
            if (numPlayers <= 6)
            {
                return(SeatType.FromMaxPlayers(6));
            }
            if (numPlayers <= 9)
            {
                return(SeatType.FromMaxPlayers(9));
            }

            return(SeatType.FromMaxPlayers(10));
        }
Exemplo n.º 23
0
        public void save(SeatType SeatType)
        {
            try
            {
                using (var context = new SmsMisDB())
                {
                    SeatType.AddDateTime = DateTime.Now;
                    var entry = context.Entry(SeatType);

                    if (entry != null)
                    {
                        if (SeatType.SeatTypeCode == 0)
                        {
                            SeatType.SeatTypeCode = Functions.getNextPk("SeatType", SeatType.SeatTypeCode, SeatType.CompanyCode);
                            entry.State           = EntityState.Added;
                        }
                        else
                        {
                            entry.State = EntityState.Modified;
                        }
                        context.SaveChanges();
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 24
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            int      Players = ParsePlayers(handLines).Count;
            SeatType seat    = SeatType.FromMaxPlayers(Players, true);

            return(seat);
        }
Exemplo n.º 25
0
 public Hand(SeatType id, GameParameters gameParameters, IDispatcher dispatcher)
 {
     Id         = id;
     Parameters = gameParameters;
     Dispatcher = dispatcher;
     OnCreateHand();
 }
Exemplo n.º 26
0
        public void UpdateSeat(Guid conferenceId, SeatType seat)
        {
            var existing = this.seatTypeRepository.GetByKey(seat.Id);

            if (existing == null)
            {
                throw new ObjectNotFoundException();
            }

            existing.Name        = seat.Name;
            existing.Description = seat.Description;
            existing.Quantity    = seat.Quantity;
            existing.Price       = seat.Price;

            this.Context.RegisterModified(existing);
            this.Context.Commit();

            var wasEverPublished = this.conferenceRepository
                                   .GetBy(x => x.Id == conferenceId)
                                   .Select(x => x.WasEverPublished)
                                   .FirstOrDefault();

            if (wasEverPublished)
            {
                this.eventBus.Publish(new SeatUpdated
                {
                    ConferenceId = conferenceId,
                    SourceId     = seat.Id,
                    Name         = seat.Name,
                    Description  = seat.Description,
                    Price        = seat.Price,
                    Quantity     = seat.Quantity,
                });
            }
        }
Exemplo n.º 27
0
        void ICreateBoardElement.OnCreateBoardElement(SeatType id, CreatureElement creatureElement, Vector3Int cell,
                                                      CardHand card)
        {
            var data = creatureElement.Data;

            CreateElement(creatureElement, data, cell);
        }
Exemplo n.º 28
0
        public void SetUp()
        {
            _handHistory = new HandHistory()
            {
                ComumnityCards =
                    BoardCards.ForFlop(new Card(5), new Card(14), new Card(40)),
                DateOfHandUtc        = new DateTime(2012, 3, 20, 12, 30, 44),
                DealerButtonPosition = 5,
                FullHandHistoryText  = "some hand text",
                GameDescription      =
                    new GameDescriptor(PokerFormat.CashGame,
                                       SiteName.Values.PartyPoker,
                                       GameType.NoLimitHoldem,
                                       Limit.FromSmallBlindBigBlind(10, 20, Currency.USD),
                                       TableType.FromTableTypeDescriptions(TableTypeDescription.Regular),
                                       SeatType.FromMaxPlayers(6)),
                HandActions = new List <HandAction>()
                {
                    new HandAction("Player1", HandActionType.POSTS, 0.25m, Street.Preflop)
                },
                HandId           = 141234124,
                NumPlayersSeated = 2,
                Players          = new PlayerList()
                {
                    new Player("Player1", 1000, 1),
                    new Player("Player2", 300, 5),
                },
                TableName = "Test Table",
            };
            _handHistory.Players[0].HoleCards = new HoleCards(CardGroup.Parse("Ac Ad"));
            _handHistory.Players[1].HoleCards = new HoleCards(CardGroup.Parse("Kh Qs"));

            BsonSerializer.RegisterSerializationProvider(new TestSerializationProvider());
        }
Exemplo n.º 29
0
        /// <summary>
        /// Adjusts seat types of the specified <see cref="HandHistory"/>
        /// </summary>
        /// <param name="handHistory"><see cref="HandHistory"/> to adjust</param>
        protected override void AdjustSeatTypes(HandHistory handHistory)
        {
            if (!handHistory.GameDescription.SeatType.IsUnknown)
            {
                return;
            }

            var maxSeatNumber = handHistory.Players.MaxOrDefault(x => x.SeatNumber);

            if (maxSeatNumber > 9)
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(10);
            }
            else if (maxSeatNumber > 8)
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(9);
            }
            else if (maxSeatNumber > 6)
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(8);
            }
            else if (maxSeatNumber > 3)
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(6);
            }
            else if (maxSeatNumber > 2 && handHistory.GameDescription.IsTournament)
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(3);
            }
            else
            {
                handHistory.GameDescription.SeatType = SeatType.FromMaxPlayers(2);
            }
        }
Exemplo n.º 30
0
 public IEnumerable <Seat> GetSeatsBySeatType(int venueId, SeatType type)
 {
     return(_seatRepository.Collection()
            .Where(seat => seat.VenueId == venueId)
            .Where(seat => seat.SeatType == type)
            .ToList());
 }
        public void when_creating_seat_then_can_find_seat()
        {
            var seat = new SeatType
            {
                Name = "precon",
                Description = "precon desc",
                Price = 100,
                Quantity = 100,
            };

            service.CreateSeat(this.conference.Id, seat);

            Assert.NotNull(service.FindSeatType(seat.Id));
        }
        public void when_creating_seat_then_seat_created_is_published()
        {
            var seat = new SeatType
            {
                Name = "precon",
                Description = "precon desc",
                Price = 100,
                Quantity = 100,
            };

            service.CreateSeat(this.conference.Id, seat);

            var e = bus.Events.OfType<SeatCreated>().Single(x => x.SourceId == seat.Id);

            Assert.Equal(this.conference.Id, e.ConferenceId);
            Assert.Equal(seat.Id, e.SourceId);
            Assert.Equal(seat.Name, e.Name);
            Assert.Equal(seat.Description, e.Description);
            Assert.Equal(seat.Price, e.Price);
            Assert.Equal(seat.Quantity, e.Quantity);
        }
        public void when_creating_seat_then_adds_to_conference()
        {
            var seat = new SeatType
            {
                Name = "precon",
                Description = "precon desc",
                Price = 100,
                Quantity = 100,
            };

            service.CreateSeat(this.conference.Id, seat);

            var seats = service.FindSeatTypes(this.conference.Id);

            Assert.Equal(2, seats.Count());
        }
Exemplo n.º 34
0
        private void WaitOrder(TrainItemInfo optimizeTrain,SeatType seatType )
        {
            WaitResponse waitResponse = null;
            int dispTime = 1;
            int nextRequestTime = 1;
            int errCnt = 0;
            do
            {

                if (dispTime <= 0)
                {

                    switch (dispTime)
                    {
                        case -1:
                            string msg = string.Format("����ɹ��������ţ�{0}", waitResponse.OrderId);
                            Log(account, optimizeTrain.TrainNo + msg);
                            if (OrderSuccessed != null)
                            {
                                OrderSuccessed(this, null); //�����ɹ��¼�
                            }
                            return;
                        case -2:
                            Log(account, "ռ��ʧ�ܣ�ԭ��:" + waitResponse.Msg);
                            break;
                        case -3:
                            Log(account, "�����ѳ���");
                            break;
                        default:
                            Log(account, "�뵽δ��ɶ���ҳ�鿴");
                            break;
                    }
                    return;
                }
                if (dispTime == nextRequestTime)
                {
                    string resContent;
                    waitResponse = account.GetWaitResponse(out resContent);
                    if (waitResponse != null)
                    {
                        dispTime = waitResponse.WaitTime;

                        int flashWaitTime = (int) (waitResponse.WaitTime/1.5);
                        flashWaitTime = flashWaitTime > 60 ? 60 : flashWaitTime;
                        var nextTime = waitResponse.WaitTime - flashWaitTime;

                        nextRequestTime = nextTime <= 0 ? 1 : nextTime;
                    }
                    else
                    {
                        if(errCnt<3)
                        {
                            errCnt++;
                            continue;
                        }
                        else
                        {
                            dispTime = 1;
                        }

                    }
                }

                TimeSpan timeSpan = TimeSpan.FromSeconds(dispTime);

                Log(account, "���Ķ����Ѿ��ύ������Ԥ���ȴ�ʱ��" + timeSpan.ToString("hhСʱmm��ss��") + "��");

                dispTime--;
                Thread.Sleep(1000);
            } while (true);
        }
        public ActionResult EditSeat(SeatType seat)
        {
            if (this.Conference == null)
            {
                return HttpNotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.Service.UpdateSeat(this.Conference.Id, seat);
                }
                catch (ObjectNotFoundException)
                {
                    return HttpNotFound();
                }

                return PartialView("SeatGrid", new SeatType[] { seat });
            }

            return PartialView(seat);
        }
Exemplo n.º 36
0
 public ActorStartingLocationsBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadStringID();
     this.position = binaryReader.ReadVector3();
     this.referenceFrame = binaryReader.ReadInt16();
     this.padding = binaryReader.ReadBytes(2);
     this.facingYawPitchDegrees = binaryReader.ReadVector2();
     this.flags = (Flags)binaryReader.ReadInt32();
     this.characterType = binaryReader.ReadShortBlockIndex1();
     this.initialWeapon = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon = binaryReader.ReadShortBlockIndex1();
     this.padding0 = binaryReader.ReadBytes(2);
     this.vehicleType = binaryReader.ReadShortBlockIndex1();
     this.seatType = (SeatType)binaryReader.ReadInt16();
     this.grenadeType = (GrenadeType)binaryReader.ReadInt16();
     this.swarmCountNumberOfCreturesInSwarmIfASwarmIsSpawnedAtThisLocation = binaryReader.ReadInt16();
     this.actorVariantName = binaryReader.ReadStringID();
     this.vehicleVariantName = binaryReader.ReadStringID();
     this.initialMovementDistanceBeforeDoingAnythingElseTheActorWillTravelTheGivenDistanceInItsForwardDirection = binaryReader.ReadSingle();
     this.emitterVehicle = binaryReader.ReadShortBlockIndex1();
     this.initialMovementMode = (InitialMovementMode)binaryReader.ReadInt16();
     this.placementScript = binaryReader.ReadString32();
     this.skip1 = binaryReader.ReadBytes(2);
     this.padding2 = binaryReader.ReadBytes(2);
 }
        public ActionResult CreateSeat(SeatType seat)
        {
            if (this.Conference == null)
            {
                return HttpNotFound();
            }

            if (ModelState.IsValid)
            {
                seat.Id = Guid.NewGuid();
                this.Service.CreateSeat(this.Conference.Id, seat);

                return PartialView("SeatGrid", new SeatType[] { seat });
            }

            return PartialView("EditSeat", seat);
        }
Exemplo n.º 38
0
        public static ICollection<SeatType> CreateSeats(Table seats)
        {
            var createdSeats = new List<SeatType>();

            foreach (var row in seats.Rows)
            {
                var seat = new SeatType()
                {
                    Id = Guid.NewGuid(),
                    Description = row["seat type"],
                    Name = row["seat type"],
                    Price = Convert.ToDecimal(row["rate"].Replace("$", "")),
                    Quantity = Convert.ToInt32(row["quota"])
                };
                createdSeats.Add(seat);
            }

            return createdSeats;
        }
Exemplo n.º 39
0
        /// <summary>
        /// ��ȡij��ϯλ��Ч���г���������
        /// </summary>
        /// <param name="seatType"></param>
        /// <returns></returns>
        private List<TrainItemInfo> GetValidTrains(SeatType seatType)
        {
            int needSeatNumber = TicketSetting.Passengers.Count(p => p.Checked);
            List<TrainItemInfo> validTrainItemInfos = new List<TrainItemInfo>();
            foreach (TrainItemInfo trainItemInfo in TrainItemInfos)
            {
                if (trainItemInfo.GetSeatNumber(seatType) >= needSeatNumber)
                {
                    validTrainItemInfos.Add(trainItemInfo);
                }
                else if (TicketSetting.ForceTicket && !string.IsNullOrEmpty(trainItemInfo.MmStr))
                {
                    validTrainItemInfos.Add(trainItemInfo);
                }
            }
            List<TrainItemInfo> optimizeTrains = validTrainItemInfos.OrderBy(p => (int)p.TripTime.TotalHours).ThenByDescending(p => p.GetSeatNumber(seatType)).ToList(); //��ô�����ǻ����ٿͣ�

            if (!string.IsNullOrEmpty(TicketSetting.TrainOrder.Trim()))
            {
                List<TrainItemInfo> orderTrains=new List<TrainItemInfo>();
                foreach (string trainNo in TicketSetting.TrainOrder.Split(new char[]{',','��','|'},StringSplitOptions.RemoveEmptyEntries))
                {
                    var train = optimizeTrains.Find(p => p.TrainNo.Trim().Equals(trainNo.Trim(),StringComparison.OrdinalIgnoreCase));
                    if(train!=null)
                    {
                        orderTrains.Add(train);
                    }
                }
                return orderTrains;
            }

            return optimizeTrains;
        }

        private void Log(Account account, Exception ex)
        {
            Log(account, ex.Message + "\r\n\t" + ex.StackTrace);
        }
Exemplo n.º 40
0
        private void OrderTrain(TrainItemInfo optimizeTrain,SeatType seatType)
        {
            Log(account, string.Format("{0}��ѡ����{1}�µ�", seatType, optimizeTrain.TrainNo));
            Passenger[] passengers =
                TicketSetting.Passengers.Where(p => p.Checked).ToArray();
            SubmitOrderRequest:
            NameValueCollection htmlForm = account.SubmitOrderRequest(optimizeTrain, passengers
                                                                      , seatType == SeatType.����
                                                                            ? SeatType.Ӳ��
                                                                            : seatType);

            optimizeTrain.YpInfoDetailReal = htmlForm["leftTicketStr"]; //����ʵʱ��ѯ��Ʊ��Ϣ
            if (string.IsNullOrEmpty(optimizeTrain.YpInfoDetailReal))
            {
                Log(account, "�µ�ʧ��:δ�ܻ�ȡ��ʵ����Ʊ����Ϣ");
                return;
            }
            if (Stop) return;

            ResPassengerJsonInfo resPassengerJsonInfo = account.GetPassengers(); //��ȡ�˿���Ϣ
            if (Stop) return;

            int vcodeCnt = 1;
            GETVCode:
            //��ȡ��֤��

            string vcode = GetVerifyCode(VCodeType.SubmitOrder, vcodeCnt);
            vcodeCnt = 0;
            if (vcode == "BREAK") return;

            // Thread.Sleep(4000);//��֤�������ʱ 4s
            if (Stop) return;
            string postStr;
            var forms = BuildOrderPostStr(seatType, htmlForm, vcode, passengers, out postStr);

            CheckOrderInfo:
            var checkOrderInfoContent = account.CheckOrderInfo(vcode, postStr);
            if (checkOrderInfoContent.Contains("��֤��"))
            {
                Log(account, "��֤�벻��ȷ:" + checkOrderInfoContent);
                // vcode = "";
                goto GETVCode;
            }
            if (Stop) return;

            //��ѯ���� ��ȡ��Ʊ��Ϣ
            ResYpInfo resYpInfo = account.GetQueueCount(forms, seatType == SeatType.���� ? SeatType.Ӳ�� : seatType);
            Thread.Sleep(1000);//�鿴ʣ����Ʊ ��ʱ1s
            int seatNum = Utils.GetRealSeatNumber(resYpInfo.Ticket, seatType);
            int wuzuo = 0;
            if (seatType == SeatType.Ӳ��)
                wuzuo = Utils.GetRealSeatNumber(resYpInfo.Ticket, SeatType.����);

            Log(account, string.Format("{0},�Ŷ�{1}��,{2} {3} �� {4}", optimizeTrain.TrainNo, resYpInfo.CountT, seatType, seatNum, wuzuo == 0 ? "" : ",���� " + wuzuo + " ��"));

            if (seatType == SeatType.Ӳ��)//Ӳ��Ҫ��ֹ��������Ʊ
            {
                if (seatNum - resYpInfo.CountT < passengers.Length) //��Ʊ����
                {
                    Log(account, optimizeTrain.TrainNo + " ,Ӳ�� ��Ʊ���㣡");
                    if (TicketSetting.ContinueCheckLeftTicketNum) //��ѯ��Ʊ����
                    {
                        Log(account, optimizeTrain.TrainNo + " ,���������Ʊ����");
                        Thread.Sleep(1000);
                        goto CheckOrderInfo;
                    }
                    return;
                }

            }
            else
            {
                if (seatNum < passengers.Length) //С����λ��
                {
                    Log(account, optimizeTrain.TrainNo + " ,��Ʊ���㣡");
                    if (!TicketSetting.ForceTicket) //ǿ���µ�
                    {
                        if (TicketSetting.ContinueCheckLeftTicketNum) //���������Ʊ
                        {
                            Log(account, optimizeTrain.TrainNo + " ,���������Ʊ����");
                            Thread.Sleep(1000);
                            goto CheckOrderInfo;
                        }
                        return;
                    }
                    Log(account, optimizeTrain.TrainNo + " ,ǿ���µ������");
                }
            }

            if (Stop) return;

            //�¶���
            string resStateContent = account.ConfirmSingleForQueue(postStr);
            if (resStateContent.Contains("��֤��"))
            {
                Log(account, "�µ�ʧ�ܣ���֤�벻��ȷ," + resStateContent);
                goto GETVCode;

            }
            ResState resState = resStateContent.ToJsonObject<ResState>();
            if (resState == null)
            {
                Common.LogUtil.Log(resStateContent);
                Log(account, optimizeTrain.TrainNo + ",�µ�ʧ��:ȷ�϶���ʱ��ϵͳ���ص����ݲ���ȷ," + resStateContent);

            }
            else
            {
                if (resState.ErrMsg.Equals("Y"))
                {
                    Log(account, optimizeTrain.TrainNo + "�µ��ɹ�");
                    WaitOrder(optimizeTrain,seatType);

                }
                else
                {
                    Log(account, "�µ�ʧ�ܣ�" + resState.ErrMsg);
                    goto GETVCode;
                }
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// �¶������������ض������
        /// </summary>
        /// <returns>�޴���ʱ���ؿգ��������ش���</returns>
        public string OrderTicket(TrainItemInfo trainItemInfo,Passenger[] passengers,SeatType seatType,ref bool stop, bool force=false,RichTextBox rtbLog=null)
        {
            /*POST https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest HTTP/1.1
             * Referer: https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init
             *
             * station_train_code=Z133&train_date=2012-10-12&seattype_num=&from_station_telecode=BXP&to_station_telecode=NCG&include_student=00
             * &from_station_telecode_name=%E5%8C%97%E4%BA%AC&to_station_telecode_name=%E5%8D%97%E6%98%8C
             * &round_train_date=2012-10-11&round_start_time_str=00%3A00--24%3A00&single_round_type=1&train_pass_type=QB&train_class_arr=QB%23D%23Z%23T%23K%23QT%23
             * &start_time_str=00%3A00--24%3A00&lishi=11%3A29&train_start_time=19%3A45&trainno4=240000Z13305
             * &arrive_time=07%3A14&from_station_name=%E5%8C%97%E4%BA%AC%E8%A5%BF&to_station_name=%E5%8D%97%E6%98%8C&ypInfoDetail=1*****31254*****00241*****00006*****00113*****0111&mmStr=7D1B712CD355990896422EECCC4C11205C7DFD31C26962626B630FEE
             */
            NameValueCollection forms=new NameValueCollection();
            forms["station_train_code"] = trainItemInfo.TrainNo;
            forms["train_date"] = BuyTicketConfig.Instance.OrderRequest.TrainDate.ToString("yyyy-MM-dd");
            forms["seattype_num"] = "";
            forms["from_station_telecode"] = trainItemInfo.FromStationTelecode;
            forms["to_station_telecode"] = trainItemInfo.ToStationTelecode;
            forms["include_student"] = "00";
            forms["from_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.FromStationTelecodeName;
            forms["to_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.ToStationTelecodeName;
            forms["round_train_date"] = System.DateTime.Today.ToString("yyyy-MM-dd");
            forms["round_start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
            forms["single_round_type"] = "1";
            forms["train_pass_type"] = BuyTicketConfig.Instance.OrderRequest.TrainPassType;
            forms["train_class_arr"] = BuyTicketConfig.Instance.OrderRequest.TrainClass;
            forms["start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
            forms["lishi"] = trainItemInfo.lishi;
            forms["train_start_time"] =trainItemInfo.TrainStartTime;
            forms["trainno4"] = trainItemInfo.TrainNo4;
            forms["arrive_time"] = trainItemInfo.ArriveTime;
            forms["from_station_name"] = trainItemInfo.FromStationName;
            forms["to_station_name"] = trainItemInfo.ToStationName;
            forms["from_station_no"] = trainItemInfo.FromStationNo;
            forms["to_station_no"] = trainItemInfo.ToStationNo;
            forms["ypInfoDetail"] = trainItemInfo.YpInfoDetail;
            forms["mmStr"] = trainItemInfo.MmStr;
            forms["locationCode"] = trainItemInfo.LocationCode;
            string content = HttpRequest.Create("https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest", "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init", Cookie, forms).GetString();
            NameValueCollection htmlForm = Utils.GetForms(content);
            trainItemInfo.YpInfoDetailReal = htmlForm["leftTicketStr"]; //����ʵʱ��ѯ��Ʊ��Ϣ
            if (string.IsNullOrEmpty(trainItemInfo.YpInfoDetailReal))
            {
                Common.LogUtil.Log(content);
                return "�µ�ʧ��:δ�ܻ�ȡ��ʵ����Ʊ����Ϣ";
            }

            ConfirmRequest:

            forms = new NameValueCollection();
            forms["org.apache.struts.taglib.html.TOKEN"] = htmlForm["org.apache.struts.taglib.html.TOKEN"];
            forms["leftTicketStr"] = htmlForm["leftTicketStr"];
            foreach (string key in htmlForm.Keys)
            {
                if(key.StartsWith("orderRequest"))
                {
                    forms[key] = htmlForm[key];
                }
            }
            //&randCode=5xpy&orderRequest.reserve_flag=A

            string vcode = "";
            do
            {
                Stream stream =
                    HttpRequest.Create("https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=randp",
                                       "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie,
                                       HttpMethod.GET, "").GetStream();
                Image image = Image.FromStream(stream);
                vcode = GetVCodeByForm(image);
                if (vcode == "BREAK")
                    return "�û���ֹ";
            } while (vcode == "");
            forms["randCode"] = vcode;
            forms["orderRequest.reserve_flag"] = BuyTicketConfig.Instance.SystemSetting.PayType == PayType.Online ? "A" : "B";//A=����֧��,B=ȡƱ�ֳ�֧��
            //if (force && trainItemInfo.GetRealSeatNumber(seatType) < passengers.Length)
            //{
            //    int p = trainItemInfo.YpInfoDetail.IndexOf(((char)seatType) + "*");
            //    if (p > -1)
            //    {
            //        string newLeftTickets = forms["leftTicketStr"].Remove(p + 6, 1);
            //        newLeftTickets = newLeftTickets.Insert(p + 6, "1");
            //        forms["leftTicketStr"] = newLeftTickets;
            //    }
            //}
            string postStr = forms.ToQueryString();
            foreach (Passenger passenger in passengers)
            {
                /*
                 * passengerTickets=3,0,1,����,1,362201198...,15910675179,Y
                 * &oldPassengers=����,1,362201198...&passenger_1_seat=3&passenger_1_seat_detail_select=0&passenger_1_seat_detail=0&passenger_1_ticket=1&passenger_1_name=����&passenger_1_cardtype=1&passenger_1_cardno=362201198&passenger_1_mobileno=15910675179&checkbox9=Y
                 * */
                if (passenger.Checked)
                {
                    postStr += "&passengerTickets=" +
                               Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2},{3},{4},{5},{6},Y",
                                                                       //passenger.SeatType.ToSeatTypeValue(),
                                                                       seatType.ToSeatTypeValue(),
                                                                       (int) passenger.SeatDetailType,
                                                                       (int) passenger.TicketType, passenger.Name,
                                                                       passenger.CardType.ToCardTypeValue(),
                                                                       passenger.CardNo, passenger.MobileNo));
                    postStr += "&oldPassengers=" +
                               Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2}", passenger.Name,
                                                                       passenger.CardType.ToCardTypeValue(),
                                                                       passenger.CardNo));
                }
            }

            string checkOrderInfoUrl = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=checkOrderInfo&rand=" + vcode;

            CheckOrderInfo:
            if(stop)
            {
                return "�û���ִֹ��";
            }
            string resCheckContent = HttpRequest.Create(checkOrderInfoUrl, "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie, HttpMethod.POST, postStr + "&tFlag=dc").GetString();

            if (resCheckContent.Contains("��֤��"))
            {
                goto ConfirmRequest;
            }
            //https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getQueueCount&train_date=2013-02-04&train_no=24000000T50E&station=T5&seat=1&from=BXP&to=NNZ&ticket=1027353027407675000010273500003048050000
            string  getQueueCountUrl=@"https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getQueueCount&train_date="
            +forms["orderRequest.train_date"]
            +"&train_no="+forms["orderRequest.train_no"]
            +"&station="+forms["orderRequest.station_train_code"]+
            "&seat="+seatType.ToSeatTypeValue()+
            "&from="+forms["orderRequest.from_station_telecode"]+
            "&to=" + forms["orderRequest.to_station_telecode"] +
            "&ticket="+ forms["leftTicketStr"];
              ResYpInfo resYpInfo =  HttpRequest.Create(getQueueCountUrl, "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie, HttpMethod.GET, "").GetJsonObject<ResYpInfo>();;
               // {"countT":0,"count":355,"ticket":"1*****30504*****00001*****00003*****0000","op_1":true,"op_2":false}

            int seatNum = Utils.GetRealSeatNumber(resYpInfo.Ticket, seatType);
            int  wuzuo =0;
            if(seatType==SeatType.Ӳ��)
             wuzuo=Utils.GetRealSeatNumber(resYpInfo.Ticket, SeatType.����);
             if (rtbLog!=null)
              {
                  if (rtbLog.InvokeRequired)
                  {
                      rtbLog.Invoke(new Action(()=>
                          {
                              rtbLog.Text += string.Format("===>{0},{1}���Ŷ�,��Ʊ {2} �� {3}\r\n", seatType, resYpInfo.CountT, seatNum, wuzuo == 0 ? "" : ",���� " + wuzuo + " ��");
                              rtbLog.SelectionStart = rtbLog.TextLength;
                              rtbLog.ScrollToCaret();
                          }));

                  }
                  else
                  {
                      rtbLog.Text += string.Format("===>{0},{1}���Ŷ�,��Ʊ {2} �� {3}\r\n", seatType, resYpInfo.CountT, seatNum, wuzuo == 0 ? "" : ",���� " + wuzuo + " ��");
                      rtbLog.SelectionStart = rtbLog.TextLength;
                      rtbLog.ScrollToCaret();
                  }
              }
              if (force &&  seatNum< passengers.Length)
              {
              if(wuzuo==0)
              {
                  System.Threading.Thread.Sleep(1000);
                  goto CheckOrderInfo;
              }else
              {
                  if(wuzuo <passengers.Length)
                  {
                      System.Threading.Thread.Sleep(1000);
                      goto CheckOrderInfo;
                  }
              }

              }
            string confirmSingleForQueueOrderUrl = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=confirmSingleForQueueOrder ";
               string resStateContent=  HttpRequest.Create(confirmSingleForQueueOrderUrl, "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie, HttpMethod.POST, postStr).GetString();

            if(resStateContent.Contains("��֤��"))
            {
                goto ConfirmRequest;
            }
            ResState resState = resStateContent.ToJsonObject<ResState>();

            if(resState==null)
            {
                Common.LogUtil.Log(resStateContent);
                return "�µ�ʧ��:ȷ�϶���ʱ��ϵͳ���ص����ݲ���ȷ," + resStateContent;
            }
            else
            {
                if (resState.ErrMsg.Equals("Y"))
                {
                    return "";
                }
                else
                {
                    Common.LogUtil.Log(resStateContent);
                   return "�����쳣,��Ӧ״̬Ϊ��" + resState.ErrMsg;
                }
            }
        }
Exemplo n.º 42
0
 /// <summary>
 /// �����µ���Ҫpost�Ĵ�
 /// </summary>
 /// <param name="seatType"></param>
 /// <param name="htmlForm"></param>
 /// <param name="vcode"></param>
 /// <param name="passengers"></param>
 /// <param name="postStr"></param>
 /// <returns></returns>
 private NameValueCollection BuildOrderPostStr(SeatType seatType, NameValueCollection htmlForm, string vcode,
                                               Passenger[] passengers, out string postStr)
 {
     NameValueCollection forms = new NameValueCollection();
     forms["org.apache.struts.taglib.html.TOKEN"] = htmlForm["org.apache.struts.taglib.html.TOKEN"];
     forms["leftTicketStr"] = htmlForm["leftTicketStr"];
     foreach (string key in htmlForm.Keys)
     {
         if (key.StartsWith("orderRequest"))
         {
             forms[key] = htmlForm[key];
         }
     }
     forms["randCode"] = vcode;
     forms["orderRequest.reserve_flag"] = TicketSetting.PayType == PayType.Online ? "A" : "B"; //A=����֧��,B=ȡƱ�ֳ�֧��
     //if (force && trainItemInfo.GetRealSeatNumber(seatType) < passengers.Length)
     //{
     //    int p = trainItemInfo.YpInfoDetail.IndexOf(((char)seatType) + "*");
     //    if (p > -1)
     //    {
     //        string newLeftTickets = forms["leftTicketStr"].Remove(p + 6, 1);
     //        newLeftTickets = newLeftTickets.Insert(p + 6, "1");
     //        forms["leftTicketStr"] = newLeftTickets;
     //    }
     //}
     postStr = forms.ToQueryString();
     foreach (Passenger passenger in passengers)
     {
         /*
          * passengerTickets=3,0,1,����,1,362201198...,15910675179,Y
          * &oldPassengers=����,1,362201198...&passenger_1_seat=3&passenger_1_seat_detail_select=0&passenger_1_seat_detail=0&passenger_1_ticket=1&passenger_1_name=����&passenger_1_cardtype=1&passenger_1_cardno=362201198&passenger_1_mobileno=15910675179&checkbox9=Y
          * */
         if (passenger.Checked)
         {
             postStr += "&passengerTickets=" +
                        Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2},{3},{4},{5},{6},Y",
                                                                //passenger.SeatType.ToSeatTypeValue(),
                                                                seatType.ToSeatTypeValue(),
                                                                (int) passenger.SeatDetailType,
                                                                (int) passenger.TicketType, passenger.Name,
                                                                passenger.CardType.ToCardTypeValue(),
                                                                passenger.CardNo, passenger.MobileNo));
             postStr += "&oldPassengers=" +
                        Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2}", passenger.Name,
                                                                passenger.CardType.ToCardTypeValue(),
                                                                passenger.CardNo));
         }
     }
     return forms;
 }
        public void when_creating_conference_and_seat_then_does_not_publish_seat_created()
        {
            var conference = new ConferenceInfo
            {
                OwnerEmail = "*****@*****.**",
                OwnerName = "test owner",
                AccessCode = "qwerty",
                Name = "test conference",
                Description = "test conference description",
                Location = "redmond",
                Slug = "test",
                StartDate = DateTime.UtcNow,
                EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
            };
            service.CreateConference(conference);

            var seat = new SeatType { Name = "seat", Description = "description", Price = 100, Quantity = 100 };
            service.CreateSeat(conference.Id, seat);

            Assert.Empty(busEvents.OfType<SeatCreated>());
        }
Exemplo n.º 44
0
 /// <summary>
 /// https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest
 /// </summary>
 /// <param name="trainItemInfo"></param>
 /// <param name="passengers"></param>
 /// <param name="seatType"></param>
 /// <returns>�õ�ҳ��ı����Ϣ</returns>
 public NameValueCollection SubmitOrderRequest(TrainItemInfo trainItemInfo, Passenger[] passengers, SeatType seatType)
 {
     /*POST https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest HTTP/1.1
     * Referer: https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init
     *
     * station_train_code=Z133&train_date=2012-10-12&seattype_num=&from_station_telecode=BXP&to_station_telecode=NCG&include_student=00
     * &from_station_telecode_name=%E5%8C%97%E4%BA%AC&to_station_telecode_name=%E5%8D%97%E6%98%8C
     * &round_train_date=2012-10-11&round_start_time_str=00%3A00--24%3A00&single_round_type=1&train_pass_type=QB&train_class_arr=QB%23D%23Z%23T%23K%23QT%23
     * &start_time_str=00%3A00--24%3A00&lishi=11%3A29&train_start_time=19%3A45&trainno4=240000Z13305
     * &arrive_time=07%3A14&from_station_name=%E5%8C%97%E4%BA%AC%E8%A5%BF&to_station_name=%E5%8D%97%E6%98%8C&ypInfoDetail=1*****31254*****00241*****00006*****00113*****0111&mmStr=7D1B712CD355990896422EECCC4C11205C7DFD31C26962626B630FEE
     */
     NameValueCollection forms = new NameValueCollection();
     forms["station_train_code"] = trainItemInfo.TrainNo;
     forms["train_date"] = BuyTicketConfig.Instance.OrderRequest.TrainDate.ToString("yyyy-MM-dd");
     forms["seattype_num"] = "";
     forms["from_station_telecode"] = trainItemInfo.FromStationTelecode;
     forms["to_station_telecode"] = trainItemInfo.ToStationTelecode;
     forms["include_student"] = "00";
     forms["from_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.FromStationTelecodeName;
     forms["to_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.ToStationTelecodeName;
     forms["round_train_date"] = System.DateTime.Today.ToString("yyyy-MM-dd");
     forms["round_start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
     forms["single_round_type"] = "1";
     forms["train_pass_type"] = BuyTicketConfig.Instance.OrderRequest.TrainPassType;
     forms["train_class_arr"] = BuyTicketConfig.Instance.OrderRequest.TrainClass;
     forms["start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
     forms["lishi"] = trainItemInfo.lishi;
     forms["train_start_time"] = trainItemInfo.TrainStartTime;
     forms["trainno4"] = trainItemInfo.TrainNo4;
     forms["arrive_time"] = trainItemInfo.ArriveTime;
     forms["from_station_name"] = trainItemInfo.FromStationName;
     forms["to_station_name"] = trainItemInfo.ToStationName;
     forms["from_station_no"] = trainItemInfo.FromStationNo;
     forms["to_station_no"] = trainItemInfo.ToStationNo;
     forms["ypInfoDetail"] = trainItemInfo.YpInfoDetail;
     forms["mmStr"] = trainItemInfo.MmStr;
     forms["locationCode"] = trainItemInfo.LocationCode;
     string content = HttpRequest.Create("https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest", "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init", Cookie, forms).GetString();
     NameValueCollection htmlForm = Utils.GetForms(content);
     //trainItemInfo.YpInfoDetailReal = htmlForm["leftTicketStr"]; //����ʵʱ��ѯ��Ʊ��Ϣ
     //if (string.IsNullOrEmpty(trainItemInfo.YpInfoDetailReal))
     //{
     //    Common.LogUtil.Log(content);
     //    return "�µ�ʧ��:δ�ܻ�ȡ��ʵ����Ʊ����Ϣ";
     //}
     return htmlForm;
 }
        public void when_creating_conference_and_seat_then_publishes_seat_created_on_publish()
        {
            var conference = new ConferenceInfo
            {
                OwnerEmail = "*****@*****.**",
                OwnerName = "test owner",
                AccessCode = "qwerty",
                Name = "test conference",
                Description = "test conference description",
                Location = "redmond",
                Slug = "test",
                StartDate = DateTime.UtcNow,
                EndDate = DateTime.UtcNow.Add(TimeSpan.FromDays(2)),
            };
            service.CreateConference(conference);

            var seat = new SeatType { Name = "seat", Description = "description", Price = 100, Quantity = 100 };
            service.CreateSeat(conference.Id, seat);

            service.Publish(conference.Id);

            var e = busEvents.OfType<SeatCreated>().FirstOrDefault();

            Assert.NotNull(e);
            Assert.Equal(e.SourceId, seat.Id);
        }
Exemplo n.º 46
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="forms"></param>
        /// <param name="seatType"></param>
        /// <returns></returns>
        public ResYpInfo GetQueueCount(NameValueCollection forms,SeatType seatType)
        {
            //https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getQueueCount&train_date=2013-02-04&train_no=24000000T50E&station=T5&seat=1&from=BXP&to=NNZ&ticket=1027353027407675000010273500003048050000
            string getQueueCountUrl = @"https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getQueueCount&train_date="
            + forms["orderRequest.train_date"]
            + "&train_no=" + forms["orderRequest.train_no"]
            + "&station=" + forms["orderRequest.station_train_code"] +
            "&seat=" + seatType.ToSeatTypeValue() +
            "&from=" + forms["orderRequest.from_station_telecode"] +
            "&to=" + forms["orderRequest.to_station_telecode"] +
            "&ticket=" + forms["leftTicketStr"];
            ResYpInfo resYpInfo = HttpRequest.Create(getQueueCountUrl+"&t="+DateTime.Now.Ticks, "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie, HttpMethod.GET, "").GetJsonObject<ResYpInfo>(); ;
            // {"countT":0,"count":355,"ticket":"1*****30504*****00001*****00003*****0000","op_1":true,"op_2":false}
            return resYpInfo;
            //int seatNum = Utils.GetRealSeatNumber(resYpInfo.Ticket, seatType);
            //int wuzuo = 0;
            //if (seatType == SeatType.Ӳ��)
            //    wuzuo = Utils.GetRealSeatNumber(resYpInfo.Ticket, SeatType.����);
            //if (rtbLog != null)
            //{
            //    if (rtbLog.InvokeRequired)
            //    {
            //        rtbLog.Invoke(new Action(() =>
            //        {
            //            rtbLog.Text += string.Format("===>{0},{1}���Ŷ�,��Ʊ {2} �� {3}\r\n", seatType, resYpInfo.CountT, seatNum, wuzuo == 0 ? "" : ",���� " + wuzuo + " ��");
            //            rtbLog.SelectionStart = rtbLog.TextLength;
            //            rtbLog.ScrollToCaret();
            //        }));

            //    }
            //    else
            //    {
            //        rtbLog.Text += string.Format("===>{0},{1}���Ŷ�,��Ʊ {2} �� {3}\r\n", seatType, resYpInfo.CountT, seatNum, wuzuo == 0 ? "" : ",���� " + wuzuo + " ��");
            //        rtbLog.SelectionStart = rtbLog.TextLength;
            //        rtbLog.ScrollToCaret();
            //    }
            //}
            //if (force && seatNum < passengers.Length)
            //{
            //    if (wuzuo == 0)
            //    {
            //        System.Threading.Thread.Sleep(1000);
            //        goto CheckOrderInfo;
            //    }
            //    else
            //    {
            //        if (wuzuo < passengers.Length)
            //        {
            //            System.Threading.Thread.Sleep(1000);
            //            goto CheckOrderInfo;
            //        }
            //    }

            //}
        }
Exemplo n.º 47
0
 /// <summary>
 /// ��ȡ��λ����Ʊ��Ϣ
 /// </summary>
 /// <param name="seatType"></param>
 /// <returns></returns>
 public int GetRealSeatNumber(SeatType seatType)
 {
     int i = 0;
     int wz = 0;
     while (i < YpInfoDetail.Length)
     {
         string s = YpInfoDetail.Substring(i, 10);
         SeatType c_seat = (SeatType)s[0];
         string numStr = s.Substring(6, 4);
         int count = int.Parse(numStr);
         if (count > 3000)
         {
             count -= 3000;
             wz = count ;
         }
         else
         {
             if(seatType==c_seat) return count;
         }
         i += 10;
     }
     if(seatType==SeatType.����) return wz;
     else
     {
         return 0;
     }
 }
        /// <summary>
        /// �¶������������ض������
        /// </summary>
        /// <returns>�޴���ʱ���ؿգ��������ش���</returns>
        public string OrderTicket(TrainItemInfo trainItemInfo,Passenger[] passengers,SeatType seatType)
        {
            /*POST https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest HTTP/1.1
             * Referer: https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init
             *
             * station_train_code=Z133&train_date=2012-10-12&seattype_num=&from_station_telecode=BXP&to_station_telecode=NCG&include_student=00
             * &from_station_telecode_name=%E5%8C%97%E4%BA%AC&to_station_telecode_name=%E5%8D%97%E6%98%8C
             * &round_train_date=2012-10-11&round_start_time_str=00%3A00--24%3A00&single_round_type=1&train_pass_type=QB&train_class_arr=QB%23D%23Z%23T%23K%23QT%23
             * &start_time_str=00%3A00--24%3A00&lishi=11%3A29&train_start_time=19%3A45&trainno4=240000Z13305
             * &arrive_time=07%3A14&from_station_name=%E5%8C%97%E4%BA%AC%E8%A5%BF&to_station_name=%E5%8D%97%E6%98%8C&ypInfoDetail=1*****31254*****00241*****00006*****00113*****0111&mmStr=7D1B712CD355990896422EECCC4C11205C7DFD31C26962626B630FEE
             */
            NameValueCollection forms=new NameValueCollection();
            forms["station_train_code"] = trainItemInfo.TrainNo;
            forms["train_date"] = BuyTicketConfig.Instance.OrderRequest.TrainDate.ToString("yyyy-MM-dd");
            forms["seattype_num"] = "";
            forms["from_station_telecode"] = trainItemInfo.FromStationTelecode;
            forms["to_station_telecode"] = trainItemInfo.ToStationTelecode;
            forms["include_student"] = "00";
            forms["from_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.FromStationTelecodeName;
            forms["to_station_telecode_name"] = BuyTicketConfig.Instance.OrderRequest.ToStationTelecodeName;
            forms["round_train_date"] = System.DateTime.Today.ToString("yyyy-MM-dd");
            forms["round_start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
            forms["single_round_type"] = "1";
            forms["train_pass_type"] = BuyTicketConfig.Instance.OrderRequest.TrainPassType;
            forms["train_class_arr"] = BuyTicketConfig.Instance.OrderRequest.TrainClass;
            forms["start_time_str"] = BuyTicketConfig.Instance.OrderRequest.StartTimeStr;
            forms["lishi"] = trainItemInfo.lishi;
            forms["train_start_time"] =trainItemInfo.TrainStartTime;
            forms["trainno4"] = trainItemInfo.TrainNo4;
            forms["arrive_time"] = trainItemInfo.ArriveTime;
            forms["from_station_name"] = trainItemInfo.FromStationName;
            forms["to_station_name"] = trainItemInfo.ToStationName;
            forms["from_station_no"] = trainItemInfo.FromStationNo;
            forms["to_station_no"] = trainItemInfo.ToStationNo;
            forms["ypInfoDetail"] = trainItemInfo.YpInfoDetail;
            forms["mmStr"] = trainItemInfo.MmStr;
            forms["locationCode"] = trainItemInfo.LocationCode;
            string content = HttpRequest.Create("https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=submutOrderRequest", "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init", Cookie, forms).GetString();
            NameValueCollection htmlForm = Utils.GetForms(content);
            trainItemInfo.YpInfoDetailReal = htmlForm["leftTicketStr"]; //����ʵʱ��ѯ��Ʊ��Ϣ
            if (string.IsNullOrEmpty(trainItemInfo.YpInfoDetailReal))
            {
                Common.LogUtil.Log(content);
                return "�µ�ʧ��:δ�ܻ�ȡ��ʵ����Ʊ����Ϣ";
            }

            ConfirmRequest:

            forms = new NameValueCollection();
            forms["org.apache.struts.taglib.html.TOKEN"] = htmlForm["org.apache.struts.taglib.html.TOKEN"];
            forms["leftTicketStr"] = htmlForm["leftTicketStr"];
            foreach (string key in htmlForm.Keys)
            {
                if(key.StartsWith("orderRequest"))
                {
                    forms[key] = htmlForm[key];
                }
            }
            //&randCode=5xpy&orderRequest.reserve_flag=A

            string vcode = "";
            do
            {
                Stream stream =
                    HttpRequest.Create("https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=randp",
                                       "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie,
                                       HttpMethod.GET, "").GetStream();
                Image image = Image.FromStream(stream);
                vcode = GetVCodeByForm(image);
            } while (vcode == "");
            forms["randCode"] = vcode;
            forms["orderRequest.reserve_flag"] = BuyTicketConfig.Instance.SystemSetting.PayType == PayType.Online ? "A" : "B";//A=����֧��,B=ȡƱ�ֳ�֧��
            string postStr = forms.ToQueryString();
            foreach (Passenger passenger in passengers)
            {
                /*
                 * passengerTickets=3,0,1,����,1,362201198...,15910675179,Y
                 * &oldPassengers=����,1,362201198...&passenger_1_seat=3&passenger_1_seat_detail_select=0&passenger_1_seat_detail=0&passenger_1_ticket=1&passenger_1_name=����&passenger_1_cardtype=1&passenger_1_cardno=362201198&passenger_1_mobileno=15910675179&checkbox9=Y
                 * */
                if (passenger.Checked)
                {
                    postStr += "&passengerTickets=" +
                               Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2},{3},{4},{5},{6},Y",
                                                                       //passenger.SeatType.ToSeatTypeValue(),
                                                                       seatType.ToSeatTypeValue(),
                                                                       (int) passenger.SeatDetailType,
                                                                       (int) passenger.TicketType, passenger.Name,
                                                                       passenger.CardType.ToCardTypeValue(),
                                                                       passenger.CardNo, passenger.MobileNo));
                    postStr += "&oldPassengers=" +
                               Common.HtmlUtil.UrlEncode(string.Format("{0},{1},{2}", passenger.Name,
                                                                       passenger.CardType.ToCardTypeValue(),
                                                                       passenger.CardNo));
                }
            }
            string confirmSingleForQueueOrderUrl = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=confirmSingleForQueueOrder ";
               string resStateContent=  HttpRequest.Create(confirmSingleForQueueOrderUrl, "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init", Cookie, HttpMethod.POST, postStr).GetString();

            if(resStateContent.Contains("��֤��"))
            {
                goto ConfirmRequest;
            }
            ResState resState = resStateContent.ToJsonObject<ResState>();

            if(resState==null)
            {
                Common.LogUtil.Log(resStateContent);
                return "�µ�ʧ��:ȷ�϶���ʱ��ϵͳ���ص����ݲ���ȷ," + resStateContent;
            }
            else
            {
                if (resState.ErrMsg.Equals("Y"))
                {
                    return "";
                }
                else
                {
                    Common.LogUtil.Log(resStateContent);
                   return "�����쳣,��Ӧ״̬Ϊ��" + resState.ErrMsg;
                }
            }
        }
Exemplo n.º 49
0
 public SeatAssignment(int position, SeatType seat)
 {
     Position = position;
     Seat = seat;
 }
Exemplo n.º 50
0
        /// <summary>
        /// ������λ���ͻ�ȡƱ��
        /// </summary>
        /// <param name="seatTypeStr"></param>
        /// <returns></returns>
        public int GetSeatNumber(SeatType seatType)
        {
            string numStr = "";
            switch (seatType)
            {
                case SeatType.Ӳ��:
                    numStr = YingzuoSeat;
                    break;
                case SeatType.����:
                    numStr = RuanzuoSeat;
                    break;
                case SeatType.Ӳ��:
                    numStr = YingwoSeat;
                    break;
                case SeatType.����:
                    numStr = RuanwoSeat;
                    break;
                case SeatType.�߼�����:
                    numStr = GaojiRuanwoSeat;
                    break;
                case SeatType.������:
                    numStr = ShangwuSeat;
                    break;
                case SeatType.һ����:
                    numStr = YidengSeat;
                    break;
                case SeatType.������:
                    numStr = ErdengSeat;
                    break;
                case SeatType.�ص���:
                    numStr = TedengSeat;
                    break;
                case SeatType.�۹���:
                    return 0;
                    break;
                case SeatType.һ�Ȱ���:
                    return 0;
                    break;
                default:
                    numStr = WuzuoSeat;
                    //return 0;
                    break;
            }

            if(numStr=="��")
            {
                return int.MaxValue;
            }
            //else if(numStr=="*")
            //    {
            //        return int.MaxValue;
            //    }
            else
            {
                int num = 0;
                int.TryParse(numStr, out num);
                return num;
            }
        }