Hi,
I’m trying to run your examples from
GitHub examples and I can’t get it work correctly.
Example VS solution (.sln) has references to v8.5.0 so I updated to the latest version v9.3.0 using Nuget Package Manager and also tried doing manually with same results.
Based on your example ‘MPPFileUpdate.Run()’, I have the following code:
Project project = new Project();
Task task = project.RootTask.Children.Add(“Task1”);
task.Set(Tsk.Start, new DateTime(2012, 8, 1));
task.Set(Tsk.Finish, new DateTime(2012, 8, 5));
Console.WriteLine(task.Get(Tsk.Start));
Console.WriteLine(task.Get(Tsk.Finish));
and I get the following output:
Actual:
8/3/2000 8:00:00 AM
8/5/2000 12:00:00 AM
Expected:
8/1/2012
8/5/2012
So… what I see here is that you can’t set “Start” nor “Finish” properties.
By the way, in the expected output you may notice that I didn’t write it with hours format because I’m not sure how it is supposed to be created, anyway I expect that dates should be set exactly as the parameter.
Please let me know how to set those properties correctly.
Notes: I get the same results running your example ‘MPPFileUpdate.Run()’ using v8.5.0 and v9.3.0.
Hi Gustavo,
Thank you for writing to Aspose Support team.
By default, the project calculation mode is set to automatic that recalculates everything and sets the dates. If you are creating a new project, it’s start date is as of today and rest of the dates are calculated automatically with reference to this start date. The following code sample gives the idea of impact about these. Please have a look at the code sample and let us know your feedback.
Sample Code:
Project project = new Project();
Console.WriteLine(project.Get(Prj.StartDate));
Console.WriteLine(project.CalculationMode.ToString());
project.CalculationMode = CalculationMode.None;
Console.WriteLine(project.CalculationMode.ToString());
Task task = project.RootTask.Children.Add(“Task1”);
task.Set(Tsk.Start, new DateTime(2012, 8, 1));
task.Set(Tsk.Finish, new DateTime(2012, 8, 5));
Console.WriteLine("*************** Before Recalculate **");
Console.WriteLine(task.Get(Tsk.Start));
Console.WriteLine(task.Get(Tsk.Finish));
project.Recalculate();
Console.WriteLine(" After Recalculate *****************");
Console.WriteLine(task.Get(Tsk.Start));
Console.WriteLine(task.Get(Tsk.Finish));
Hi Kashif,
Thanks for replying, it was huge help and your code made me understand a few things I didn't get while first reading the API documentation.
Now I have this situation on my unit tests and I'm not sure why it's happening.
On my unit tests' setup I have something like:
var project = new Project();
project.CalculationMode = CalculationMode.None;
Task task = project.RootTask.Children.Add("task1");
and if I output 'task.Get(Tsk.Start)' I get '1/1/0001 12:00 AM' while 'project.Get(Prj.StartDate)' is '4/8/2000 8:00 AM', which somehow make sense on what you replied but not completely.
I've read somewhere in the documentation, I can't find it now, that when using the trial version makes that objects creation's dates will be in year 2000 and as I have a license maybe it's somehow mixing. BTW I'm not loading the license on my unit tests.
NOTE: I want to avoid setting 'Tsk.Start' and 'Tsk.Finish' on unit tests' setup because I have tests that makes things on those properties.
Thanks for your help! keep it up the good work!
Hi Gustavo,
These are the evaluation limitations that are affecting the output. Please initialize the license in your sample application to avoid such issue and let us know your feedback.
Kashif,
Did not try activating the license for those unit tests. Decided to take another approach.
Thanks for your time and help!
BTW, the content in the link
you sent previously is out-of-date with deprecated syntax coding examples.
Hi,
Thank you for sharing your feedback.
We have also rectified the documentation sample code and these will soon be further upgraded to the latest documentation style. Please feel free to write to us if you have further inquiry related to the API.