Scripts for changing the business calendar
Add the namespace:
using EleWise.ELMA.Calendar
To change the business calendar, run the following scripts:
- Change the working day time (for all days):
var schedule = ProductionSchedule.Load();
schedule.WorkEnd = new TimeSpan(0, 17, 30, 0, 0); // set working day end time
schedule.WorkStart = new TimeSpan(0, 8, 30, 0, 0); // set working day start time
schedule.DinnerStart = new TimeSpan(0, 12, 30, 0, 0); // set lunch start time
schedule.DinnerEnd = new TimeSpan(0, 13, 30, 0, 0); // set lunch end time
schedule.Save();
- Set a short day (change the working day time for a specific date):
var schedule = ProductionSchedule.Load();
var shortDay = new ProductionSchedule.ExceptionDay(ProductionSchedule.ExceptionDayType.ShortDay)
{
Date = new DateTime(2012, 11, 23),
StartTime = new TimeSpan(9, 0, 0),
EndTime = new TimeSpan(17, 0, 0)
};
schedule.ExceptionDays.Add(shortDay);
schedule.Save();
- Set a day off:
var schedule = ProductionSchedule.Load();
var hoilday = new ProductionSchedule.ExceptionDay(ProductionSchedule.ExceptionDayType.Holiday)
{
Date = new DateTime(2012, 11, 23)
};
schedule.ExceptionDays.Add(hoilday);
schedule.Save();
To check, whether the settings applied, display them in a variable:
1. Data on the working hours and the lunch time:
var schedule = ProductionSchedule.Load();
context.text += schedule.WorkEnd +" "+ schedule.WorkStart +" "+ schedule.DinnerStart + " "+ schedule.DinnerEnd ;
2. Check whether the context.Date is a working day:
var calendar = Locator.GetServiceNotNull<IProductionCalendarService>();
if (calendar.IsWorkDay(context.Date)){
context.CheckWorkDay = true;
}
else{
context.CheckWorkDay = false;
}