gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 19:23:33 25 4
gpt4 key购买 nike

我有一个 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.**"
}

最佳答案

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

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

关于wpf - 我们如何使用 Mycrosoft Sync Framework 2.0 推迟 SQL Express DB 作为客户端和 SQL Server 作为服务器的冲突解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13840274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com