2016-04-13 13 views
0

このオフライン同期クライアントの実行に問題はありませんでした。今は何も引っ張っていないと私は私の人生のために理由を理解することはできません!クライアントの同期コードは次のとおりです。Azureオフライン同期プルなしなし

private async Task InitLocalStoreAsync() 
    { 
     if (!App.MobileService.SyncContext.IsInitialized) 
     { 
      var store = new MobileServiceSQLiteStore("localstore.db"); 
      store.DefineTable<clist>(); 
      await App.MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler()); 
     } 

     await SyncAsync(); 
     await RefreshNcards(); 

    } 
    private async Task SyncAsync() 
    { 
     String errorString = null; 
     PullOptions pageSize = new PullOptions { MaxPageSize =1000 }; 

     try 
     { 
      await LocalCards.PullAsync("clist", LocalCards.CreateQuery(),pullOptions:pageSize); // first param is query ID, used for incremental sync 
     } 

     catch (Exception ex) 
     { 
      errorString = "It look's like we weren't able to make sure your cards were updated. No worries, next time you start the app we will try again. This won't impact your experience."; 

      // errorString = "Pull failed: " + ex.Message + 
      //  "\n\nIf you are still in an offline scenario, " + 
      //  "you can try your Pull again when connected with your Mobile Serice."; 
     } 

     if (errorString != null) 
     { 
      MessageDialog d = new MessageDialog(errorString); 
      await d.ShowAsync(); 
     } 
    } 

このコードは、エラーがスローされずに移動する数秒間一時停止します。

class clist : INotifyPropertyChanged 
{ 

    public event PropertyChangedEventHandler PropertyChanged; 
    [JsonProperty(PropertyName ="id")] 
    public string id { get; set; } 

    [JsonProperty(PropertyName = "_createdAt")] 
    public DateTime _createdAt { get; set; } 

    [JsonProperty(PropertyName = "_updatedAt")] 
    public DateTime _updatedAt { get; set; } 

    [JsonProperty(PropertyName = "_version")] 
    public DateTime _version { get; set; } 
    public bool _deleted { get; set; } 
    [JsonProperty(PropertyName = "Nid")] 
    public string Nid { get; set; } 

    [JsonProperty(PropertyName = "Nname")] 
    public string Nname { get; set; } 

    [JsonProperty(PropertyName = "Nset")] 
    public string Nset { get; set; } 

    public void RaisePropertyChanged(string name) 
    { 
     if (PropertyChanged != null) 
     { 
      PropertyChanged(this, new PropertyChangedEventArgs(name)); 
     } 
    } 
} 

ここで役立つのは、Azureポータルでログを記録するときのログストリームです。

2016年4月13日午前4時36分05秒〜1MAGICHUB POSTは/ dev/API /イベント/ wwwrootに/ longpoll X-ARR-LOG-ID = d9ceb9a8-433f-4a23-a4ab-3caf984cb8e8 443 - 172.103.28.93 Mozillaの/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/46.0.2486.0+Safari/537.36+Edge/13.10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522131849 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 914 1625 11874 2016 -04-13 04:36:26〜1MAGICHUB POST/dev/api/events/wwwroot/longpoll X-ARR-LOG-ID = 159b6aa0-df2e-46a8-8a24-d0a0086acdaf 443-172.103.28.93 Mozilla/5.0 +(Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like Gecko)+ Chrome/46.0.2486.0 + Safari/537.36 + Edge/13.10586 ARRAff inity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522152216 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1626 20039 2016-04-13 04:36:46〜1MAGICHUB POST/dev/api/events/wwwroot/longpoll X-ARR-LOG-ID = e7c12e75-54a8-4be3-9e66-7399635657f6 443 - 172.103。 28.93 Mozilla/5.0 +(Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like Gecko)+ Chrome/46.0.2486.0 + Safari/537.36 + Edge/13.10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522164231 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1625 20065 2016-04-13 04:37:06〜1MAGICHUB POST/dev/api/events/wwwroot/lon gpoll X-ARR-LOG-ID = c78b53c1-15d8-491b-8c6b-22d8239fd920 443 - 172.103.28.93 Mozilla/5.0 +(Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like + Gecko)+ Chrome/46.0.2486.0 + Safari/537.36 + Edge/13.10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522184449 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1625 20027 2016-04-13 04:37:26〜1MAGICHUB POST/dev/api/events/wwwroot/longpoll X-ARR- (+ Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like + Gecko)+ Chrome /46.0.2486.0+Safari/537.36+Edge/13.10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_sessi on = R6FJD | 1460519240333 | 1460522204509 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1625 20052 2016-04-13 04:37:46〜1MAGICHUB POST/dev/api/events/wwwroot/longpoll X-ARR-LOG (Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like + Gecko)+ Chrome/46.0.2486.0 +サファリ/ 537.36 +エッジ/ 13.10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522224587 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1625 20023 2016-04-13 04:38:06〜1MAGICHUB POST/dev/api/events/wwwroot/longpoll X-ARR-LOG-ID = f715514e- f0aa-4299-950a-88b1884d89bf 443 - 172.103.28.93 Mozilla/5.0 +(Windows + NT + 10.0; + Win64; + x64)+ AppleWebKit/537.36 +(KHTML、+ like Gecko)+ Chrome/46.0.2486.0 + Safari/53 7.36 +エッジ/ 13。10586 ARRAffinity = 6910fd768a90c2d11e23085af4d93c48a8cc9617be87c545bc1e82b0186ea1da; + __ RequestVerificationToken = ded78fdc-d9b2-49ad-bb5b-3a791b4a6886; + ai_user = 3MLsg | 2016-04-13T03:47:20.208Z; + ai_session = R6FJD | 1460519240333 | 1460522244667 https://magichub.scm.azurewebsites.net/dev/wwwroot/tables/clist.js magichub.scm.azurewebsites.net 200 0 0 584 1625 20056 2016-04-13 04:38:13 MAGICHUB GET/tables/clist $ filter =(updatedAt%20ge%20datetimeoffset'1970-01-01T00%3A00%3A00.0000000%2B00%3A00 ') & $ orderbyの= updatedAt & $スキップ= 0 & $トップ= 1000 & __includeDeleted =真& $フィルタ=(%の20GEの%20datetimeoffset'1970-01-01T00%3A00%3A00.0000000%2B00%updatedAt 3A00' )& $ orderbyの= updatedAt & $ skip = 0 & $ top = 1000 & __includeDeleted = true & X-ARR-LOG-ID = c6b2681c-2dbe-4452-8c49-367343c36655 443 - 172.103.28.93 ZUMO/2.0 +(lang = Managed; + os = Windows + Store; + os_version = - ; + arch = X64; + version = 2.0.31125.0) - - magichub.azurewebsites.net 200 0 0 695 1286 93

なぜこれがうまくいかないのか完全に困惑しています。だれでも私が犯人を絞り込み、この作業!

答えて

2

モデルにいくつかのエラーがあります。

システムプロパティはcreatedAt,updatedAtとする必要があります。これ以上アンダースコアはありません。 versionフィールドは、DateTimeではなく文字列でなければなりません。 Idフィールドは大文字にする必要があります。

キャッシュプッシュを実行するPullAsyncに依存しています。あなたは実際にそれについて明示し、PushAsync()を実行する必要があります。

LocalCardsの定義を指定していませんが、それがIMobileServiceSyncTable<clist>client.GetSyncTable<clist>()で取得)のインスタンスであることを確認してください。

+0

AzureポータルでTodoリストのクイックスタートを使い始めると、実際のサンプルが得られ、特定のデータモデルで調整することができます。 リクエストのデバッグに役立つFiddlerの使用またはロギングハンドラの追加もお勧めします。[このサンプルLoggingHandler](https://github.com/Azure-Samples/app-service-mobile-dotnet-todo-list-files)を参照してください。 /blob/master/src/client/MobileAppsFilesSample/Helpers/LoggingHandler.cs#L63)。 –

関連する問題