hi all
Hi Hamid,
Thank you for writing to Aspose Support team.
The behavior is similar to MS Project. If you create a resource in MSP and assign it to a task which is of 3 days duration, you will see 24 hours (if the calendar is of 8 hours per day) in the resource usage window. You can, however, view the work hours per day in the right timeline window of Resource Usage sheet which shows 8 hour per day. Please let us know if you still have inquiry in this regard.
this is my code:
ResourceAssignment resAssignment = project.ResourceAssignments.Add(selectedTask, mspResource);
resAssignment.Set(Asn.Units, ra.Value);
project.Save(fs, (ATasks.Saving.SaveFileFormat) setting.SaveFileFormat);
I expect when units = 12 and duration is 3 then work per day be: 4, while it is 12*8=96
when I reset units in microsoft project itself its gonna be alright and work per day will
reset to 4. even when i use update project menu and complete uncompleted tasks all this
values gonna be alright.
I dont know how to fix it by aspose tasks.
Hi Hamid,
You may please use Asn.Work for setting the work for the assignment and set Asn.Units as 0.5 (day) which set 4 hours max per day. Please give a try to the following sample code and let us know the feedback.
Project project = new Project(“Blank2010.mpp”);
Task task1 = project.RootTask.Children.Add("Task1");
task1.Set(Tsk.Duration, project.GetDuration(3, TimeUnitType.Day));
task1.Set(Tsk.Start, new DateTime(2016, 3, 1));
task1.Set(Tsk.ActualStart, task1.Get(Tsk.Start));
task1.Set(Tsk.Type, TaskType.FixedDuration);
Resource res = project.Resources.Add("Person1");
res.Set(Rsc.Type, ResourceType.Work);
ResourceAssignment Assn = project.ResourceAssignments.Add(task1, res);
Assn.Set(Asn.Units, 0.5);//Half unit Per day i.e. 4 hours per day
Assn.Set(Asn.Work, project.GetDuration(12, TimeUnitType.Hour));
MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
project.Save("output.mpp", mppSaveOptions);
thanks kashif for answer.
Hi Hamid,
MSP 2010 allows minimum work value as 1.2 minutes where as I have tested 0.002 minutes value as well using Aspose.Tasks. Could you please give a try to the following sample code using latest version Aspose.Tasks for .NET 9.2.1 and let us know the feedback?
Project project = new Project(“Blank2010.mpp”);
Task task1 = project.RootTask.Children.Add("Task1");
task1.Set(Tsk.Duration, project.GetDuration(3, TimeUnitType.Day));
task1.Set(Tsk.Start, new DateTime(2016, 3, 1));
task1.Set(Tsk.ActualStart, task1.Get(Tsk.Start));
task1.Set(Tsk.Type, TaskType.FixedDuration);
Resource res = project.Resources.Add("Person1");
res.Set(Rsc.Type, ResourceType.Work);
ResourceAssignment Assn = project.ResourceAssignments.Add(task1, res);
Assn.Set(Asn.Units, 0.5);//Half unit Per day i.e. 4 hours per day
Assn.Set(Asn.Work, project.GetDuration(0.00208, TimeUnitType.Minute));
MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
project.Save("output.mpp", mppSaveOptions);
hi.
Hi Hamid,
You may please use following statement to set material type:
res.Set(Rsc.Type, ResourceType.Material);
Then unit is important to mention the material. Microsoft project allows minimum 0.01 unit of a material which is also supported by Aspose.Tasks as follows:
ResourceAssignment Assn = project.ResourceAssignments.Add(task1, res);
Assn.Set(Asn.Units, 0.01);
You may not leave the Work value un-attended and may set it to some value as shown in the following sample.
Assn.Set(Asn.Work, project.GetDuration(1, TimeUnitType.Day));
hi kashif
resAssignment.Set(Asn.Units, 1);
resAssignment.Set(Asn.Work, project.GetDuration(32, ATasks.TimeUnitType.Day));
and task duration is 4.
i expect units per day in ms project be 1 and work of resource assignment be : 32
but ms project or aspose will set work to units/8 = 1/8.
and then cash flow isnt the wanted value!
in fact I expect work be 32 and units per day be 1 and cash flow also be
true value. please help me in material case.
thanks alot.
Hi Hamid,
hi kashif
Hi Hamid,
Our Product team is currently investigating the issue. Meanwhile, we have requested for any work around method if available and will update you here once the information is available in this regard.
hi kashif,
Hi Hamid,
We have analyzed the issue in detail and following is the sample code which fulfills your requirement. Please give it a try and let us know the feedback.
Project project = new Project(@“Blank2010.mpp”);
project.Set(Prj.StartDate, new DateTime(2016, 3, 21, 8, 0, 0));
Resource resource = project.Resources.Add("RESOURCE 1");
resource.Set(Rsc.Type, ResourceType.Material);
Task task = project.RootTask.Children.Add("Task 1");
task.Set(Tsk.Start, new DateTime(2016, 3, 21, 8, 0, 0));
task.Set(Tsk.Duration, project.GetDuration(4, TimeUnitType.Day));
ResourceAssignment resAssignment = project.ResourceAssignments.Add(task, resource, 32); // setting units
resAssignment.Set(Asn.Work, project.GetDuration(32, TimeUnitType.Hour));
var work = resAssignment.Get(Asn.Work).ToDouble(); // expected work 32 hours same as ms project does
hi kashif,
Hi Hamid,
hi kashif,
using ATasks = Aspose.Tasks;
var path = “D:\NewProject.mpp”;
Project project = new Project(path);
ATasks.Task mspTask = project.RootTask.Children.Add("test"); ;
mspTask.Set(Tsk.Start, DateTime.Now.AddDays(-30));
mspTask.Set(Tsk.Duration, project.GetDuration(5, ATasks.TimeUnitType.Day));
ATasks.Resource mspResource = project.Resources.Add();
mspResource.Set(Rsc.Name, "testRes");
mspResource.Set(Rsc.StandardRate, 1000);
mspResource.Set(Rsc.Initials, "t");
mspResource.Set(Rsc.Type, ATasks.ResourceType.Material);
mspResource.Set(Rsc.MaterialLabel, "test");
ResourceAssignment resAssignment = project.ResourceAssignments.Add(mspTask, mspResource, 50);
resAssignment.Set(Asn.Work, project.GetDuration(50, ATasks.TimeUnitType.Hour));
project.Save("D:\\testMSP.mpp", ATasks.Saving.SaveFileFormat.MPP);</span></pre><pre style="font-family: Consolas; font-size: 13px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="background-color: rgb(255, 255, 255);"><br></span></pre><pre style="font-family: Consolas; font-size: 13px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="background-color: rgb(255, 255, 255);">I expect in msproject daily unit be 50/5=10 and work to be 50.</span></pre><pre style="font-family: Consolas; font-size: 13px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="background-color: rgb(255, 255, 255);">but when i export to ms project daily units ( in calendar) in resource usage menu is 50*8=400.</span></pre></div>
Haamiid:but when i export to ms project daily units ( in calendar) in resource usage menu is 50*8=400.
hi kashif,
Hi Hamid,