Multiple problems with output from Project.Save and ProjectWriter.Write

I am currently evaluating Aspose.Tasks for creating PDF/XPS/XML/MPP files within our application. However, I am having some issues with inconsistencies between the different file format. I am listing them all below.

I have created a simple project with 3 summary tasks, each having 3 child tasks. Each child task spans 2 days, so each summary task is a total of 6 days. Each summary task begins in separate months (for example, January, February and March).

Problems:

1) Duration value is calculated incorrectly (for PDF and XPS output)

2) Range bars for each child task spans 4 days, not 2 (for XPS output)

3) Project.WeekStartDay property is not respected (for PDF and XPS output)

4) Output should span across multiple pages (since there are 3 months involved), but only the first page is output to file (for PDF and XPS output)

5) Creation of XML file seems to contain correct project information, however, when importing it into MS Project, the dates default to the current date (Sept 17), not Jan, Feb or Mar. Also, Duration is not calculated correctly and also does not show consistent Duration type (summary level shows "minutes", child level shows "days").

I haven't even attempted to assign resources or link tasks together, so if I have any further problems I will send those to you as well.

Can you please look into these reported issues and let me know what can be done to resolve them? I have attached the PDF, XPS and XML formats that demonstrate the problems.

As mentioned earlier, I am evaluating Aspose.Tasks and pessimistic that I will purchase a license unless these issues can be resolved.

Thank you for your attention to this matter.

Hi Mark,


Thanks for considering Aspose.Tasks and writing to support team.

I have analyzed the information and need more assistance to identify the problem. Could you please send us the sample console application which can be used to re-produce these output files here? It will help us to resolve the issue and provide solution in a better way.

Info on 2 additional problems:

6) Adding task links works when importing XML into MS Project, but PDF/XPS output does not show any task links

7) Adding resources to the project will cause task start/end dates to reset (for XML imported into MS Project)

Please review these new items and let me know what can be done to resolve them.

Thank you

I have attached a file with my sample code.

Hi Mark,


Here is a sample code which creates output file as per your requirements. Currently you may please consider testing XML output only as we are further investigating the PDF and XPS issues and we will soon share our findings here regarding PDF/XPS output. Sample XML output snapshot is also attached here for your reference. Please give a try to the following code and let us know your feedback.
Sub Main()
SampleTest()
End Sub
Private Sub Recalculate(ByVal project As Project)
project.CalcTaskIds()
project.CalcTaskUids()
project.CalcResourceIds()
project.CalcResourceUids()
project.CalcResourceAssignmentIds()
project.CalcResourceAssignmentUids()
project.CalcCalendarUids()
project.UpdateReferences()
End Sub
Private Function GetTestResource(ByVal name As String) As Resource
Dim rsc As New Resource(name)
rsc.StandardRate = New Decimal(10)
rsc.StandardRateFormat = RateFormatType.Hour
rsc.OvertimeRate = New Decimal(20)
rsc.OvertimeRateFormat = RateFormatType.Hour
rsc.CostPerUse = New Decimal(50)
rsc.MaxUnits = 1
rsc.AccrueAt = CostAccrualType.[End]
rsc.EmailAddress = “Testemail@d.com”
rsc.Initials = “R.S.C.”
rsc.Type = ResourceType.Work
rsc.Hyperlink = “link.org”
rsc.HyperlinkAddress = “http://www.microsoft.com”
rsc.HyperlinkSubAddress = “subaddress”
rsc.Group = “Test Group”
rsc.Code = “Test Rsc Code”
rsc.NtAccount = “Test NtAccount”
rsc.NotesText = “TEST NOTE!”
Return rsc
End Function

Sub SampleTest()
Dim prj As New Project()
prj.StartDate = New DateTime(2013, 1, 1, 8, 0, 0)
prj.FinishDate = New DateTime(2014, 12, 31, 17, 0, 0)
prj.MinutesPerDay = 8 * 60
prj.MinutesPerWeek = 5 * 8 * 60
prj.DaysPerMonth = 20
prj.DurationFormat = TimeUnitType.Hour
prj.WorkFormat = TimeUnitType.Hour

'Create a calendar for the project'
Dim standard As New Aspose.Tasks.Calendar(“Standard”)
standard = Aspose.Tasks.Calendar.MakeStandardCalendar(standard)
prj.Calendars.Add(standard)
prj.Calendar = standard

'Create an empty resource for new project'
prj.Resources.Add(New Resource(""))

'Create project resources'
Dim ResourceNamesList As New List(Of String)(New String() {“Mark”, “bob”, “Jcob”})
Dim ResourcesList As New List(Of Resource)()
Dim rootTask As New Task(“Root Task”)
prj.RootTask = rootTask


'Define Tasks'
Dim SummaryNamesList As New List(Of String)(New String() {“Activity 1”, “Activity 2”, “Activity 3”})
Dim TaskNamesList As New List(Of String)(New String() {“Task 1”, “Task 2”, “Task 3”})
For iSummary As Integer = 0 To 2
Dim Summary As New Task(SummaryNamesList(iSummary))
Dim CurrentTasks As New List(Of Task)()
For iTask As Integer = 0 To 2
Dim tsk As New Task(TaskNamesList(iTask))
tsk.Start = DateTime.Now
tsk.Duration = New TimeSpan(15, 0, 0, 0)
CurrentTasks.Add(tsk)
Summary.Children.Add(tsk)
Next

prj.TaskLinks.Add(New TaskLink(CurrentTasks(0), CurrentTasks(1), TaskLinkType.FinishToStart))
prj.TaskLinks.Add(New TaskLink(CurrentTasks(1), CurrentTasks(2), TaskLinkType.FinishToStart))
rootTask.Children.Add(Summary)
Dim res As Resource = GetTestResource(ResourceNamesList(iSummary))
prj.Resources.Add(res)

'Assign resources'
Dim assgn As New ResourceAssignment(CurrentTasks(0), res)
assgn.Start = CurrentTasks(0).Start
assgn.Finish = CurrentTasks(0).Finish
assgn.Task.Work = assgn.Task.Duration
assgn.RemainingWork = assgn.Task.Work
assgn.RegularWork = assgn.RemainingWork
assgn.Work = assgn.RegularWork
prj.ResourceAssignments.Add(assgn)
Next

'perform recalculations'
Recalculate(prj)
prj.Save(“Project.XML”, Aspose.Tasks.Saving.SaveFileFormat.XML)
End Sub

Thanks for your sample code.

When I use your sample, I generate exactly the XML/MPP that you have shown in your image. However, I don't fully understand how the various properties need to be set in order to get a specific setup to the project.

I have attached a screenshot of what I am hoping to have the MPP look like after importing from an XML generated by the Project.Save method.

What I am looking for is the following:

- all child tasks begin at the start date of the summary task

- child tasks may have different durations

- child tasks will be assigned a to a single person (resource)

- summary tasks may be linked together (not child tasks)

- calendar should ignore all working hours inlcuding weekends, meaning that any task can be assigned to any day

- duration should be automatically calculated based on the given Start and Finish dates of each summary and child task

I've been experimenting with my code further to achieve the desired format (as shown in the attached screenshot), but so far I have been unable to do so.

Can you provide any further suggestion on how I would achieve my requirements?

Thank you,

Hi Mark,


Thanks for writing again.

Following is the sample code which fulfills all your requirements. I have used minimum properties to simplify the code. Details of the sample code are as follows:
  • A template project is used to create the project. However new project can also be created using the Aspose.Tasks as given in the previous sample.
  • The template project contains standard calendar by default. This calendar is modified to add Saturday and Sunday as working days. You may create your own calendar and make it standard. Details are given here for working with calendars.
  • Each sub tasks is having particular start date. It requires that constraint like StartNoEarlierThan be used along with the date (similar to MSP).
  • All the tasks have same start date as the summary task.
  • Child tasks have different dates as per the requirement.
  • Three resources are created and assigned to each sub-task under the summary task. During resource assignment, properties are set for the ResourceAssignment object w.r.t the task for which this assignment is created.
  • Summary tasks have been linked via TaskLink and then adding it to the project
You may please review the code by giving it a try and let us know your feedback then. Output of the following code is attached here for your reference.

Private Function GetTestResource(ByVal name As String) As Resource
Dim rsc As New Resource(name)
rsc.MaxUnits = 1
rsc.AccrueAt = CostAccrualType.[End]
rsc.Type = ResourceType.Work
Return rsc
End Function

Private Sub CreateProject()
Dim prj As New Project(“Blank2010.mpp”)

'add working days Saturday and Sunday
Dim wt1 As New WorkingTime()
wt1.FromTime = New DateTime(1, 1, 1, 8, 0, 0, 0)
wt1.ToTime = New DateTime(1, 1, 1, 12, 0, 0, 0)

Dim wt2 As New WorkingTime()
wt2.FromTime = New DateTime(1, 1, 1, 13, 0, 0, 0)
wt2.ToTime = New DateTime(1, 1, 1, 17, 0, 0, 0)

prj.Calendars(0).Days(6).DayWorking = True

'Saturday
prj.Calendars(0).Days(6).WorkingTimes.Add(wt1)
prj.Calendars(0).Days(6).WorkingTimes.Add(wt2)
prj.Calendars(0).Days(6).DayWorking = True

'Sunday
prj.Calendars(0).Days(0).WorkingTimes.Add(wt1)
prj.Calendars(0).Days(0).WorkingTimes.Add(wt2)
prj.Calendars(0).Days(0).DayWorking = True


Dim ResourceNamesList As New List(Of String)(New String() {“Mark”, “bob”, “Jcob”})
Dim ResourcesList As New List(Of Resource)()
Dim rootTask As Task = prj.RootTask
For i As Integer = 0 To 2
Dim res As Resource = GetTestResource(ResourceNamesList(i))
prj.Resources.Add(res)
Next

'Define Tasks
Dim SummaryNamesList As New List(Of String)(New String() {“Activity 1”, “Activity 2”, “Activity 3”})
Dim TaskNamesList As New List(Of String)(New String() {“Task 1”, “Task 2”, “Task 3”})
For iSummary As Integer = 0 To 2
Dim Summary As New Task(SummaryNamesList(iSummary))
For iTask As Integer = 0 To 2
Dim task As New Task(TaskNamesList(iTask))
task.Start = DateTime.Now.AddDays(iSummary * 210)
task.Duration = New TimeSpan(16 * (1 + iTask), 0, 0)
task.ConstraintType = ConstraintType.StartNoEarlierThan
task.ConstraintDate = DateTime.Now.AddDays(iSummary * 210)

'Assign resources
Dim assgn As New ResourceAssignment(task, prj.Resources(iTask + 1))
assgn.Start = task.Start
assgn.Finish = task.Finish
assgn.Task.Work = assgn.Task.Duration
assgn.RemainingWork = assgn.Task.Work
assgn.RegularWork = assgn.RemainingWork
assgn.Work = assgn.RegularWork
prj.ResourceAssignments.Add(assgn)

'CurrentTasks.Add(task);
Summary.Children.Add(task)
Next
rootTask.Children.Add(Summary)
Next

'Add links
prj.TaskLinks.Add(New TaskLink(rootTask.Children(0), rootTask.Children(1), TaskLinkType.FinishToStart))
prj.TaskLinks.Add(New TaskLink(rootTask.Children(1), rootTask.Children(2), TaskLinkType.FinishToStart))

'perform recalculations
Recalculate(prj)

prj.Save(“Project.XML”, Aspose.Tasks.Saving.SaveFileFormat.XML)
End Sub

Private Sub Recalculate(ByVal project As Project)
project.CalcTaskIds()
project.CalcTaskUids()
project.CalcResourceIds()
project.CalcResourceUids()
project.CalcResourceAssignmentIds()
project.CalcResourceAssignmentUids()
project.CalcCalendarUids()
project.UpdateReferences()
End Sub

There were some bugs in your latest sample code, but I was able to work around them. The output is looking much better after importing the XML into MSProject, there are still some inconsistencies that need resolving.

Unfortunately, I am still not convinced this solution will fit our needs. It's taken quite a bit of effort (almost seems like trial-and-error) between us to set the project properties just right for my very simple example. I am not optimistic that we will be able to write code that will convert the real-life data from our application to produce the desired results in XML/MPP.

I will be abandoning my research on Aspose.Tasks for now. Thank you for the help you have provided to date.

Hi Mark,

We are sorry for the inconvenience caused to you.

Could you please mention/identify the bugs and issues in the last sample as it will help us to analyze the inconsistencies in the code and provide solution.

In the sample code there are few properties that need to be set similar to Microsoft Project. Details of these properties are as follows:

  • Adding working days to Calendar
    • For adding more working days in the calendar, working times are to be decided and then set as WorkingTime.FromTime and WorkingTime.ToTime. While setting the WorkingTime, the date part is not important and just hours, minutes and seconds part is given importance.
    • We also need to set the property WorkingDay to true for marking it as working day. Days are indexed such that 0 = Sunday, 1 = Monday, …, 6 = Saturday, so these index numbers are used to set the properties.
  • Defining the resources
    • When resource is defined, we set property like name, MaxUnits which is 1 for 100% and fraction like 0.5 is for 50%. Similarly if we create a resource in MSP, it also assigns resource type and AccrueAt property by default. We used these properties to set our own values.
  • Create tasks
    • Normally we set the task name, start date and duration. However as each new task contains default constraint type “AsSoonAsPossible”, so the project start date over rides the task start date. This the reason we set the ConstraintType to StartNoEarlierThan so that the date set with task start date is followed rather than the project start date.
  • Assign Resources
    • For assigning the resources, we have to link task with particular resource. If we perform same activity in MSP, we can see that ResourceAssignment properties Start, Finish, Task.Work, RemainingWork, RegularWork and Work are auto set by MSP. Here we have set these properties for similarities with MSP.
  • Linking Tasks
    • For task linking we need to select two tasks and TaskLinkType for creation of a link. The same link is then added to project list of TaskLinks.

Your feedback will help us provide
you with your requirements and log any bugs found. Looking forward to assist
you further.

As mentioned in my previous post, we have decided to abandon further investigation of Aspose.Tasks due to the problems reported. We must now move forward with other priorities for our development project, and thus will be exploring other solutions.

The bugs I listed in my previous posts should be enough for your development team to begin investigating and finding solutions. I am very disappointed at the amount of effort involved so far to get this working, but yet, we did not end up with a workable solution. The fact that the same Project object didn't produce consistent results in PDF / XPS / XML / MPP formats is a huge issue.

Thanks again for your time and assistance in this matter.

Hi Mark,

Thanks for the feedback.

In order to avoid the dates set to N/A, please recalculate the root task of the project as well in the Recalculate method above. i.e. modify your Recalculate() method as follow:

Sample Code:

Private Sub Recalculate(ByVal project As Project)
project.CalcTaskIds()
project.CalcTaskUids()
project.CalcResourceIds()
project.CalcResourceUids()
project.CalcResourceAssignmentIds()
project.CalcResourceAssignmentUids()
project.CalcCalendarUids()
project.UpdateReferences()

Task.Recalculate(project.RootTask) 'This is new statment

End Sub

This will recalculate the project similar to when Microsoft opens MPP file. There is, however, one limitation at Aspose.Tasks end in the output rendered files i.e. the links are missing in the Gantt view. We are still in the process of implementing this feature for rendered output files where lag is negative. Please give a try to the above mentioned code and let us know your feedback.

As I have said before, we have halted our evaluation of Aspose.Tasks.

However out of curiosity, I tried adding the new Recalculate statement and re-running the code. To my dismay, an exception was generated. I will include the exception and stack trace below.

From this point forward, we will not be doing any further evaluation of Aspose.Tasks.

-----------------------------------------------------------------------------------------------------------

Date cannot be DateTime.MinValue
Parameter name: datev

at Aspose.Tasks.Calendar.GetPreviousWorkingDayEnd(DateTime date)
at Aspose.Tasks.Task.get_SplitParts()
at Aspose.Tasks.Calendar.“ˆ(Task , DateTime , TimeSpan )
at .™.€(Task )
at .™.€(List`1 , ž )
at .™.€()
at .™.€()
at .™.e‹()
at Aspose.Tasks.Task.Recalculate(Task task)
at AsposeTasksTest.frmTest.RecalculateProject(Project Project) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 333
at AsposeTasksTest.frmTest.GetAspose2() in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 403
at AsposeTasksTest.frmTest.AsposeTasksExport(eReportType ReportType) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 65
at AsposeTasksTest.frmTest.RunReport_Aspose2() in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 42
at AsposeTasksTest.frmTest._Lambda$__3(Object a0, EventArgs a1) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 23
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at AsposeTasksTest.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() at Aspose.Tasks.Calendar.GetPreviousWorkingDayEnd(DateTime date)
at Aspose.Tasks.Task.get_SplitParts()
at Aspose.Tasks.Calendar.“ˆ(Task , DateTime , TimeSpan )
at .™.€(Task )
at .™.€(List`1 , ž )
at .™.€()
at .™.€()
at .™.e‹()
at Aspose.Tasks.Task.Recalculate(Task task)
at AsposeTasksTest.frmTest.RecalculateProject(Project Project) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 333
at AsposeTasksTest.frmTest.GetAspose2() in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 403
at AsposeTasksTest.frmTest.AsposeTasksExport(eReportType ReportType) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 65
at AsposeTasksTest.frmTest.RunReport_Aspose2() in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 42
at AsposeTasksTest.frmTest._Lambda$__3(Object a0, EventArgs a1) in C:\P4SS\AsposeTasksTest\AsposeTasksTest\frmTest.vb:line 23
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at AsposeTasksTest.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Hi Mark,


I am afraid to share that I am not able to reproduce this issue at my end with the sample code shared above. No exception is generated when the code is executed.

In addition, an issue with id: TASKS-33447 has been created in our issue tracking system for setting default project attributes when created from scratch. Once implemented, behavior of the API in many cases will be the same as for a newly created project in MSP.

We regret the inconvenience caused to you in this regard.

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


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

As mentioned previously, we have discontinued our company’s evaluation of Aspose.Tasks, so we will not be able to verify that the update you have provided fixes the bugs reported.

Hi Mark,


Thank you for the feedback.

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