2017-12-10 19 views
0

私はXamarin.iOSアプリケーション用にAzure Mobile Servicesを使用しています。バックエンドとクライアント側の両方にApp Serviceを設定しているので、アプリにアカウントを正常に登録し、バックエンドの各テーブルのエントリを確認することができます。Azure Mobileサービス - IMobileServiceSyncTable PullAsyncはローカル同期テーブルを埋めません

ただし、ローカルテーブルを作成するときに、PullAsyncへの呼び出しを使用すると、クエリのフィルタを使用せずに、そのテーブルのすべてのレコードを返すときでも、同期テーブルは常に空です。

例外がない場合でも、なぜPullAsyncに同期テーブルが設定されないのかわかりません。

以下は私のコードです:

右新規ユーザの登録が成功した後、ローカル・ストア

public class AzureMobileClientServiceDataManager : IAzureMobileClientServiceDataManager, IMobileServiceSyncHandler 
{ 

    const string localDbPath = "sample.db"; 
    MobileServiceSQLiteStore store; 

    MobileServiceClient client { get; set; } 

    public AzureMobileClientServiceDataManager(IAzureMobileClientService azureMobileClientService) 
    { 
     CurrentPlatform.Init(); 

     SQLitePCL.CurrentPlatform.Init(); 

     //Initialize the Mobile service client with the Mobile App URL,Gatewaty URL and Key 
     client = azureMobileClientService.GetMobileServiceClientInstance(); 
    } 

    public async Task InitializeStoreAsync() 
    { 
     store = new MobileServiceSQLiteStore(localDbPath); 
     store.DefineTable<Account>(); 
     store.DefineTable<UserProfile>(); 
     store.DefineTable<Purchase>(); 

     await client.SyncContext.InitializeAsync(store, this); 

    } 

    public MobileServiceClient GetInstance() 
    { 
     return client; 
    } 

    public Task OnPushCompleteAsync(MobileServicePushCompletionResult result) 
    { 
     foreach (var error in result.Errors) 
     { 
      Console.WriteLine("Error :" + error.RawResult); 
     } 

     return Task.FromResult(0); 
    } 

    public Task<JObject> ExecuteTableOperationAsync(IMobileServiceTableOperation operation) 
    { 
     return operation.ExecuteAsync(); 
    } 
} 

public interface IAzureMobileClientServiceDataManager 
{ 
    Task InitializeStoreAsync(); 

    MobileServiceClient GetInstance(); 

} 

の初期化、私は私のテーブルを埋めるために、この関数を呼び出します。

public async Task<Result<bool>> PopulateData() 
    { 
     try{ 

     await accountTable.PullAsync("localAccount", accountTable.Where(ac => ac.Id == mobileServiceClient.CurrentUser.UserId)); 
     await userProfileTable.PullAsync("localUserProfile", userProfileTable.Where(up => up.AccountId == mobileServiceClient.CurrentUser.UserId)); 


     return Result<bool>.Success(true); 

    }catch(Exception ex) 
     { 
      return Result<bool>.Failure(ex, ex.StackTrace); 
     } 

    } 

答えて

0

表ごとにアキュラタマニアマネージャーがいますか?もしそうなら、あなたは問題にぶつかります。 MobileServiceClientはグローバルであるため、毎回テーブルを再初期化するので、複数のテーブルの問題にぶつかります。

また、すべてのローカルデータベースステートメントをログに記録するアプリケーションにロギングSQLiteストアを追加してみてください。ここにサンプルがあります:https://github.com/Azure-Samples/app-service-mobile-dotnet-todo-list-files/blob/master/src/client/MobileAppsFilesSample/Helpers/LoggingHandler.cs

関連する問題