0

私はこのシステムがどのように機能するかを理解する任務を負っていましたが、これらの問題に関してはほとんど初心者なので、親切にしてください.

テスト用のサンプル DB と同期して実行しています。私は Visual Studio を使用しており、C# を使用しています。以下は、現在の同期用プロビジョニングのコードです。

        // define a new scope named ProductsScope
        DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("ProductsScope");

        // get the description of the Products table from SyncDB dtabase
        DbSyncTableDescription tableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("Products", serverConn);

        // add the table description to the sync scope definition
        scopeDesc.Tables.Add(tableDesc);

        // setting my provision

        // create a server scope provisioning object based on the ProductScope
        SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc);

        // skipping the creation of table since table already exists on server
        serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);

        // start the provisioning process
        serverProvision.Apply();

そして、これが同期用の私のコードです。

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

        // set local provider of orchestrator to a CE sync provider associated with the 
        // ProductsScope in the SyncCompactDB compact client database
        syncOrchestrator.LocalProvider = new SqlSyncProvider("ProductsScope", clientConn);

        // set the remote provider of orchestrator to a server sync provider associated with
        // the ProductsScope in the SyncDB server database
        syncOrchestrator.RemoteProvider = new SqlSyncProvider("ProductsScope", serverConn);

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

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

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

        //


        // this will show me the statistics after sync
        Console.WriteLine("Start Time: " + syncStats.SyncStartTime);
        Console.WriteLine("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
        Console.WriteLine("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
        Console.WriteLine("Complete Time: " + syncStats.SyncEndTime);
        Console.WriteLine(String.Empty);}

        static void Program_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)

{

この時点で、同期はデータ行の完全な再書き込みです。私が探しているのは、個々の列に加えられた変更を認識するように同期を設定するためのちょっとした指示です (それが正しいかどうかはわかりません)。

たとえば、次の場合:

Column   ID (PK)    Name        Phone      Address
 Row     1          John Smith  555-5555   123 Anywhere St
 Row     2          Jane Smith  555-5555   124 Anywhere St

営業担当者 1 は行 1 の住所を 125 Anywhere に変更し、営業担当者 2 は行 1 の電話番号を 555-5556 に変更します。私の最終結果が両方の営業担当者になるように、変更の追跡対象を設定する方法はありますか?持つ:

Column   ID (PK)  Name        Phone     Address
Row      1        John Smith  555-5556  125 Anywhere St
Row      2        Jane Smith  555-5555  124 Anywhere St

同期が完了した後。私が現在言ったように、それは行全体を取り、最後にあったものに書き換えます。複数のユーザーが同じレコードに変更を加えると、正しく処理されません。

これは、スコープと追跡の設定方法に関係していると確信していますが、Google は何の回答も得ていません。切り取り、リンク、または提案は素晴らしいでしょう。

4

1 に答える 1