Merge branch 'feature/backend-refactor' into feature/winsw

This commit is contained in:
Anton Suhorukov 2022-02-25 11:18:26 +03:00
commit 88c7f5ba72
9 changed files with 41 additions and 19 deletions

View File

@ -22,6 +22,7 @@
"common\\services\\ASC.ElasticSearch\\ASC.ElasticSearch.csproj",
"common\\services\\ASC.Feed.Aggregator\\ASC.Feed.Aggregator.csproj",
"common\\services\\ASC.Notify\\ASC.Notify.csproj",
"common\\services\\ASC.Socket.IO.Svc\\ASC.Socket.IO.Svc.csproj",
"common\\services\\ASC.Studio.Notify\\ASC.Studio.Notify.csproj",
"common\\services\\ASC.TelegramService\\ASC.TelegramService.csproj",
"common\\services\\ASC.Webhooks.Service\\ASC.Webhooks.Service.csproj",

View File

@ -11,8 +11,6 @@ call start\stop.bat nopause
dotnet build ..\asc.web.slnf /fl1 /flp1:logfile=asc.web.log;verbosity=normal
echo.
call start\start.bat nopause
echo install nodejs projects dependencies...
echo.
@ -25,6 +23,10 @@ for /R "scripts\" %%f in (*.bat) do (
echo.
call start\start.bat nopause
echo.
if "%1"=="nopause" goto end
pause

4
build/run/SocketIO.bat Normal file
View File

@ -0,0 +1,4 @@
@echo off
PUSHD %~dp0..\..
set servicepath=%cd%\common\services\ASC.Socket.IO.Svc\bin\Debug\ASC.Socket.IO.Svc.exe urls=http://0.0.0.0:5028 $STORAGE_ROOT=%cd%\Data log:dir=%cd%\Logs log:name=socketio pathToConf=%cd%\config core:products:folder=%cd%\products core:products:subfolder=server socket:path=%cd%\common\ASC.Socket.IO

View File

@ -0,0 +1 @@
yarn install --cwd %~dp0../../common/ASC.Socket.IO/ --frozen-lockfile

View File

@ -47,7 +47,7 @@ using StackExchange.Redis.Extensions.Newtonsoft;
namespace ASC.Socket.IO.Svc
{
public class Program
public class Program
{
public async static Task Main(string[] args)
{
@ -92,7 +92,9 @@ public class Program
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
services.AddMemoryCache();
services.AddHttpClient();
var diHelper = new DIHelper(services);
var redisConfiguration = hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>();
@ -100,11 +102,11 @@ public class Program
if (kafkaConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCache<>));
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
}
else if (redisConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(RedisCache<>));
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(redisConfiguration);
}

View File

@ -83,6 +83,12 @@ namespace ASC.Socket.IO.Svc
try
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
var path = settings.Path;
if (!Path.IsPathRooted(settings.Path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path));
}
PingInterval = settings.PingInterval.GetValueOrDefault(10000);
ReconnectAttempts = settings.ReconnectAttempts.GetValueOrDefault(5);
@ -93,7 +99,7 @@ namespace ASC.Socket.IO.Svc
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path, "server.js"))}\"",
Arguments = $"\"{Path.Combine(path, "server.js")}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};

View File

@ -752,11 +752,13 @@ namespace ASC.Files.Core.Data
using (var tx = await FilesDbContext.Database.BeginTransactionAsync().ConfigureAwait(false))
{
var fromFolders = Query(FilesDbContext.Files)
var fromFolders = await Query(FilesDbContext.Files)
.Where(r => r.Id == fileId)
.Select(a => a.FolderId)
.Distinct()
.AsAsyncEnumerable();
.AsAsyncEnumerable()
.ToListAsync()
.ConfigureAwait(false);
toUpdate = await Query(FilesDbContext.Files)
.Where(r => r.Id == fileId)
@ -778,7 +780,11 @@ namespace ASC.Files.Core.Data
await FilesDbContext.SaveChangesAsync().ConfigureAwait(false);
await tx.CommitAsync().ConfigureAwait(false);
await fromFolders.ForEachAwaitAsync(async folderId => await RecalculateFilesCountAsync(folderId).ConfigureAwait(false)).ConfigureAwait(false);
foreach (var f in fromFolders)
{
await RecalculateFilesCountAsync(f).ConfigureAwait(false);
}
await RecalculateFilesCountAsync(toFolderId).ConfigureAwait(false);
}

View File

@ -63,7 +63,7 @@ namespace ASC.Web.Files.Services.DocumentService
[DebuggerDisplay("{Type} - {UserId}")]
public class Action
{
public string Type { get; set; }
public int Type { get; set; }
public string UserId { get; set; }
}

View File

@ -1086,13 +1086,13 @@ namespace ASC.Api.Documents
/// <category>Files</category>
/// <returns>File info</returns>
[Read("fileAsync/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Read("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
public Task<FileWrapper<string>> GetFileInfoAsync(string fileId, int version = -1)
{
return FilesControllerHelperString.GetFileInfoAsync(fileId, version);
}
[Read("fileAsync/{fileId:int}")]
[Read("file/{fileId:int}")]
public Task<FileWrapper<int>> GetFileInfoAsync(int fileId, int version = -1)
{
return FilesControllerHelperInt.GetFileInfoAsync(fileId, version);
@ -1148,26 +1148,26 @@ namespace ASC.Api.Documents
/// <param name="title">New title</param>
/// <param name="lastVersion">File last version number</param>
/// <returns>File info</returns>
[Update("fileAsync/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
public Task<FileWrapper<string>> UpdateFileFromBodyAsync(string fileId, [FromBody] UpdateFileModel model)
{
return FilesControllerHelperString.UpdateFileAsync(fileId, model.Title, model.LastVersion);
}
[Update("fileAsync/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileWrapper<string>> UpdateFileFromFormAsync(string fileId, [FromForm] UpdateFileModel model)
{
return FilesControllerHelperString.UpdateFileAsync(fileId, model.Title, model.LastVersion);
}
[Update("fileAsync/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FileWrapper<int>> UpdateFileFromBodyAsync(int fileId, [FromBody] UpdateFileModel model)
{
return FilesControllerHelperInt.UpdateFileAsync(fileId, model.Title, model.LastVersion);
}
[Update("fileAsync/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileWrapper<int>> UpdateFileFromFormAsync(int fileId, [FromForm] UpdateFileModel model)
{
@ -1209,7 +1209,7 @@ namespace ASC.Api.Documents
if (model == null)
{
model = new CheckConversionModel<string>();
}
}
model.FileId = fileId;
return FilesControllerHelperString.StartConversionAsync(model);
}
@ -1220,7 +1220,7 @@ namespace ASC.Api.Documents
if (model == null)
{
model = new CheckConversionModel<int>();
}
}
model.FileId = fileId;
return FilesControllerHelperInt.StartConversionAsync(model);
}