Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active September 3, 2021 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/40d82603d1b3f12f68f5fe614ae2835c to your computer and use it in GitHub Desktop.
Save aspose-cloud/40d82603d1b3f12f68f5fe614ae2835c to your computer and use it in GitHub Desktop.
Code snippets for converting MPP files to Primavera P6 XER using C#
Code snippets for converting MPP to Oracle Prmavera P6 XER using Aspose.Tasks Cloud SDK For .NET
// Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "caac6e3d4a4724b2feb53f4e460eade3";
string clientID = "4ccf1790-accc-41e9-8d18-a78dbb2ed1aa";
// create a configuration object
var config = new Configuration{ AppSid= clientID, AppKey = clientSecret };
// initialize Aspose.Tasks object
var tasksApi = new TasksApi(config);
String inputFile = "Home move plan.mpp";
String resultant = "Output.xer";
try
{
// read the input MPP file from local storage
using (var inputStream = new FileStream("/Users/nshahbaz/Downloads/" + inputFile, FileMode.Open))
{
var uploadFileRequest = new PostCreateRequest(inputFile, inputStream);
// upload the file to cloud storage
tasksApi.UploadFile(uploadFileRequest);
}
// initialize the MPP to XER conversion process
var response = tasksApi.GetTaskDocumentWithFormat(new GetTaskDocumentWithFormatRequest
{
Format = Aspose.Tasks.Cloud.Sdk.Model.ProjectFileFormat.Xer,
Name = inputFile,
Folder = null,
});
if (response != null )
{
Console.WriteLine("Successfully converted MPP to XER !");
}
// save the resultant file on local drive
saveToDisk(response, "/Users/nshahbaz/Downloads/" + resultant);
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
public static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment