Hi
Is there a way to change Hours per Day from 8 hours to (for example) 9 hours in Aspose or is it not supportet?
I hope you can help me
thx
Dejan
Hi
Is there a way to change Hours per Day from 8 hours to (for example) 9 hours in Aspose or is it not supportet?
I hope you can help me
thx
Dejan
Sure, it’s possible. Check example for CalendarHours class in the API Reference:
Just set correct FromTime and ToTime properties. For example:
// Set new work hours
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“13:00:00”);
ch.FromTime2 = System.DateTime.Parse(“14:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
ch.FromTime3 = null;
ch.ToTime3 = null;
Thx for help
Dejan
Hm... is it possible that it does not work when i'm saving it as xml file? Because i tried to set but when i've exported the File to MS Project it was still 8 hours per day (in Extras/Options/Calendar) i still see 8 hours per day / 40 hours per week / 20 days a month.
Options/Calendar is default values. They are used if project doesn’t have own calendar or for some calculations.
I used this code to change work hours and got 9 work hours per day calendar (in Tools/Change Working Time).
Calendar cal = file.GetBaseCalendar(“Standard”);
CalendarHours ch = cal.GetCalendarHours(Aspose.Tasks.DayOfWeek.Monday);
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“12:00:00”);
ch.FromTime2 = System.DateTime.Parse(“13:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
ch = cal.GetCalendarHours(Aspose.Tasks.DayOfWeek.Tuesday);
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“12:00:00”);
ch.FromTime2 = System.DateTime.Parse(“13:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
ch = cal.GetCalendarHours(Aspose.Tasks.DayOfWeek.Wednesday);
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“12:00:00”);
ch.FromTime2 = System.DateTime.Parse(“13:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
ch = cal.GetCalendarHours(Aspose.Tasks.DayOfWeek.Thursday);
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“12:00:00”);
ch.FromTime2 = System.DateTime.Parse(“13:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
ch = cal.GetCalendarHours(Aspose.Tasks.DayOfWeek.Friday);
ch.FromTime1 = System.DateTime.Parse(“08:00:00”);
ch.ToTime1 = System.DateTime.Parse(“12:00:00”);
ch.FromTime2 = System.DateTime.Parse(“13:00:00”);
ch.ToTime2 = System.DateTime.Parse(“18:00:00”);
Well the same code i wrote and the Worktime is set but the hours per day is still 8 hours. Mabe it's because i have to save it as xml because i can't open mpx files.
I opened the xml file to see where i can set this property and i saw:
<MinutesPerDay>480MinutesPerDay> here i have to set 540 to have 9 hours per day
Mabe in mpx there is no need to set this property because it calculates the hours per day from the CalendarHours you set.
I save it in xml format too.
I already wrote in previous message. property is not a calendar.
After creating xml file you should open “Tools/Change Working Time” dialog and check working hours.