private async Task<MobileServicePushStatus> ExecuteBatchAsync(OperationBatch batch, List<MobileServiceTableOperationError> syncErrors) { // when cancellation is requested, abort the batch this.CancellationToken.Register(() => batch.Abort(MobileServicePushStatus.CancelledByToken)); try { await ExecuteAllOperationsAsync(batch); } catch (Exception ex) { batch.OtherErrors.Add(ex); } MobileServicePushStatus batchStatus = batch.AbortReason.GetValueOrDefault(MobileServicePushStatus.Complete); try { syncErrors.AddRange(await batch.LoadSyncErrorsAsync(this.client.SerializerSettings)); } catch (Exception ex) { batch.OtherErrors.Add(new MobileServiceLocalStoreException("Failed to read errors from the local store.", ex)); } return batchStatus; }
private async Task <MobileServicePushStatus> ExecuteBatchAsync(OperationBatch batch, List <MobileServiceTableOperationError> syncErrors) { // when cancellation is requested, abort the batch this.CancellationToken.Register(() => batch.Abort(MobileServicePushStatus.CancelledByToken)); try { await ExecuteAllOperationsAsync(batch); } catch (Exception ex) { batch.OtherErrors.Add(ex); } MobileServicePushStatus batchStatus = batch.AbortReason.GetValueOrDefault(MobileServicePushStatus.Complete); try { syncErrors.AddRange(await batch.LoadSyncErrorsAsync(this.client.SerializerSettings)); } catch (Exception ex) { batch.OtherErrors.Add(new MobileServiceLocalStoreException("Failed to read errors from the local store.", ex)); } return(batchStatus); }
private bool TryAbortBatch(OperationBatch batch, Exception ex) { if (ex.IsNetworkError()) { batch.Abort(MobileServicePushStatus.CancelledByNetworkError); } else if (ex.IsAuthenticationError()) { batch.Abort(MobileServicePushStatus.CancelledByAuthenticationError); } else if (ex is MobileServicePushAbortException) { batch.Abort(MobileServicePushStatus.CancelledByOperation); } else { return(false); // not a known exception that should abort the batch } return(true); }
private static async Task TryStoreOperation(Func <Task> action, OperationBatch batch, string error) { try { await action(); } catch (Exception ex) { batch.Abort(MobileServicePushStatus.CancelledBySyncStoreError); throw new MobileServiceLocalStoreException(error, ex); } }
private bool TryAbortBatch(OperationBatch batch, Exception ex) { if (ex.IsNetworkError()) { batch.Abort(MobileServicePushStatus.CancelledByNetworkError); } else if (ex.IsAuthenticationError()) { batch.Abort(MobileServicePushStatus.CancelledByAuthenticationError); } else if (ex is MobileServicePushAbortException) { batch.Abort(MobileServicePushStatus.CancelledByOperation); } else { return false; // not a known exception that should abort the batch } return true; }
private static async Task TryStoreOperation(Func<Task> action, OperationBatch batch, string error) { try { await action(); } catch (Exception ex) { batch.Abort(MobileServicePushStatus.CancelledBySyncStoreError); throw new MobileServiceLocalStoreException(error, ex); } }