I have analyzed your code and would like to share that we just need to add one split interval that is May 01, 2014. The Saturday and Sunday are taken off by default. Also as resource assignments are modified, you may call CalcResourceAssignmentIds() and CalcResourceAssignmentUids() at the end.
Could you please give a try to the following sample code which generates the file as per your requirement and let us know your feedback?
//Create new project Project splitTaskProject = new Project(); Aspose.Tasks.Calendar calendar = splitTaskProject.Calendar; splitTaskProject.StartDate = new DateTime(2014, 4, 30, 8, 0, 0);
//Add a new task Task taskToSplit = splitTaskProject.AddTask(“Task1”); taskToSplit.Start = new DateTime(2014, 4, 30, 8, 0, 0); taskToSplit.Duration = new TimeSpan(40, 0, 0); taskToSplit.Finish = calendar.GetFinishDateByStartAndWork(taskToSplit.Start, taskToSplit.Duration); taskToSplit.DurationFormat = TimeUnitType.Day;
//Set the parent project for calculation. taskToSplit.ParentProject = splitTaskProject;
//Create a new resource assignment ResourceAssignment splitResourceAssignment = new ResourceAssignment(taskToSplit, null); splitTaskProject.ResourceAssignments.Add(splitResourceAssignment); splitResourceAssignment.Start = taskToSplit.Start; splitResourceAssignment.Finish = taskToSplit.Finish;
//Generate resource assignment timephased data splitResourceAssignment.TimephasedDataFromTaskDuration(calendar);
//Split the task into 2 parts. //Provide start date and finish date arguments to SplitTask method //These dates will be used for split splitResourceAssignment.SplitTask(new DateTime(2014, 5, 1, 8, 0, 0), new DateTime(2014, 5, 1, 17, 0, 0), calendar);
Hi Kashif Iqbal Thank for your reply As I said I’m writing a program that load some MSP related data from db and Create a msp file , so end user can manipulate generated file and then update db , your sample code somehow generate my file , but cause I read data form db so really I don’t need e.g call GetFinishDateByStartAndWork because finish date of task has been calculated by msp and insert to db. If User Manually Split Tasks our code is fine either your code , but when user change actual data or change Resources or Level project then problem starts,am I miss something about split task ? The attached file contain one of our generated files (a sample) , I write a tiny program that open this file and report task data , one of difference between Office automation & Aspose Task is that , last task is split but aspose said not . Thank for your help
Earlier it was assumed that sample is required to create split task, therefore above mentioned sample code is suggested.
For investigating the SplitParts count issue, I have written a small piece of code to display the SplitParts count of each task in the sample file and observed that it does not display proper value of SplitParts count for last task. This issue is logged in our issue tracking system under id:TASKS-33622.
We will write back here as soon as some feedback is received for the above mentioned ticket. Please feel free to write us back if you have any other query related to Aspose.Tasks.