示例#1
0
        public void Start()
        {
            using var scope = ServiceProvider.CreateScope();
            var service = scope.ServiceProvider.GetService <MigrationService>();

            CacheMigrationNotify.Subscribe(n =>
            {
                service.Migrate(n.TenantId, new StorageSettings {
                    Module = n.StorSettings.Module,
                });
            },
                                           CacheNotifyAction.Insert);

            UploadCdnMigrationNotify.Subscribe(n =>
            {
                service.UploadCdn(n.Tenant, n.RelativePath, n.MappedPath, new CdnStorageSettings {
                    Module = n.CdnStorSettings.Module
                });
            },
                                               CacheNotifyAction.Insert);

            CacheMigrationNotify.Subscribe(n =>
            {
                service.StopMigrate();
            },
                                           CacheNotifyAction.InsertOrUpdate);
        }
        public void Migrate(int tenant, StorageSettings storageSettings)
        {
            var storSettings = new StorSettings {
                ID = storageSettings.ID.ToString(), Module = storageSettings.Module
            };

            CacheMigrationNotify.Publish(new MigrationCache
            {
                TenantId     = tenant,
                StorSettings = storSettings
            },
                                         CacheNotifyAction.Insert);
        }
 public void StopMigrate()
 {
     CacheMigrationNotify.Publish(new MigrationCache(), CacheNotifyAction.InsertOrUpdate);
 }