Setting explicit start time

I’m trying to create a Task that starts at 10am and ends at 2pm on a 24hr calendar. I created this small example of what I thought would do the trick, but I end up with a task that starts at 10am and ends at 3pm. As you can see, i’m creating the schedule from scratch and saving as XML. I’m using Project 2010 when I see this result.


var project = new Aspose.Tasks.Project();
project.Set(DurationFormat, TimeUnitType.Hour);
var fullDayCalendar = project.Calendars.GetByName(“24 Hours”);
var task = project.RootTask.Children.Add(“Task”);

DateTime startTime = new DateTime(2015, 5, 5, 10, 0, 0);

task.Set(Aspose.Tasks.Tsk.Calendar, fullDayCalendar);
task.Set(Aspose.Tasks.Tsk.Start, startTime);
task.Set(Aspose.Tasks.Tsk.Duration, project.GetDuration(4, TimeUnitType.Hour));

project.Save(@“C:\Project.xml”, SaveFileFormat.XML);

Hi Brian,

Thank you for writing to Aspose support team.

I have tested this issue using the latest version of Aspose.Tasks for .NET 8.3.0 and was not able to reproduce the same at my end. With a 24-Hour calendar, the task time starts from 10:00 and ends at 14:00. Please have a look at the following sample code that I have used to test this issue at my end.

Sample Code:

Project project = new Project();

Calendar calendar = project.Calendars.Add("24 Hour");

Calendar.Make24HourCalendar(calendar);

var task = project.RootTask.Children.Add("Task");

DateTime startTime = new DateTime(2015, 5, 5, 10, 0, 0);

task.Set(Aspose.Tasks.Tsk.Calendar, calendar);

task.Set(Aspose.Tasks.Tsk.Start, startTime);

task.Set(Aspose.Tasks.Tsk.Duration, project.GetDuration(4, TimeUnitType.Hour));

Console.WriteLine(task.Get(Tsk.Start));

Console.WriteLine(task.Get(Tsk.Finish));

project.Save("E1.xml", SaveFileFormat.XML);

Were you also able to test opening the file in Project 2010? I also have the same result in that getting the start/end dates of the Task in code works fine, but the export seems to be the issue when its opened in Project 2010.

Hi Brian,

Could you please share a screenshot of the problem you are observing in MS Project 2010? I have noticed that the following code statement returns NULL from your sample code when you create a new Project.

var fullDayCalendar = project.Calendars.GetByName(“24 Hours”);

I have attached the output XML file here for your reference where the start and finish time of the task is as expected. Please check it at your end and share your feedback with us for our reference.

Task Timings in Output XML file:

<<Start>2015-05-05T10:00:00</Start>
<Finish>2015-05-05T14:00:00</Finish>

Sorry, my example was missing some information. Below is a new example that creates the 24 hour calendar, and has two boolean variables that can be changed to show the differences in what I’m seeing in Project 2010 and Aspose Tasks:



// Change these to see variations:
bool allMinutesPerDay = false;
bool manualTasks = false;

var project = new Project();

if(allMinutesPerDay)
{
project.Set(Prj.MinutesPerDay, 60 * 24);
}

var calendar = project.Calendars.Add(“24 Hour”);
Calendar.Make24HourCalendar(calendar);

var task = project.RootTask.Children.Add(“Task”);

DateTime startTime = new DateTime(2015, 5, 5, 10, 0, 0);

task.Set(Tsk.IsManual, manualTasks);
task.Set(Tsk.Calendar, calendar);
task.Set(Tsk.Start, startTime);
task.Set(Tsk.Duration, project.GetDuration(4, TimeUnitType.Day));

Console.WriteLine("Aspose Start: " + task.Get(Tsk.Start));
Console.WriteLine("Aspose Finish: " + task.Get(Tsk.Finish));

project.Save(@“C:\SomeFile.xml”, SaveFileFormat.XML);

// allMinutesPerDay = true, manualTasks = true
// Aspose Start: 5/5/2015 10:00:00 AM
// Aspose Finish: 5/9/2015 10:00:00 AM
// Project 2010 Start: 5/6/15 12:00 AM
// Project 2010 Finish: 5/10/15 12:00 AM

// allMinutesPerDay = true, manualTasks = false
// Aspose Start: 5/5/2015 10:00:00 AM
// Aspose Finish: 5/9/2015 10:00:00 AM
// Project 2010 Start: 5/5/2015 10:00:00 AM
// Project 2010 Finish: 5/9/2015 10:00:00 AM

// allMinutesPerDay = false, manualTasks = true
// Aspose Start: 5/5/2015 10:00:00 AM
// Aspose Finish: 5/6/2015 6:00:00 PM
// Project 2010 Start: 5/6/15 12:00 AM
// Project 2010 Finish: 5/7/15 8:00 AM

// allMinutesPerDay = false, manualTasks = false
// Aspose Start: 5/5/2015 10:00:00 AM
// Aspose Finish: 5/6/2015 6:00:00 PM
// Project 2010 Start: 5/5/15 10:00 AM
// Project 2010 Finish: 5/6/15 6:00 PM

Hi Brian,

This seems to be related to the project calculation modes and recalculations involved. We are currently investigating this issue further at our end and will soon share our feedback with you here.

Hi Brian,


We have further investigated this issue at our end and could notice the misbehavior of the API. The issue has been logged as TASKS-34003 in our bug tracking system. Our Product team will investigated it further and we shall share the feedback here with you as soon as there is some information available.

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


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

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.