personalToDocSpace:fix
This commit is contained in:
parent
119722f308
commit
cc33ef21a7
Binary file not shown.
@ -29,6 +29,7 @@ global using System.Data.Common;
|
||||
global using System.Xml.Linq;
|
||||
|
||||
global using ASC.Api.Core;
|
||||
global using ASC.Api.Core.Core;
|
||||
global using ASC.Api.Core.Extensions;
|
||||
global using ASC.Common;
|
||||
global using ASC.Common.Logging;
|
||||
@ -36,7 +37,6 @@ global using ASC.Common.Utils;
|
||||
global using ASC.Core.Common.EF;
|
||||
global using ASC.Core.Common.EF.Context;
|
||||
global using ASC.Core.Common.Hosting;
|
||||
global using ASC.Core.Data;
|
||||
global using ASC.Core.Tenants;
|
||||
global using ASC.Core.Users;
|
||||
global using ASC.Data.Backup;
|
||||
@ -48,7 +48,6 @@ global using ASC.Data.Backup.Tasks.Data;
|
||||
global using ASC.Data.Backup.Tasks.Modules;
|
||||
global using ASC.Data.Storage;
|
||||
global using ASC.Data.Storage.DiscStorage;
|
||||
global using ASC.Data.Storage.S3;
|
||||
global using ASC.EventBus.Abstractions;
|
||||
global using ASC.EventBus.Events;
|
||||
global using ASC.EventBus.Extensions.Logger;
|
||||
|
@ -25,7 +25,8 @@
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Migration.PersonalToDocspace.Creator;
|
||||
|
||||
|
||||
[Scope]
|
||||
public class MigrationCreator
|
||||
{
|
||||
private readonly IDbContextFactory<UserDbContext> _userDbContext;
|
||||
@ -83,18 +84,19 @@ public class MigrationCreator
|
||||
|
||||
|
||||
|
||||
public async Task Create(int tenant, string userName, string toRegion)
|
||||
public async Task<string> Create(int tenant, string userName, string toRegion)
|
||||
{
|
||||
Init(tenant, userName, toRegion);
|
||||
|
||||
var id = GetId();
|
||||
|
||||
var path = Path.Combine(_pathToSave, _userName + ".tar.gz");
|
||||
var fileName = _userName + ".tar.gz";
|
||||
var path = Path.Combine(_pathToSave, fileName);
|
||||
using (var writer = new ZipWriteOperator(_tempStream, path))
|
||||
{
|
||||
DoMigrationDb(id, writer);
|
||||
await DoMigrationStorage(id, writer);
|
||||
}
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private void Init(int tenant, string userName, string toRegion)
|
||||
@ -176,7 +178,8 @@ public class MigrationCreator
|
||||
|
||||
if (data.TableName == "tenants_tenants")
|
||||
{
|
||||
ChangeAlias(data);
|
||||
ChangeAlias(data);
|
||||
ChangeName(data);
|
||||
}
|
||||
|
||||
using (var file = _tempStream.Create())
|
||||
@ -216,6 +219,11 @@ public class MigrationCreator
|
||||
}
|
||||
}
|
||||
data.Rows[0]["alias"] = newAlias;
|
||||
}
|
||||
|
||||
private void ChangeName(DataTable data)
|
||||
{
|
||||
data.Rows[0]["name"] = "";
|
||||
}
|
||||
|
||||
private List<string> GetAliases()
|
||||
|
@ -25,7 +25,8 @@
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Migration.PersonalToDocspace.Runner;
|
||||
|
||||
|
||||
[Scope]
|
||||
public class MigrationRunner
|
||||
{
|
||||
private readonly DbFactory _dbFactory;
|
||||
|
@ -24,7 +24,6 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
|
||||
var options = new WebApplicationOptions
|
||||
{
|
||||
Args = args,
|
||||
@ -63,6 +62,8 @@ var config = builder.Configuration;
|
||||
|
||||
builder.WebHost.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.RegisterFeature();
|
||||
|
||||
services.AddScoped<EFLoggerFactory>();
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpClient();
|
||||
@ -88,29 +89,24 @@ builder.WebHost.ConfigureServices((hostContext, services) =>
|
||||
var diHelper = new DIHelper();
|
||||
diHelper.Configure(services);
|
||||
|
||||
diHelper.TryAdd<TempStream>();
|
||||
diHelper.TryAdd<DbFactory>();
|
||||
diHelper.TryAdd<ModuleProvider>();
|
||||
diHelper.TryAdd<DbTenantService>();
|
||||
diHelper.TryAdd<StorageFactoryConfig>();
|
||||
diHelper.TryAdd<StorageFactory>();
|
||||
diHelper.TryAdd<DiscDataStore>();
|
||||
diHelper.TryAdd<S3Storage>();
|
||||
diHelper.TryAdd<MigrationCreator>();
|
||||
diHelper.TryAdd<MigrationRunner>();
|
||||
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var tenant = Int32.Parse(args[0]);
|
||||
var userName = args[1];
|
||||
var region = args[2];
|
||||
var tenant = Int32.Parse(config["tenant"]);
|
||||
var userName = config["userName"];
|
||||
var region = config["region"];
|
||||
|
||||
var migrationCreator = app.Services.GetService<MigrationCreator>();
|
||||
await migrationCreator.Create(tenant, userName, region);
|
||||
var fileName = await migrationCreator.Create(tenant, userName, region);
|
||||
|
||||
var migrationRunner = app.Services.GetService<MigrationRunner>();
|
||||
await migrationRunner.Run(userName + ".tar.gz", region);
|
||||
await migrationRunner.Run(fileName, region);
|
||||
|
||||
Directory.GetFiles(AppContext.BaseDirectory).Where(f => f.Contains(".tar")).ToList().ForEach(File.Delete);
|
||||
Directory.GetFiles(AppContext.BaseDirectory).Where(f => f.Equals(fileName)).ToList().ForEach(File.Delete);
|
||||
|
||||
if (Directory.Exists(AppContext.BaseDirectory + "\\temp"))
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"profiles": {
|
||||
"ASC.Migration.PersonalToDocspace.Creator": {
|
||||
"ASC.Migration.PersonalToDocspace": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false
|
||||
}
|
||||
|
@ -4,16 +4,6 @@
|
||||
"name": "default",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
},
|
||||
"postgre": {
|
||||
"name": "postgre",
|
||||
"connectionString": "Host=localhost;Port=5432;Database=onlyoffice;Username=postgres;Password=dev;",
|
||||
"providerName": "Npgsql"
|
||||
},
|
||||
"mysql": {
|
||||
"name": "mysql",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
}
|
||||
},
|
||||
"DbProviderFactories": {
|
||||
@ -24,30 +14,27 @@
|
||||
"type": "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"
|
||||
}
|
||||
},
|
||||
|
||||
"$STORAGE_ROOT": "../../../Data",
|
||||
"pathToConf": "../../../config",
|
||||
"core": {
|
||||
"machinekey": "1123askdasjklasbnd"
|
||||
"machinekey": "1123askdasjklasbnd",
|
||||
"payment": {
|
||||
"delay": 10,
|
||||
"region": "test",
|
||||
"test": true,
|
||||
"url": "",
|
||||
"key": "",
|
||||
"secret": ""
|
||||
}
|
||||
},
|
||||
|
||||
"regions": {
|
||||
"1": {
|
||||
"docSpace": {
|
||||
"ConnectionStrings": {
|
||||
"default": {
|
||||
"name": "default",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice1;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
},
|
||||
"postgre": {
|
||||
"name": "postgre",
|
||||
"connectionString": "Host=localhost;Port=5432;Database=onlyoffice;Username=postgres;Password=dev;",
|
||||
"providerName": "Npgsql"
|
||||
},
|
||||
"mysql": {
|
||||
"name": "mysql",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
}
|
||||
},
|
||||
"storage": {
|
||||
|
@ -4,16 +4,6 @@
|
||||
"name": "default",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
},
|
||||
"postgre": {
|
||||
"name": "postgre",
|
||||
"connectionString": "Host=localhost;Port=5432;Database=onlyoffice;Username=postgres;Password=dev;",
|
||||
"providerName": "Npgsql"
|
||||
},
|
||||
"mysql": {
|
||||
"name": "mysql",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
}
|
||||
},
|
||||
"DbProviderFactories": {
|
||||
@ -24,30 +14,27 @@
|
||||
"type": "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"
|
||||
}
|
||||
},
|
||||
|
||||
"$STORAGE_ROOT": "../../Data",
|
||||
"pathToConf": "../../config",
|
||||
"core": {
|
||||
"machinekey": "1123askdasjklasbnd"
|
||||
"machinekey": "1123askdasjklasbnd",
|
||||
"payment": {
|
||||
"delay": 10,
|
||||
"region": "test",
|
||||
"test": true,
|
||||
"url": "",
|
||||
"key": "",
|
||||
"secret": ""
|
||||
}
|
||||
},
|
||||
|
||||
"regions": {
|
||||
"1": {
|
||||
"docSpace": {
|
||||
"ConnectionStrings": {
|
||||
"default": {
|
||||
"name": "default",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice1;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
},
|
||||
"postgre": {
|
||||
"name": "postgre",
|
||||
"connectionString": "Host=localhost;Port=5432;Database=onlyoffice;Username=postgres;Password=dev;",
|
||||
"providerName": "Npgsql"
|
||||
},
|
||||
"mysql": {
|
||||
"name": "mysql",
|
||||
"connectionString": "Server=localhost;Database=onlyoffice;User ID=dev;Password=dev;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=True;ConnectionReset=false",
|
||||
"providerName": "MySql.Data.MySqlClient"
|
||||
}
|
||||
},
|
||||
"storage": {
|
||||
|
Loading…
Reference in New Issue
Block a user