我们如何推迟SQL Express DB的冲突解决方案作为Client& SQL Server作为使用Mycrosoft Sync Framework 2.0的服务器

时间:2012-12-12 12:54:50

标签: wpf sql-server-express microsoft-sync-framework

我有一个SQL Express DB作为本地服务器& SQL Server DB作为远程服务器。我正在使用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 :(得分:0)

如果要跳过,请指定RetryNextSync作为操作...

我建议你不要长时间推迟解决方案...如果推迟它并且用户继续更新行,那么当你遇到冲突时你已经存储的行已经在你循环它们时已经改变了解决冲突......