(1) I can set up the daily schedule for each owner by using
owner.DayOfWeekSettings[ DayOfWeekEnum.xxx ].WorkDayStartTime = DateTime.Today.Date.AddHours( start24hr );owner.DayOfWeekSettings[ DayOfWeekEnum.xxx ].WorkDayEndTime = DateTime.Today.Date.AddHours( end24hr );
where "xxx" is Monday, Tuesday, Wednesday, and Thursday; where each day is 9 hours long.
(2) however, in a 9/80 schedule, Fridays alternate between 8 hrs workday (on day), and 0 hr workday (off day).
(3) Therefore, if I use the following logic, the TimelineView will show this for every friday.
owner.DayOfWeekSettings[ DayOfWeekEnum.Friday ].WorkDayStartTime = DateTime.Today.Date.AddHours( start24hr );owner.DayOfWeekSettings[ DayOfWeekEnum.xxx ].WorkDayEndTime = DateTime.Today.Date.AddHours( end24hr -1.0 );
(4) I was going to set up the "off-day" as an appointment programatically, but my users don't like the clutter in the TimelineView.
Is there another way to set up a 9/80 workweek?
Thanks.
Hello ,
Owner object has RecurrentDateSettings property which allows you to managed recurrent day settings along with working hours based on some pattern:
http://help.infragistics.com/Help/Doc/WinForms/2014.2/CLR4.0/html/Infragistics4.Win.UltraWinSchedule.v14.2~Infragistics.Win.UltraWinSchedule.Owner~RecurringDateSettings.html
Also I’ve implemented simple sample in order to demonstrate you this approach.
Please let me know if you have any further questions.
It is working great for the ON-days (working days)! Thank you!
However, when I tried to reverse the settings to be an OFF-day (friday day off, similar to weekend), it gives me unusual results:
DateRecurrence offFriday = new DateRecurrence( new DateTime(2014, 1,3) ); // this is offset by 1 week from the ON-fridaysoffFriday.RangeEndDate = new DateTime(2014, 12,19) ); // this is offset by 1 week from the ON-fridaysoffFriday.PatternFrequency = RecurrencePatternFrequency.Weekly;offFriday.PatternInterval = 2; // every 2 weeksoffFriday.PatternDaysOfWeek = RecurrencePatternDaysOfWeek.Friday; // every other Friday off
OwnerRecurringDateSettings offFridaySettings = new OwnerRecurringDateSettings(offFriday) ;//**does-nothing**// offFridaySettings.WorkingHours.Add( new TimeRange( TimeSpan.FromHours(0.0), TimeSpan.FromHours(0.0) )); // OFF Friday, so no working hours//**crash**// offFridaySettings.WorkingHours.Remove( new TimeRange( TimeSpan.FromHours(0.0), TimeSpan.FromHours(24.0) )); // OFF Friday, so no workingoffFridaySettings.IsWorkDay = DefaultableBoolean.False;myOwner.RecurringDateSettings.Add( offFridaySettings );
I was expecting the daySchedule to display the day to be similar to weekends (highlighted in color). and hourSchedule to display the entire day (highlighted in color), but instead, it showed workingHours to be (startHour+3 to endHour-1) and (startHour-1 to endHour) for my two owners...???
if I set every friday as off, and try to override with the code above, it doesn't get overwritten - all fridays are always off: owner.DayOfWeekSettings[DayOfWeekEnum.Friday].IsWorkDay = DefaultableBoolean.False;
Is there a different set of code to add (off fridays)?
thanks.
Edit: it showed workingHours to be (startHour+3 to endHour-1) and (startHour-1 to endHour) for my two ownersno matter what I put as offFridaySettings.WorkingHours.Add( new TimeRange( TimeSpan.FromHours(start), TimeSpan.FromHours(end) ), the value displayed for owner1 is 8:00-16:00, and owner2 is 5:00-16:00. seems random... the start/end Hours are not set anywhere else for Fridays, except for the OnFridays.
I don’t see any sense making of OFF and ON Fridays, since OFF is exception of ON (and vice versa, they are alternate) you need only offFriday (when you mange pattern frequently on 2 weeks, you will get one working and one nonworking Friday followed alternate). And here is the code from my sample that works exact as you expected:
owner.RecurringDateSettings.Add(new Infragistics.Win.UltraWinSchedule.DateRecurrence(DateTime.Today)
{
PatternFrequency = Infragistics.Win.UltraWinSchedule.RecurrencePatternFrequency.Weekly,
PatternInterval = 2,
PatternDaysOfWeek = Infragistics.Win.UltraWinSchedule.RecurrencePatternDaysOfWeek.Friday
});
owner.RecurringDateSettings[0].IsWorkDay = Infragistics.Win.DefaultableBoolean.False;
what I assume happens in your scenarios is that off and on Fridays overlaps and working-hours takes precede over the non-working hours.
Note the loop below, where each owner has different start/end times, and different schedule 9/80 days off - could be regular 5/40.My default last week was setting ON friday first, then setting OFF-friday. results were fridays because 6-14 (6am-2pm, ON fridays), and 6-15 (6am-3pm, supposedly off fridays).I tried the recurring OFF friday (IsWorkday=false) by itself, and it didn't work - every friday became 6-14 (which is not default). This duplicates your recommendation. I tried the recurring ON friday by itself, and it didn't work - there were no off fridays. fridays were set alternately 6-14 (on fridays), 6-15 (supposedly off fridays).I tried setting OFF friday first, then ON-friday. fridays were set alternately 6-14 (on fridays), and 6-15 (supposedly off fridays).I verified start980OffFridayScheduleA() returns 1/10/2014 and start980OnFridayScheduleA() returns 1/3/2014.MyFile.Designer.cs// // CalendarInfo// dayOfWeek1.WorkDayEndTime = new System.DateTime(2014, 12, 31, 17, 0, 0, 0); // default workinghourEnd = 5pmdayOfWeek1.WorkDayStartTime = new System.DateTime(2014, 12, 31, 5, 0, 0, 0); // default workinghourStart = 5am...dayOfWeek5.WorkDayEndTime = new System.DateTime(2014, 12, 31, 17, 0, 0, 0); // default workinghourEnd = 5pmdayOfWeek5.WorkDayStartTime = new System.DateTime(2014, 12, 31, 5, 0, 0, 0); // default workinghourStart = 5amthis.CalendarInfo.DaysOfWeek.Add(dayOfWeek1);...this.CalendarInfo.DaysOfWeek.Add(dayOfWeek5);this.CalendarInfo.LogicalDayDuration = System.TimeSpan.Parse("12:00:00"); // default workingday = 12 hours (5am-5pm)this.CalendarInfo.LogicalDayOffset = System.TimeSpan.Parse("05:00:00"); // default workinghour = 5amthis.CalendarInfo.TaskWorkingHourMode = Infragistics.Win.UltraWinSchedule.TaskWorkingHourMode.AutoAdjust; // tried to comment this out. no impact.
MyFile.csforeach (var owner in this.CalendarInfo.Owners){ ... // startTimeOfWorkday & endTimeOfWorkday are different for each owner ... // set 9/80 schedule A fridays on\off // owner.RecurringDateSetting.Add(schedule980_OffFridays() ); // changed order to see if it makes a difference... nope. owner.RecurringDateSettings.Add(schedule980_OnFridays(startTimeOfWorkday,endTimeOfWorkday-1.0) ); owner.RecurringDateSettings.Add(schedule980_OffFridays() ); ... owner.DayOfWeekSettings[ DayOfWeekEnum.Monday ].WorkDayStartTime = DateTime.Today.Date.AddHours( startTimeOfWorkday ); owner.DayOfWeekSettings[ DayofWeekEnum.Monday ].WorkDayEndTime = DateTime.Today.Date.AddHours( endTimeOfWorkday ); ... // ... tuesday, wednesday, ... owner.DayOfWeekSettings[ DayOfWeekEnum.Thursday ].WorkDayStartTime = DateTime.Today.Date.AddHours( startTimeOfWorkday ); owner.DayOfWeekSettings[ DayOfWeekEnum.Thursday ].WorkDayEndTime = DateTime.Today.Date.AddHours( endTimeOfWorkday );}...OwnerRecurringDateSettings schedule980_OnFridays(double start, double end){ DateRecurrence onFriday = new DateRecurrence( start980OnFridayScheduleA() ); // first 9/80A friday ON onFriday.RangeEndDate = end980OnFridayScheduleA(); // last 9/80A friday ON onFriday.PatternFrequency = RecurrencePatternFrequency.Weekly; onFriday.PatternInterval = 2; // every 2 weeks onFriday.PatternDaysOfWeek = RecurrencePatternDaysOfWeek.Friday; // every other friday ON OwnerRecurringDateSettings onFridaysSettings = new OwnerRecurringDateSettings(onFriday); onFridaysSettings.WorkingHours.Add( new TimeRange(TimeSpan.FromHours(start), TimeSpan.FromHours(end))); // ON fridays return onFridaysSettings;}OwnerRecurringDateSettings schedule980_OffFridays(){ DateRecurrence offFriday = new DateRecurrence(start980OffFridayScheduleA()); // first 9/80A friday OFF offFriday.RangeEndDate = end980OffFridayScheduleA(); // last 9/80A friday OFF offFriday.PatternFrequency = RecurrencePatternFrequency.Weekly; offFriday.PatternInterval = 2; // every 2 weeks offFriday.PatternDaysOfWeek = RecurrencePatternDaysOfWeek.Friday; // every other friday OFF OwnerRecurringDateSettings offFridaysSettings = new OwnerRecurringDateSettings(offFriday); //offFridaysSettings.WorkingHours.Add(new TimeRange(TimeSpan.FromHours(0.0), TimeSpan.FromHours(0.0))); // OFF fridays //offFridaysSettings.WorkingHours.Remove( new TimeRange( TimeSpan.FromHours(0.0), TimeSpan.FromHours(24.0) )); // all day is off //offFridaysSettings.WorkingHours.Remove(new TimeRange(TimeSpan.FromHours(6.0), TimeSpan.FromHours(20.0))); // all day is off //offFridaysSettings.WorkingHours.Add(new TimeRange(TimeSpan.FromHours(5.1), TimeSpan.FromHours(5.2))); // OFF fridays //offFridaysSettings.WorkingHours.Add(new TimeRange(TimeSpan.FromHours(5.1), TimeSpan.FromHours(6.2))); // OFF fridays offFridaysSettings.IsWorkDay = DefaultableBoolean.False; return offFridaysSettings;}
Thank you for the example code. It worked like a charm!
I isolated my problem to a copy and paste error on start/end for the recurring dates.
Thank you for the help. This issue is solved!
Hello,
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue?
Thank you for using Infragistics Components
What I assume happens here is that you set logical day duration to 12 hours, this meant that your total day duration will be 12 hours starting from 5 AM and ending on 5 PM (this includes working and nonworking hours). So if any of your recurrent days or day of weeks has a working hours outside of the 5 AM and ending on 5 PM, they will be auto adjusted (maybe not on the best way you are expecting ). And I assume that exact here is the issue which you are facing, other your code works as charm, please see attached sample.