Exemple #1
0
        private async Task GetNewMedia(IServerSyncProvider provider,
                                       ISyncDataProvider dataProvider,
                                       SyncTarget target,
                                       string serverId,
                                       string serverName,
                                       IProgress <double> progress,
                                       CancellationToken cancellationToken)
        {
            var jobItems = await _syncManager.GetReadySyncItems(target.Id).ConfigureAwait(false);

            var    numComplete     = 0;
            double startingPercent = 0;
            double percentPerItem  = 1;

            if (jobItems.Count > 0)
            {
                percentPerItem /= jobItems.Count;
            }

            foreach (var jobItem in jobItems)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var currentPercent = startingPercent;
                var innerProgress  = new ActionableProgress <double>();
                innerProgress.RegisterAction(pct =>
                {
                    var totalProgress = pct * percentPerItem;
                    totalProgress    += currentPercent;
                    progress.Report(totalProgress);
                });

                try
                {
                    await GetItem(provider, dataProvider, target, serverId, serverName, jobItem, innerProgress, cancellationToken).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error syncing item", ex);
                }

                numComplete++;
                startingPercent  = numComplete;
                startingPercent /= jobItems.Count;
                startingPercent *= 100;
                progress.Report(startingPercent);
            }
        }
Exemple #2
0
        public async Task <object> Get(GetReadySyncItems request)
        {
            var result = await _syncManager.GetReadySyncItems(request.TargetId).ConfigureAwait(false);

            return(ToOptimizedResult(result));
        }
Exemple #3
0
 public object Get(GetReadySyncItems request)
 {
     return(ToOptimizedResult(_syncManager.GetReadySyncItems(request.TargetId)));
 }