Ejemplo n.º 1
0
        public static void Start(int tenantId, StorageSettings newStorageSettings)
        {
            if (TokenSource.Token.IsCancellationRequested)
            {
                return;
            }

            MigrateOperation migrateOperation;

            lock (Locker)
            {
                migrateOperation = Cache.Get <MigrateOperation>(GetCacheKey(tenantId));
                if (migrateOperation != null)
                {
                    return;
                }

                migrateOperation = new MigrateOperation(tenantId, newStorageSettings);
                Cache.Insert(GetCacheKey(tenantId), migrateOperation, DateTime.MaxValue);
            }

            var task = new Task(migrateOperation.RunJob, TokenSource.Token, TaskCreationOptions.LongRunning);

            task.ConfigureAwait(false)
            .GetAwaiter()
            .OnCompleted(() =>
            {
                lock (Locker)
                {
                    Cache.Remove(GetCacheKey(tenantId));
                }
            });

            task.Start(Scheduler);
        }
Ejemplo n.º 2
0
        public void Start(int tenantId, StorageSettings newStorageSettings, StorageFactoryConfig storageFactoryConfig)
        {
            lock (Locker)
            {
                var id = GetCacheKey(tenantId);
                var migrateOperation = Queue.GetTask <MigrateOperation>(id);
                if (migrateOperation != null)
                {
                    return;
                }

                migrateOperation = new MigrateOperation(ServiceProvider, CacheMigrationNotify, id, tenantId, newStorageSettings, storageFactoryConfig, TempStream);
                Queue.QueueTask(migrateOperation);
            }
        }