Skip to main content

Output Change Set as XML

The change set data that is generated by Data Sync when you run the comparison between your source and target can be output as a file in two ways:

  • Using the Export Options from the Compare Results tab
  • Using Project Automation to create and save the file locally

Quick Export

If you want to export the changeset data on an ad-hoc basis then making use of the export options within the compare window is the quickest route.

Run the compare between your source and target to open the Comparison Results tab. Then, in the toolbar, choose between Export Results and Export Results XML.

Export Results will export the changeset data as an Excel file and Export Results XML will export the changeset data as an XML file.

Export Options - Compare Results

Project Automation

If you want the changeset data to be exported each time the project runs, then you can make use of Project Automation to automatically output the changeset results to an XML file locally. The code below shows how you can export the results to an XML file each time the project completes :

public override void End(ProjectAutomationResult result)
{
if(result.HasChanges)
{
result.CompareResult.GetChangeSetSerializer().WriteXml(string.Format("ChangeSet-{0}.xml", Environment.TickCount));
}
}

Export Only when Run from Run Tool

If you want to write the changeset data (compare results) from a Data Sync project to a file when a project is run from the Run Tool or via Task Scheduler, you can do so with the code below:

public override void AfterCompare(ProjectAutomationCompareResult compareResult)
{
if(compareResult.HasChanges && !IsInteractive)
{
var instanceID = Properties["Auto_InstanceID"] ?? "0";
compareResult.GetChangeSetSerializer().WriteXml($"./.ds/logs/{instanceID}-ChangeSet.xml");
}
}

This writes the changeset data to an XML file in the DS logs folder and pulls the instance ID from the Run Tool into the file name.

If it is run from the Data Sync designer it will not write the change set to the file (as you can see the results in Data Sync and export them manually) but if it is running from the Run Tool then it will create the file and write the results.