Exemplo n.º 1
0
        public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
        {
            foreach (var error in result.Errors)
            {
                Debug.WriteLine(error);
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 2
0
        public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
        {
            Debug.WriteLine("Push result: {0}", result.Status);
            foreach (var error in result.Errors)
            {
                Debug.WriteLine("Push error: {0}", error.Status);
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 3
0
        async Task ResolveConflicts(MobileServicePushCompletionResult result)
        {
            foreach (var prError in result.Errors)
            {
                bool serverWins = false;
                bool localWins  = false;

                var server = prError.Result.ToObject <ToDoItem>();
                var local  = prError.Item.ToObject <ToDoItem>();

                // First take the complted = always favor the server
                if (server.Complete)
                {
                    serverWins = true;
                }
                else if (local.Complete)
                {
                    localWins = true;
                }

                // Longer description
                if (!serverWins && !localWins)
                {
                    if (server.Notes.Length >= local.Notes.Length)
                    {
                        serverWins = true;
                    }
                    else
                    {
                        localWins = true;
                    }
                }

                var winnerName = "";
                if (serverWins)
                {
                    await prError.CancelAndUpdateItemAsync(prError.Result);

                    winnerName = "server";
                }
                else
                {
                    // VERY IMPORTANGT!!
                    local.Version = server.Version;
                    await prError.UpdateOperationAsync(JObject.FromObject(local));

                    winnerName = "local";
                }

                await App.Current.MainPage.DisplayAlert("Conflict", $"We detected a conflict and chose the {winnerName}.", "OK");
            }

            // This is so we can get a pull of the data back out
            await SyncOfflineCache();
        }
 public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
 {
     foreach (var error in result.Errors)
     {
         if (error.Status == HttpStatusCode.Conflict)
         {
             error.CancelAndUpdateItemAsync(error.Result);
             error.Handled = true;
         }
     }
     return(Task.FromResult(0));
 }
Exemplo n.º 5
0
 public override Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
 {
     this.PushCompletionResult = result;
     if (this.PushCompleteAction != null)
     {
         return(PushCompleteAction(result));
     }
     else
     {
         return(base.OnPushCompleteAsync(result));
     }
 }
Exemplo n.º 6
0
        public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
        {
            Debug.WriteLine("Push result: {0}", result.Status);
            foreach (var error in result.Errors)
            {
                Debug.WriteLine("  Push error: {0}", error.Status);
                if (error.Status == HttpStatusCode.Conflict)
                {
                    // Simplistic conflict handling - server wins
                    error.Handled = true;
                    error.CancelAndUpdateItemAsync(error.Item);
                }
            }


            return(Task.FromResult(0));
        }
Exemplo n.º 7
0
        public override async Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
        {
            if (result.Status == MobileServicePushStatus.Complete)
            {
                Helpers.PmdAppSetting.LastSuccessfulSync = DateTimeOffset.Now.DateTime;
            }

            if (result.Status == MobileServicePushStatus.CancelledByNetworkError)
            {
                System.Diagnostics.Debug.WriteLine(result.Status);
                await _userNotificationService.DisplayMessage(Strings.Label_Error_SyncError_Title, Strings.Message_Error_SynErrorDueToBadNetwork);
            }

            if (result.Status == MobileServicePushStatus.CancelledByAuthenticationError)
            {
                Helpers.PmdAppSetting.IsProviderAuthenticated = false;
                await _userNotificationService.DisplayMessage(Strings.Label_Error_SyncError_Title, Strings.Message_Error_SyncErrorDueToAuthentication);
            }

            if (result != null && result.Errors.Any())
            {
                await ExecuteConflictPolicyHandlerAsync(result.Errors);
            }
        }
Exemplo n.º 8
0
 public Task OnPushCompleteAsync(MobileServicePushCompletionResult result) => Task.CompletedTask;
 /// bulk conflict handling
 public virtual Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
 {
     return(Task.FromResult(0));
 }
Exemplo n.º 10
0
 /// <inheritdoc />
 public override Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
 {
     Debug.WriteLine("Pushed to server - {0} - {1} errors", result.Status, result.Errors);
     return(base.OnPushCompleteAsync(result));
 }
Exemplo n.º 11
0
 public Task OnPushCompleteAsync(MobileServicePushCompletionResult result)
 {
     return(Task.CompletedTask);
 }
Exemplo n.º 12
0
 public Task OnPushCompleteAsync(MobileServicePushCompletionResult result) => Task.FromResult(0);