Unexpected result of Task split


#1

I have tried to use the split task functionality in Aspose.Tasks but unfortunately, I am getting unexpected results.

Below is method to illustrate my problem. In the method, I create a single task that runs from 15 March, 8 AM to 21 April, 5 PM. I add a split on 16 March that extends from 9 AM to 11 AM.

When I look at the xml file in MS-Project, the start and finish times for the task look correct, but the split interval starts at 5 PM, 16 March and ends at 8 AM on 20 March.

I would be gratefully appreciated any advice on where I am going wrong.

Thanks,
Ian

    void MakeSplits()
    {
        Project splitTaskProject = new Project();
        Aspose.Tasks.Calendar calendar = splitTaskProject.Calendars.Add("example");
        var start = new DateTime(2000, 3, 16, 8, 0, 0);
        var finish = new DateTime(2000, 3, 16, 14, 0, 0);
        var asposeDuration = splitTaskProject.GetDuration((finish - start).TotalMinutes, TimeUnitType.Minute);

        // Set project's calendar settings
        splitTaskProject.Set(Prj.StartDate, new DateTime(2000, 3, 15, 8, 0, 0));
        splitTaskProject.Set(Prj.FinishDate, new DateTime(2000, 4, 21, 17, 0, 0));

        //var calendar = Aspose.Tasks.Calendar.Make24HourCalendar();
        splitTaskProject.Set(Prj.Calendar, calendar);      
        Resource resource = splitTaskProject.Resources.Add("Rsc");

        // Add a new task to root task
        Task rootTask = splitTaskProject.RootTask;
        rootTask.Set(Tsk.Name, "Root");
        Task taskToSplit = rootTask.Children.Add("Task1");
        taskToSplit.Set(Tsk.IgnoreResourceCalendar, true);
        taskToSplit.Set(Tsk.Duration, splitTaskProject.GetDuration(3));

        var resourceAssignment = splitTaskProject.ResourceAssignments.Add(taskToSplit, resource);
        resourceAssignment.Set(Asn.Units, 1);

        var splitResourceAssignment = splitTaskProject.ResourceAssignments.Add(taskToSplit, resource); 
        splitResourceAssignment.TimephasedDataFromTaskDuration(calendar);

        splitResourceAssignment.SplitTask(new DateTime(2000, 3, 16, 9, 0, 0), new DateTime(2000, 3, 16, 11, 0, 0), calendar);
        splitResourceAssignment.Set(Asn.WorkContour, WorkContourType.Contoured);

        // Save the Project
        string dataDir = "";
        splitTaskProject.Save(dataDir + "CreateSplitTasks_out.xml", SaveFileFormat.XML);
        // ExEnd:CreateSplitTasks
    }

#2

@ian.whitehouse.linkf,

Thank you for contacting Aspose support team.

This issue is reproduced and logged under Id:TASKSNET-2658 in our issue tracking system for detailed analysis later. We will write back here as soon as some feedback is available in this regard.