コード例 #1
0
        static TeamData()
        {
            Random = new Random();
            Start  = GetStart();

            if (ViewModelBase.IsInDesignMode)
            {
                Employees                   = new List <Employee>();
                Calendars                   = CreateCalendars().ToList();
                VacationAppointments        = new TeamAppointment[] { };
                CompanyBirthdayAppointments = new TeamAppointment[] { };
                BirthdayAppointments        = new TeamAppointment[] { };
                ConferenceAppointments      = new TeamAppointment[] { };
                MeetingAppointments         = new TeamAppointment[] { };
                PhoneCallsAppointments      = new TeamAppointment[] { };
                CarWashAppointments         = new TeamAppointment[] { };
                PayBillsAppointments        = new TeamAppointment[] { };
                DentistAppointments         = new TeamAppointment[] { };
                RestaurantAppointments      = new TeamAppointment[] { };
                AllAppointments             = new TeamAppointment[] { };
                return;
            }

            //Employees = NWindContext.Create().Employees.ToList();
            Employees[0].BirthDate = Start.AddDays(4).AddYears(-30);

            Calendars                   = CreateCalendars().ToList();
            VacationAppointments        = CreateVacationsAppts(Start).ToList();
            CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList();
            BirthdayAppointments        = CreateBirthdayAppts(Start).ToList();
            ConferenceAppointments      = CreateConferenceAppts(Start).ToList();
            MeetingAppointments         = CreateMeetingAppts(Start).ToList();
            PhoneCallsAppointments      = CreatePhoneCallsAppts(Start).ToList();
            CarWashAppointments         = CreateCarWashAppts(Start).ToList();
            TrainingAppointments        = CreateTrainingAppts(Start).ToList();
            PayBillsAppointments        = CreatePayBillsAppts(Start).ToList();
            DentistAppointments         = CreateDentistAppts(Start).ToList();
            RestaurantAppointments      = CreateRestaurantAppts(Start).ToList();
            AllAppointments             = VacationAppointments
                                          .Concat(BirthdayAppointments)
                                          .Concat(CompanyBirthdayAppointments)
                                          .Concat(ConferenceAppointments)
                                          .Concat(MeetingAppointments)
                                          .Concat(PhoneCallsAppointments)
                                          .Concat(CarWashAppointments)
                                          .Concat(TrainingAppointments)
                                          .Concat(PayBillsAppointments)
                                          .Concat(DentistAppointments)
                                          .Concat(RestaurantAppointments)
                                          .ToList();
            int id = 0;

            foreach (TeamAppointment appt in AllAppointments)
            {
                appt.Id = id++;
            }
        }
コード例 #2
0
        static IEnumerable <TeamAppointment> CreatePhoneCallsAppts(DateTime start)
        {
            List <TeamAppointment> res = new List <TeamAppointment>()
            {
                CreatePhoneCallAppt(Employees[0], start.AddDays(0).AddHours(10)),
                CreatePhoneCallAppt(Employees[1], start.AddDays(3).AddHours(11)),
                CreatePhoneCallAppt(Employees[2], start.AddDays(3).AddHours(12).AddMinutes(40), TimeSpan.FromMinutes(15)),
                CreatePhoneCallAppt(Employees[3], start.AddDays(-4).AddHours(14)),
                CreatePhoneCallAppt(Employees[4], start.AddDays(9).AddHours(15)),
                CreatePhoneCallAppt(Employees[5], start.AddDays(12).AddHours(15)),

                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(0).AddHours(16)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(2).AddHours(15.6)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(4).AddHours(15)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(5).AddHours(10.5)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(5).AddHours(16)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(6).AddHours(9.7)),
                CreatePhoneCallAppt(GetRandomEmployee(), start.AddDays(6).AddHours(16.8)),
            };
            DateTimeRange interval = new DateTimeRange(start.AddDays(-7), start.AddDays(21));

            for (int i = 0; i < 50; i++)
            {
                Employee emp      = Employees[Random.Next(0, Employees.Count)];
                DateTime newStart = start.AddYears(-1);
                newStart = newStart.AddDays(Random.Next(365));
                if (interval.Start <= newStart && interval.End >= newStart)
                {
                    continue;
                }
                if (VacationAppointments.Any(x => x.Start <= newStart && x.End >= newStart))
                {
                    continue;
                }
                res.Add(CreatePhoneCallAppt(emp, newStart.AddHours(Random.Next(9, 18))));
            }
            return(res);
        }
コード例 #3
0
        static IEnumerable <TeamAppointment> CreateCarWashAppts(DateTime start)
        {
            List <TeamAppointment> res = new List <TeamAppointment>()
            {
                CreateCarWashAppt(start.AddDays(1).AddHours(17)),
            };
            DateTime newStart = start.AddYears(-1);

            while (newStart < start.AddMonths(1))
            {
                newStart = newStart.AddDays(Random.Next(18, 35));
                if (VacationAppointments.Any(x => x.Start <= newStart && x.End >= newStart))
                {
                    continue;
                }
                if (newStart >= start && newStart <= start.AddDays(7))
                {
                    continue;
                }
                CreateCarWashAppt(newStart);
            }
            return(res);
        }
コード例 #4
0
        static IEnumerable <TeamAppointment> CreateMeetingAppts(DateTime start)
        {
            List <TeamAppointment> res = new List <TeamAppointment>()
            {
                CreateMeetingRecurrenceAppt("Weekly meeting", start.AddMonths(-6).Add(new TimeSpan(5, 14, 00, 0))),
                CreateLunchAppt(Employees[0], start.AddDays(1).AddHours(13)),
                CreateLunchAppt(Employees[1], start.AddDays(3).AddHours(13)),
                CreateLunchAppt(Employees[2], start.AddDays(-4).AddHours(13)),
                CreateLunchAppt(Employees[3], start.AddDays(9).AddHours(13)),
                CreateLunchAppt(Employees[4], start.AddDays(12).AddHours(13)),
            };
            DateTimeRange interval = new DateTimeRange(start.AddDays(-7), start.AddDays(21));
            List <int>    days     = new List <int>();

            for (int i = 0; i < 50; i++)
            {
                Employee emp      = Employees[Random.Next(0, Employees.Count)];
                DateTime newStart = start.AddYears(-1);
                newStart = newStart.AddDays(Random.Next(365));
                if (interval.Start <= newStart && interval.End >= newStart)
                {
                    continue;
                }
                if (days.Contains(newStart.DayOfYear))
                {
                    continue;
                }
                if (VacationAppointments.Any(x => x.Start <= newStart && x.End >= newStart))
                {
                    continue;
                }
                days.Add(newStart.DayOfYear);
                res.Add(CreateLunchAppt(emp, newStart.AddHours(13)));
            }
            return(res);
        }
コード例 #5
0
        static TeamData()
        {
            Random = new Random();
            Start  = GetStart();

            if (ViewModelBase.IsInDesignMode)
            {
                Employees                   = new List <Employee>();
                Calendars                   = CreateCalendars().ToList();
                VacationAppointments        = new TeamAppointment[] { };
                CompanyBirthdayAppointments = new TeamAppointment[] { };
                BirthdayAppointments        = new TeamAppointment[] { };
                ConferenceAppointments      = new TeamAppointment[] { };
                MeetingAppointments         = new TeamAppointment[] { };
                PhoneCallsAppointments      = new TeamAppointment[] { };
                CarWashAppointments         = new TeamAppointment[] { };
                PayBillsAppointments        = new TeamAppointment[] { };
                DentistAppointments         = new TeamAppointment[] { };
                RestaurantAppointments      = new TeamAppointment[] { };
                AllAppointments             = new TeamAppointment[] { };
                return;
            }

            Employees = new List <Employee>();
            Employees.Add(new Employee()
            {
                FirstName = "Andrew", LastName = "Glover"
            });
            Employees.Add(new Employee()
            {
                FirstName = "Mark", LastName = "Oliver"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John", LastName = "Heart"
            });
            Employees.Add(new Employee()
            {
                FirstName = "Olivia", LastName = "Peyton"
            });
            Employees.Add(new Employee()
            {
                FirstName = "Sandra", LastName = "Johnson"
            });
            Employees.Add(new Employee()
            {
                FirstName = "Amelia", LastName = "Harper"
            });
            Employees[0].BirthDate = Start.AddDays(4).AddYears(-30);
            Employees[1].BirthDate = Start.AddDays(1).AddYears(-27);
            Employees[2].BirthDate = Start.AddDays(14).AddYears(-32);
            Employees[3].BirthDate = Start.AddDays(-8).AddYears(-41);
            Employees[4].BirthDate = Start.AddDays(-18).AddYears(-41);
            Employees[5].BirthDate = Start.AddDays(48).AddYears(-25);

            Calendars                   = CreateCalendars().ToList();
            VacationAppointments        = CreateVacationsAppts(Start).ToList();
            CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList();
            BirthdayAppointments        = CreateBirthdayAppts(Start).ToList();
            ConferenceAppointments      = CreateConferenceAppts(Start).ToList();
            MeetingAppointments         = CreateMeetingAppts(Start).ToList();
            PhoneCallsAppointments      = CreatePhoneCallsAppts(Start).ToList();
            CarWashAppointments         = CreateCarWashAppts(Start).ToList();
            TrainingAppointments        = CreateTrainingAppts(Start).ToList();
            PayBillsAppointments        = CreatePayBillsAppts(Start).ToList();
            DentistAppointments         = CreateDentistAppts(Start).ToList();
            RestaurantAppointments      = CreateRestaurantAppts(Start).ToList();
            AllAppointments             = VacationAppointments
                                          .Concat(BirthdayAppointments)
                                          .Concat(CompanyBirthdayAppointments)
                                          .Concat(ConferenceAppointments)
                                          .Concat(MeetingAppointments)
                                          .Concat(PhoneCallsAppointments)
                                          .Concat(CarWashAppointments)
                                          .Concat(TrainingAppointments)
                                          .Concat(PayBillsAppointments)
                                          .Concat(DentistAppointments)
                                          .Concat(RestaurantAppointments)
                                          .ToList();
            int id = 0;

            foreach (TeamAppointment appt in AllAppointments)
            {
                appt.Id = id++;
            }
        }
        static TeamData()
        {
            Random = new Random();
            Start  = GetStart();

            if (ViewModelBase.IsInDesignMode)
            {
                Employees                   = new List <Employee>();
                Calendars                   = CreateCalendars().ToList();
                VacationAppointments        = new TeamAppointment[] { };
                CompanyBirthdayAppointments = new TeamAppointment[] { };
                BirthdayAppointments        = new TeamAppointment[] { };
                ConferenceAppointments      = new TeamAppointment[] { };
                MeetingAppointments         = new TeamAppointment[] { };
                PhoneCallsAppointments      = new TeamAppointment[] { };
                CarWashAppointments         = new TeamAppointment[] { };
                PayBillsAppointments        = new TeamAppointment[] { };
                DentistAppointments         = new TeamAppointment[] { };
                RestaurantAppointments      = new TeamAppointment[] { };
                AllAppointments             = new TeamAppointment[] { };
                return;
            }

            Employees = new List <Employee>();
            Employees.Add(new Employee()
            {
                FirstName = "John1", LastName = "Smith1"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John2", LastName = "Smith2"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John3", LastName = "Smith3"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John4", LastName = "Smith4"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John5", LastName = "Smith5"
            });
            Employees.Add(new Employee()
            {
                FirstName = "John6", LastName = "Smith6"
            });
            Employees[0].BirthDate = Start.AddDays(4).AddYears(-30);
            Employees[1].BirthDate = Start.AddDays(1).AddYears(-27);
            Employees[2].BirthDate = Start.AddDays(14).AddYears(-32);
            Employees[3].BirthDate = Start.AddDays(-8).AddYears(-41);
            Employees[4].BirthDate = Start.AddDays(-18).AddYears(-41);
            Employees[5].BirthDate = Start.AddDays(48).AddYears(-25);

            Calendars                   = CreateCalendars().ToList();
            VacationAppointments        = CreateVacationsAppts(Start).ToList();
            CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList();
            BirthdayAppointments        = CreateBirthdayAppts(Start).ToList();
            ConferenceAppointments      = CreateConferenceAppts(Start).ToList();
            MeetingAppointments         = CreateMeetingAppts(Start).ToList();
            PhoneCallsAppointments      = CreatePhoneCallsAppts(Start).ToList();
            CarWashAppointments         = CreateCarWashAppts(Start).ToList();
            TrainingAppointments        = CreateTrainingAppts(Start).ToList();
            PayBillsAppointments        = CreatePayBillsAppts(Start).ToList();
            DentistAppointments         = CreateDentistAppts(Start).ToList();
            RestaurantAppointments      = CreateRestaurantAppts(Start).ToList();
            AllAppointments             = VacationAppointments
                                          .Concat(BirthdayAppointments)
                                          .Concat(CompanyBirthdayAppointments)
                                          .Concat(ConferenceAppointments)
                                          .Concat(MeetingAppointments)
                                          .Concat(PhoneCallsAppointments)
                                          .Concat(CarWashAppointments)
                                          .Concat(TrainingAppointments)
                                          .Concat(PayBillsAppointments)
                                          .Concat(DentistAppointments)
                                          .Concat(RestaurantAppointments)
                                          .ToList();
            int id = 0;

            foreach (TeamAppointment appt in AllAppointments)
            {
                appt.Id = id++;
            }

            List <TimeRegion> regions = new List <TimeRegion>();

            regions.Add(new TimeRegion()
            {
                Id    = 0,
                Start = DateTime.Today.AddHours(13).AddMinutes(20),
                End   = DateTime.Today.AddHours(14).AddMinutes(45),
                Brush = new SolidColorBrush(Colors.Blue)
                {
                    Opacity = 0.4
                },
                CalendarId     = 0,
                Type           = (int)TimeRegionType.Pattern,
                RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(13).AddMinutes(20)).Build()).ToXml()
            });

            regions.Add(new TimeRegion()
            {
                Id    = 2,
                Start = DateTime.Today.AddHours(20),
                End   = DateTime.Today.AddHours(22),
                Brush = new SolidColorBrush(Colors.DarkBlue)
                {
                    Opacity = 0.4
                },
                CalendarId     = 0,
                Type           = (int)TimeRegionType.Pattern,
                RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(20)).Build()).ToXml()
            });
            regions.Add(new TimeRegion()
            {
                Id    = 1,
                Start = DateTime.Today.AddHours(13),
                End   = DateTime.Today.AddHours(14),
                Brush = new SolidColorBrush(Colors.Blue)
                {
                    Opacity = 0.4
                },
                CalendarId     = 1,
                Type           = (int)TimeRegionType.Pattern,
                RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(13)).Build()).ToXml()
            });
            TimeRegions = regions;
        }
コード例 #7
0
        static TeamData()
        {
            Random = new Random();
            Start  = GetStart();

            Employees = new List <Employee>()
            {
                new Employee()
                {
                    BirthDate = new DateTime(1978, 12, 08), FirstName = "Nancy", LastName = "Davolio"
                },
                new Employee()
                {
                    BirthDate = new DateTime(1965, 02, 19), FirstName = "Andrew", LastName = "Fuller"
                },
                new Employee()
                {
                    BirthDate = new DateTime(1968, 06, 26), FirstName = "Janet", LastName = "Leverling"
                },
                new Employee()
                {
                    BirthDate = new DateTime(1993, 05, 03), FirstName = "Margaret", LastName = "Peacock"
                },
                new Employee()
                {
                    BirthDate = new DateTime(1993, 10, 17), FirstName = "Steven", LastName = "Buchanan"
                },
                new Employee()
                {
                    BirthDate = new DateTime(1999, 10, 17), FirstName = "Michael", LastName = "Suyama"
                },
            };
            Employees[0].BirthDate = Start.AddDays(4).AddYears(-30);

            Calendars                   = CreateCalendars().ToList();
            VacationAppointments        = CreateVacationsAppointments(Start).ToList();
            CompanyBirthdayAppointments = CreateCompanyBirthdayAppointments(Start).ToList();
            BirthdayAppointments        = CreateBirthdayAppointments(Start).ToList();
            ConferenceAppointments      = CreateConferenceAppointments(Start).ToList();
            MeetingAppointments         = CreateMeetingAppointments(Start).ToList();
            PhoneCallsAppointments      = CreatePhoneCallsAppointments(Start).ToList();
            CarWashAppointments         = CreateCarWashAppointments(Start).ToList();
            TrainingAppointments        = CreateTrainingAppointments(Start).ToList();
            PayBillsAppointments        = CreatePayBillsAppointments(Start).ToList();
            DentistAppointments         = CreateDentistAppointments(Start).ToList();
            RestaurantAppointments      = CreateRestaurantAppointments(Start).ToList();
            AllAppointments             = VacationAppointments
                                          .Concat(BirthdayAppointments)
                                          .Concat(CompanyBirthdayAppointments)
                                          .Concat(ConferenceAppointments)
                                          .Concat(MeetingAppointments)
                                          .Concat(PhoneCallsAppointments)
                                          .Concat(CarWashAppointments)
                                          .Concat(TrainingAppointments)
                                          .Concat(PayBillsAppointments)
                                          .Concat(DentistAppointments)
                                          .Concat(RestaurantAppointments)
                                          .ToList();
            int id = 0;

            foreach (TeamAppointment apt in AllAppointments)
            {
                apt.Id = id++;
            }
        }