Bought license- dates are still wrong

Good morning.

My company purchased the license for the product last night. I followed the rules, dropping the lic into the bin and referencing it in code. So far, the dates are still being skewered to the current date. Now, the information in the xml is pretty accurate. During the conversion however, the information gets mangled.

What am I doing wrong? This needs to be done yesterday.

Thanks,

Jamarl L Thomas


This message was posted using Page2Forum from Applying the license - Aspose.Tasks for .NET

Hi Thomas,

You can also try Task.ActualStart instead of Task.Start if you are reading xml. Can you please explain the complete scenario? That is, are you reading the mpp / xml or writing the xml. In case, issue is not resolved, you can send the mpp / xml for investigation.

Thanks

Sure. I’m pulling information from the database and writing the xml. Looking through the code, I can check the Project object before it’s being pushed to xml. Everything from that end looks good. In fact, the xml looks good. The start and finished date a populated correctly. However, when coverted from and xml to an mpp file; the dates and all set to the current date.

All right. I tried using “Actual Start”. Whle it changed the start date on some of the values; it actually randomized the start and finish on most of the items on the page. It also created some type of error when opening the document. Something about an item being added after completion of the document. Would it help you to take a look at the code or the resulting xml document?

Attached is the xml file created using Aspose.Task. The file looks file. On opening with Microsoft Project however, the dates are not preserved.

Hi Thomas,

1) As per our chat on live support, you are creating the project file from database. It is very difficult why the dates have been modified without the source code. I have noticed that all the durations are 0 days in your file. I have tested dates problem with three tasks and it is working fine, that is dates are correct and duration is also correct. You can just replace the task names, start dates and duration with your database values. Here is the sample code:

Project prj = new Project();

prj.MinutesPerDay = 480;

Task rootTsk = new Task();

Task tsk1 = new Task(this.TaskName1.Text);

Task tsk2 = new Task(this.TaskName2.Text);

Task tsk3 = new Task(this.TaskName3.Text);

tsk1.ActualStart = DateTime.Parse(this.TaskDate2.Text);

tsk2.ActualStart = DateTime.Parse(this.TaskDate2.Text);

tsk3.ActualStart = DateTime.Parse(this.TaskDate3.Text);

tsk1.Duration = new TimeSpan(int.Parse(this.TaskDuration1.Text) * 8, 0, 0);

tsk1.DurationFormat = TimeUnitType.Day;

tsk2.Duration = new TimeSpan(int.Parse(this.TaskDuration2.Text) * 8, 0, 0);

tsk2.DurationFormat = TimeUnitType.Day;

tsk3.Duration = new TimeSpan(int.Parse(this.TaskDuration3.Text) * 8, 0, 0);

tsk3.DurationFormat = TimeUnitType.Day;

prj.RootTask = rootTsk;

rootTsk.Children.Add(tsk1);

rootTsk.Children.Add(tsk2);

rootTsk.Children.Add(tsk3);

prj.CalcTaskIds();

prj.CalcTaskUids();

2) I have not tested with the license file, however the above code is fine with evaluation version with the year limitation.

I might be of help…


As a test, try saving a Microsoft Project XML file via Microsoft Project. Then read this before adding all your data to the aspose classes.

I found that the aspose api does not have any default data that microsoft project requires.

Hope that helps.

Hi,

You are right, however, you have to set certain properties when using Aspose.Tasks for .NET to achieve desired results.

Hi Guys. I did get the dates working; sort of. There seems to be an odd link between dates and subtask resources. I’ve found that when my dates are preserved, the subtask resources are not. The reverse is also true. When subtask resources are preserved, the duration for those task goes to zero and the start and finish date default to the same value.

Hi Thomas,

An issue has been created with issue id 10100 for the said problem and you will be informed accordingly as soon as it is resolved.

Hi Thomas,

I have completed the investigation with the help of product development team. In fact, there is no such bug in Aspose.Tasks for .NET. Actually, we have to set the proper properties.

1) For Task.Start to work correctly, we shall have to set the Project.StartDate less than start date of all the tasks, which is by default current date. Moreover, we shall have to apply the "StartNoEarlierThan" constraint on task.

2) For ResourceAssignment, we shall have to set the RemainingWork property.

A complete working example is as under:

License lic = new License();

lic.SetLicense("Aspose.Total.lic");

Project prj = new Project();

prj.MinutesPerDay = 480;

prj.Calendar = Aspose.Tasks.Calendar.MakeStandardCalendar();

prj.IsScheduleFromStart = true;

prj.StartDate = DateTime.Now.AddMonths(-6);

Task rootTsk = new Task();

Task tsk1 = new Task("tsk1");

Task tsk2 = new Task("tsk2");

Task tsk3 = new Task("tsk3");

tsk1.Start = DateTime.Parse("30-Oct-2009 08:00 AM");

tsk2.Start = DateTime.Parse("10-Nov-2009 08:00 AM");

tsk3.Start = DateTime.Parse("25-Dec-2009 08:00 AM");

tsk1.Duration = new TimeSpan(3 * 8, 0, 0);

tsk1.DurationFormat = TimeUnitType.Day;

tsk2.Duration = new TimeSpan(4 * 8, 0, 0);

tsk2.DurationFormat = TimeUnitType.Day;

tsk3.Duration = new TimeSpan(25 * 8, 0, 0);

tsk3.DurationFormat = TimeUnitType.Day;

tsk1.IgnoreResourceCalendar = true;

tsk1.Type = TaskType.FixedUnits;

tsk1.ConstraintType = ConstraintType.StartNoEarlierThan;

tsk2.IgnoreResourceCalendar = true;

tsk2.Type = TaskType.FixedUnits;

tsk2.ConstraintType = ConstraintType.StartNoEarlierThan;

tsk3.IgnoreResourceCalendar = true;

tsk3.Type = TaskType.FixedUnits;

tsk3.ConstraintType = ConstraintType.StartNoEarlierThan;

prj.RootTask = rootTsk;

rootTsk.Children.Add(tsk1);

rootTsk.Children.Add(tsk2);

rootTsk.Children.Add(tsk3);

Resource res = new Resource();

Resource res1 = new Resource("res1");

Resource res2 = new Resource("res2");

prj.Resources.Add(res);

prj.Resources.Add(res1);

prj.Resources.Add(res2);

ResourceAssignment ra1 = new ResourceAssignment(tsk1, res1);

ra1.Units = 2;

ra1.RemainingWork = new TimeSpan((long)ra1.Units * tsk1.Duration.Ticks);

ResourceAssignment ra2 = new ResourceAssignment(tsk2, res2);

ra2.Units = 2;

ra2.RemainingWork = new TimeSpan((long)ra2.Units * tsk2.Duration.Ticks);

prj.ResourceAssignments.Add(ra1);

prj.ResourceAssignments.Add(ra2);

prj.CalcTaskIds();

prj.CalcTaskUids();

prj.CalcResourceAssignmentIds();

prj.CalcResourceAssignmentUids();

prj.CalcResourceIds();

prj.CalcResourceUids();

prj.CalcResourceFields();

prj.CalcResourceStartFinish();

ProjectWriter prjWrt = new ProjectWriter();

FileStream fs = new FileStream("d:\\mpp\\thomas\\mpp_st.xml", FileMode.Create, FileAccess.Write);

prjWrt.Write(prj, fs, TasksDataFormat.XML);

fs.Close();

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