0

n 層の同期ソリューションを構築する方法を研究しています。WebSharingAppDemo-CEProviderEndToEnd サンプルからはほぼ実行可能に見えますが、何らかの理由で、クライアントがライブ SQL データベース接続を持っている場合にのみアプリが同期されます。不足しているものと、SQL をインターネットに公開せずに同期する方法を説明できますか?

私が経験している問題は、クライアントからの開いている SQL 接続を持つリレーショナル同期プロバイダーを提供すると正常に動作しますが、例のように、閉じているが構成された接続文字列を持つリレーショナル同期プロバイダーを提供すると、 、サーバーがバッチ ファイルを受信しなかったことを示すエラーが WCF から表示されます。それで、私は何を間違っていますか?

  SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
  builder.DataSource = hostName;
  builder.IntegratedSecurity = true;
  builder.InitialCatalog = "mydbname";
  builder.ConnectTimeout = 1;
  provider.Connection = new SqlConnection(builder.ToString());

  // provider.Connection.Open();  **** un-commenting this causes the code to work**

  //create anew scope description and add the appropriate tables to this scope
  DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(SyncUtils.ScopeName);

  //class to be used to provision the scope defined above
  SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning();

....

私が得るエラーは、WCF コードのこの部分で発生します。

public SyncSessionStatistics ApplyChanges(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeData)
{
  Log("ProcessChangeBatch: {0}", this.peerProvider.Connection.ConnectionString);

  DbSyncContext dataRetriever = changeData as DbSyncContext;

  if (dataRetriever != null && dataRetriever.IsDataBatched)
  {
    string remotePeerId = dataRetriever.MadeWithKnowledge.ReplicaId.ToString();
    //Data is batched. The client should have uploaded this file to us prior to calling ApplyChanges.
    //So look for it.
    //The Id would be the DbSyncContext.BatchFileName which is just the batch file name without the complete path
    string localBatchFileName = null;
    if (!this.batchIdToFileMapper.TryGetValue(dataRetriever.BatchFileName, out localBatchFileName))
    {
      //Service has not received this file. Throw exception
      throw new FaultException<WebSyncFaultException>(new WebSyncFaultException("No batch file uploaded for id " + dataRetriever.BatchFileName, null));
    }
    dataRetriever.BatchFileName = localBatchFileName;
  }

何か案は?

4

2 に答える 2

0

単なる馬鹿げた例だと思います。「いくつかの」テクニックを公開していますが、自分で適切な順序で配置する必要があることを前提としています。

http://msdn.microsoft.com/en-us/library/cc807255.aspx

于 2010-03-29T08:08:53.020 に答える
0

バッチ ファイルが利用できない問題については、IRelationalSyncContract.UploadBatchFile から IsOneWay=true 設定を削除します。バッチ ファイルのサイズが大きい場合、前の UploadBatchfile が完全に完了する前であっても、ApplyChanges が呼び出されます。

//
[OperationContract(IsOneWay = true)] を置き換えます

//
[OperationContract] を使用して void UploadBatchFile(string batchFileid, byte[] batchFile, string remotePeer1

于 2010-03-05T13:01:21.877 に答える