2016-04-13 30 views
0

Bu çevrimdışı senkronizasyon istemcisinin çalışmasıyla ilgili sorunlardan başka bir şey yapmadım. Şimdi hiçbir şey çekmiyor ve benim için hayatımı neden yapamayacağımı anlayamıyorum!Azure Çevrimdışı Senkronizasyon Hiçbir Şey Çeker

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(); 
     } 
    } 

Bu kod atılan hatasız üzerine hamle daha birkaç saniye duraklar: Burada istemci üzerinde benim senkronizasyon kodudur.

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)); 
     } 
    } 
} 

Sadece vaka ben Azure Portal giriş çalıştırmak zaman olsun günlük akışları vardır burada eski faydalı içinde: İşte benim sınıftır. 172.103.28.93 Mozilla -

2016-04-13 04:36:05 ~ 1MAGICHUB POST/dev/API/etkinlik/wwwroot/longpoll X-arr-LOG-ID = d9ceb9a8-433f-4a23-a4ab-3caf984cb8e8 443 /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 | 14.05.2013. -04-13 04:36:26 ~ 1MAGICHUB POST/dev/api/olaylar/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) + Krom/46.0.2486.0 + Safari/537.36 + Kenar/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 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, + benzeri + Gecko) + Krom/46.0.2486.0 + Safari/537.36 + Kenar/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, + gibi + Gecko) + krom/46.0.2486.0 + Safari/537,36 + Kenar/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/olaylar/wwwroot/longpoll X-ARR- LOG-ID = a5e45861-bedd-4162-bc88-373306825e85 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_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/olaylar/wwwroot/longpoll X-ARR-LOG -ID = 90f17ac1-2516-4bf8-ba9b-470fa1bf7748 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 + Kenar/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 + Kenar/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 & $ atlama = 0 & $ en = 1000 & __includeDeleted = gerçek & $ filtre = (% 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

Neden bu işe yaramazsa ve kimse beni suçluyu daraltmaya yardım edebilecekse, sakıncalı olurum. Bu çalışıyor!

cevap

2

Modelinizde bir takım hatalar var.

Sistem özelliklerinin createdAt, updatedAt olarak adlandırılması gerekir - bunlar artık alt çizgilere sahip değildir. version alanı bir dize olmalı - bir DateTime değil. Kimlik alanı büyük harfle yazılmalıdır.

Sizin için önbellek itmeyi gerçekleştiren PullAsync'e güveniyorsunuz. Bu konuda gerçekten açık olmalı ve PushAsync() yapmalısınız.

LocalCards tanımını vermediniz, ancak bunun client.GetSyncTable<clist>() tarafından elde edilen IMobileServiceSyncTable<clist> örneğinin olduğundan emin olun.

+0

Azure Portalı'nda Todo listesi hızlı başlat ile başlarsanız, daha sonra belirli bir veri modelinizle değiştirebileceğiniz bir çalışma örneğiniz olur. Ayrıca Fiddler'ı kullanmanızı veya isteklerinizi hata ayıklamaya yardımcı olmak için bir günlüğe kaydetme işleyicisi eklemeyi öneririm, [bu örnek LoggingHandler] konusuna bakın (https://github.com/Azure-Samples/app-service-mobile-dotnet-todo-list-files /blob/master/src/client/MobileAppsFilesSample/Helpers/LoggingHandler.cs#L63). –