コード例 #1
0
        /// <summary>
        /// Offlines the request data context did fail with error.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="context">The context.</param>
        /// <param name="error">The error.</param>
        public void OfflineRequestDidFailWithError(UPOfflineRequest request, object data, object context, Exception error)
        {
            if (error.IsConnectionOfflineError())
            {
                for (int i = this.currentIndex; i < this.requestArray.Count; i++)
                {
                    UPOfflineRequest followUpRequest = this.requestArray[i];
                    if (!followUpRequest.StoreBeforeRequest)
                    {
                        followUpRequest.RedoRecordOperations();
                    }
                }

                this.RequestDelegate.OfflineRequestDidFailWithError(request, data, context, error);
                this.RequestDelegate.OfflineRequestDidFinishMultiRequest(this);
            }
            else
            {
                request.DeleteRequest(false);
                while (this.currentIndex < this.requestArray.Count)
                {
                    UPOfflineRequest req = this.requestArray[this.currentIndex++];
                    req.DeleteRequest(false);
                }

                this.RequestDelegate.OfflineRequestDidFailWithError(request, data, context, error);
            }
        }
コード例 #2
0
        /// <summary>
        /// Offlines the request data online context did finish with result.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="online">if set to <c>true</c> [online].</param>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        public void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online, object context, Dictionary <string, object> result)
        {
            if (online)
            {
                request.DeleteRequest(false);
                for (int i = this.currentIndex; i < this.requestArray.Count; i++)
                {
                    UPOfflineRequest followUpRequest = this.requestArray[i];
                    followUpRequest.RedoRecordOperations();
                }

                this.RequestDelegate.OfflineRequestDidFinishWithResult(request, data, online, context, result);
                this.StartNextRequest();
            }
            else
            {
                this.RequestDelegate.OfflineRequestDidFinishWithResult(request, data, online, context, result);
                for (int i = this.currentIndex; i < this.requestArray.Count; i++)
                {
                    UPOfflineRequest followUpRequest = this.requestArray[i];
                    if (!followUpRequest.StoreBeforeRequest)
                    {
                        followUpRequest.RedoRecordOperations();
                    }

                    this.RequestDelegate.OfflineRequestDidFinishWithResult(followUpRequest, data, false, null, null);
                }

                this.RequestDelegate.OfflineRequestDidFinishMultiRequest(this);
            }
        }
コード例 #3
0
        /// <summary>
        /// Dependents the requests deep.
        /// </summary>
        /// <returns></returns>
        public Dictionary <int, UPOfflineRequest> DependentRequestsDeep()
        {
            List <int> dependentRequestNumbers = this.DependentRequestNumbers();

            if (dependentRequestNumbers == null || dependentRequestNumbers.Count == 0)
            {
                return(null);
            }

            Dictionary <int, UPOfflineRequest> dependentRequestNumberDictionary = new Dictionary <int, UPOfflineRequest>();
            IOfflineStorage offlineStorage = this.Storage;

            foreach (int cur in dependentRequestNumbers)
            {
                if (!dependentRequestNumberDictionary.ContainsKey(cur))
                {
                    UPOfflineRequest childRequest = offlineStorage.RequestWithNr(cur);
                    if (childRequest != null)
                    {
                        dependentRequestNumberDictionary.SetObjectForKey(childRequest, cur);
                        Dictionary <int, UPOfflineRequest> subdep = childRequest.DependentRequestsDeep();
                        foreach (int sub in subdep.Keys)
                        {
                            if (!dependentRequestNumberDictionary.ContainsKey(sub))
                            {
                                dependentRequestNumberDictionary.SetObjectForKey(subdep[sub], sub);
                            }
                        }
                    }
                }
            }

            return(dependentRequestNumberDictionary);
        }
コード例 #4
0
        /// <summary>
        /// Adds the request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void AddRequest(UPOfflineRequest request)
        {
            if (this.requestArray == null)
            {
                this.requestArray = new List <UPOfflineRequest>();
            }

            this.requestArray.Add(request);
        }
コード例 #5
0
 /// <summary>
 /// Offlines the request data online context did finish with result.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="data">The data.</param>
 /// <param name="online">if set to <c>true</c> [online].</param>
 /// <param name="context">The context.</param>
 /// <param name="result">The result.</param>
 public void OfflineRequestDidFinishWithResult(
     UPOfflineRequest request,
     object data,
     bool online,
     object context,
     Dictionary <string,
                 object> result)
 {
     this.ExecuteNextRequest();
 }
コード例 #6
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);
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        /// <summary>
        /// Offlines the request data context did fail with error.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="context">The context.</param>
        /// <param name="error">The error.</param>
        public void OfflineRequestDidFailWithError(UPOfflineRequest request, object data, object context, Exception error)
        {
            if (error.IsConnectionOfflineError())
            {
                if (this.TheDelegate != null)
                {
                    this.offlineRequests = null;
                    UPOfflineStorageSyncDelegate _delegate = this.TheDelegate;
                    this.TheDelegate  = null;
                    this.syncIsActive = false;
                    _delegate.OfflineStorageDidFailWithError(this, error);
                }

                return;
            }

            this.ExecuteNextRequest();
        }
コード例 #9
0
        /// <summary>
        /// Requests the with nr.
        /// </summary>
        /// <param name="requestNr">The request nr.</param>
        /// <returns></returns>
        public UPOfflineRequest RequestWithNr(int requestNr)
        {
            DatabaseRecordSet recordSet = new DatabaseRecordSet(this.Database);

            if (recordSet.Query.Prepare("SELECT requestnr, requesttype, processtype FROM requests WHERE requestnr = ?"))
            {
                recordSet.Query.Bind(1, requestNr);
                int ret = recordSet.Execute();

                if (ret != 0 || recordSet.GetRowCount() == 0)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }

            UPOfflineRequest request = this.RequestFromResultRow(recordSet.GetRow(0));

            return(request);
        }
コード例 #10
0
 /// <summary>
 /// Requests the type of the with nr type process.
 /// </summary>
 /// <param name="requestNr">The request nr.</param>
 /// <param name="requestType">Type of the request.</param>
 /// <param name="processType">Type of the process.</param>
 /// <returns></returns>
 public UPOfflineRequest RequestWithNrTypeProcessType(int requestNr, OfflineRequestType requestType, OfflineRequestProcess processType)
 {
     return(UPOfflineRequest.RequestWithIdTypeProcesstype(requestNr, requestType, processType));
 }
コード例 #11
0
 /// <summary>
 /// Offlines the request did finish multi request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void OfflineRequestDidFinishMultiRequest(UPOfflineRequest request)
 {
     // Function part of interface implementation, not applicable here, will never be implemented.
     throw new NotImplementedException();
 }