Merge branch 'release/1.0.0' of github.com:ONLYOFFICE/AppServer into release/1.0.0

This commit is contained in:
Viktor Fomin 2021-08-13 06:45:09 +03:00
commit 205a9af165
30 changed files with 113 additions and 89 deletions

View File

@ -16,12 +16,12 @@
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.2" /> <PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\web\ASC.Web.Core\ASC.Web.Core.csproj" /> <ProjectReference Include="..\..\web\ASC.Web.Core\ASC.Web.Core.csproj" />
<ProjectReference Include="..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\ASC.Core.Common\ASC.Core.Common.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -8,7 +8,9 @@ using ASC.Api.Core.Middleware;
using ASC.Common; using ASC.Common;
using ASC.Common.Caching; using ASC.Common.Caching;
using ASC.Common.DependencyInjection; using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Mapping; using ASC.Common.Mapping;
using ASC.Common.Utils;
using Autofac; using Autofac;
@ -27,10 +29,13 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using NLog;
using NLog.Extensions.Logging;
namespace ASC.Api.Core namespace ASC.Api.Core
{ {
public abstract class BaseStartup public abstract class BaseStartup
{ {
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
public IHostEnvironment HostEnvironment { get; } public IHostEnvironment HostEnvironment { get; }
public virtual JsonConverter[] Converters { get; } public virtual JsonConverter[] Converters { get; }
@ -164,4 +169,16 @@ namespace ASC.Api.Core
builder.Register(Configuration, LoadProducts, LoadConsumers); builder.Register(Configuration, LoadProducts, LoadConsumers);
} }
} }
public static class LogNLogConfigureExtenstion
{
public static IHostBuilder ConfigureNLogLogging(this IHostBuilder hostBuilder)
{
return hostBuilder.ConfigureLogging((hostBuildexContext, r) =>
{
_ = new ConfigureLogNLog(hostBuildexContext.Configuration, new ConfigurationExtension(hostBuildexContext.Configuration));
r.AddNLog(LogManager.Configuration);
});
}
}
} }

View File

@ -52,7 +52,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> --> </PackageReference> -->
<PackageReference Include="NLog" Version="4.7.5" /> <PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NVelocity" Version="1.2.0" /> <PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" /> <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup> </ItemGroup>

View File

@ -247,6 +247,8 @@ namespace ASC.Core.Caching
public UserInfo GetUser(int tenant, Guid id) public UserInfo GetUser(int tenant, Guid id)
{ {
if (id.Equals(Guid.Empty)) return null;
if (CoreBaseSettings.Personal) if (CoreBaseSettings.Personal)
{ {
return GetUserForPersonal(tenant, id); return GetUserForPersonal(tenant, id);

View File

@ -288,36 +288,6 @@ namespace ASC.Core
return findUsers.ToArray(); return findUsers.ToArray();
} }
public UserInfo SaveUserInfo(UserInfo u)
{
if (IsSystemUser(u.ID)) return SystemUsers[u.ID];
if (u.ID == Guid.Empty) PermissionContext.DemandPermissions(Constants.Action_AddRemoveUser);
else PermissionContext.DemandPermissions(new UserSecurityProvider(u.ID), Constants.Action_EditUser);
if (Constants.MaxEveryoneCount <= GetUsersByGroup(Constants.GroupEveryone.ID).Length)
{
throw new TenantQuotaException("Maximum number of users exceeded");
}
if (u.Status == EmployeeStatus.Active)
{
var q = TenantManager.GetTenantQuota(Tenant.TenantId);
if (q.ActiveUsers < GetUsersByGroup(Constants.GroupUser.ID).Length)
{
throw new TenantQuotaException(string.Format("Exceeds the maximum active users ({0})", q.ActiveUsers));
}
}
if (u.Status == EmployeeStatus.Terminated && u.ID == TenantManager.GetCurrentTenant().OwnerId)
{
throw new InvalidOperationException("Can not disable tenant owner.");
}
var newUser = UserService.SaveUser(Tenant.TenantId, u);
return newUser;
}
public UserInfo SaveUserInfo(UserInfo u, bool isVisitor = false) public UserInfo SaveUserInfo(UserInfo u, bool isVisitor = false)
{ {
if (IsSystemUser(u.ID)) return SystemUsers[u.ID]; if (IsSystemUser(u.ID)) return SystemUsers[u.ID];

View File

@ -30,6 +30,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -100,6 +101,7 @@ namespace ASC.ApiSystem
{"pathToConf", path} {"pathToConf", path}
}); });
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -28,6 +28,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common; using ASC.Common;
using ASC.Common.Caching; using ASC.Common.Caching;
using ASC.Common.DependencyInjection; using ASC.Common.DependencyInjection;
@ -89,6 +90,7 @@ namespace ASC.Thumbnails.Svc
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -75,7 +76,8 @@ namespace ASC.Data.Backup
{"pathToConf", path } {"pathToConf", path }
} }
); );
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -28,6 +28,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -98,6 +99,7 @@ namespace ASC.Data.Storage.Encryption
.AddJsonFile("kafka.json") .AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true) .AddJsonFile($"kafka.{env}.json", true)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -73,6 +73,7 @@ namespace ASC.Data.Storage.Migration
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration); builder.Register(context.Configuration);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -82,6 +82,7 @@ namespace ASC.Notify
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration); builder.Register(context.Configuration);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -24,9 +24,15 @@
*/ */
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common; using ASC.Common;
using ASC.Common.Caching; using ASC.Common.Caching;
using ASC.Common.Logging; using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using Autofac; using Autofac;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -35,12 +41,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
namespace ASC.Radicale namespace ASC.Radicale
{ {
@ -98,6 +98,7 @@ namespace ASC.Radicale
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -99,7 +99,8 @@ namespace ASC.Socket.IO.Svc
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -21,7 +21,6 @@
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="NLog" Version="4.7.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -100,7 +100,8 @@ namespace ASC.Socket.IO.Svc
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -76,6 +76,7 @@ namespace ASC.Studio.Notify
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration); builder.Register(context.Configuration);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -28,6 +28,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -98,6 +99,7 @@ namespace ASC.TelegramService
.AddJsonFile("kafka.json") .AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true) .AddJsonFile($"kafka.{env}.json", true)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -98,6 +98,7 @@ namespace ASC.Thumbnails.Svc
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -99,6 +99,7 @@ namespace ASC.UrlShortener.Svc
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, false, false); builder.Register(context.Configuration, false, false);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -14,12 +14,12 @@
<default-target-parameters type="SelfCleaning" encoding="utf-8" archiveNumbering="DateAndSequence" archiveEvery="Day" enableArchiveFileCompression="true" archiveAboveSize="52428800" keepFileOpen="true" archiveDateFormat="MM-dd" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}"/> <default-target-parameters type="SelfCleaning" encoding="utf-8" archiveNumbering="DateAndSequence" archiveEvery="Day" enableArchiveFileCompression="true" archiveAboveSize="52428800" keepFileOpen="true" archiveDateFormat="MM-dd" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}"/>
<target name="web" type="SelfCleaning" fileName="${var:dir}${var:name}.log" /> <target name="web" type="SelfCleaning" fileName="${var:dir}${var:name}.log" />
<target name="sql" type="SelfCleaning" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=duration}|${message}|${event-properties:item=sql}|${event-properties:item=sqlParams}"/> <target name="sql" type="SelfCleaning" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=duration}|${message}|${event-properties:item=sql}|${event-properties:item=sqlParams}"/>
<target name="ownFile-web" type="File" fileName="${var:dir}web.asp.log" layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" /> <target name="ownFile-web" type="File" fileName="${var:dir}${var:name}.asp.log" layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
</targets> </targets>
<rules> <rules>
<logger name="ASC.SQL" minlevel="Debug" writeTo="sql" final ="true" /> <logger name="ASC.SQL" minlevel="Debug" writeTo="sql" final ="true" />
<logger name="ASC*" minlevel="Debug" writeTo="web" /> <logger name="ASC*" minlevel="Debug" writeTo="web" />
<logger name="Microsoft.*" maxlevel="Debug" writeTo="web" final="true" /> <logger name="Microsoft.*" minlevel="Debug" writeTo="ownFile-web" final="true" />
</rules> </rules>
</nlog> </nlog>

View File

@ -2,6 +2,7 @@
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common; using ASC.Common;
using ASC.Common.Caching; using ASC.Common.Caching;
using ASC.Common.DependencyInjection; using ASC.Common.DependencyInjection;
@ -83,6 +84,7 @@ namespace ASC.CRM.BackgroundTasks
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, true, false, "search.json"); builder.Register(context.Configuration, true, false, "search.json");
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -3,10 +3,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ASC.Common.DependencyInjection; using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -74,6 +73,7 @@ namespace ASC.CRM
{ {
{"pathToConf", path} {"pathToConf", path}
}); });
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -2,6 +2,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -47,7 +49,8 @@ namespace ASC.Calendar
.AddJsonFile("kafka.json") .AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true) .AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
.AddEnvironmentVariables() .AddEnvironmentVariables()
.AddCommandLine(args); .AddCommandLine(args);
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -73,6 +74,7 @@ namespace ASC.Files
{ {
{"pathToConf", path} {"pathToConf", path}
}); });
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -89,6 +89,7 @@ namespace ASC.Files.Service
.ConfigureContainer<ContainerBuilder>((context, builder) => .ConfigureContainer<ContainerBuilder>((context, builder) =>
{ {
builder.Register(context.Configuration, true, false, "search.json", "feed.json"); builder.Register(context.Configuration, true, false, "search.json", "feed.json");
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -51,6 +53,7 @@ namespace ASC.Mail
{ {
{"pathToConf", path} {"pathToConf", path}
}); });
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -75,7 +76,8 @@ namespace ASC.People
{"pathToConf", path } {"pathToConf", path }
} }
); );
}); })
.ConfigureNLogLogging();
} }
} }
} }

View File

@ -5,6 +5,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -74,6 +75,7 @@ namespace ASC.Projects
{ {
{"pathToConf", path} {"pathToConf", path}
}); });
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -12,7 +13,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
namespace ASC.Web.Api namespace ASC.Web.Api
{ {
public class Program public class Program
@ -75,6 +75,7 @@ namespace ASC.Web.Api
{"pathToConf", path } {"pathToConf", path }
} }
); );
}); })
.ConfigureNLogLogging();
} }
} }

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils; using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
@ -75,6 +76,7 @@ namespace ASC.Web.Studio
} }
); );
}); })
.ConfigureNLogLogging();
} }
} }