示例#1
0
 /// <summary>
 /// Starts the next request.
 /// </summary>
 private void StartNextRequest()
 {
     if (this.requestArray.Count > this.currentIndex)
     {
         UPOfflineRequest request = this.requestArray[this.currentIndex++];
         request.StartSync(this, false);
     }
     else
     {
         this.RequestDelegate.OfflineRequestDidFinishMultiRequest(this);
     }
 }
        public void ExecuteNextRequest()
        {
            if (this.offlineRequests == null)
            {
                return;
            }

            while (this.nextRequestIndex < this.offlineRequests.Count)
            {
                var recentMostRequest    = this.offlineRequests[this.offlineRequests.Count - this.nextRequestIndex - 1];
                UPOfflineRequest request = recentMostRequest;
                request.LoadFromOfflineStorage();
                if (!request.CanSync())
                {
                    ++this.nextRequestIndex;
                    this.Logger.LogDebug($"UPSync: request {request.RequestNr} cannot be synced ({request})", LogFlag.LogUpSync);
                    continue;
                }

                if (request.NeedsWLANForSync && ServerSession.CurrentSession.ConnectionWatchDog.LastServerReachabilityStatus != ReachabilityStatus.ReachableViaWiFi)
                {
                    ++this.nextRequestIndex;
                    this.Logger.LogDebug($"UPSync: request {request.RequestNr} cannot be synced because no WLAN available ({request})", LogFlag.LogUpSync);
                    continue;
                }

                ++this.nextRequestIndex;
                this.TheDelegate?.OfflineStorageDidProceedToStepNumberOfSteps(this, this.nextRequestIndex, this.offlineRequests.Count);

                this.Logger.LogDebug($"UPSync: syncing request {request.RequestNr} ({request})", LogFlag.LogUpSync);

                if (request.StartSync(this))
                {
                    continue;
                }
            }

            if (this.TheDelegate != null)
            {
                this.offlineRequests = null;
                UPOfflineStorageSyncDelegate _delegate = this.TheDelegate;
                this.TheDelegate  = null;
                this.syncIsActive = false;
                if (this.blockingRequest?.RequestNr <= 0)
                {
                    this.blockOnlineRecordRequest = false;
                }
                this.Logger.LogDebug("UPSync finished.", LogFlag.LogUpSync);
                _delegate.OfflineStorageDidFinishWithResult(this, null);
            }
        }