Exemple #1
0
        private async Task FillFakeDatabase(int i)
        {
            DateTime da = DateTime.Now.AddDays(-i);
            CreateDatatableStrings str  = new CreateDatatableStrings();
            List <Taxi>            taxi = new List <Taxi>();
            //List<Owner> owner = new List<Owner>();
            //List<Driver> driver = new List<Driver>();
            List <Person>        person        = new List <Person>();
            List <PersonType>    personType    = new List <PersonType>();
            List <Expense>       expense       = new List <Expense>();
            List <Income>        income        = new List <Income>();
            List <TypeExpense>   typeExpense   = new List <TypeExpense>();
            List <TypeIncome>    typeIncome    = new List <TypeIncome>();
            List <TaxiPayment>   taxiPayment   = new List <TaxiPayment>();
            List <PrimaryDriver> primaryDriver = new List <PrimaryDriver>();
            List <Kilometer>     kilometer     = new List <Kilometer>();
            List <Shift>         shift         = new List <Shift>();
            List <Depth>         depth         = new List <Depth>();


            taxiPayment.Add(new TaxiPayment {
                TaxiID = 1, PersonID = 2, RentPrice = 100, PaymentsPerMonth = 1
            });
            primaryDriver.Add(new PrimaryDriver {
                TaxiID = i - 1, PersonID = i - 1
            });
            kilometer.Add(new Kilometer {
                TaxiID = 1, PersonID = 1, ShiftDate = da, KlmStart = 200000, KlmFinish = 200000, KlmShift = 200000
            });
            shift.Add(new Shift {
                TaxiID = 1, PersonID = 1, ShiftDate = da, XZ = 10.25m, Oil = 10.25m, XZFPA = 10.25m, OilFPA = 10.25m, ShiftPayment = 10.25m, Insurance = 10.25m, FPA = 10.25m, Comment = "comment"
            });
            depth.Add(new Depth {
                TaxiID = 1, PersonID = 1, DepthDate = da, Paid = null, Amount = 15.25m, RepaidAmount = 5.25m, Comment = "comment"
            });

            typeIncome.Add(new TypeIncome {
                Name = "MR test"
            });
            typeExpense.Add(new TypeExpense {
                Name = "MR test"
            });
            income.Add(new Income {
                PersonID = 1, Amount = 2105873695.25m, Comment = "Dis is a comment  ", Date = da, TypeIncomeID = 1
            });
            expense.Add(new Expense {
                PersonID = 1, Amount = 2105873695.25m, Comment = "Dis is a comment  ", Date = da, TypeExpenseID = 1
            });
            //driver.Add(new Driver { IdCard = "AA 15"+i, Name = "MR test"+i, Surname = "Smith", PhoneNumber1 = 2105873695, PhoneNumber2 = 251855512, Email = "*****@*****.**", AFM = 123456789, BirthDate = da });
            //owner.Add(new Owner { IdCard = "AA 15"+i, Name = "MR test" + i, Surname = "Smith", PhoneNumber1 = 2105873695, PhoneNumber2 = 251855512, Email = "*****@*****.**", AFM = 123456789, BirthDate = da });
            person.Add(new Person {
                IdCard = "AA 15" + i, Reserve = 0.0m, Name = "Αλέξανδρος" + i, Surname = "Ανδρικόπουλος driver", PhoneNumber1 = 2105873695, PhoneNumber2 = 251855512, Email = "*****@*****.**", AFM = 123456789, BirthDate = da, PersonTypeID = 1
            });
            person.Add(new Person {
                IdCard = "AA 15" + i, Reserve = 0.0m, Name = "Αλέξανδρος" + i, Surname = "Ανδρικόπουλος", PhoneNumber1 = 2105873695, PhoneNumber2 = 251855512, Email = "*****@*****.**", AFM = 123456789, BirthDate = da, PersonTypeID = 2
            });

            //personType.Add(new PersonType { Name = "Driver"});
            taxi.Add(new Taxi {
                LicensePlate = "taa" + i, Make = "BMW", Model = "i14", MakeDate = 2004, InsuranceCompany = "URair", InsurancePrice = 300.14m, reg_date = da, PersonID = 1
            });

            personType = await sqlexec.SQLGetPersonType(Properties.Settings.Default.DBName, 0, "none", true);

            if (personType.Count != 2)
            {
                personType.Clear();
                personType.Add(new PersonType {
                    Name = "Driver"
                });
                personType.Add(new PersonType {
                    Name = "Owner"
                });
                await sqlexec.SqlInsertPersonType(Properties.Settings.Default.DBName, personType);
            }
            personType.Clear();

            List <Task> tasks = new List <Task>();

            tasks.Add(Task.Run(() => sqlexec.SqlInsertTypeIncome(Properties.Settings.Default.DBName, typeIncome)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertTypeExpense(Properties.Settings.Default.DBName, typeExpense)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertIncome(Properties.Settings.Default.DBName, income)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertExpense(Properties.Settings.Default.DBName, expense)));
            //tasks.Add(Task.Run(() => sqlexec.SqlInsertDriver(Properties.Settings.Default.DBName, driver)));
            //tasks.Add(Task.Run(() => sqlexec.SqlInsertOwner(Properties.Settings.Default.DBName, owner)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertPerson(Properties.Settings.Default.DBName, person)));
            //tasks.Add(Task.Run(() => sqlexec.SqlInsertPersonType(Properties.Settings.Default.DBName, personType)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertTaxi(Properties.Settings.Default.DBName, taxi)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertTaxiPayment(Properties.Settings.Default.DBName, taxiPayment)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertPrimaryDriver(Properties.Settings.Default.DBName, primaryDriver)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertKilometer(Properties.Settings.Default.DBName, kilometer)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertShift(Properties.Settings.Default.DBName, shift)));
            tasks.Add(Task.Run(() => sqlexec.SqlInsertDepth(Properties.Settings.Default.DBName, depth)));


            await Task.WhenAll(tasks);
        }