如何使用Microsoft Sync Framework 2.0在以SQL Server为服务器和SQL Express DB为客户端的情况下推迟冲突解决?

3
我有一个 SQL Express 数据库作为本地服务器,还有一个 SQL Server 数据库作为远程服务器。我正在使用 SyncOrchestrator 同步代理进行冲突解决。每当出现冲突时,我希望将其存储起来,以便稍后获取所有冲突并逐个解决。但是 ApplyAction 枚举没有类似于 "SkipChange" 或 "Defer" 的任何值。
请指导。
以下是代码: private void btnSync_Click(object sender, RoutedEventArgs e) { SqlConnection clientConn = new SqlConnection(connectionstring1); }
        SqlConnection serverConn = new SqlConnection(connectionstring2);

        // create the sync orhcestrator
        SyncOrchestrator syncOrchestrator = new SyncOrchestrator();


        SqlSyncProvider localProvider = new SqlSyncProvider("Scope1", clientConn);
        SqlSyncProvider remoteProvider = new SqlSyncProvider("Scope2", serverConn);

        // set local provider of orchestrator to a sync provider associated with the 
        // ProductsScope in the SyncExpressDB express client database
        syncOrchestrator.LocalProvider = localProvider;

        // set the remote provider of orchestrator to a server sync provider associated with
        // the ProductsScope in the SyncDB server database
        syncOrchestrator.RemoteProvider = remoteProvider;

        // set the direction of sync session to Upload and Download
        syncOrchestrator.Direction = SyncDirectionOrder.DownloadAndUpload;

        // subscribe for errors that occur when applying changes to the client
        ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);

        // execute the synchronization process
 SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();             

        MessageBox.Show("Synchronization of Table1 Completed");

        BindClientTables();
        BindServerTables();
        }

    private void btnServerData_Click(object sender, RoutedEventArgs e)
        {
        BindServerTables();
        }

    private void btnClientData_Click(object sender, RoutedEventArgs e)
        {
        BindClientTables();
        }

    static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
        {
        "**Here I want to defer the Resolution for future.**"
        }
1个回答

0

如果您想跳过...,则应将RetryNextSync指定为操作。

我建议您不要推迟解决冲突的时间太长...如果您推迟了它并且用户继续更新行,则在您循环遍历它们以解决冲突时,您遇到冲突时存储的行可能已经发生了更改...


我希望冲突能够被存储,并在管理员登录时由管理员解决。用户将无权解决冲突,只能提出冲突......这是业务需求。 - Kaustav Chakraborty

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接