Hi,
Hi Anderson,
//Create a project instance
Project prj = new Project();
//Define Calendar
Aspose.Tasks.Calendar cal = prj.Calendars.GetByUid(1);
WeekDay sunday = cal.WeekDays.ToArray()[6];
sunday.DayWorking = true;
//Sets working time. Only time part of DateTime is important
WorkingTime wt1 = new WorkingTime();
wt1.FromTime = new DateTime(1, 1, 1, 9, 0, 0, 0);
wt1.ToTime = new DateTime(1, 1, 1, 12, 0, 0, 0);
WorkingTime wt2 = new WorkingTime();
wt2.FromTime = new DateTime(1, 1, 1, 13, 0, 0, 0);
wt2.ToTime = new DateTime(1, 1, 1, 17, 0, 0, 0);
sunday.WorkingTimes.Add(wt1);
sunday.WorkingTimes.Add(wt2);
Task task = prj.RootTask.Children.Add(“Task 1”);
task.Set(Tsk.Start, new DateTime(2015, 1, 1));
task.Set(Tsk.Finish, new DateTime(2015, 1, 4));
//Save the Project
prj.Save(“Project.Xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);
Hi Anderson,
Hi Muhammad,
Hi Anderson,
We are sorry for any inconvenience you are facing.
I have re-tested this issue at my end with a new Microsoft Project 2010 (MPP) file as input and the following code sample, but was unable to reproduce the issue. Please check the following code sample where I am calling the MakeWeekendAsWorking() method first from the Main() method and then calling the CheckWorkingCalendarReload() after that. The output is as attached here with this post. Could you please try it at your end and share your feedback with us.
Code:
public static void CheckWorkingCalendarReload()
{
Project project = new Project("Project.mpp");
Calendar cal = project.Calendars.GetByName("Standard");
Console.WriteLine("\n******** After loading the MPP file *********");
foreach (WeekDay day in cal.WeekDays)
Console.WriteLine(day.DayType+ "=" + day.DayWorking);
project.Save("Project1.Xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
}
public static void MakeWeekendAsWorking()
{
Project project = new Project("New project 2010.mpp");
Calendar cal = project.Calendars.GetByName("Standard");
Console.WriteLine("\n******** Before setting Saturday/Sunday to Working *********");
foreach (WeekDay day in cal.WeekDays)
Console.WriteLine(day.DayType + "=" + day.DayWorking);
WeekDay saturday = cal.WeekDays.ToArray<WeekDay>()[6];
saturday.DayWorking = true;
//Sets working time. Only time part of DateTime is important
WorkingTime wt1 = new WorkingTime();
wt1.FromTime = new DateTime(1, 1, 1, 9, 0, 0, 0);
wt1.ToTime = new DateTime(1, 1, 1, 12, 0, 0, 0);
WorkingTime wt2 = new WorkingTime();
wt2.FromTime = new DateTime(1, 1, 1, 13, 0, 0, 0);
wt2.ToTime = new DateTime(1, 1, 1, 17, 0, 0, 0);
saturday.WorkingTimes.Add(wt1);
saturday.WorkingTimes.Add(wt2);
WeekDay sunday = cal.WeekDays.ToArray<WeekDay>()[0];
sunday.DayWorking = true;
//Sets working time. Only time part of DateTime is important
sunday.WorkingTimes.Add(wt1);
sunday.WorkingTimes.Add(wt2);
Console.WriteLine("\n******** After setting Saturday/Sunday to Working *********");
foreach (WeekDay day in cal.WeekDays)
Console.WriteLine(day.DayType + "=" + day.DayWorking);
project.Save("Project.Xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
project.Save("Project.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);
}
Hi Muhammad,
Hi Anderson,
Can you please check the attached files at your end in Microsoft Project and share your feedback with us? These have been generated through the code sample above and show Saturday/Sunday as working. I am using Microsoft Project 2010 at my end. In case the problem persists, please share screenshots as above with us for our further investigation.
Hi Kashif,
Hi Anderson,