Esempio n. 1
0
        public static object GenerateAgendaAppointmentCollection(SchedulerStorage storage)
        {
            AppointmentBaseCollection       sourceAppointments = storage.GetAppointments(SelectedInterval);
            BindingList <AgendaAppointment> agendaAppointments = new BindingList <AgendaAppointment>();

            foreach (Appointment appointment in sourceAppointments)
            {
                TimeInterval currentDayInterval = new TimeInterval(appointment.Start.Date, appointment.Start.Date.AddDays(1));
                string       startTime          = "";
                string       endTime            = "";
                if (currentDayInterval.Contains(appointment.End))
                {
                    startTime = currentDayInterval.Start == appointment.Start ? "" : appointment.Start.TimeOfDay.ToString(@"hh\:mm");
                    endTime   = currentDayInterval.End == appointment.End ? "" : appointment.End.TimeOfDay.ToString(@"hh\:mm");
                    agendaAppointments.Add(CreateAgendaAppointment(storage, appointment, currentDayInterval.Start, startTime, endTime));
                }
                else
                {
                    startTime = currentDayInterval.Start == appointment.Start ? "" : appointment.Start.TimeOfDay.ToString(@"hh\:mm");
                    agendaAppointments.Add(CreateAgendaAppointment(storage, appointment, currentDayInterval.Start, startTime, ""));
                    while (true)
                    {
                        currentDayInterval = new TimeInterval(currentDayInterval.End, currentDayInterval.End.AddDays(1));
                        if (currentDayInterval.Contains(appointment.End))
                        {
                            endTime = currentDayInterval.End == appointment.End ? "" : appointment.End.TimeOfDay.ToString(@"hh\:mm");
                            agendaAppointments.Add(CreateAgendaAppointment(storage, appointment, currentDayInterval.Start, "", endTime));
                            break;
                        }
                        else
                        {
                            agendaAppointments.Add(CreateAgendaAppointment(storage, appointment, currentDayInterval.Start, "", ""));
                        }
                    }
                }
            }
            return(agendaAppointments);
        }