Split Tasks in Ruby

Aspose.Tasks - Split Tasks

To Split Tasks using Aspose.Tasks Java for Ruby, simply invoke SplitTasks module. Here you can see example code.

Ruby Code

 1project = Rjb::import('com.aspose.tasks.Project').new
 2prj = Rjb::import('com.aspose.tasks.Prj')
 3tsk = Rjb::import('com.aspose.tasks.Tsk')
 4calendar = project.get(prj.CALENDAR)
 5cal = Rjb::import('java.util.Calendar').getInstance()
 6cal.set(2011, 3, 15, 8, 0, 0)
 7project.set(prj.START_DATE, cal.getTime())
 8cal.set(2011, 3, 21, 17, 0, 0)
 9project.set(prj.FINISH_DATE, cal.getTime())
10rootTask = project.getRootTask()
11rootTask.set(tsk.NAME, "Root")
12taskToSplit = rootTask.getChildren().add("Task1")
13taskToSplit.set(tsk.DURATION, project.getDuration(3))
14splitResourceAssignment = project.getResourceAssignments().add(taskToSplit, nil)
15splitResourceAssignment.timephasedDataFromTaskDuration(calendar)
16cal = Rjb::import('java.util.Calendar').getInstance()
17cal2 = Rjb::import('java.util.Calendar').getInstance()
18cal.set(2011, 3, 16, 8, 0, 0)
19cal2.set(2011, 3, 16, 17, 0, 0)
20splitResourceAssignment.splitTask(cal.getTime(), cal2.getTime(), calendar)
21cal.set(2011, 3, 18, 8, 0, 0)
22cal2.set(2011, 3, 18, 17, 0, 0)
23splitResourceAssignment.splitTask(cal.getTime(), cal2.getTime(), calendar)
24splitResourceAssignment.set(Rjb::import('com.aspose.tasks.Asn').WORK_CONTOUR, Rjb::import('com.aspose.tasks.WorkContourType').Contoured)
25project.save("SplitTasks.xml", Rjb::import('com.aspose.tasks.SaveFileFormat').XML)

Download Running Code

Download Split Tasks (Aspose.Tasks) from any of the below mentioned social coding sites:

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.