protected override void DoJob()
        {
            try
            {
                Log.DebugFormat("Tenant: {0}", tenantId);
                var tenant = CoreContext.TenantManager.GetTenant(tenantId);
                CoreContext.TenantManager.SetCurrentTenant(tenant);
                SecurityContext.CurrentUser = tenant.OwnerId;

                foreach (var module in Modules)
                {
                    var oldStore = StorageFactory.GetStorage(ConfigPath, tenantId.ToString(), module);
                    var store    = StorageFactory.GetStorageFromConsumer(ConfigPath, tenantId.ToString(), module, settings.DataStoreConsumer);
                    var domains  = StorageFactory.GetDomainList(ConfigPath, module).ToList();

                    var crossModuleTransferUtility = new CrossModuleTransferUtility(oldStore, store);

                    string[] files;
                    foreach (var domain in domains)
                    {
                        Status = module + domain;
                        Log.DebugFormat("Domain: {0}", domain);
                        files = oldStore.ListFilesRelative(domain, "\\", "*.*", true);

                        foreach (var file in files)
                        {
                            Log.DebugFormat("File: {0}", file);
                            crossModuleTransferUtility.CopyFile(domain, file, domain, file);
                        }
                    }

                    Log.DebugFormat("Module:{0},Domain:", module);

                    files = oldStore.ListFilesRelative(string.Empty, "\\", "*.*", true)
                            .Where(path => domains.All(domain => !path.Contains(domain + "/")))
                            .ToArray();

                    foreach (var file in files)
                    {
                        Log.DebugFormat("File: {0}", file);
                        crossModuleTransferUtility.CopyFile("", file, "", file);
                    }

                    StepDone();
                    Log.DebugFormat("Percentage:{0}", Percentage);
                }

                settings.Save();
                Log.Debug("StaticUploader Save");
                tenant.SetStatus(TenantStatus.Active);
                CoreContext.TenantManager.SaveTenant(tenant);
                Log.Debug("StaticUploader SetStatus");
            }
            catch (Exception e)
            {
                Error = e;
                Log.Error(e);
            }
        }
        protected override void DoJob()
        {
            try
            {
                Log.DebugFormat("Tenant: {0}", tenantId);
                Status = DistributedTaskStatus.Running;

                using var scope = ServiceProvider.CreateScope();
                var tempPath   = scope.ServiceProvider.GetService <TempPath>();
                var scopeClass = scope.ServiceProvider.GetService <MigrateOperationScope>();
                var(tenantManager, securityContext, storageFactory, options, storageSettingsHelper, settingsManager) = scopeClass;
                var tenant = tenantManager.GetTenant(tenantId);
                tenantManager.SetCurrentTenant(tenant);

                securityContext.AuthenticateMeWithoutCookie(tenant.OwnerId);

                foreach (var module in Modules)
                {
                    var oldStore = storageFactory.GetStorage(ConfigPath, tenantId.ToString(), module);
                    var store    = storageFactory.GetStorageFromConsumer(ConfigPath, tenantId.ToString(), module, storageSettingsHelper.DataStoreConsumer(settings));
                    var domains  = StorageFactoryConfig.GetDomainList(ConfigPath, module).ToList();

                    var crossModuleTransferUtility = new CrossModuleTransferUtility(options, TempStream, tempPath, oldStore, store);

                    string[] files;
                    foreach (var domain in domains)
                    {
                        //Status = module + domain;
                        Log.DebugFormat("Domain: {0}", domain);
                        files = oldStore.ListFilesRelative(domain, "\\", "*.*", true);

                        foreach (var file in files)
                        {
                            Log.DebugFormat("File: {0}", file);
                            crossModuleTransferUtility.CopyFile(domain, file, domain, file);
                        }
                    }

                    Log.Debug("Domain:");

                    files = oldStore.ListFilesRelative(string.Empty, "\\", "*.*", true)
                            .Where(path => domains.All(domain => !path.Contains(domain + "/")))
                            .ToArray();

                    foreach (var file in files)
                    {
                        Log.DebugFormat("File: {0}", file);
                        crossModuleTransferUtility.CopyFile("", file, "", file);
                    }

                    StepDone();

                    MigrationPublish();
                }

                settingsManager.Save(settings);
                tenant.SetStatus(TenantStatus.Active);
                tenantManager.SaveTenant(tenant);

                Status = DistributedTaskStatus.Completed;
            }
            catch (Exception e)
            {
                Status    = DistributedTaskStatus.Failted;
                Exception = e;
                Log.Error(e);
            }

            MigrationPublish();
        }
Exemple #3
0
        protected override void DoJob()
        {
            try
            {
                Log.DebugFormat("Tenant: {0}", tenantId);
                using var scope = ServiceProvider.CreateScope();
                var tenantManager = scope.ServiceProvider.GetService <TenantManager>();
                var tenant        = tenantManager.GetTenant(tenantId);
                tenantManager.SetCurrentTenant(tenant);

                var securityContext       = scope.ServiceProvider.GetService <SecurityContext>();
                var storageFactory        = scope.ServiceProvider.GetService <StorageFactory>();
                var options               = scope.ServiceProvider.GetService <IOptionsMonitor <ILog> >();
                var storageSettingsHelper = scope.ServiceProvider.GetService <StorageSettingsHelper>();
                var settingsManager       = scope.ServiceProvider.GetService <SettingsManager>();

                securityContext.AuthenticateMe(tenant.OwnerId);

                foreach (var module in Modules)
                {
                    var oldStore = storageFactory.GetStorage(ConfigPath, tenantId.ToString(), module);
                    var store    = storageFactory.GetStorageFromConsumer(ConfigPath, tenantId.ToString(), module, storageSettingsHelper.DataStoreConsumer(settings));
                    var domains  = StorageFactoryConfig.GetDomainList(ConfigPath, module).ToList();

                    var crossModuleTransferUtility = new CrossModuleTransferUtility(options, oldStore, store);

                    string[] files;
                    foreach (var domain in domains)
                    {
                        Status = module + domain;
                        Log.DebugFormat("Domain: {0}", domain);
                        files = oldStore.ListFilesRelative(domain, "\\", "*.*", true);

                        foreach (var file in files)
                        {
                            Log.DebugFormat("File: {0}", file);
                            crossModuleTransferUtility.CopyFile(domain, file, domain, file);
                        }
                    }

                    Log.Debug("Domain:");

                    files = oldStore.ListFilesRelative(string.Empty, "\\", "*.*", true)
                            .Where(path => domains.All(domain => !path.Contains(domain + "/")))
                            .ToArray();

                    foreach (var file in files)
                    {
                        Log.DebugFormat("File: {0}", file);
                        crossModuleTransferUtility.CopyFile("", file, "", file);
                    }

                    StepDone();
                }

                settingsManager.Save(settings);
                tenant.SetStatus(TenantStatus.Active);
                tenantManager.SaveTenant(tenant);
            }
            catch (Exception e)
            {
                Error = e;
                Log.Error(e);
            }
        }