Exemple #1
0
        public async Task <SyncResult> Sync(User user)
        {
            var pullResult = await _pullService.Pull <Disaster>();

            var pulledItems = new HashSet <string>(pullResult.SuccessfulItems.Select(i => i.ObjectId));

            if (!pullResult.FailedItems.Any() && pulledItems.Any())
            {
                PurgeRelated <Assessment>(pulledItems);
                PurgeRelated <Shelter>(pulledItems);
            }
            return(pullResult.FailedItems.Any() ? SyncResult.Failed("Unable to pull latest Disasters.")
                : SyncResult.Success());
        }
Exemple #2
0
        public async Task <SyncResult> Sync(User user)
        {
            foreach (var syncService in _syncServices)
            {
                var result = await syncService.Sync(user);

                if (result.HasErrors)
                {
                    return(result);
                }
            }

            RecordLastSync();
            return(SyncResult.Success());
        }
        public async Task <SyncResult> Sync(User user)
        {
            if (!await PushWith(user))
            {
                return(SyncResult.Failed($"Unable to completely push {typeof(TItem).Name}."));
            }

            var query = _queryProvider.Where().OwnedBy(user.ObjectId).IsActive();

            if (!await PullAssessments(query))
            {
                return(SyncResult.Failed($"Unable to pull latest {typeof(TItem).Name} from server."));
            }

            if (!await PullAttributes(query))
            {
                return(SyncResult.Failed($"Unable to pull latest {typeof(TValuedAttribute).Name} from server."));
            }

            // remove all assessments that do not belong to this user
            RemoveOtherUsersItems(user);
            return(SyncResult.Success());
        }
Exemple #4
0
        public async Task <SyncResult> Sync(User user)
        {
            var result = await _pullService.Pull <Attribute>();

            return(result.FailedItems.Any() ? SyncResult.Failed("Unable to pull latest Attributes.") : SyncResult.Success());
        }