我们如何使用 Mycrosoft Sync Framework 2.0 推迟将 SQL Express DB 作为客户端和 SQL Server 作为服务器的冲突解决

Posted

技术标签:

【中文标题】我们如何使用 Mycrosoft Sync Framework 2.0 推迟将 SQL Express DB 作为客户端和 SQL Server 作为服务器的冲突解决【英文标题】:How can we defer conflict resolution for SQL Express DB as Client & SQL Server as Server using Mycrosoft Sync Framework 2.0 【发布时间】:2012-12-12 12:54:50 【问题描述】:

我有一个 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】:

如果你想跳过,你应该指定 RetryNextSync 作为动作......

我建议您不要将解决方案推迟那么久...如果您推迟它并且用户继续更新行,那么您在遇到冲突时存储的行在您遍历它们时已经改变了解决冲突...

【讨论】:

我希望在登录时存储冲突并让经理解决冲突。用户将无权解决冲突,只能提出冲突......这是业务需求。

以上是关于我们如何使用 Mycrosoft Sync Framework 2.0 推迟将 SQL Express DB 作为客户端和 SQL Server 作为服务器的冲突解决的主要内容,如果未能解决你的问题,请参考以下文章