Question c# Develop a ScheduleBody Library (To Make it standard)

ale pax

New member
Joined
Jun 19, 2024
Messages
2
Programming Experience
10+
Hi to All
I need to Manage Schedule Expressions

I Analized the problem and decide to develop a Library
to Manage a ScheduleBody
maybe it is too complicated
### need Help to simplify ###

problem1: WorkTime
Description of problem:
My Work Time is [From Mon to Fri] NationalHoliDay:Excluded PersonalHoliDay:Excluded
from 08:13 to 13:00 From 14:00 to 18:00 PersonalHolyHour Excluded


problem2: Course
Description of problem:
My Course
is Every [Mon] NationalHoliDay:Excluded SummerPause:Excluded StartAt="2024-02-24" EndAt="2024-12-24"
from 18:00 to 20:00

problem3: Historicizing
Description of Problem:
My procedure of Historicize Data run
Every day from 22:00 to 03:00

problem4: DailyMeeting
Description of Problem:
My DailyMeeting
is Every WorkDay $PlanningDay:Excluded $ReviewDay:Excluded
From 09:45 to 10:00


Solution
Foresee a SchedulerBody

SchedulerBody for Problem1:

SchedulePhrase $WorkTime
_DaysOfWeek:Included=[Mon,Tue,Wed,Thu,Fri]
_Time:Included=[_Start=08:00 _End=13:00, _Start=14:00 _End=17:00]
$IsHoliday:Excluded
@PersonalPauseTime:Excluded

SchedulePhrase $IsHolyday
_Date=[yyyy-01-01, yyyy-01-06, ..., @IsEasterMonday, $IsCountrySaintDay, @IsPersonalHoliday]

SchedulePhrase $IsCountrySaintDay
if(@Sede='Roma'){_Date=yyyy-06-29}if(@Sede='Milano'){_Date=yyyy-12-09}


SchedulerBody for Problem2:
SchedulePhrase $Course
_Date:Included=[_Start=2024-02-24 _End=2024-06-25, _Start=2024-09-01 _End=2024-12-24]
_DaysOfWeek:Included=[Lun]
_Time:Included=[_Start=18:00 _End=20:00]
$IsHolyday:Excluded

SchedulePhrase $IsHolyday
_Date=[yyyy-01-01, yyyy-01-06, ...,@IsEasterMonday]



SchedulerBody for Problem3:
SchedulePhrase $Historicizing
_Time=[_Start=22:00 _Duration=05:00:00]

SchedulerBody for Problem4:
SchedulePhrase $DailyMeeting
_DaysOfWeek:Included=[Mon,Tue,Wed,Thu,Fri]
$IsHolyday:Excluded
$PlanningDay:Excluded

SchedulePhrase $IsHolyday
_Date=[yyyy-01-01, yyyy-01-06, ..., @IsEasterMonday]

SchedulePhrase $PlanningDay
_Date=[2024-04-02, ...]
 
Moving to C# general since this isn't specific to Visual Studio...
 
So it looks like you've done your initial analysis. The next step is do another round of analysis to find what is common and what is different. There's a lot of software design books that cover this process. I'm kind of old-school and would point you to CRC cards, but there are other methodologies.

Another thing to consider instead of a data driven approach, or a purely algorithmic approach is a hybrid approach. Use bit patterns to represent active days/hours. As I recall, this is how Windows Active Directory represents what hours and days that a user is allowed to log on to the system.
 
Simplified:
Solution
Foresee a SchedulerBody

Parameters:
List<Date> DayExcluded  ---> Holidays, PlanningDay
List<DateTimeElaps> TimeElapsExclueded  ---> Start="yyyy-MM-ddT08:00:00" Duration="32:20:00"  (32 hours)


SchedulerBody for Problem1:

SchedulePhrase $WorkTime
    _DaysOfWeek=[Mon,Tue,Wed,Thu,Fri]
    _TimeElaps=[_Start=yyyy-MM-ddT08:00:00 _Duration=05:00:00, _Start=yyyy-MM-ddT14:00:00 _Duration=03:00:00]



SchedulerBody for Problem2:
SchedulePhrase $Course
    _DateElaps=[_Start=2024-02-24 _End=2024-06-25, _Start=2024-09-01 _End=2024-12-24]
    _DaysOfWeek=[Lun]
    _TimeElaps=[_Start=yyyy-MM-ddT18:00:00 _Duration=02:00:00]


SchedulerBody for Problem3:
SchedulePhrase $Historicizing
    _TimeElaps=[_Start=22:00 _Duration=05:00:00]

SchedulerBody for Problem4:
SchedulePhrase $DailyMeeting
    _DaysOfWeek=[Mon,Tue,Wed,Thu,Fri]
    _TimeElaps=[_Start=09:45 _Duration=00:15:00]
 
You might also want to take some inspiration from this existing library:
 
Back
Top Bottom