示例#1
0
 /// <summary>
 /// Stops the current sync in progress
 /// </summary>
 public void Stop()
 {
     if (this.currentServerOperation != null)
     {
         this.operationCancelRequested = true;
         this.serverOperations.Remove(this.currentServerOperation);
         this.currentServerOperation   = null;
         this.currentRemoteDataRequest = null;
     }
 }
示例#2
0
        /// <summary>
        /// Triggers when remotes data did fail while loading.
        /// </summary>
        /// <param name="remoteData">
        /// The remote data.
        /// </param>
        /// <param name="error">
        /// The error.
        /// </param>
        public void RemoteDataDidFailLoadingWithError(RemoteData remoteData, Exception error)
        {
            if (error.IsApplicationStartingError())
            {
                this.applicationRestartingRetryCounter++;
                if (this.applicationRestartingRetryCounter == 5)
                {
                    this.applicationRestartingRetryCounter = 0;
                    this.currentServerOperation?.ProcessFailedDueToInternetConnection(error, remoteData);
                    this.currentServerOperation?.FinishProcessing();
                    this.CleanUpFinishedServerOperation();
                }
                else
                {
                    this.CleanRemoteData();
                    this.suspended = true;
                    this.TriggerRetryForRemoteOperationForCurrentServerOperation();
                }
            }
            else if (error.IsNotAuthenticatedError() &&
                     !(this.currentServerOperation is AuthenticateServerOperation) &&
                     !(this.currentServerOperation is LogoutServerOperation) &&
                     !(this.currentServerOperation is RevolutionCookieServerOperation))
            {
                this.CleanRemoteData();
                this.currentServerOperation = null;
                this.Login();
            }
            else if (error.Message == ".Code == UP_NO_DATA_RETURNED")
            {
                if (this.currentServerOperation is AuthenticateServerOperation ||
                    this.currentServerOperation is RevolutionCookieServerOperation)
                {
                    this.Delegate?.ServerOperationManagerDidFailWithInternetConnectionError(
                        this,
                        error,
                        !string.IsNullOrEmpty(this.newPassword) ? PasswordChangeResult.PasswordNotChanged : PasswordChangeResult.NoPasswordChangeRequested);
                }
                else
                {
                    this.currentServerOperation.ProcessFailedDueToInternetConnection(error, remoteData);
                }

                this.currentServerOperation.FinishProcessing();
                this.CleanUpFinishedServerOperation();
            }
            else
            {
                this.currentServerOperation?.ProcessErrorWithRemoteData(error, remoteData);
                this.currentServerOperation?.FinishProcessing();
                this.CleanUpFinishedServerOperation();
            }
        }
示例#3
0
        /// <summary>
        /// Queues the server operation.
        /// </summary>
        /// <param name="serverOperation">
        /// The server operation.
        /// </param>
        public void QueueServerOperation(ServerOperation serverOperation)
        {
            if (this.serverOperations == null)
            {
                return;
            }

            lock (this.serverOperations)
            {
                this.serverOperations.Add(serverOperation);
            }

            this.StartNextOperation();
        }
示例#4
0
        /// <summary>
        /// Queues the server operation at top of the queue.
        /// </summary>
        /// <param name="serverOperation">
        /// The server operation.
        /// </param>
        public void QueueServerOperationAtTopOfTheQueue(ServerOperation serverOperation)
        {
            if (this.serverOperations == null)
            {
                return;
            }

            // #82360: retain remote session until RemoteData object is created
            this.currentRemoteSession = this.remoteSession;

            lock (this.serverOperations)
            {
                this.serverOperations.Insert(this.currentServerOperation != null ? 1 : 0, serverOperation);
            }

            this.StartNextOperation();
        }
示例#5
0
        /// <summary>
        /// Starts the next operation.
        /// </summary>
        public void StartNextOperation()
        {
            if (this.serverOperations == null || this.operationCancelRequested)
            {
                return;
            }

            if (this.serverOperations.Count == 0 || this.currentServerOperation != null)
            {
                // || suspended)
                return;
            }

            var cancelledOperations = this.serverOperations.Where(serverOperation => serverOperation.Canceled).ToList();

            foreach (var cancelledOperation in cancelledOperations)
            {
                this.serverOperations.Remove(cancelledOperation);
            }

            if (!this.serverOperations.Any())
            {
                return;
            }

            this.currentServerOperation = this.serverOperations[0] as ServerOperation;
            if (this.currentServerOperation == null)
            {
                return;
            }

#if PORTING
            CurrentServerOperation.AddObserverForKeyPathOptionsContext(this, "cancelled", NSKeyValueObservingOptionNew, null);
#endif
            this.applicationRestartingRetryCounter = 0;

            if (!this.currentServerOperation.AlwaysPerform && this.currentServerOperation.BlockedByPendingUpSync &&
                UPOfflineStorage.DefaultStorage.BlockOnlineRecordRequest)
            {
                this.FailCurrentServerOperationBecauseOfMissingInternetConnection();
                return;
            }

            this.StartRemoteOperationForCurrentServerOperation();
        }
示例#6
0
        /// <summary>
        /// Cleans up finished server operation Start next operation.
        /// </summary>
        /// <param name="startNextOperation">
        /// if set to <c>true</c> [Start next operation].
        /// </param>
        private void CleanUpFinishedServerOperationStartNextOperation(bool startNextOperation)
        {
            if (this.serverOperations == null)
            {
                return;
            }

            if (this.currentServerOperation == null && this.currentRemoteDataRequest == null)
            {
                return;
            }

            // CurrentRemoteDataRequest.OperationManagerService = null;
            this.currentRemoteDataRequest = null;

            // CurrentServerOperation.RemoveObserverForKeyPath(this, "cancelled");
            this.serverOperations.Remove(this.currentServerOperation);
            this.currentServerOperation = null;

            if (startNextOperation)
            {
                this.StartNextOperation();
            }
        }