Free Support Forum - aspose.com

Aspose.Tasks overriding MS Project Task's GUID

I'm developing a sync function with Aspose.Tasks, but to do this I need a MSProject GUID to make a entity relation.

In my tests when I just read a MPP file with Aspose.Tasks and then save to file, every Task's GUID are recalculated.

How can I fix this?

Hi Lucas,


Thank you for contacting Aspose support team.

I have compared the two MPP files but am afraid to share that no difference was observed in GUID as shown in the attached image. I also tried to re-produce the scenario using following code, however both the MPP files contain similar GUID.

static void Main(string[] args)
{
new License().SetLicense(@“E:\Aspose.Total.Net2015.lic”);
Tasks_600558(@“D:\Aspose\ProjectFormattedTasks.mpp”, true);
Tasks_600558(@“D:\Aspose\ProjectFormattedTasks1.mpp”, false);
Console.WriteLine(“Press any ket to continue…”);
Console.ReadKey();
}

static public void Tasks_600558(String FileName, bool bWrite)
{
Project prj = new Project(FileName);
ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
TaskUtils.Apply(prj.RootTask, collector, 1); // Collect all the tasks from RootTask using TaskUtils
foreach (Task tsk in collector.Tasks)
{
Console.WriteLine("Id = " + tsk.Get(Tsk.Id));
Console.WriteLine("Uid = " + tsk.Get(Tsk.Uid));
Console.WriteLine("Guid = " + tsk.Get(Tsk.Guid));
}
if (bWrite)
prj.Save(@“D:\Aspose\ProjectFormattedTasks1.mpp”, SaveFileFormat.MPP);
}

Could you please give it a try and let us know the feedback? If problem still exists please send us the complete code and sample files which can be used here to reproduce the scenario here. It will help us to observe the issue and provide assistance as soon as possible.
Hi Kashif,

Thank you for quick response.
I don't know what happen, but in MS Project (2013) the Task's GUIDs are different.

In console.write the GUIDs looks right.

Hi Lucas,


We are further investigating this issue at our end and will soon share our findings with you here. We are sorry for the delay incurred in this regard.

Hi Kashif,

Do you have some news about this issue?
I'm still getting this problem and it's impeditive for my project.

If I save the file with MPP Aspose, every time I open and save the file in MS Project all Tasks's GUID are recalculated and changed.

Thanks.

Hi Lucas,


We have further investigated the issue and following are the findings.

  1. Open your Projeto1.mpp file in Microsoft Project (MSP) 2010 and just save it back with some other name. Now open both the MPP files and you will observe that GUIDs are different.
  2. Open your Projeto1.mpp in MSP 2013 and save it with some other name. Now open the newly saved MPP file and you will observe that all the GUIDs are changed similar to the GUIDs in the image sent by you here. Sometimes all the GUIDs contain similar values which is completely wrong behavior.
  3. Open the Projeto1.mpp file using Aspose.Tasks and save it with some other name as shown in the above sample code. Open the saved file in MSP 2010 and you will see that all the GUIDs are maintained which is the expected behavior.
  4. Open the saved file by Aspose.Tasks in MSP 2013 and you will see entirely wrong GUIDs similar to the output in point 2 above.

Here we can see that MSP 2013 has strange issues while saving the MPP file and opening the re-saved file. As Aspose.Tasks is behaving fine while re-saving the MPP, therefore it is not an issue with the library but an un-expected behavior of MSP 2013. You may please check the Microsoft respective support forums for solution to any such issue.

Hi Muhammad,


I’ve tested what you said and it’s right.
When I “save as” a file all the task’s GUID are recalculated.

The issue is that I’m not saving other file with Aspose.Tasks, I’m just reading and updating a same .MPP file. But when I do this and then open in MS Project, all the task’s GUID are changing (just like ‘save as’).

There’s no property being set wrong at “prj.Save” function?

Hi Lucas,


You can save the updated file again with the same name. Now open this updated file in MSP 2010 and you will find that all the GUID values are same as in the original MPP file. However you may get wrong result in MSP 2013 which is beyond our control.

Please let us know if we can provide any other assistance in this regard.
Hi Muhammad,

As you said, if I open a MPP file and save it in MS Project with "save" menu, the task's GUID are not recalculated.
I just wanna do this with Aspose. How can I do this?

Thanks.

Hi Lucas,

In our discussion here in point 1 and 2, I shared that if we open MPP in MSP 2010 or 2013 and save it back on disc again, the GUIDs are changed.

In the same post, I mentioned in point 3 that if we read the MPP file using Aspose.Tasks and then save back with the same name, the GUIDs are SAME in original as well in saved MPP.

I could not understand your following comments in this regard and request you to test the scenario again:

Lucas Sepe:
As you said, if I open a MPP file and save it in MS Project with "save" menu, the task's GUID are not recalculated.

For clarification, I am again attaching the images where "OriginalMppInMsp2010.png" is the image of original MPP file.

Second image is "MppSavedByMsp2010.png" which shows that GUIDs are CHANGED while MPP is saved again by MSP 2010.

Finally the third image "OriginalMppSavedByAsposeTasks_8.1.0.png" shows the MPP which is read and saved back by Aspose.Tasks for .NET 8.1.0 and it can be seen that GUIDs are UNCHANGED.

Lucas Sepe:
I just wanna do this with Aspose. How can I do this?

It seems that your above requirement is already fulfilled by Aspose.Tasks. Please write us back if you have any other query related to Aspose.Tasks.

Hi Muhammad,


A task’s GUID are recalculated in MS Project only if I save a file with function’s “save as” , with another filename or no. If I open a MS Project file, update some data and save with same filename (function “save”) the task’s GUID are the same.

How can I do it in Aspose.Tasks.? Save a same file (not “save as”) and preserve GUIDs.

I tried to do some logic using other extended attribute, but a ExtendedAttribute.ValueGuid are always null. Can’t I manipulate that data?

Thanks.

Hi Lucas,


At present, there is no such option available in Aspose.Tasks API for differentiating between “Save” and “Save As” behavior of MSP 2013 in this case. I have
logged this issue in our issue tracking system for analysis by the
development team as TASKS-33937. You will be automatically notified, once any update is
available in this regard.

Hi José,


We have investigated this issue at our end, however, no specific reason for the cause could be found. However, the same purpose can be achieved by saving the task’s GUID in one of the task’s custom text fields as shown in the code sample below. Please try it at your end and share your feedback with us.

Code:

static void CheckGuidIssue()<o:p></o:p>

{

new License().SetLicense(@"Aspose.Tasks.lic");

Project project = new Project("Projecto1.mpp");

ChildTasksCollector coll = new ChildTasksCollector();

TaskUtils.Apply(project.RootTask, coll, 0);

ExtendedAttributeDefinition customField =

project.ExtendedAttributes.FirstOrDefault(x => x.FieldId.Equals(ExtendedAttributeTask.Text10.ToString("D")));

if (customField == null)

{

customField = CreateCustomField();

project.ExtendedAttributes.Add(customField);

}

customField.Alias = "Persistent GUID";

foreach (Task task in coll.Tasks)

{

ExtendedAttribute attr =

task.ExtendedAttributes.FirstOrDefault(x => x.FieldId.Equals(customField.FieldId));

if (attr == null)

{

attr = customField.CreateExtendedAttribute();

attr.Value = task.Get(Tsk.Guid);

task.ExtendedAttributes.Add(attr);

}

}

project.Save("saved.mpp", SaveFileFormat.MPP);

}

private static ExtendedAttributeDefinition CreateCustomField()

{

ExtendedAttributeDefinition field = new ExtendedAttributeDefinition();

field.FieldId = ExtendedAttributeTask.Text10.ToString("D");

return field;

}

Hi José,

Your concerns are valid and we already have requested further information about the possible rectification of the issue via API. We’ll update you here as soon as some feedback is available in this regard.

Hi José,


Sure. We shall update you here as soon as the product team’s feedback is available in this regard.

Hi José,

Thank you for being patient in this regard.

Our product team has investigated this issue further. Unfortunately, the issue can’t be fixed in near future. One thing is that Task’s Unique ID (UID) is persistent when “Save As” options is used and the combination of this UID and project file path can be a primary key in client’s database. Thus, this combination can also be used to preserve the task uniqueness with both “save” and “save as” operation for any project file on the client machine and can be used as a workaround for this issue.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.