Resource assignment units work per day

hi all

I want export to ms project in my program. when adding resource and resource assignemnts , when setting units with real work in aspose tasks, I expect work per day be : Resource work /task duration. but when open ms project file, the work per day is : units value * 8. anyone help me?

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.

but my new question is , if work per day < 0.01 then setting units raise error!
what can i do?
sicerely yours.

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.

thanks kashif for your codes!
I use both material and work resource types, what the case (code) for material resource types?

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

thanks for all of your support.
in case material resources my primary problem yet exist. i mean in code:
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,


We are sorry for the inconvenience caused to you.

We have logged this issue for investigation by the product team under Id: TASKS-34505. You will be automatically notified once any update is received in this regard.

hi kashif

is there any workaround for my problem until then? i need it criticaly.
thanks.

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,


I currently using trial version for my programming task. My team has a question that If buy the product, how much time needs your team to fix my problem for unit and works.
thanks.

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,

I test your code and work is same as what you said. But do favour for me and for seeing what exactly occure in ms project, please look at 2 pic that took from ms project. my problem is in the first pic that daily units is equal work*8, but when I edit the work in ru2.jpg ms project too, edit daily units to work/duration and ru2.jpg is corrected. I confused why this problem occur.
two pic ru1.jpg and ru2.jpg are attached.

thanks.

Hi Hamid,


I am afraid that I could not figure out the issue out of these images. Could you please elaborate it more along with the complete sample code, supporting files and steps to re-produce the issue? It will help us to analyze the problem and provide assistance accordingly.

hi kashif,

my code:

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>
Hi Hamid,

Could you please elaborate the following? I could not see total units = 400 anywhere in MS Project. Please share some snapshot or other steps to view this issue.

Haamiid:
but when i export to ms project daily units ( in calendar) in resource usage menu  is 50*8=400.

hi kashif,

I attached the picature, yes units are 50 but ,on the calendar, 400 is on the daily units.

Hi Hamid,


Thank you for providing details.

I have observed the issue and logged it under Id: TASKS-34567 for further investigation by the product team. You will be automatically notified once any update is received in this regard.