We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Resource usage

Hi,
how to distribute the use of resources?

I tried:

    static void Main(string[] args)
    {
        License license = new License();
        license.SetLicense("Aspose.Tasks.lic");

        Project project = new Project("Template.mpp");
        //project.CalculationMode = CalculationMode.None;

        /*Begin Resource*/
        Resource resource1 = project.Resources.Add("Resource 1 (Material)");

        resource1.Set(Rsc.Name, "Resource 1 (Material)");
        resource1.Set(Rsc.MaterialLabel, "Pct");
        resource1.Set(Rsc.Type, ResourceType.Material);
        resource1.Set(Rsc.StandardRate, Convert.ToDecimal(30));
        resource1.Set(Rsc.Code, "1");


        Resource resource2 = project.Resources.Add("Resource 2 (Material)");

        resource2.Set(Rsc.Name, "Resource 2 (Material)");
        resource2.Set(Rsc.MaterialLabel, "Un");
        resource2.Set(Rsc.Type, ResourceType.Material);
        resource2.Set(Rsc.StandardRate, Convert.ToDecimal(50));
        resource2.Set(Rsc.Code, "2");
        /*End Resource*/

        /*Begin Tasks*/
        Task tsk1 = project.RootTask.Children.Add("Task 1");
        tsk1.Set(Tsk.IsManual, true);
        tsk1.Set(Tsk.Type, TaskType.FixedUnits);
        tsk1.Set(Tsk.Start, DateTime.ParseExact("2018-01-01", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture));
        tsk1.Set(Tsk.Duration, project.GetDuration(10, TimeUnitType.Day));
        tsk1.Set(Tsk.Work, tsk1.Get(Tsk.Duration));
        /*End Tasks*/


        /*Begin Assigment*/
        ResourceAssignment assignment1 = project.ResourceAssignments.Add(tsk1, resource1);
        assignment1.Set(Asn.Units, 5);

        ResourceAssignment assignment2 = project.ResourceAssignments.Add(tsk1, resource2);
        assignment2.Set(Asn.Units, 5);
        assignment2.Set(Asn.WorkContour, WorkContourType.Contoured);

        ClearTimephasedData(assignment2);

        var td = new TimephasedData();
        td.Start = new DateTime(2018, 1, 1, 8, 0, 0);
        td.Finish = td.Start.AddHours(8);
        td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
        td.Value = TimeSpanToTDString(TimeSpan.FromHours(1));
        assignment2.TimephasedData.Add(td);

        td = new TimephasedData();
        td.Start = new DateTime(2018, 1, 2, 8, 0, 0);
        td.Finish = td.Start.AddHours(8);
        td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
        td.Value = TimeSpanToTDString(TimeSpan.FromHours(1));
        assignment2.TimephasedData.Add(td);

        td = new TimephasedData();
        td.Start = new DateTime(2018, 1, 3, 8, 0, 0);
        td.Finish = td.Start.AddHours(8);
        td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
        td.Value = TimeSpanToTDString(TimeSpan.FromHours(1));
        assignment2.TimephasedData.Add(td);

        td = new TimephasedData();
        td.Start = new DateTime(2018, 1, 4, 8, 0, 0);
        td.Finish = td.Start.AddHours(8);
        td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
        td.Value = TimeSpanToTDString(TimeSpan.FromHours(1));
        assignment2.TimephasedData.Add(td);

        td = new TimephasedData();
        td.Start = new DateTime(2018, 1, 5, 8, 0, 0);
        td.Finish = td.Start.AddHours(8);
        td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
        td.Value = TimeSpanToTDString(TimeSpan.FromHours(1));
        assignment2.TimephasedData.Add(td);


        project.CalcResourceFields();
        project.CalcResourceStartFinish();
        project.Recalculate();

        project.Save(@"output.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
        project.Save(@"output.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);
    }
    static private string TimeSpanToTDString(TimeSpan timeSpan)
    {
        return string.Format("PT{0}H{1}M{2}S", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
    }

    static private void ClearTimephasedData(ResourceAssignment assignment)
    {
        foreach (TimephasedData tph in assignment.TimephasedData.ToList())
            assignment.TimephasedData.Remove(tph);
    }

Result:
Print.png (112.8 KB)

Expected:
Print2.png (79.5 KB)

@FabioMartins,

Thank you for contacting Aspose support team.

I have tried the scenario using latest version Aspose.Tasks for .NET 18.5.0 and observed that output is similar to the expected output. You may please give it a try using your own template mpp file and share the feedback.

XMLOutputWith18.5.png (1.9 KB)

Hi @kashif.iqbal,

I did the upgrade to Aspose.Tasks for .NET 18.5.0 and the result was the same:

XML18.5.png (13.2 KB)

MPP18.5.png (4.6 KB)

I’m using MSP 2016.

@FabioMartins,

Could you please send your template mpp file and the output mpp and xml files for our analysis?

@kashif.iqbal,

is attached:
Files.zip (45.3 KB)

@FabioMartins,

Thank you for sending us the supporting files. We will look into it and share the feedback soon.

@FabioMartins,

I have established the environment for checking your sample “output.mpp” in MSP 2016. I am afraid that in MSP 2016, the resource usage view is different than the image sent by you as “MPP18.5.png”. Snap shot is attached here where your MPP file is opened in MSP 2016. Could you please confirm that have you sent the same MPP file which is shown in MPP18.5.png?

MPPResourceUsage.png (15.0 KB)

Hi @kashif.iqbal,

Yes, the information I submitted is correct.
I made a video:
Video.zip (692.7 KB)

For me it looks like this:
NewPrintMPP.png (118.2 KB)

@FabioMartins,

I have checked the video and astonished to see different views of the same MPP using MSP 2016. For further investigation, could you please provide us the exact version number of MSP 2016 which you are using? Also please share the link to download the installer of the same for our analysis here.

I was surprised, too.

Version:VersionMSP.png (7.3 KB)

Link:LinkOffice360MSP.png (23.8 KB)

@FabioMartins,

We are working on this issue, however in the meanwhile we need you to please use the attached template file in your project, create both XML and MPP files using your sample code and view the ResourceUsage for both XML and MPP. Here we are getting correct ResourceUsage in XML output file using attached template file. However we are not getting proper output in MPP file. If you also get correct output using XML file, we will log an issue for similar MPP output file with the attached template file.

Blank2010.zip (24.0 KB)

Hi @kashif.iqbal,

Using the template file (Blank2010.mpp) the result was the same.
In XML the information is correct. But MPP does not.
Attached is the generated files:
Files2.zip (49.1 KB)

XML:XMLOutput.png (30.0 KB)

MPP: MPPOutput.png (12.6 KB)

@FabioMartins,

Thank you for providing the feedback. We are analyzing the available data and following are the concerns. In your template file, calendar working hours are 9 am to 6 pm where as in your code sample you are using 8 am as start time in timephased data as follows:

td.Start = new DateTime(2018, 1, 1, 8, 0, 0);

Could you please clarify, is it done intentionally or is it some typo mistake?

We request you to open your output MPP file on some other system and observe the ResourceUsage because we could not re-produce this view in our environment.

You may also open your MPP output file in MSP and save it as XML using MSP. Open this XML file in notepad and observe the timephased data. If it contains distributed data, then it seems to be some view setting issue in your MSP. Please send us the saved XML file as well for our analysis.

Once your feedback is received, we will proceed accordingly.

Hi @kashif.iqbal

It was intentional, but I made the change for 9 am and the result was exactly the same.

I opened the MPP file in another station with MSP 2013 and the result was the same.
OutraMaquina.png (57.5 KB)
OutraMaquinaVersao.png (206.0 KB)

Calendar default
1.png (115.4 KB)
Change to 9 am:
2.png (147.2 KB)
Output MPP:
3.png (106.7 KB)
Output XML:
4.png (83.7 KB)
Export MPP to XML using MSP:
5.png (89.8 KB)

Is attached:
Files3.zip (27.7 KB)

@FabioMartins,

Thank you for providing detailed feedback.

I have logged an issue under Id:TASKSNET-2450 which is for difference in distributed values between XML and MPP file using your original sample code in first post and template file Blank2010.mpp provided by us. In this issue, the MPP file contains multiple distributed values (5 in number) as shared by me during analysis.

Another investigation ticket is logged where issue of single value 5 in MPP is noted in your environment instead of 5 values under Id:TASKSNET-2451 .

We will investigate these logged issues thoroughly on their turn and share the feedback once ready. Thank you for your patience in this regard.

Hello,
any news?

@FabioMartins,

Thank you for contacting Aspose support team again. Both the issues logged under ticket Ids TASKSNET-2450 and 2451 are resolved and will be part of our incoming release in the mid of June, 2018. You will be automatically notified once new version is released and publicly available for download.

Hello,
any news?

@FabioMartins,

Please use the latest version of the API 18.7.1. This has already been fixed.

1 Like