Esempio n. 1
0
        public IList <Appointment> FetchAvailAppointmentTimeSlots(int facultyId, DateTime selDate, out bool isFacultyUnAvaillable)
        {
            DAL.Schedule        schedule          = facAppDataRepo.FetchScheduleForDayOfWeekOfFaculty(facultyId, selDate.DayOfWeek.ToString());
            IList <Appointment> availAppointments = new List <Appointment>();

            if (schedule == null || schedule.IsUnavailableEntireDay)
            {
                isFacultyUnAvaillable = true;
                return(availAppointments);
            }
            isFacultyUnAvaillable = schedule.IsUnavailableEntireDay;
            IList <DAL.Appointment> bookedAppointments = facAppDataRepo.FetchScheduledAppointments(facultyId, selDate);
            TimeSpan?startTime = schedule.AvailableFromTime;
            TimeSpan?endTime   = schedule.AvailableTillTime;

            if (bookedAppointments.Count == 0)
            {
                DateTime tempStartDate = (selDate.Date + schedule.AvailableFromTime) ?? DateTime.Now;
                DateTime tempEndDate   = (selDate.Date + schedule.AvailableTillTime) ?? DateTime.Now;
                availAppointments.Add(new Appointment()
                {
                    StartTime = tempStartDate, EndTime = tempEndDate
                });
            }
            else
            {
                for (int i = 0; i < bookedAppointments.Count;)
                {
                    if (startTime < bookedAppointments[i].StartTime.TimeOfDay)
                    {
                        DateTime tempDate = (selDate.Date + startTime) ?? DateTime.Now;
                        availAppointments.Add(new Appointment()
                        {
                            StartTime = tempDate, EndTime = bookedAppointments[i].StartTime
                        });
                        startTime = bookedAppointments[i].StartTime.TimeOfDay;
                    }
                    else
                    {
                        startTime = bookedAppointments[i].EndTime.TimeOfDay;
                        i++;
                    }
                }
                if (startTime < schedule.AvailableTillTime)
                {
                    DateTime tempStartDate = (selDate.Date + startTime) ?? DateTime.Now;
                    DateTime tempEndDate   = (selDate.Date + schedule.AvailableTillTime) ?? DateTime.Now;
                    availAppointments.Add(new Appointment()
                    {
                        StartTime = tempStartDate, EndTime = tempEndDate
                    });
                }
            }
            return(availAppointments);
        }
Esempio n. 2
0
        private void ApplySelectedSchedule()
        {
            try
            {
                Boolean errors = false;
                if (ScheduleAddEditMode == "edit")
                //Edit ScheduleAddEditMode
                {
                }
                else
                //Add New
                {
                    scheduleItem = new DAL.Schedule();
                    DateTime datestart = new DateTime();
                    DateTime schedstart = new DateTime();
                    DateTime schedend = new DateTime();
                    DateTime timestart = new DateTime();
                    DateTime starts = new DateTime();
                    DateTime ends = new DateTime();
                    //datestart = (DateTime)radSchedulingCalender.SelectedDate;
                    //schedstart = (DateTime)radtimePickerStart.SelectedValue;
                    //schedend = (DateTime)radtimePickerEnd.SelectedValue;
                    DateTime? t1 = new DateTime(datestart.Year, datestart.Month, datestart.Day, schedstart.Hour, schedstart.Minute, schedstart.Second);
                    DateTime? t2 = new DateTime(datestart.Year, datestart.Month, datestart.Day, schedend.Hour, schedend.Minute, schedend.Second);
                    starts = (DateTime)t1;
                    ends = (DateTime)t2;
                    //MessageBox.Show(starts.ToString());

                    //configureScheduleItem
                    scheduleItem.Loopstart = starts;
                    scheduleItem.Loopend= ends;
                    try
                    {
                        DAL.Loop loop = new DAL.Loop();
                        //loop = (DAL.Loop)cbMediaLoop.SelectedItem;
                        scheduleItem.Loopid = loop.Id;
                        scheduleItem.Loopname = loop.Name;
                        scheduleItem.Createdon = (DateTime)DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        errors = true;
                    }
                    try
                    {
                        if (rbGroup.IsChecked == true)
                        {
                            scheduleItem.Screenid = "0";
                            scheduleItem.Screenname = "";
                            DAL.Screengroups scrg = new DAL.Screengroups();
                            scrg = (DAL.Screengroups)cbGroup.SelectedItem;
                            scheduleItem.Groupid = scrg.Id;
                            scheduleItem.Groupname = scrg.Name;
                        }
                        else
                        {
                            scheduleItem.Groupid = "0";
                            scheduleItem.Groupname = "";
                            DAL.Screen scr = new DAL.Screen();
                            scr = (DAL.Screen)cbDisplay.SelectedItem;
                            scheduleItem.Screenid = scr.Id;
                            scheduleItem.Screenname = scr.Screenname;
                        }
                    }
                    catch (Exception ex)
                    {
                        si.sii("Error creating schedule item");
                        si.six(ex);
                        errors = true;
                    }
                    if (errors == false)
                    {
                        si.sii("Creating OK, inserting Schedule Item");
                        proxy.InsertScheduleItem(scheduleItem);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 3
0
 private void PublishGroupSchedule()
 {
     //DAL.ScheduleCollection scheduleCollection = new DAL.ScheduleCollection();
     ObservableCollection<DAL.Schedule> scheduleCollection = new ObservableCollection<DAL.Schedule>();
     try
     {
         showWait();
         foreach (var item in _Model.Appointments)
         {
             DAL.Schedule newSchedule = new DAL.Schedule();
             newSchedule.Groupid = "0";
             newSchedule.Groupname = item.OwnerKey;
             newSchedule.Loopname = item.Subject;
             newSchedule.Screenname = "";
             newSchedule.Loopstart = item.StartTime;
             newSchedule.Loopend = item.EndTime;
             scheduleCollection.Add(newSchedule);
         }
         showConfirmation();
     }
     catch (Exception ex)
     {
     }
     if (scheduleCollection.Count > 0) proxy.UpdateScheduleForGroups(scheduleCollection);
 }
Esempio n. 4
0
        private void PublishDisplaySchedule()
        {
            DAL.RDB proxy = new DAL.RDB();
            si.sii("Publishing Display Schedule");
            //ObservableCollection<DAL.Schedule> scheduleCollection = new ObservableCollection<DAL.Schedule>();
            try
            {
                //Build Schedule
                showWait();

                si.sii("Appointments = " + _Model.Appointments.Count().ToString());

                foreach (var item in _Model.Appointments)
                {
                    DAL.Schedule newSchedule = new DAL.Schedule();
                    newSchedule.Groupid = "0";
                    newSchedule.Groupname = "";
                    newSchedule.Loopname = item.Subject;
                    newSchedule.Screenname = item.OwnerKey;
                    newSchedule.Loopstart = item.StartTime;
                    newSchedule.Loopend = item.EndTime;
                    //scheduleCollection.Add(newSchedule);
                    try //imageSource is not null (imageSource is the schedule ID in RDB), try update first, if that fails then the ID wasn't set, do an insert
                    {
                        si.sii("Update Schedule Now");
                        proxy.UpdateScheduleForScreen(newSchedule, item.ImageSource);
                    }
                    catch (Exception)
                    {
                        si.sii("Inserting New Schedule Now");
                        item.ImageSource = proxy.InsertNewScheduleForScreen(newSchedule);
                    }
                }

            }
            catch (Exception ex)
            {
                si.six(ex);
            }

            showConfirmation();
        }
Esempio n. 5
0
        private string AddOrUpdateScheduleShift(WorkingShift schedule)
        {
            Table <DAL.Schedule> scheduleTable = GetScheduleTable();
            int matchedScheduleID = (from sch in scheduleTable
                                     where schedule.StartTime.Date.CompareTo(sch.date) == 0 && sch.workingShiftID == schedule.ShiftID
                                     select sch.scheduleID).FirstOrDefault();

            if (matchedScheduleID == default(int))
            {
                // Create new schedule
                DAL.Schedule newData = new DAL.Schedule();
                try
                {
                    newData.date           = schedule.StartTime.Date;
                    newData.workingShiftID = schedule.ShiftID;

                    scheduleTable.InsertOnSubmit(newData);
                    scheduleTable.Context.SubmitChanges();
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }

                matchedScheduleID = newData.scheduleID;
            }

            string err = DeleteCurrentWorkingStaffInfo(matchedScheduleID);

            if (err != "")
            {
                return(err);
            }

            foreach (Staff staff in schedule.WorkingStaff.Values)
            {
                err = "No data updated";
                if (staffManager.GetPositionCode(staff.CurrentPosition) == 1)
                {
                    err = AddOrNewWorkingCashier(staff, matchedScheduleID);
                }
                else if (staffManager.GetPositionCode(staff.CurrentPosition) == 2)
                {
                    err = AddOrUpdateNewWorkingManager(staff, matchedScheduleID);
                }
                else if (staffManager.GetPositionCode(staff.CurrentPosition) == 3)
                {
                    err = AddOrUpdateNewWorkingKeeper(staff, matchedScheduleID);
                }
                else if (staffManager.GetPositionCode(staff.CurrentPosition) == 4)
                {
                    err = AddOrUpdateNewWorkingStaff(staff, matchedScheduleID);
                }
                if (err != "")
                {
                    return(err);
                }
                staffManager.AddWorkingHours(staff.StaffID, ParameterManager.GetShiftHour());
            }

            return("");
        }