コード例 #1
0
        /// <summary>
        /// This function maps a FSServiceContract weekly frequency to a WeeklySchedule in the Scheduler module.
        /// </summary>
        public static Schedule mapWeeklyFrequency(FSServiceContract fsServiceContractRow, DateTime?lastGeneratedElementDate, Period period = null)
        {
            List <DayOfWeek> days = new List <DayOfWeek>();
            var weeklySchedule    = new WeeklySchedule
            {
                Name = TX.FrecuencySchedule.WEEKLY,
                LastGeneratedTimeSlotDate = lastGeneratedElementDate,
                SubScheduleID             = 0,
                TimeOfDayBegin            = new TimeSpan(5, 0, 0),
                TimeOfDayEnd    = new TimeSpan(11, 0, 0),
                SchedulingRange = period ?? new Period((DateTime)fsServiceContractRow.StartDate, fsServiceContractRow.EndDate),
                Frequency       = 1,
            };

            #region SetDaysToList

            days.Add(fsServiceContractRow.StartDate.Value.DayOfWeek);
            weeklySchedule.SetDays(days.ToArray());
            #endregion

            return(weeklySchedule);
        }
コード例 #2
0
        /// <summary>
        /// This function maps a FSSchedule weekly frequency to a WeeklySchedule in the Scheduler module.
        /// </summary>
        public static Schedule mapWeeklyFrequency(PXCache cache, FSSchedule fsScheduleRow, DateTime?toDate, string recordType, Period period = null)
        {
            bool applySeasonInSchedule = recordType != ID.RecordType_ServiceContract.EMPLOYEE_SCHEDULE_CONTRACT ? SharedFunctions.GetEnableSeasonSetting(cache.Graph, fsScheduleRow) : false;

            List <DayOfWeek> days = new List <DayOfWeek>();
            var weeklySchedule    = new WeeklySchedule
            {
                Name       = TX.FrecuencySchedule.WEEKLY,
                EntityID   = fsScheduleRow.EntityID,
                EntityType = fsScheduleRow.EntityType,
                LastGeneratedTimeSlotDate = fsScheduleRow.LastGeneratedElementDate,
                ScheduleID      = (int)fsScheduleRow.ScheduleID,
                SubScheduleID   = 0,
                TimeOfDayBegin  = new TimeSpan(5, 0, 0),
                TimeOfDayEnd    = new TimeSpan(11, 0, 0),
                SchedulingRange = period ?? new Period((DateTime)fsScheduleRow.StartDate, fsScheduleRow.EndDate),
                Frequency       = (int)fsScheduleRow.WeeklyFrequency,
                Descr           = fsScheduleRow.ContractDescr,
                ApplySeason     = applySeasonInSchedule,
                SeasonOnJan     = fsScheduleRow.SeasonOnJan,
                SeasonOnFeb     = fsScheduleRow.SeasonOnFeb,
                SeasonOnMar     = fsScheduleRow.SeasonOnMar,
                SeasonOnApr     = fsScheduleRow.SeasonOnApr,
                SeasonOnMay     = fsScheduleRow.SeasonOnMay,
                SeasonOnJun     = fsScheduleRow.SeasonOnJun,
                SeasonOnJul     = fsScheduleRow.SeasonOnJul,
                SeasonOnAug     = fsScheduleRow.SeasonOnAug,
                SeasonOnSep     = fsScheduleRow.SeasonOnSep,
                SeasonOnOct     = fsScheduleRow.SeasonOnOct,
                SeasonOnNov     = fsScheduleRow.SeasonOnNov,
                SeasonOnDec     = fsScheduleRow.SeasonOnDec
            };

            #region SetDaysToList
            if (fsScheduleRow.WeeklyOnFri == true)
            {
                days.Add(DayOfWeek.Friday);
            }

            if (fsScheduleRow.WeeklyOnMon == true)
            {
                days.Add(DayOfWeek.Monday);
            }

            if (fsScheduleRow.WeeklyOnSat == true)
            {
                days.Add(DayOfWeek.Saturday);
            }

            if (fsScheduleRow.WeeklyOnSun == true)
            {
                days.Add(DayOfWeek.Sunday);
            }

            if (fsScheduleRow.WeeklyOnThu == true)
            {
                days.Add(DayOfWeek.Thursday);
            }

            if (fsScheduleRow.WeeklyOnTue == true)
            {
                days.Add(DayOfWeek.Tuesday);
            }

            if (fsScheduleRow.WeeklyOnWed == true)
            {
                days.Add(DayOfWeek.Wednesday);
            }

            weeklySchedule.SetDays(days.ToArray());
            #endregion

            return(weeklySchedule);
        }