User Guide

Values Service

The Values service provides a way to read and save a simple value into a persistent backing store. This is really useful in Project Automation where you can update the Data Connection configuration properties from this store at runtime.

The Ouvvi Store uses the Ouvvi User Settings which allow you to easily view and update the setting values from Ouvvi. To use an Ouvvi Instance set the URL in Ouvvi System Settings for the Value Store Service to point to Ouvvi Instance URL.

Example getting a LastSyncTime value from an Ouvvi Value Store Service, where the value doesn't exist a default value is returned.

var startDate = ValueStoreService.GetValue<DateTime>("LastSyncTime", DateTime.Today.AddYears(-10));

Using the Default Store requires a GUID value to isolate your values from other users.

string AppID = "{903A4B0A-586D-4666-95F4-EB858DBEF1F3}";
var startDate = ValueStoreService.GetValue<DateTime>(AppID, "LastSyncTime", DateTime.Today.AddYears(-10));

In this example we are using the Value Store Service to adjust the Dynamics CRM Fetch XML Filter Expression for an Incremental Sync based on the last successful synchronisation time.

class ProjectAutomationOverride : Simego.DataSync.Automation.ProjectAutomationShim
{    
    private string AppID = "{903A4B0A-586D-4666-95F4-EB858DBEF1F3}";
    private string AppKey = "AccountsSync1";

    private DateTime SinceValue;
    private DateTime StartValue = DateTime.UtcNow;
    
    public override void Start()
    {
        SinceValue = ValueStoreService.GetValue(AppID, AppKey, DateTime.Today.AddYears(-1));
        
        DataSourceA.FetchXmlFilterExpression = DataSourceA.GetFetchFilterXmlForModifiedSince(SinceValue);
    }    
    public override void End(ProjectAutomationResult result)
    {
        if(result.Success && result.HasChanges)
        {
            ValueStoreService.SetValue(AppID, AppKey, StartValue);    
        }
    }
}