Пример #1
0
        async Task <SyncResult> SynchronizeAsyncCore(SyncResult.Builder syncResultBuilder, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();

            /*
             * // Get latest state variables from DB
             * var stateVars = LoadSyncEngineStateVariables();
             *
             * var retrieveRequest = new RetrieveRequest()
             * {
             *  Count = SyncPageSize,
             *  DetailType = RetrieveDetailType.Complete,
             *  Since = stateVars.LastSyncStartTime,
             *  State = RetrieveState.All
             * };
             *
             * RetrieveResponse retrieveResponse = null;
             *
             * while (retrieveResponse == null || retrieveResponse.IsComplete == false)
             * {
             *  retrieveResponse = await _pocketClient.SendRequest(retrieveRequest);
             *
             *  foreach (var retrieveResponseItem in retrieveResponse.Items)
             *  {
             *      var pocketItem = _syncDbContext.Items.Find(retrieveResponseItem.Key);
             *      if (pocketItem == null)
             *      {
             *          pocketItem = new Data.Models.PocketItem();
             *          pocketItem.CopyFrom(retrieveResponseItem.Value);
             *          _syncDbContext.Items.Add(pocketItem);
             *      }
             *      else
             *      {
             *          pocketItem.CopyFrom(retrieveResponseItem.Value);
             *      }
             *  }
             *
             *  retrieveRequest.NextPage(SyncPageSize);
             * }
             *
             * _syncDbContext.SaveChanges();
             *
             * stateVars.LastSyncStartTime = syncResultBuilder.StartTime;
             * SaveSyncEngineStateVariables(stateVars);
             *
             * syncResultBuilder.Code = SyncResultCode.Completed;
             * var syncResult = syncResultBuilder.Build();
             * return syncResult;
             */
        }
Пример #2
0
        public Task <SyncResult> SynchronizeAsync(CancellationToken cancellationToken)
        {
            EnsureIsInitialized();
            var syncResultBuilder = new SyncResult.Builder();

            if (_isSyncInProgress.TrySet(true))
            {
                return(SynchronizeAsyncCore(syncResultBuilder, cancellationToken));
            }
            else
            {
                syncResultBuilder.Code = SyncResultCode.SyncAlreadyInProgress;
                var result = syncResultBuilder.Build();
                return(Task.FromResult(result));
            }
        }