Example #1
0
 public DayInCalendarObject(DayInCalendar dayInCalendarEntity)
 {
     Id               = dayInCalendarEntity.Id;
     CalendarId       = dayInCalendarEntity.CalendarId;
     Date             = dayInCalendarEntity.Date;
     DayTypeId        = dayInCalendarEntity.DayTypeId;
     DayOfWeekId      = dayInCalendarEntity.DayOfWeekId;
     IsDayTypeWeekend = dayInCalendarEntity.GetTypedColumnValue <bool>("DayType_IsWeekend");
     DayOfWeekNumber  = dayInCalendarEntity.GetTypedColumnValue <int>("DayOfWeek_Number");
 }
Example #2
0
        private KeyValuePair <DateTime, DayInCalendar> GetNearestNotWeekendDay(DateTime registrationDateTime,
                                                                               bool moveForvard = true)
        {
            DayInCalendar day = Utils.GetCalendarDay(CalendarIdsChain, registrationDateTime);

            if (!day.GetTypedColumnValue <bool>("DayType_IsWeekend"))
            {
                return(new KeyValuePair <DateTime, DayInCalendar>(registrationDateTime, day));
            }
            registrationDateTime = registrationDateTime.Date.AddDays(moveForvard ? 1 : -1);
            return(GetNearestNotWeekendDay(registrationDateTime, moveForvard));
        }
Example #3
0
        public bool IsTimeInWorkingInterval(DateTime registrationDateTime)
        {
            DayInCalendar day = Utils.GetCalendarDay(CalendarIdsChain, registrationDateTime);

            if (day.GetTypedColumnValue <bool>("DayType_IsWeekend"))
            {
                return(false);
            }

            var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "WorkingTimeInterval");

            esq.AddColumn("Id");
            esq.RowCount = 1;
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "DayInCalendar",
                                                           day.PrimaryColumnValue));
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.GreaterOrEqual, "To",
                                                           registrationDateTime.TimeOfDay));
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.LessOrEqual, "From",
                                                           registrationDateTime.TimeOfDay));
            return(esq.GetEntityCollection(UserConnection).Any());
        }