Example #1
0
        private static int GetDayOfWeekValue(DayOfWeekEnum dayOfWeekOption)
        {
            switch (dayOfWeekOption)
            {
            case DayOfWeekEnum.Sun:
                return(0);

            case DayOfWeekEnum.Mon:
                return(1);

            case DayOfWeekEnum.Tue:
                return(2);

            case DayOfWeekEnum.Wed:
                return(3);

            case DayOfWeekEnum.Thu:
                return(4);

            case DayOfWeekEnum.Fri:
                return(5);

            case DayOfWeekEnum.Sat:
                return(6);

            default:
                return(0);
            }
        }
Example #2
0
 /// <summary>
 /// Every n month(s), every week, selected week day(s)
 /// </summary>
 /// <param name="monthIntervals">Month interval. E.g., Every 1 month, every 2 months, .... , every n months.</param>
 /// <param name="firstDateTime">Used when monthIntervals > 1 to check a month that comes under expected month interval.</param>
 /// <param name="dayOfWeek">Day(s) of the week</param>
 public MonthTE(int monthIntervals, DateTime firstDateTime, DayOfWeekEnum dayOfWeek)
 {
     _monthIntervals    = monthIntervals;
     _firstDateTime     = firstDateTime.Date;
     _dayOfWeek         = TEHelpers.GetDayOfWeekValue(dayOfWeek);
     _monthIntervalType = eMonthIntervalType.EachWeekSelectedWeekDays;
 }
Example #3
0
        public static DayOfWeek GetDayOfWeek(DayOfWeekEnum dayOfWeek)
        {
            switch (dayOfWeek)
            {
            case DayOfWeekEnum.Sun:
                return(DayOfWeek.Sunday);

            case DayOfWeekEnum.Mon:
                return(DayOfWeek.Monday);

            case DayOfWeekEnum.Tue:
                return(DayOfWeek.Tuesday);

            case DayOfWeekEnum.Wed:
                return(DayOfWeek.Wednesday);

            case DayOfWeekEnum.Thu:
                return(DayOfWeek.Thursday);

            case DayOfWeekEnum.Fri:
                return(DayOfWeek.Friday);
                //case DayOfWeekEnum.Sat:
                //	return DayOfWeek.Saturday;
            }
            return(DayOfWeek.Sunday);
        }
Example #4
0
 /// <summary>
 /// Every n month(s), every week, selected week day(s)
 /// </summary>
 /// <param name="monthIntervals">Month interval. E.g., Every 1 month, every 2 months, .... , every n months.</param>
 /// <param name="firstDateTime">Used when monthIntervals > 1 to check a month that comes under expected month interval.</param>
 /// <param name="dayOfWeek">Day(s) of the week</param>
 public MonthTE(int monthIntervals, DateTime firstDateTime, DayOfWeekEnum dayOfWeek)
 {
     _monthIntervals = monthIntervals;
     _firstDateTime = firstDateTime.Date;
     _dayOfWeek = TEHelpers.GetDayOfWeekValue(dayOfWeek);
     _monthIntervalType = eMonthIntervalType.EachWeekSelectedWeekDays;
 }
Example #5
0
 /// <summary>
 /// The day of week value
 /// </summary>
 /// <param name="aDayOfWeek"></param>
 public DayInWeekTE(DayOfWeekEnum aDayOfWeek, DateTime aFirstDateTime, int aWeeklyInterval)
 {
     _dayOfWeek = aDayOfWeek;
      _firstDayOfWeek = StartOfWeek(aFirstDateTime, DayOfWeek.Sunday);
     _weeklyIntervals = aWeeklyInterval;
     _firstDateTime = aFirstDateTime;
 }
Example #6
0
 /// <summary>
 /// The day of week value
 /// </summary>
 /// <param name="aDayOfWeek"></param>
 public DayInWeekTE(DayOfWeekEnum aDayOfWeek, DateTime aFirstDateTime, int aWeeklyInterval)
 {
     _dayOfWeek       = aDayOfWeek;
     _firstDayOfWeek  = StartOfWeek(aFirstDateTime, DayOfWeek.Sunday);
     _weeklyIntervals = aWeeklyInterval;
     _firstDateTime   = aFirstDateTime;
 }
Example #7
0
        internal static int GetDayOfWeekValue(DayOfWeekEnum dayOfWeekOption)
        {
            switch (dayOfWeekOption)
            {
                case DayOfWeekEnum.Sun:
                    return 0;

                case DayOfWeekEnum.Mon:
                    return 1;

                case DayOfWeekEnum.Tue:
                    return 2;

                case DayOfWeekEnum.Wed:
                    return 3;

                case DayOfWeekEnum.Thu:
                    return 4;

                case DayOfWeekEnum.Fri:
                    return 5;

                case DayOfWeekEnum.Sat:
                    return 6;

                default:
                    return 0;
            }
        }
Example #8
0
 private List <AgendaItem> FilterCurrentWeekAgenda(DayOfWeekEnum day)
 {
     return(agendaViewerManager.GetCurrentWeekDayAgendaItems(
                weekObject.SelectedWeek[(int)day].Month,
                weekObject.SelectedWeek[(int)day].Day)
            .Where(x => x.FinishDate.Year == weekObject.SelectedWeek[defaultIndex].Year)
            .OrderBy(x => x.FinishDate).ToList());
 }
Example #9
0
 public Availability(
     DayOfWeekEnum dayOfWeek,
     TimeSpan openTime,
     TimeSpan closeTime
     )
 {
     this.DayOfWeek = dayOfWeek;
     this.SetTime(openTime, closeTime);
 }
Example #10
0
 public DayInQuarterTE(
     QuarterEnum quarter,
     QuarterlyIntervalEnum quarterInterval,
     MonthlyIntervalEnum monthInterval,
     DayOfWeekEnum dayOfWeek)
 {
     _quarter         = GetQuarterValue(quarter);
     _dayOfWeek       = TEHelpers.GetDayOfWeekValue(dayOfWeek);
     _monthInterval   = TEHelpers.GetMonthlyIntervalValue(monthInterval);
     _quarterInterval = GetQuarterIntervalValue(quarterInterval);
 }
 public DayInQuarterTE(
     QuarterEnum quarter,
     QuarterlyIntervalEnum quarterInterval, 
     MonthlyIntervalEnum monthInterval, 
     DayOfWeekEnum dayOfWeek)
 {
     _quarter = GetQuarterValue(quarter);
     _dayOfWeek = TEHelpers.GetDayOfWeekValue(dayOfWeek);
     _monthInterval = TEHelpers.GetMonthlyIntervalValue(monthInterval);
     _quarterInterval = GetQuarterIntervalValue(quarterInterval);
 }
Example #12
0
 static void StepWeek1(DayOfWeekEnum dayOfWeek)
 {
     if (dayOfWeek == DayOfWeekEnum.Saturday || dayOfWeek == DayOfWeekEnum.Sanday)
     {
         Console.WriteLine($"{DayToRussian(dayOfWeek)} - Выходной день");
     }
     else
     {
         Console.WriteLine($"{DayToRussian(dayOfWeek)} - Рабочий день");
     }
 }
Example #13
0
        public async Task <HttpResponseMessage> ScheduleAdd(TutorScheduleApiModels model)
        {
            string        user_id = db.User.Where(x => x.UserName == model.Username).FirstOrDefault().Id;
            DayOfWeekEnum dow     = (DayOfWeekEnum)Enum.Parse(typeof(DayOfWeekEnum), model.Day);
            DateTime      _start  = DateTime.Parse(model.Start);
            DateTime      start   = new DateTime(1970, 1, 1, _start.Hour, _start.Minute, 0);
            DateTime      _end    = DateTime.Parse(model.End);
            DateTime      end     = new DateTime(1970, 1, 1, _end.Hour, _end.Minute, 0);

            CommonRequestModels data = new CommonRequestModels();

            var isExist = await db.TutorSchedules
                          .Where(x => x.Tutor_UserAccounts_Id == user_id &&
                                 x.DayOfWeek == dow &&
                                 x.StartTime == start && x.EndTime == end).FirstOrDefaultAsync();

            if (isExist != null)
            {
                data.Message = "This schedule already exist.";
            }
            else
            {
                if (start.Hour > end.Hour || (start.Hour == end.Hour && start.Minute > end.Minute))
                {
                    data.Message = "The Start Time cannot greater than End Time";
                }
            }

            if (string.IsNullOrEmpty(data.Message))
            {
                TutorSchedulesModels tutorSchedulesModels = new TutorSchedulesModels
                {
                    Id = Guid.NewGuid(),
                    Tutor_UserAccounts_Id = user_id,
                    DayOfWeek             = dow,
                    StartTime             = start,
                    EndTime  = end,
                    IsActive = true,
                    Notes    = model.Notes
                };
                db.TutorSchedules.Add(tutorSchedulesModels);
                await db.SaveChangesAsync();
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data));
        }
Example #14
0
        public async Task <HttpResponseMessage> ScheduleEdit(TutorScheduleApiModels model)
        {
            string        user_id = db.User.Where(x => x.UserName == model.Username).FirstOrDefault().Id;
            DayOfWeekEnum dow     = (DayOfWeekEnum)Enum.Parse(typeof(DayOfWeekEnum), model.Day);
            DateTime      _start  = DateTime.Parse(model.Start);
            DateTime      start   = new DateTime(1970, 1, 1, _start.Hour, _start.Minute, 0);
            DateTime      _end    = DateTime.Parse(model.End);
            DateTime      end     = new DateTime(1970, 1, 1, _end.Hour, _end.Minute, 0);

            CommonRequestModels data = new CommonRequestModels();

            var isExist = await db.TutorSchedules
                          .Where(x => x.Id.ToString() != model.Schedule_Id &&
                                 x.Tutor_UserAccounts_Id == user_id &&
                                 x.DayOfWeek == dow &&
                                 x.StartTime == start && x.EndTime == end).FirstOrDefaultAsync();

            if (isExist != null)
            {
                data.Message = "This schedule already exist.";
            }
            else
            {
                if (start.Hour > end.Hour || (start.Hour == end.Hour && start.Minute > end.Minute))
                {
                    data.Message = "The Start Time cannot greater than End Time";
                }
            }

            if (string.IsNullOrEmpty(data.Message))
            {
                var current_data = await db.TutorSchedules.Where(x => x.Id.ToString() == model.Schedule_Id).FirstOrDefaultAsync();

                current_data.Tutor_UserAccounts_Id = user_id;
                current_data.DayOfWeek             = dow;
                current_data.StartTime             = start;
                current_data.EndTime = end;
                //current_data.IsActive = tutorSchedulesModels.IsActive;
                current_data.Notes           = model.Notes;
                db.Entry(current_data).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data));
        }
        /* DATABASE METHODS ***********************************************************************************************************************************/

        public bool isExists(Guid?Id, string Description, DayOfWeekEnum DayOfWeek, DateTime StartTime, DateTime EndTime)
        {
            return(db.Database.SqlQuery <ClubSchedulesModel>(@"
                        SELECT ClubSchedules.*
                        FROM ClubSchedules
                        WHERE 1=1 
							AND (@Id IS NULL OR ClubSchedules.Id <> @Id)
                            AND ClubSchedules.Description = @Description
                            AND ClubSchedules.[DayOfWeek] = @DayOfWeek
                            AND ((@StartTime >= ClubSchedules.StartTime AND @StartTime < ClubSchedules.EndTime)
                                OR (@EndTime > ClubSchedules.StartTime AND @EndTime <= ClubSchedules.EndTime)
                            )
                    ",
                                                             DBConnection.getSqlParameter(ClubSchedulesModel.COL_Id.Name, Id),
                                                             DBConnection.getSqlParameter(ClubSchedulesModel.COL_Description.Name, Description),
                                                             DBConnection.getSqlParameter(ClubSchedulesModel.COL_DayOfWeek.Name, DayOfWeek),
                                                             DBConnection.getSqlParameter(ClubSchedulesModel.COL_StartTime.Name, StartTime),
                                                             DBConnection.getSqlParameter(ClubSchedulesModel.COL_EndTime.Name, EndTime)
                                                             ).Count() > 0);
        }
        /* DATABASE METHODS ***********************************************************************************************************************************/

        public bool isExists(Guid?Id, Guid Tutor_UserAccounts_Id, DayOfWeekEnum DayOfWeek, DateTime StartTime, DateTime EndTime)
        {
            return(db.Database.SqlQuery <TutorSchedulesModel>(@"
                        SELECT TutorSchedules.*
                        FROM TutorSchedules
                        WHERE 1=1 
							AND (@Id IS NULL OR TutorSchedules.Id <> @Id)
                            AND TutorSchedules.Tutor_UserAccounts_Id = @Tutor_UserAccounts_Id
                            AND TutorSchedules.[DayOfWeek] = @DayOfWeek
                            AND ((@StartTime >= TutorSchedules.StartTime AND @StartTime < TutorSchedules.EndTime)
                                OR (@EndTime > TutorSchedules.StartTime AND @EndTime <= TutorSchedules.EndTime)
                            )
                    ",
                                                              DBConnection.getSqlParameter(TutorSchedulesModel.COL_Id.Name, Id),
                                                              DBConnection.getSqlParameter(TutorSchedulesModel.COL_Tutor_UserAccounts_Id.Name, Tutor_UserAccounts_Id),
                                                              DBConnection.getSqlParameter(TutorSchedulesModel.COL_DayOfWeek.Name, DayOfWeek),
                                                              DBConnection.getSqlParameter(TutorSchedulesModel.COL_StartTime.Name, StartTime),
                                                              DBConnection.getSqlParameter(TutorSchedulesModel.COL_EndTime.Name, EndTime)
                                                              ).Count() > 0);
        }
Example #17
0
        public Schedule GetSchedule()
        {
            DayOfWeekEnum daysOfWeekOptions = (this.Monday ? DayOfWeekEnum.Mon: 0) |
                                              (this.Tuesday ? DayOfWeekEnum.Tue: 0) |
                                              (this.Wednesday ? DayOfWeekEnum.Wed : 0) |
                                              (this.Thursday ? DayOfWeekEnum.Thu : 0) |
                                              (this.Friday ? DayOfWeekEnum.Fri : 0) |
                                              (this.Saturday ? DayOfWeekEnum.Sat : 0) |
                                              (this.Sunday ? DayOfWeekEnum.Sun : 0);
            int frequency = 0;

            if (this.Frequency == ShiftFrequencyDTO.Weekly || this.Frequency == ShiftFrequencyDTO.Fortnight1 || this.Frequency == ShiftFrequencyDTO.Fortnight2)
            {
                frequency = 2;
            }
            else if (this.Frequency == ShiftFrequencyDTO.Monthly)
            {
                frequency = 4;
            }

            int weeklyInterval = 0;

            if (this.Frequency == ShiftFrequencyDTO.Weekly)
            {
                weeklyInterval = 1;
            }
            else if (this.Frequency == ShiftFrequencyDTO.Fortnight1 || this.Frequency == ShiftFrequencyDTO.Fortnight2)
            {
                weeklyInterval = 2;
            }

            var aEvent = new Event
            {
                FrequencyTypeOptions = ScheduleWidget.Enums.FrequencyTypeEnum.Weekly,
                DaysOfWeekOptions    = daysOfWeekOptions,
                Frequency            = frequency,
                RepeatInterval       = weeklyInterval
            };

            return(new Schedule(aEvent));
        }
 public static DayOfWeek GetDayOfWeek(DayOfWeekEnum dayOfWeek)
 {
     switch (dayOfWeek)
     {
         case DayOfWeekEnum.Sun:
             return DayOfWeek.Sunday;
         case DayOfWeekEnum.Mon:
             return DayOfWeek.Monday;
         case DayOfWeekEnum.Tue:
             return DayOfWeek.Tuesday;
         case DayOfWeekEnum.Wed:
             return DayOfWeek.Wednesday;
         case DayOfWeekEnum.Thu:
             return DayOfWeek.Thursday;
         case DayOfWeekEnum.Fri:
             return DayOfWeek.Friday;
         //case DayOfWeekEnum.Sat:
         //	return DayOfWeek.Saturday;
     }
     return DayOfWeek.Sunday;
 }
Example #19
0
        static string DayToRussian(DayOfWeekEnum dayOfWeek)
        {
            string output = "";

            switch (dayOfWeek)
            {
            case DayOfWeekEnum.Monday:
                output = "Понедельник";
                break;

            case DayOfWeekEnum.Tuesday:
                output = "Вторник";
                break;

            case DayOfWeekEnum.Wednesday:
                output = "Среда";
                break;

            case DayOfWeekEnum.Thursday:
                output = "Четверг";
                break;

            case DayOfWeekEnum.Fridey:
                output = "Пятница";
                break;

            case DayOfWeekEnum.Saturday:
                output = "Суббота";
                break;

            case DayOfWeekEnum.Sanday:
                output = "Воскресенье";
                break;

            default:
                break;
            }
            return(output);
        }
Example #20
0
        static string DayToRussian(DayOfWeekEnum dayOfWeek)
        {
            string output = "";

            switch (dayOfWeek)
            {
            case DayOfWeekEnum.Monday:
                output = "понедельник";
                break;

            case DayOfWeekEnum.Tuesday:
                output = "вторник";
                break;

            case DayOfWeekEnum.Wednesday:
                output = "среда";
                break;

            case DayOfWeekEnum.Thursday:
                output = "четверг";
                break;

            case DayOfWeekEnum.Friday:
                output = "пятница";
                break;

            case DayOfWeekEnum.Saturday:
                output = "суббота";
                break;

            case DayOfWeekEnum.Sunday:
                output = "воскресенье";
                break;
            }
            return(output);
        }
Example #21
0
 /// <summary>
 /// The day of week value
 /// </summary>
 /// <param name="aDayOfWeek"></param>
 public DayOfWeekTE(DayOfWeekEnum aDayOfWeek)
 {
     _dayOfWeek = aDayOfWeek;
 }
 /// <summary>
 /// The holiday month, day, and count where the holiday falls on a different
 /// date every year, e.g., first Monday of September (Labor Day):
 /// 
 /// var laborDay = new FloatingHolidayTE(9, 1, 1);
 /// </summary>
 /// <param name="month"></param>
 /// <param name="dayOfWeekOption"></param>
 /// <param name="monthlyIntervalOption"></param>
 public FloatingHolidayTE(int month, DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption)
     : base(dayOfWeekOption, monthlyIntervalOption)
 {
     _month = month;
 }
Example #23
0
        public async Task <JsonResult> GetAvailableSchedule(string tutor_id, string language_id, DayOfWeekEnum dow, DateTime start, DateTime end)
        {
            string table_html = "";

            table_html += @"
                <table class='table table-striped table-condensed'>
                    <thead>
                        <tr>
                            <th>Tutor</th>";

            DateTime startFilter = new DateTime(1970, 1, 1, start.Hour, start.Minute, 0);
            DateTime endFilter   = new DateTime(1970, 1, 1, end.Hour, end.Minute, 0);

            List <string> list_header = new List <string>();

            AddHeaderTable(startFilter, endFilter, list_header);
            foreach (var header in list_header)
            {
                table_html += "<th>" + header + "</th>";
            }

            table_html += @"
                        </tr>
                    </thead>
                </thead>";

            var items = string.IsNullOrEmpty(tutor_id)
                ? await(from u in db.User
                        join ts in db.TutorSchedules on u.Id equals ts.Tutor_UserAccounts_Id
                        where ts.DayOfWeek == dow && ts.IsActive == true && (u.Interest != null || u.Interest != "")
                        orderby u.Firstname ascending
                        select new { u, ts }).ToListAsync()
                : await(from u in db.User
                        join ts in db.TutorSchedules on u.Id equals ts.Tutor_UserAccounts_Id
                        where ts.Tutor_UserAccounts_Id == tutor_id && ts.DayOfWeek == dow && ts.IsActive == true && (u.Interest != null || u.Interest != "")
                        orderby u.Firstname ascending
                        select new { u, ts }).ToListAsync();

            table_html += "<tbody>";

            foreach (var item in items)
            {
                bool isLanguage = false;
                var  languages  = JsonConvert.DeserializeObject <List <InterestViewModels> >(item.u.Interest);
                foreach (var language in languages)
                {
                    if (language_id == language.Languages_Id)
                    {
                        isLanguage = true;
                    }
                }

                if (isLanguage)
                {
                    List <string> list_booked  = new List <string>();
                    List <string> list_expired = new List <string>();
                    var           bookings     = await db.TutorStudentSchedules.Where(x => x.Tutor_UserAccounts_Id == item.u.Id && x.DayOfWeek == dow && x.IsActive == true).OrderBy(x => x.StartTime).ToListAsync();

                    foreach (var booking in bookings)
                    {
                        decimal  hours_remaining = db.SaleInvoiceItems.Find(booking.InvoiceItems_Id).SessionHours_Remaining.Value;
                        DateTime book_start      = booking.StartTime;
                        DateTime book_end        = booking.EndTime;
                        if (hours_remaining > 0)
                        {
                            AddBookedTime(book_start, book_end, list_booked);
                        }
                        else
                        {
                            AddBookedTime(book_start, book_end, list_expired);
                        }
                    }

                    table_html += "<tr><td>" + string.Format("{0}", item.u.Firstname) + "</td>";
                    foreach (var t in list_header)
                    {
                        if (list_booked.Contains(t))
                        {
                            table_html += "<td><a target='_blank' href='" + Url.Action("StudentIndex", "Schedules", new { dow = (int)dow, tutorid = item.u.Id }) + "'><span class='badge badge-danger d-block'>Booked</span></a></td>";
                        }
                        else if (list_expired.Contains(t))
                        {
                            table_html += "<td><a target='_blank' href='" + Url.Action("StudentIndex", "Schedules", new { dow = (int)dow, tutorid = item.u.Id }) + "'><span class='badge bg-orange d-block'>Expired</span></a></td>";
                        }
                        else
                        {
                            string[] splitTime  = t.Split(':');
                            DateTime timeHeader = new DateTime(1970, 1, 1, int.Parse(splitTime[0]), int.Parse(splitTime[1]), 0);
                            if (timeHeader >= item.ts.StartTime && timeHeader <= item.ts.EndTime)
                            {
                                table_html += "<td><a target='_blank' href='" + Url.Action("StudentCreate", "Schedules", new { dow = (int)dow, start = t.Replace(":", "_"), tutorid = item.u.Id }) + "'><span class='badge badge-success d-block'>Free</span></a></td>";
                            }
                            else
                            {
                                table_html += "<td></td>";
                            }
                        }
                    }
                    table_html += "</tr>";
                }
            }

            table_html += "</tbody></table>";

            return(Json(new { content = table_html }, JsonRequestBehavior.AllowGet));
        }
Example #24
0
 /// <summary>
 /// The day of week value
 /// </summary>
 /// <param name="aDayOfWeek"></param>
 public DayOfWeekTE(DayOfWeekEnum aDayOfWeek)
 {
     _dayOfWeek = aDayOfWeek;
 }
        public IEnumerable <EmployeeSummaryDTO> GetUnavailableEmployees(Guid businessLocationId, string startTime, string finishTime, Guid shiftId)
        {
            DateTime dtStart  = new DateTime(long.Parse(startTime));
            DateTime dtFinish = new DateTime(long.Parse(finishTime));
            var      busLoc   = db.BusinessLocations.Find(businessLocationId);

            if (busLoc == null)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Business Location with given ID does not exist"));
            }

            //ONCE-OFF: If unavail start time is within shift period then staff member is unavailable
            var unavailList1 = db.Schedules.Where(s => s.StartDate == dtStart.Date && s.Frequency == (short)FrequencyEnum.OnceOff &&
                                                  (dtStart.TimeOfDay <= s.StartTime && s.StartTime <= dtFinish.TimeOfDay)
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            //If end time is within shift period then staff member is unavailable
            var unavailList2 = db.Schedules.Where(s => s.StartDate == dtStart.Date && s.Frequency == (short)FrequencyEnum.OnceOff &&
                                                  (dtStart.TimeOfDay <= s.EndTime && s.EndTime <= dtFinish.TimeOfDay)
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            //If shift is completely covered by unavailability is unavailable
            var unavailList3 = db.Schedules.Where(s => s.StartDate == dtStart.Date && s.Frequency == (short)FrequencyEnum.OnceOff &&
                                                  (dtStart.TimeOfDay >= s.StartTime && dtFinish.TimeOfDay <= s.EndTime)).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();


            //Recurring daily, if shift starts within the start and end dates of the recurrence AND (start Times overlaps with unavailable time OR Unavailable start time is within shift time)
            var unavailList4 = db.Schedules.Where(s => s.Frequency == (short)FrequencyEnum.Daily &&
                                                  (s.StartDate <= dtStart.Date && dtStart.Date <= s.EndDate) &&             //AND Shift start date is within recurring period
                                                  ((s.StartTime <= dtStart.TimeOfDay && dtStart.TimeOfDay <= s.EndTime) ||  //AND shift start time is within the unavailable time on the day
                                                   (dtStart.TimeOfDay <= s.StartTime && s.StartTime <= dtFinish.TimeOfDay)) //OR Unavailable start time is within shift time
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            //Recurring daily, if shift  ends within the start and end dates of the recurrence AND end time overlaps with unavailable time)
            var unavailList5 = db.Schedules.Where(s => s.Frequency == (short)FrequencyEnum.Daily &&
                                                  (s.StartDate <= dtFinish.Date && dtFinish.Date <= s.EndDate) &&        // AND shift finish date is within recurring period
                                                  (s.StartTime <= dtFinish.TimeOfDay && dtFinish.TimeOfDay <= s.EndTime) //AND finish time is within unavailable time
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            DayOfWeekEnum startDay  = GetDayOfWeek(dtStart.DayOfWeek);
            DayOfWeekEnum finishDay = GetDayOfWeek(dtFinish.DayOfWeek);

            //Recurring weekly AND day of week is a selected day of week AND Shift start date is within recurring period AND start time is within unavailable time
            var unavailList6 = db.Schedules.Where(s => s.Frequency == (short)FrequencyEnum.Weekly &&                   //Recurring weekly
                                                  (((int)s.DaysOfWeek & (int)startDay) != 0) &&                        //AND day of week is a selected day of week
                                                  (s.StartDate <= dtStart.Date && dtStart.Date <= s.EndDate) &&        //AND Shift start date is within recurring period
                                                  (s.StartTime <= dtStart.TimeOfDay && dtStart.TimeOfDay <= s.EndTime) //AND shift start time is within the unavailable time on the day
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            //Recurring weekly AND shift finish day of week is a selected day of week AND Shift finish date is within recurring period AND finish time is within unavailable time
            var unavailList7 = db.Schedules.Where(s => s.Frequency == (short)FrequencyEnum.Weekly &&                     //Recurring weekly
                                                  (((int)s.DaysOfWeek & (int)finishDay) != 0) &&                         //AND day of week is a selected day of week
                                                  (s.StartDate <= dtFinish.Date && dtFinish.Date <= s.EndDate) &&        //AND Shift finish date is within recurring period
                                                  (s.StartTime <= dtFinish.TimeOfDay && dtFinish.TimeOfDay <= s.EndTime) //AND finish time is within unavailable time
                                                  ).SelectMany(s => s.UserProfile.Employees.Where(e => e.BusinessLocation.Id == businessLocationId)).Distinct().ToList();

            var overlappingShifts = db.Shifts.Where(s => s.InternalLocation.BusinessLocation.Id == businessLocationId &&
                                                    s.Employee != null &&
                                                    s.Id != shiftId &&                                       //Filter out the given shift ID as this could be an edit shift, if create new this should be Guid.Empty
                                                    dtStart <= s.FinishTime &&
                                                    dtFinish >= s.StartTime)
                                    .Select(s => s.Employee).ToList();

            unavailList1.AddRange(unavailList2);
            unavailList1.AddRange(unavailList3);
            unavailList1.AddRange(unavailList4);
            unavailList1.AddRange(unavailList5);
            unavailList1.AddRange(unavailList6);
            unavailList1.AddRange(unavailList7);
            unavailList1.AddRange(overlappingShifts);

            return(MapperFacade.MapperConfiguration.Map <IEnumerable <Employee>, IEnumerable <EmployeeSummaryDTO> >(unavailList1.Distinct()));
        }
Example #26
0
 /// <summary>
 /// 获取星期的中文数字
 /// </summary>
 /// <param name="dayOfWeek"></param>
 /// <returns></returns>
 public static string DayIndexOfWeekCN(DayOfWeekEnum dayOfWeek)
 {
     return(_dayIndexOfWeekDic[(int)dayOfWeek]);
 }
Example #27
0
 /// <summary>
 /// Creates a temporal expression using day of the week. For example:
 ///
 /// var sunday = new DayInMonthTE(1);
 /// var monday = new DayInMonthTE(2);
 /// var tuesday = new DayInMonthTE(4);
 /// var wednesday = new DayInMonthTE(8);
 /// var thursday = new DayInMonthTE(16);
 /// var friday = new DayInMonthTE(32);
 /// var saturday = new DayInMonthTE(64);
 ///
 /// </summary>
 /// <param name="dayOfWeekOption">Day of week</param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption)
     : base(1, DateTime.MinValue, dayOfWeekOption)
 {
 }
Example #28
0
 /// <summary>
 /// Creates a temporal expression using day of the week 0 to 6 and day
 /// of week in a month which can be positive (counting from the beginning
 /// of the month) or negative (counting from the end of the month).
 ///
 /// var example1 = new DayInMonthTE(4, 2);  // "second Tues of the month"
 /// var example2 = new DayInMonthTE(32, 16); // "last Friday of the month"
 ///
 /// </summary>
 /// <param name="dayOfWeekOption">day of week</param>
 /// <param name="monthlyIntervalOption"></param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption)
     : base(1, DateTime.MinValue, dayOfWeekOption, monthlyIntervalOption)
 {
 }
Example #29
0
 /// <summary>
 /// Creates a temporal expression using day of the week. For example:
 /// 
 /// var sunday = new DayInMonthTE(1);
 /// var monday = new DayInMonthTE(2);
 /// var tuesday = new DayInMonthTE(4);
 /// var wednesday = new DayInMonthTE(8);
 /// var thursday = new DayInMonthTE(16);
 /// var friday = new DayInMonthTE(32);
 /// var saturday = new DayInMonthTE(64);
 /// 
 /// </summary>
 /// <param name="dayOfWeekOption">Day of week</param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption)
     : base(1, DateTime.MinValue, dayOfWeekOption)
 { }
 private WeekDay CreateWeekday(DayOfWeekEnum day)
 {
     return new WeekDay()
     {
         Day = day,
         StartTime = 8,
         EndTime = 16,
         IsActive = false
     };
 }
Example #31
0
 public static string generateFILTER_Custom(DayOfWeekEnum DayOfWeek, DateTime StartTime, DateTime EndTime)
 {
     return(string.Format("{0}_{1:HH_mm}_{2:HH_mm}", (int)DayOfWeek, StartTime, EndTime));
 }
Example #32
0
 /// <summary>
 /// Creates a temporaral expression using day of the week. For example:
 ///
 /// var sunday = new DayInMonthTE(1);
 /// var monday = new DayInMonthTE(2);
 /// var tuesday = new DayInMonthTE(4);
 /// var wednesday = new DayInMonthTE(8);
 /// var thursday = new DayInMonthTE(16);
 /// var friday = new DayInMonthTE(32);
 /// var saturday = new DayInMonthTE(64);
 ///
 /// </summary>
 /// <param name="dayOfWeekOption">Day of week</param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption)
 {
     _dayOfWeek  = GetDayOfWeekValue(dayOfWeekOption);
     _ignoreWeek = true;
 }
Example #33
0
 /// <summary>
 /// Creates a temporaral expression using day of the week 0 to 6 and day
 /// of week in a month which can be positive (counting from the beginning
 /// of the month) or negative (counting from the end of the month).
 ///
 /// var example1 = new DayInMonthTE(4, 2);  // "second Tues of the month"
 /// var example2 = new DayInMonthTE(32, 16); // "last Friday of the month"
 ///
 /// </summary>
 /// <param name="dayOfWeekOption">day of week</param>
 /// <param name="monthlyIntervalOption"></param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption)
 {
     _dayOfWeek       = GetDayOfWeekValue(dayOfWeekOption);
     _monthlyInterval = GetMonthlyIntervalValue(monthlyIntervalOption);
     _ignoreWeek      = false;
 }
Example #34
0
 /// <summary>
 /// Creates a temporaral expression using day of the week. For example:
 /// 
 /// var sunday = new DayInMonthTE(1);
 /// var monday = new DayInMonthTE(2);
 /// var tuesday = new DayInMonthTE(4);
 /// var wednesday = new DayInMonthTE(8);
 /// var thursday = new DayInMonthTE(16);
 /// var friday = new DayInMonthTE(32);
 /// var saturday = new DayInMonthTE(64);
 /// 
 /// </summary>
 /// <param name="dayOfWeekOption">Day of week</param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption)
 {
     _dayOfWeek = GetDayOfWeekValue(dayOfWeekOption);
      _ignoreWeek = true;
 }
        public JsonResult Ajax_GetSchedules(Guid?Tutor_UserAccounts_Id, Guid?Languages_Id, DayOfWeekEnum DayOfWeek, DateTime StartTime, DateTime EndTime, int MinutesPerColumn)
        {
            StartTime = standardizeTime(StartTime);
            EndTime   = standardizeTime(EndTime);

            //adjust minutes to multiplication of MinutesPerColumn
            StartTime = StartTime.AddMinutes(StartTime.Minute % MinutesPerColumn == 0 ? 0 : -1 * (StartTime.Minute % MinutesPerColumn));
            EndTime   = EndTime.AddMinutes(EndTime.Minute % MinutesPerColumn == 0 ? 0 : MinutesPerColumn - (EndTime.Minute % MinutesPerColumn));

            string content = string.Format(@"
                    <div class='table-responsive mt-1'>
                        <table class='table table-bordered table-striped table-condensed'>
                            <thead>
                                <tr style='height:80px;'>
                                    <th class='text-center' style='width:200px'>Tutor</th>
                ");

            //create columns
            DateTime        counter = StartTime;
            List <DateTime> columns = new List <DateTime>();

            while (counter < EndTime)
            {
                columns.Add(counter);
                counter = counter.AddMinutes(MinutesPerColumn);
            }

            //format header text
            int colspan = 60 / MinutesPerColumn;

            for (int i = 0; i < columns.Count; i++)
            {
                if (i == 0 && columns[i].Minute != 0)
                {
                    content += string.Format("<th colspan='{0}' class='px-1 py-0' style='width:10px'></th>", (60 - columns[i].Minute) / MinutesPerColumn);
                }
                else if (columns[i].Minute == 0)
                {
                    if (i + colspan > columns.Count)
                    {
                        colspan = columns.Count - i;
                    }
                    content += string.Format("<th colspan='{0}' class='px-1 py-0' style='width:10px'>{1:HH:mm}</th>", colspan, columns[i]);
                }
            }

            content += string.Format(@"
                                </tr>
                            </thead>
                            <tbody>
                ");

            //generate table content
            Dictionary <Guid, List <string> > tableContent   = new Dictionary <Guid, List <string> >();
            Dictionary <Guid, List <string> > popovers       = new Dictionary <Guid, List <string> >();
            List <TutorSchedulesModel>        TutorSchedules = get(Tutor_UserAccounts_Id, Languages_Id, DayOfWeek, StartTime, EndTime);

            foreach (TutorSchedulesModel schedule in TutorSchedules)
            {
                List <string> row        = initializeRow(ref tableContent, ref popovers, columns, schedule.Tutor_UserAccounts_Id, schedule.Tutor_UserAccounts_Name);
                List <string> popoverRow = popovers[schedule.Tutor_UserAccounts_Id];

                //add schedule
                for (int i = 0; i < columns.Count; i++)
                {
                    if (columns[i] >= schedule.StartTime && columns[i] < schedule.EndTime)
                    {
                        row[i + 1] = string.Format("<td class='px-0 py-1' style='width:10px'><a target='_blank' href='{0}'><span class='btn btn-success d-block py-2' style='border-radius: 0 !important;'></span></a></td>",
                                                   Url.Action("Create", "StudentSchedules", new {
                            DayOfWeek = (int)DayOfWeek,
                            StartTime = string.Format("{0:HH_mm}", columns[i]),
                            Id        = schedule.Tutor_UserAccounts_Id,
                            Name      = schedule.Tutor_UserAccounts_Name
                        }));
                    }
                }
            }

            //add booked/expired slots
            List <StudentSchedulesModel> StudentSchedules = StudentSchedulesController.get(Session, Tutor_UserAccounts_Id, null, Languages_Id, DayOfWeek, StartTime, EndTime, null);
            string url;

            foreach (StudentSchedulesModel schedule in StudentSchedules)
            {
                List <string> row        = initializeRow(ref tableContent, ref popovers, columns, schedule.Tutor_UserAccounts_Id, schedule.Tutor_UserAccounts_Name);
                List <string> popoverRow = popovers[schedule.Tutor_UserAccounts_Id];

                //add schedule
                for (int i = 0; i < columns.Count; i++)
                {
                    if (columns[i] >= schedule.StartTime && columns[i] < schedule.EndTime)
                    {
                        popoverRow[i + 1] = Util.append(popoverRow[i + 1], string.Format("[{0} hours] {1}", schedule.SessionHours_Remaining, schedule.Student_UserAccounts_Name), "<br>");
                        bool isMultipleSchedules = row[i + 1] != DEFAULT_EMPTY_CELL;
                        row[i + 1] = string.Format("<td class='px-0 py-1'><a target='_blank' href='{0}' class='btn {2} d-block py-2' style='border-radius: 0 !important;' data-toggle='popover' data-container='body' data-placement='bottom' data-content='{1}'></a></td>",
                                                   url = Url.Action("Index", "StudentSchedules", new {
                            FILTER_Keyword           = isMultipleSchedules ? "" : schedule.Student_UserAccounts_Name,
                            FILTER_UserAccounts_Name = schedule.Tutor_UserAccounts_Name,
                            FILTER_Custom            = StudentSchedulesController.generateFILTER_Custom(schedule.DayOfWeek, schedule.StartTime, schedule.EndTime)
                        }),
                                                   popoverRow[i + 1],
                                                   isMultipleSchedules ? "btn-primary" : (schedule.SessionHours_Remaining > 0 ? "btn-warning" : "btn-secondary")
                                                   );
                    }
                }
            }

            //create rows
            foreach (KeyValuePair <Guid, List <string> > row in tableContent)
            {
                foreach (string cell in row.Value)
                {
                    content += cell;
                }
            }

            content += string.Format(@"
                            </tbody>
                        </table>
                    </div>
                ");

            return(Json(new { content = content }, JsonRequestBehavior.AllowGet));
        }
Example #36
0
 /// <summary>
 /// Creates a temporal expression using day of the week 0 to 6 and day
 /// of week in a month which can be positive (counting from the beginning
 /// of the month) or negative (counting from the end of the month).
 /// 
 /// var example1 = new DayInMonthTE(4, 2);  // "second Tues of the month"
 /// var example2 = new DayInMonthTE(32, 16); // "last Friday of the month"
 /// 
 /// </summary>
 /// <param name="dayOfWeekOption">day of week</param>
 /// <param name="monthlyIntervalOption"></param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption)
     : base(1, DateTime.MinValue, dayOfWeekOption, monthlyIntervalOption)
 { }
Example #37
0
 /// <summary>
 /// Creates a temporaral expression using day of the week 0 to 6 and day
 /// of week in a month which can be positive (counting from the beginning
 /// of the month) or negative (counting from the end of the month).
 /// 
 /// var example1 = new DayInMonthTE(4, 2);  // "second Tues of the month"
 /// var example2 = new DayInMonthTE(32, 16); // "last Friday of the month"
 /// 
 /// </summary>
 /// <param name="dayOfWeekOption">day of week</param>
 /// <param name="monthlyIntervalOption"></param>
 public DayInMonthTE(DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption)
 {
     _dayOfWeek = GetDayOfWeekValue(dayOfWeekOption);
     _monthlyInterval = GetMonthlyIntervalValue(monthlyIntervalOption);
     _ignoreWeek = false;
 }
 /// <summary>
 /// The holiday month, day, and count where the holiday falls on a different
 /// date every year, e.g., first Monday of September (Labor Day):
 ///
 /// var laborDay = new FloatingHolidayTE(9, 1, 1);
 /// </summary>
 /// <param name="month"></param>
 /// <param name="dayOfWeekOption"></param>
 /// <param name="monthlyIntervalOption"></param>
 public FloatingHolidayTE(int month, DayOfWeekEnum dayOfWeekOption, MonthlyIntervalEnum monthlyIntervalOption) : base(dayOfWeekOption, monthlyIntervalOption)
 {
     _month = month;
 }