public static void Seed(BusTicketsContext context)
        {
            Town[] towns = TownGenerator.GenerateTowns();
            context.Towns.AddRange(towns);

            BusCompany[] companies = BusCompanyGenerator.GenerateBusCompanies();
            context.BusCompanies.AddRange(companies);

            BusStation[] stations = BusStationGenerator.GenerateBusStations(towns);
            context.BusStations.AddRange(stations);

            Customer[] customers = CustomerGenerator.GenerateCustomers(towns);
            context.Customers.AddRange(customers);

            BankAccount[] accounts = BankAccountGenerator.GenerateBankAccounts(customers);
            context.BankAccounts.AddRange(accounts);

            //BusCompany[] companiesFromDb = context.BusCompanies.ToArray();
            Review[] reviews = ReviewGenerator.GenerateReviews(companies, customers);
            context.Reviews.AddRange(reviews);

            Trip[] trips = TripGenerator.GenerateTrips(stations, companies);
            context.Trips.AddRange(trips);

            Ticket[] tickets = TicketGenerator.GenerateTicket(customers, trips);
            context.Tickets.AddRange(tickets);

            context.SaveChanges();

            Console.WriteLine("Sample data inserted successfully.");
        }
Beispiel #2
0
        private void GenerateTickets(Nintendo3DSTitle[] entries, string outputDir)
        {
            this.statusProgressbar.Style = ProgressBarStyle.Blocks;

            Directory.CreateDirectory(outputDir);

            var types = entries.Select(a => a.Type).Distinct().ToList();

            var total     = entries.Length;
            var processed = 0;

            foreach (var type in types)
            {
                var ticketOutputPath = outputDir + "\\" + "tickets" + "\\" + type;
                Directory.CreateDirectory(ticketOutputPath);

                var filtered = entries.Where(a => a.Type == type).ToArray();

                foreach (var title in filtered)
                {
                    TicketGenerator.GenerateTicket(title, $"{title.Name} ({title.Serial}).tik", $"{ticketOutputPath}\\{title.Region}");

                    processed++;

                    var percentageDone = (int)Math.Ceiling((double)processed / total * 100);

                    if (percentageDone != this.statusProgressbar.Value)
                    {
                        this.progressUpdater.ReportProgress(percentageDone, new[] { processed, total });
                    }
                }
            }
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     int[,] ticket = new int[3, 9];
     TicketGenerator.GenerateTicket(ref ticket);
     TicketGenerator.PrintTicket(ticket);
     Console.ReadLine();
 }
Beispiel #4
0
        public void TestPiterTicketLucky(int ticketNumber, bool isLucky)
        {
            bool          result;
            Ticket        ticket        = new Ticket(ticketNumber);
            TicketCounter ticketCounter = new PiterTicketCounter(TicketGenerator.Build(0, 1));

            result = ticketCounter.IsLucky(ticket);

            Assert.Equal(result, isLucky);
        }
Beispiel #5
0
        public void TestPiterTicketLuckyCountCorrect()
        {
            int             minRange        = 0;
            int             maxRange        = 999999;
            TicketGenerator ticketGenerator = TicketGenerator.Build(minRange, maxRange);
            TicketCounter   ticketCounter   = new PiterTicketCounter(ticketGenerator);
            int             expectedAmount  = 55252;

            int amount = ticketCounter.CountLuckyTickets();

            Assert.Equal(expectedAmount, amount);
        }
        public void GeneratorMakesTheCorrectAmountOfTickets(int minRange, int maxRange, int ticketsAmount)
        {
            TicketGenerator ticketGenerator = TicketGenerator.Build(minRange, maxRange);
            int             count           = 0;

            foreach (var item in ticketGenerator)
            {
                count++;
            }

            Assert.Equal(ticketsAmount, count);
        }
 public void GetJsapiTicket()
 {
     //Id	URL	Token	AppId	AppSecret	ApplicationId	CreateDateTime	IsHide	IsDelete	Remark	AppKey	PartnerId	PartnerKey
     //wxa22b9cfd8fdec01a	d383a6032a4cef3dc22ba9c5130b60e2	7BBFA36C-8115-47AD-8D47-9E52B58E7EFD	2014-06-25 15:46:19.643	0	0	NULL	IUInS0W9rSnhRsF1AC1YZx9TVX5elH2bbRV4wbcEMN8ykdz4r7ht3jyOjqiYYqZcNi1SIig7EVKckcl6eIQs0GdH6BmmbRo5dElL5e9cinlmbnbXhClKbItAAfE0wuCY	1220064601	a09d39a068eda7245dbc8de29e4f2ba5
     //var a = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2");
     var a = new AccessToken("wxa22b9cfd8fdec01a", "d383a6032a4cef3dc22ba9c5130b60e2");
     var t = new TicketGenerator(a);
     var js_ticket = t.GetJsapiTicket();
     var s = new YuChang.Core.PromoteService(a);
     for (var i = 10842; i <= 10841 + 20; i++)
     {
         var str = s.GenerateSquareCode(i);
         Console.WriteLine(str);
     }
     //Assert.IsNotNull(js_ticket);
     //Console.WriteLine(js_ticket);
 }
Beispiel #8
0
        public void GetJsapiTicket()
        {
            //Id	URL	Token	AppId	AppSecret	ApplicationId	CreateDateTime	IsHide	IsDelete	Remark	AppKey	PartnerId	PartnerKey
            //wxa22b9cfd8fdec01a	d383a6032a4cef3dc22ba9c5130b60e2	7BBFA36C-8115-47AD-8D47-9E52B58E7EFD	2014-06-25 15:46:19.643	0	0	NULL	IUInS0W9rSnhRsF1AC1YZx9TVX5elH2bbRV4wbcEMN8ykdz4r7ht3jyOjqiYYqZcNi1SIig7EVKckcl6eIQs0GdH6BmmbRo5dElL5e9cinlmbnbXhClKbItAAfE0wuCY	1220064601	a09d39a068eda7245dbc8de29e4f2ba5
            //var a = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2");
            var a         = new AccessToken("wxa22b9cfd8fdec01a", "d383a6032a4cef3dc22ba9c5130b60e2");
            var t         = new TicketGenerator(a);
            var js_ticket = t.GetJsapiTicket();
            var s         = new YuChang.Core.PromoteService(a);

            for (var i = 10842; i <= 10841 + 20; i++)
            {
                var str = s.GenerateSquareCode(i);
                Console.WriteLine(str);
            }
            //Assert.IsNotNull(js_ticket);
            //Console.WriteLine(js_ticket);
        }
        public void Run()
        {
            string message = string.Empty;

            try
            {
                TicketGeneratorDTO generatorDTO    = _ticketView.GetTicketGenerator();
                TicketGenerator    ticketGenerator = TicketGenerator.Build(generatorDTO);
                TicketCounterMode  mode            = GetTicketCounterMode();
                TicketCounter      ticketCounter   = TicketCounterFactory.Build(mode, ticketGenerator);
                int luckyTickets = ticketCounter.CountLuckyTickets();

                message = string.Format("Lucky tickets count: {0}", luckyTickets);
                Log.Information("LuckyTickets count: {luckyTickets}", luckyTickets);
            }
            catch (FormatException ex)
            {
                _ticketView.DisplayInstruction();
                Log.Error(ex, "Exception thrown");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _ticketView.DisplayInstruction();
                Log.Error(ex, "Exception thrown");
            }
            catch (OverflowException ex)
            {
                _ticketView.DisplayInstruction();
                Log.Error(ex, "Exception thrown");
            }
            catch (FileNotFoundException ex)
            {
                _ticketView.DisplayInstruction();
                Log.Error(ex, "Exception thrown");
            }

            _ticketView.Display(message);
        }
Beispiel #10
0
 public void SetUp()
 {
     _sut = new TicketGenerator();
 }
 public void BuildGeneratorWithWrongRangeThrowsException(int minRange, int maxRange)
 {
     Assert.Throws <ArgumentOutOfRangeException>(
         () => TicketGenerator.Build(minRange, maxRange));
 }