Programmatically Removing Items from Compare Result

With some basic C# code in Project Automation we can automatically remove items from the sync

Using the Project Automation feature you and intercept the comparison results and disable items for synchronisation by setting the Sync property false. This has the same effect as un-checking items in the Data Sync UI manually. With some basic C# code in Project Automation we can automatically remove items from the sync where there is only 1 change the Updated field in this example. In this case we need at least 2 columns to have changed to send the results to the server.

Compare Result

The code below looks at the Updated items collection after the comparison phase and before the synchronisation. The Row collection lists the changed columns for the row we use this to decide whether to disable the item for synchronisation.

public override void BeforeSynchronisation(ProjectAutomationCompareResult compareResult)
    {
        //Disable Update on all Items where there is only 1 change i.e. Date Modified
        compareResult.Updated.Where(i => i.Row.Count == 1).ToList().ForEach(i => i.Sync = false);
    }

The Complete Project Automation Code is below.

#region Usings
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Text;
using System.Linq;
using Simego.DataSync;
#endregion

/// <summary>
/// </summary>
class ProjectAutomationOverride : Simego.DataSync.Automation.ProjectAutomationShim //Do Not Change This Line
{    
    
    public override void Start()
    {
        
    }

    public override void BeforeCompare(ProjectAutomationLoadResult loadResult)
    {

    }

    public override void BeforeSynchronisation(ProjectAutomationCompareResult compareResult)
    {
        //Disable Update on all Items where there is only 1 change i.e. Date Modified<
        compareResult.Updated.Where(i =>; i.Row.Count == 1).ToList().ForEach(i =>; i.Sync = false);
    }

    public override void End(ProjectAutomationResult result)
    {
        
    }

    public override void Error(ProjectAutomationException e)
    {
        
    }

}


Can't find the answers you're looking for? Contact our support team and we'll personally get back to you as quickly as we can.