Exemple #1
0
        public void LoadScheduleSlotFromDatabase()
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            //Get all the current week's scheduleSlots
            List <ScheduleSlot> scheduleSlotsWeek = PlanningGeneratorTools.GetWeekScheduleSlots(d, bdModel);

            //Add the week's slot in the scheduler
            foreach (ScheduleSlot ss in scheduleSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Mininum : " + ss.minAttendency.ToString(),
                    Start         = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End           = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek     = ss.dayOfWeek,
                    Color         = new SolidColorBrush(Colors.Aqua),
                    FirstDay      = ss.firstDay,
                    LastDay       = ss.lastDay,
                    IdShift       = ss.idTimeSlot,
                    MinAttendency = ss.minAttendency
                });
                this.btnNext.Visibility = Visibility.Visible;
                this.btnPrev.Visibility = Visibility.Visible;
            }
        }
Exemple #2
0
        private void btnGenerationAbs_Click(object sender, RoutedEventArgs e)
        {
            if (isDateChecked() && areDatesCorrect())
            {
                MessageBox.Show("Le traitement peux prendre du temps merci de patienter jusqu'au message indicant la fin du traitement.", "Génération des plages horaires");
                // Disabled simulation's components
                dpFirstDay.IsEnabled    = false;
                dpLastDay.IsEnabled     = false;
                btnGeneration.IsEnabled = false;
                PlanningGeneratorTools.ClearWorkingShiftScheduler(weekGenerationScheduler);

                //gets first and last day
                DateTime firstDay = (DateTime)dpFirstDay.SelectedDate;
                DateTime lastDay  = (DateTime)dpLastDay.SelectedDate;

                List <DateTime>     generationDates = new List <DateTime>();
                List <WorkingShift> shifts          = null;
                while (firstDay < lastDay)
                {
                    Tuple <List <WorkingShift>, List <string> > resultat = new FlowGraph(bdModel.People.ToList(), PlanningGeneratorTools.GetWeekScheduleSlots(firstDay, bdModel), firstDay, bdModel.AbsenceDemands.ToList()).GetShifts();
                    shifts = resultat.Item1;
                    string message = "";
                    int    count   = 0;
                    foreach (string problem in resultat.Item2)
                    {
                        count++;
                        message += (count + ". " + problem + "\n");
                    }
                    if (count > 0)
                    {
                        MessageBox.Show(message);
                    }
                    PlanningGeneratorTools.AddWorkingShiftScheduler(shifts, weekGenerationScheduler);
                    totalWorkingShifts.AddRange(shifts);
                    firstDay = firstDay.AddDays(7); //go to the next week
                }
                MessageBox.Show("Traitement terminé", "Génération des plages horaires");
                btnSaveInDB.IsEnabled = true; //Enable the database recording button
            }
            else
            {
                MessageBox.Show("Veuillez remplir les champs \"Premier jour\" et \"Dernier Jour\"" +
                                "\n" + " et vérifier que le premier jour soit avant ou égal au dernier jour");
            }
        }