Unable to read teh 2 fields Flag1 & Task Mode

Hi Team,


Unable to read TaskMode & Flag1 (Field) even after using external attribute.

foreach (ExtendedAttribute att in tsk.ExtendedAttributes)
{
// Console.WriteLine(tsk.Get(Tsk.Name) + ", Field Name = " + att.AttributeDefinition.FieldName + ", Value = " + att.Value);
if (att.AttributeDefinition.FieldName == “Text1”)
tskObj.Deliverable = att.Value;
if (att.AttributeDefinition.FieldName == “Text2”)
tskObj.TaskLevel = att.Value;

if (att.AttributeDefinition.FieldName == “Text3”)
tskObj.ActionFlag = att.Value;

if (att.AttributeDefinition.FieldName == “Flag1”)
tskObj.CriticalPathInd = att.Value;



// if(att.AttributeDefinition.FieldName == “Flag1”)

}

Thanks in advance!!

Regards
Abhishek Prasad

Hi Abhishek,


Thank you for writing to Aspose Support team.

Could you please confirm to us the following for investing the issue further at our end?

1. If we set the value of Flag1 to Yes, the API reads it. But if we set it to No, it doesn’t read this value. Are you facing the same problem?

2. How are you reading the Task mode? We couldn’t locate this parameter exactly to investigate the issue further.

Hi Team,


I want to read an flag1 field created in the MPP, just like the Extended Attribute but I am unable to read the same even when I have marked the Flag1 as Yes.

Please let me know How can I do this.

Thanks
Abhishek Prasad

Hi Abhishek,

We create a project in MSP 2010, create two tasks and set one task Flag1 value as Yes and second task Flag1 value as No. Save this project as XML and open it in in Notepad. You will observe that for the task which has Flag1 value Yes, there is one element in the task’s extended attributes collection, whereas for the second task whose Flag1 value is No, there are zero elements in the task’s extended attribute collection.

This shows that if some task has Flag1 value = No, then this extended attribute will not be added in the extended attribute collection by MSP as well. With this assumption, following is the sample code which displays the Flag1 value of the tasks. Similarly task mode can be obtained using IsManual flag. Please give a try to the following sample code and share the feedback using attached sample MPP file.

static void Tasks_756131()
{
    Project proj = new Project("SampleProject.mpp");
    ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
    TaskUtils.Apply(proj.RootTask, collector, 5); // Collect all the tasks from RootTask using TaskUtils
    foreach (Task tsk in collector.Tasks)
    {
        bool bIsFlag1Found = false;
        foreach (ExtendedAttribute ext in tsk.ExtendedAttributes)
        {
            String str = Field.TaskFlag1.ToString();
            if (ext.AttributeDefinition.FieldName == "Flag1")
            {
                if (ext.Value == "1")
                    Console.WriteLine("Flag1 = Yes");
                else
                    Console.WriteLine("Flag1 = No");
                bIsFlag1Found = true;
            }
        }
        if (!bIsFlag1Found)
            Console.WriteLine("Flag1 = No");
        //Read Task Mode
        bool bIsManual = tsk.Get(Tsk.IsManual);
        if (bIsManual)
            Console.WriteLine("Its Manual");
        else
            Console.WriteLine("Its Automatic");
    }
}

Hi Team,


Thanks for the response I am able to read those fields.

I need one help.
I am able to import the tasks in the form of list. but I want to know the logic to store the same in the database so that I can maintain the child parent relationship. (Reading which is child and which is parent level.)

How can I do so?
Please let me know so that I am able to reproduce the same from the DB while exporting.

Regards
Abhishek Prasad

Hi Team,

I want to know the logic to maintain the child parent hierarchy while storing the same in the DB.

Please let me know a sample so that I can reproduce the imported data while exporting the MPP from DB.

Thanks

Abhi



Hi Abhishek,


You will have to use your own custom logic to store this information. Please note that every task retains its parent information that can be retrieved using the Task.ParentTask property. In order to import the while exporting the MPP from DB, you can use this information (of course you need to store it in DB as well) to maintain the child parent hierarchy. Please let us know if you have any confusion in this regard or need further assistance.