示例#1
0
        public void Execute()
        {
            if (_azureAuthService.CheckAuthentication() != AzureAuthService.AccessStatus.Authorized)
            {
                return;
            }

            if (_azureSyncService == null)
            {
                _azureSyncService = new AzureSyncService(_azureAuthService.GetRestService());
            }

            if (_cooldowns == null)
            {
                var limits  = _azureSyncService.GetLimitations();
                var regular = new LimitationSet(cooldownDeletion: limits.Regular.Delete, cooldownUpload: limits.Regular.Upload, cooldownDownload: limits.Regular.Download);
                var multi   = new LimitationSet(cooldownDeletion: limits.MultiUsage.Delete, cooldownUpload: limits.MultiUsage.Upload, cooldownDownload: limits.MultiUsage.Download);
                _cooldowns = new Limitations(regular: regular, multiUsage: multi);
            }

            var limitations = _isDualComputerInstance() ? _cooldowns.MultiUsage : _cooldowns.Regular;

            limitations.DeletionCooldown.ExecuteIfReady(SyncDeletions);
            limitations.UploadCooldown.ExecuteIfReady(SyncUp);

            // TODO:
            // Downloads will eventually stop
            const int syncFreezeTime = 31;
            var       canSyncDown    = !_hasSyncedDownOnce || _isDualComputerInstance(); // Either first sync since startup, or we're in dual-pc mode.

            if (canSyncDown && (DateTimeOffset.UtcNow - _lastSearchDt).TotalMinutes < syncFreezeTime)
            {
                limitations.DownloadCooldown.ExecuteIfReady(SyncDown);
            }
        }
示例#2
0
        public void Execute()
        {
            if (_authService.CheckAuthentication() != AuthService.AccessStatus.Authorized)
            {
                return;
            }

            if (_cloudSyncService == null)
            {
                _cloudSyncService = new CloudSyncService(_authService.GetRestService());
            }

            if (_cooldowns == null)
            {
                var limits  = _cloudSyncService.GetLimitations();
                var regular = new LimitationSet(cooldownDeletion: limits.Regular.Delete, cooldownUpload: limits.Regular.Upload, cooldownDownload: limits.Regular.Download);
                var multi   = new LimitationSet(cooldownDeletion: limits.MultiUsage.Delete, cooldownUpload: limits.MultiUsage.Upload, cooldownDownload: limits.MultiUsage.Download);
                _cooldowns = new Limitations(regular: regular, multiUsage: multi);
            }


            var isDualPc    = _settings.GetPersistent().UsingDualComputer;
            var limitations = isDualPc ? _cooldowns.MultiUsage : _cooldowns.Regular;

            //Logger.Debug($"UploadCooldown IsReady={limitations.UploadCooldown.IsReady}, isDualPc={isDualPc}");
            //Logger.Debug(limitations.ToString());
            limitations.DeletionCooldown.ExecuteIfReady(SyncDeletions);
            limitations.UploadCooldown.ExecuteIfReady(SyncUp);

            // Downloads will go into 'idle mode' and stop trying to download new items when IA is not in use.
            const int syncFreezeTime = 31;
            var       canSyncDown    = isDualPc || !_hasSyncedDownOnce; // Either first sync since startup, or we're in dual-pc mode.

            if (canSyncDown && (DateTimeOffset.UtcNow - _lastSearchDt).TotalMinutes < syncFreezeTime)
            {
                if (!limitations.DownloadCooldown.IsReady)
                {
                    return;
                }

                if (!SyncDown())
                {
                    _hasSyncedDownOnce = true;
                }

                limitations.DownloadCooldown.Reset();
            }
        }
示例#3
0
 public Limitations(LimitationSet regular, LimitationSet multiUsage)
 {
     Regular    = regular;
     MultiUsage = multiUsage;
 }