Пример #1
0
 public TermCalculatorActions(UserConnection userConnection, Guid calendarId)
 {
     UserConnection   = userConnection;
     Utils            = new CalendarUtils(UserConnection);
     CalendarId       = calendarId;
     CalendarIdsChain = Utils.GetCalendarIdsChain(calendarId);
 }
        /// <summary>
        /// ########### ########## #######
        /// </summary>
        /// <param name="day">#### #########</param>
        private void DisplayWorkingTimeIntervals(DayInCalendarObject day)
        {
            var calendarUtils = new CalendarUtils(UserConnection);
            IEnumerable <WorkingTimeInterval> timeIntervalsEntities = calendarUtils.GetWorkingTimeIntervals(day.Id);
            List <WorkingTimeIntervalObject>  timeIntervals         =
                ChangesStore.MergeIntervals(day.Id, timeIntervalsEntities
                                            .Select(t => new WorkingTimeIntervalObject(t))).ToList();

            CurrentWorkingTimeIntervalsData = timeIntervals;
            ClearIntervalDateTimeControls();
            var container = _page.PageContainer;

            foreach (WorkingTimeIntervalObject timeInterval in CurrentWorkingTimeIntervalsData)
            {
                var i        = timeInterval.Index;
                var fromDate =
                    (DateTimeEdit)
                    container.FindControl(string.Format(FromControlNameFormat, TimeIntervalTypeControlAlias, i));
                var toDate =
                    (DateTimeEdit)
                    container.FindControl(string.Format(ToControlNameFormat, TimeIntervalTypeControlAlias, i));
                fromDate.SuspendAjaxEvents();
                toDate.SuspendAjaxEvents();
                fromDate.SelectedDate = timeInterval.From;
                toDate.SelectedDate   = timeInterval.To;
                fromDate.ResumeAjaxEvents();
                toDate.ResumeAjaxEvents();
            }
        }
Пример #3
0
        protected override IEnumerable <DayInCalendarObject> GetDays()
        {
            Guid calendarId     = _page.DataSource.ActiveRowPrimaryColumnValue;
            var  calendarHelper = new CalendarUtils(UserConnection);
            IEnumerable <DayInCalendar> daysEntities = calendarHelper.GetWeekDays(CalendarIdsChain,
                                                                                  ChangesStore.GetDeletedDaysIds());

            return
                (ChangesStore.MergeWeekDays(calendarId, daysEntities.Select(d => new DayInCalendarObject(d)))
                 .OrderBy(d => d.DayOfWeekNumber));
        }
        private bool HasDayOfWeekOverrides(Guid treeGridRecordId)
        {
            if (!CurrentDaysGridData.Keys.Contains(treeGridRecordId))
            {
                return(false);
            }
            DateTime date = CurrentDaysGridData[treeGridRecordId].Date.Date;
            var      esq  = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "DayInCalendar");

            esq.AddColumn("Id");
            esq.RowCount = 1;
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Calendar",
                                                           _page.DataSource.ActiveRowPrimaryColumnValue));
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.IsNull, "Date"));
            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "DayOfWeek.Number",
                                                           CalendarUtils.GetDayOfWeekNumber(date)));
            return(esq.GetEntityCollection(UserConnection).Any());
        }
        protected override DayInCalendarObject GetDay(Guid treeGridRecordId)
        {
            Guid     calendarId = _page.DataSource.ActiveRowPrimaryColumnValue;
            DateTime date       = CurrentDaysGridData[treeGridRecordId].Date;

            var calendarUtils = new CalendarUtils(UserConnection);

            CalendarEditPageChangesStore.DayInCalendarChangedObject changedDay = ChangesStore.Days.SingleOrDefault(d =>
                                                                                                                   d.DayInCalendar.CalendarId == calendarId && d.DayInCalendar.Date.Date == date.Date &&
                                                                                                                   d.ChangedStatus != CalendarEditPageChangesStore.ChangedStatus.Deleted);
            if (changedDay != null)
            {
                return(changedDay.DayInCalendar);
            }
            DayInCalendarExtended day = calendarUtils.GetCalendarDayExtended(CalendarIdsChain, date,
                                                                             ChangesStore.GetDeletedDaysIds());

            return(new DayInCalendarObject(day));
        }
Пример #6
0
        protected override DayInCalendarObject GetDay(Guid treeGridRecordId)
        {
            Guid calendarId      = _page.DataSource.ActiveRowPrimaryColumnValue;
            int  dayOfWeekNumber = CurrentDaysGridData[treeGridRecordId].DayOfWeekNumber;

            var calendarHelper = new CalendarUtils(UserConnection);

            CalendarEditPageChangesStore.DayInCalendarChangedObject changedDay = ChangesStore.Days.SingleOrDefault(d =>
                                                                                                                   d.DayInCalendar.CalendarId == calendarId && d.DayInCalendar.DayOfWeekNumber == dayOfWeekNumber &&
                                                                                                                   d.ChangedStatus != CalendarEditPageChangesStore.ChangedStatus.Deleted);
            if (changedDay != null)
            {
                return(changedDay.DayInCalendar);
            }
            DayInCalendar day = calendarHelper.GetWeekDay(CalendarIdsChain, dayOfWeekNumber,
                                                          ChangesStore.GetDeletedDaysIds());

            return(new DayInCalendarObject(day));
        }
        protected override IEnumerable <DayInCalendarObject> GetDays()
        {
            Guid     calendarId    = _page.DataSource.ActiveRowPrimaryColumnValue;
            var      calendarUtils = new CalendarUtils(UserConnection);
            DateTime fromDate      = _page.StartDateEdit.SelectedDate;
            DateTime toDate        = _page.EndDateEdit.SelectedDate;

            if (fromDate.Date == DateTime.MinValue.Date || toDate.Date == DateTime.MinValue.Date)
            {
                return(new List <DayInCalendarObject>());
            }
            List <Guid> ignoredIds = ChangesStore.GetDeletedDaysIds().ToList();

            IEnumerable <DayInCalendarObject> calendarDaysEntities =
                calendarUtils.GetCalendarDaysExtended(CalendarIdsChain, fromDate, toDate, ignoredIds)
                .Select(d => new DayInCalendarObject(d));
            List <DayInCalendarObject> calendarDays =
                ChangesStore.MergeCalendarDays(calendarId, calendarDaysEntities, fromDate, toDate).ToList();

            return(calendarDays);
        }