Select to view content in your preferred language

How to retrieve the target version of a reconcile action (using EditCompletedEvent or other)

262
1
05-08-2024 08:15 AM
MarcusPolivirus
Occasional Contributor

Hello,

ArcGIS Pro : 2.9.6

DB : Oracle : 12.2.0.1

Sde connection

Traditionnal versionning

I'm using EditCompletedEvent to capture the reconcile event and to identify the changes (differences) that happened.

I would like to know how to retrieve the target version of the reconcile. Or how to replace the Reconcile popup with another one.

MarcusPolivirus_1-1715179794374.png

I want to avoid to reconcile in Default since there is a lot of users and it is a very slow process.

default => departmentA => service1 => userAlpha

default => departmentA => service2 => userAlpha

default => departmentB => service1 => userAlpha

The ideal, version userAlpha should be reconcile to "service" level only.

The code I'm using for now: (since I don't know witch version was choose I'm using the Default)

 

protected override Task EditCompletedEventExecuted(EditCompletedEventArgs args)
{            
    switch (args.CompletedType)
    {
        case EditCompletedType.Post:
            LogEvent(args);
            HandlePostEvent();
            break;
        case EditCompletedType.Reconcile:
            LogEvent(args);                    
            HandleReconcileEvent(args);
            break;
    }

    return Task.CompletedTask;
}

protected void HandleReconcileEvent(EditCompletedEventArgs args)
{
    var startTick = Environment.TickCount;
    
    foreach (var mapMember in args.Members)
    {                
        var tableName = mapMember.GetNameInDatabase();
        if (_dictionaryOfParamElements.ContainsKey(tableName))
        {
            _dictionaryOfParamElements[tableName].Clear();
            VersionChangesService.CheckDifferences(
                mapMember,
                _dictionaryOfParamElements);
        }
    }
    
    var endTick = Environment.TickCount;
    Log.Information($"HandleReconcileEvent en {endTick - startTick}");
}

private static void GetDifferences(
    Datastore store,
    Table currentTable,
    Dictionary<string, ItemElement> itemToFollow)
{
    if (store is Geodatabase geoDatabase)
    {
        using (var versionManager = geoDatabase.GetVersionManager())
        using (var currentVersion = versionManager.GetCurrentVersion())
        using (var tableDefinition = currentTable.GetDefinition())
        using (var defaultVersion = Utils.GetDefaultVersion(geoDatabase))
        using (var defaultGdb = defaultVersion.Connect())
        using (var defaultFc = defaultGdb.OpenDataset<Table>(currentTable.GetName()))
        {
            Log.Information($"Default version name {defaultVersion.GetName()}");
            Log.Information($"Current version name {currentVersion.GetName()}");                    

            var tableName = tableDefinition.GetName();
            var userName = geoDatabase.GetUserName();

            if (itemToFollow.ContainsKey(tableName))
            {
                HistorizationService.Instance.CheckNewFieldsExists(Utils.GetTempoLayerNameFromFClassName(tableName));

                // CREATE
                var cursor = currentTable.Differences(defaultFc, DifferenceType.Insert);

 

Best regards,

Marc

 

0 Kudos
1 Reply
Aashis
by Esri Contributor
Esri Contributor

Have you looked into the ReconcileDescription? You can set your target version to reconcile in it. If a target version is not provided, reconcile always performs at the default version.

0 Kudos