Working days is wrong when saving to MPX

Hello,

I'm new to Aspose.Tasks and I'm using a 30-day license.

I'm trying to create a simple MPX file to test and see if it will help us.

Everything seems ok, but when I open the file, the Calendar is wrong. Sunday is been considered as a working day and Friday/Saturday as weekend. I'm attaching a printscreen.

Here is my code:

Project newProject = new Project();

Task T1 = newProject.RootTask.Children.Add();
T1.Set(Tsk.Name, "Teste 1");
T1.Set(Tsk.Start, new DateTime(2015, 9, 5));
T1.Set(Tsk.Duration, newProject.GetDuration(3, TimeUnitType.Day));
T1.Set(Tsk.ConstraintType, ConstraintType.StartNoEarlierThan);
T1.Set(Tsk.ConstraintDate, new DateTime(2015, 9, 5));

Task T2 = newProject.RootTask.Children.Add();
T2.Set(Tsk.Name, "Teste 2");
T2.Set(Tsk.Start, new DateTime(2015, 9, 11));
T2.Set(Tsk.Duration, newProject.GetDuration(7, TimeUnitType.Day));
T2.Set(Tsk.ConstraintType, ConstraintType.StartNoEarlierThan);
T2.Set(Tsk.ConstraintDate, new DateTime(2015, 9, 5));

newProject.Save("C:\\TestFile.mpx", Aspose.Tasks.Saving.SaveFileFormat.MPX);

Thanks

Hi Thales,


Thank you for your inquiry.

Can you please run the following code and share your output details with us? It shows Saturday and Sunday as non-working day as expected. The resultant MPX file doesn’t show any tasks at our end and we doubt that the saved file has an issue. Can you also please share your output MPX file with us for our investigation? We need to verify that the output file opens fine in MSP 2010 before we report any such issue to our product team.

Code:


Project newProject = new Project();


Console.WriteLine(newProject.Calendars.Count);


Calendar cal = newProject.Calendars.GetByUid(1);

foreach (WeekDay wday in cal.WeekDays)

Console.WriteLine(wday.DayType + “::” + wday.DayWorking);

Thanks for the fast reply.


Here’s the output of the code you asked:

1
Monday::True
Tuesday::True
Wednesday::True
Thursday::True
Friday::True
Saturday::False
Sunday::False

I runned the same code with my sample and it showed that Sat and Sun were both non-working days, but when I save and open the file, it goes wrong.

I’m attaching the MPX file.
MSProject version: 14.0.7011.1000 SP2

Hi Thales,

Thank you for sharing your feedback.

We were able to reproduce this issue at our end and have logged it as TASKS-34170 in our issue tracking system. Our product team will investigate it further and we’ll notify you here once there is some information available in this regard.

The issues you have found earlier (filed as TASKS-34170) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,
I have a query - I am taking data from database with start and end date and I am calculating the duration based on start and end date and we do consider saturday sunday also as working days. But when I convert to Mpp file it considers Saturday and Sunday as non-working day. Could you please advise if there’s any method to consider them under working day as well.

@IshuAbrol,

We are looking into your requirements and will soon assist you further in this regard.

@IshuAbrol,

Thank you for contacting Aspose support team.

You need to define a calendar with 7 working days and set it to project. After this when duration is taken, it considers all days as working. Following sample code is working fine with XML file. You may please try it with your sample template MPP file, save output to MPP and share the feedback.

Project project = new Project();

// Define Calendar
Aspose.Tasks.Calendar cal = project.Calendars.Add("Calendar1");

// Add working days monday through thursday with default timings
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Saturday));
cal.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Sunday));

project.Set(Prj.Calendar, cal);
var task1 = project.RootTask.Children.Add("Task 1");
task1.Set(Tsk.Start, new DateTime(2018,8,16,8,0,0));
task1.Set(Tsk.Duration, project.GetDuration(10, TimeUnitType.Day));
// Save the Project
project.Save(path + "Project_DefineCalendarWeekdays_out.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);

Thanks for your response. I have set Actual_start and Actual_end date in Task instead of Start and Finish parameter and it worked. Its taking the original data I am getting from database and printing.