Merge pull request #30 from ONLYOFFICE/feature/elastic

Feature/elastic
This commit is contained in:
Nikolay Rechkin 2020-02-27 15:52:34 +03:00 committed by GitHub
commit 7d21902c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
465 changed files with 59813 additions and 2532 deletions

View File

@ -40,10 +40,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Notify", "common\servic
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Studio.Notify", "common\services\ASC.Studio.Notify\ASC.Studio.Notify.csproj", "{E3567AB9-0926-444D-A0D0-A369D5890EAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASC.Textile", "common\ASC.Textile\ASC.Textile.csproj", "{C8F410B4-B83B-47B9-9ECD-07590A8750A7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Textile", "common\ASC.Textile\ASC.Textile.csproj", "{C8F410B4-B83B-47B9-9ECD-07590A8750A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Notify.Textile", "common\ASC.Notify.Textile\ASC.Notify.Textile.csproj", "{DB50E2EF-B4D8-493A-8568-29CAC0DF9062}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASC.ElasticSearch", "common\services\ASC.ElasticSearch\ASC.ElasticSearch.csproj", "{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files", "products\ASC.Files\Server\ASC.Files.csproj", "{77BA2F61-6155-4283-BB39-F8E42F46A0B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -126,6 +130,14 @@ Global
{DB50E2EF-B4D8-493A-8568-29CAC0DF9062}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB50E2EF-B4D8-493A-8568-29CAC0DF9062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB50E2EF-B4D8-493A-8568-29CAC0DF9062}.Release|Any CPU.Build.0 = Release|Any CPU
{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}.Release|Any CPU.Build.0 = Release|Any CPU
{77BA2F61-6155-4283-BB39-F8E42F46A0B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77BA2F61-6155-4283-BB39-F8E42F46A0B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77BA2F61-6155-4283-BB39-F8E42F46A0B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77BA2F61-6155-4283-BB39-F8E42F46A0B0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -15,6 +15,10 @@
{
"name": "ASC.People.Client"
"path": "./products/ASC.People/Client"
},
{
"name": "ASC.Files.Client"
"path": "./products/ASC.Files/Client"
}
],
"settings": {}

View File

@ -18,6 +18,9 @@ call build\scripts\client.sh
echo "ASC.Web.People.Client"
call build\scripts\people.sh
echo "ASC.Web.Files.Client"
call build\scripts\files.sh
echo "ASC.Web.sln"
call dotnet build ASC.Web.sln /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal

View File

@ -29,6 +29,11 @@ call yarn link "asc-web-components" --cwd products/ASC.People/Client
call yarn link "asc-web-common" --cwd products/ASC.People/Client
call yarn install --cwd products/ASC.People/Client > build\ASC.Web.People.Client.log
echo "ASC.Web.Files.Client"
call yarn link "asc-web-components" --cwd products/ASC.Files/Client
call yarn link "asc-web-common" --cwd products/ASC.Files/Client
call yarn install --cwd products/ASC.Files/Client > build\ASC.Web.Files.Client.log
echo "ASC.Web.sln"
call dotnet build ASC.Web.sln /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal

2
build/run/FileClient.bat Normal file
View File

@ -0,0 +1,2 @@
echo "RUN ASC.Web.Files"
call set BROWSER=none&&npm start --prefix ../../products/ASC.Files/Client

2
build/run/FileServer.bat Normal file
View File

@ -0,0 +1,2 @@
echo "RUN ASC.Files"
call dotnet run --project ..\..\products\ASC.Files\Server\ASC.Files.csproj --no-build --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=files

3
build/scripts/files.sh Normal file
View File

@ -0,0 +1,3 @@
yarn link "asc-web-components" --cwd products/ASC.Files/Client
yarn link "asc-web-common" --cwd products/ASC.Files/Client
yarn install --cwd products/ASC.Files/Client --frozen-lockfile

View File

@ -6,11 +6,12 @@ using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Core;
using ASC.Security.Cryptography;
using ASC.Web.Studio.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -109,7 +110,7 @@ namespace ASC.Api.Core.Auth
public static class ConfirmAuthHandlerExtension
{
public static IServiceCollection AddConfirmAuthHandler(this IServiceCollection services)
public static DIHelper AddConfirmAuthHandler(this DIHelper services)
{
return services
.AddSecurityContextService()

View File

@ -2,9 +2,11 @@
using System.Security.Authentication;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -39,7 +41,7 @@ namespace ASC.Api.Core.Auth
public static class CookieAuthHandlerExtension
{
public static IServiceCollection AddCookieAuthHandler(this IServiceCollection services)
public static DIHelper AddCookieAuthHandler(this DIHelper services)
{
return services.AddSecurityContextService();
}

View File

@ -27,11 +27,12 @@
using System;
using System.Linq;
using System.Security.Claims;
using ASC.Common;
using ASC.Core;
using ASC.Core.Tenants;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Api.Core
{
@ -270,13 +271,12 @@ namespace ASC.Api.Core
public static class ApiContextConfigExtension
{
public static IServiceCollection AddApiContextService(this IServiceCollection services)
public static DIHelper AddApiContextService(this DIHelper services)
{
services.TryAddScoped<ApiContext>();
return services
.AddTenantManagerService()
.AddHttpContextAccessor()
.AddSecurityContextService();
}
}

View File

@ -28,8 +28,11 @@ using System;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
using ASC.Common;
using ASC.Common.Utils;
using ASC.Core;
using Newtonsoft.Json;
namespace ASC.Api.Core
@ -360,4 +363,29 @@ namespace ASC.Api.Core
return typeof(ApiDateTime).IsAssignableFrom(objectType);
}
}
public class ApiDateTimeHelper
{
public TenantManager TenantManager { get; }
public TimeZoneConverter TimeZoneConverter { get; }
public ApiDateTimeHelper(TenantManager tenantManager, TimeZoneConverter timeZoneConverter)
{
TenantManager = tenantManager;
TimeZoneConverter = timeZoneConverter;
}
public ApiDateTime Get(DateTime? from) => ApiDateTime.FromDate(TenantManager, TimeZoneConverter, from);
}
public static class ApiDateTimeHelperExtension
{
public static DIHelper AddApiDateTimeHelper(this DIHelper services)
{
services.TryAddScoped<ApiDateTimeHelper>();
return services
.AddTenantManagerService();
}
}
}

View File

@ -1,10 +1,12 @@
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Api.Core.Middleware
{
@ -50,7 +52,7 @@ namespace ASC.Api.Core.Middleware
return builder.UseMiddleware<CultureMiddleware>();
}
public static IServiceCollection AddCultureMiddleware(this IServiceCollection services)
public static DIHelper AddCultureMiddleware(this DIHelper services)
{
return services
.AddUserManagerService()

View File

@ -1,11 +1,13 @@
using System.Net;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.IPSecurity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ASC.Api.Core.Middleware
@ -45,7 +47,7 @@ namespace ASC.Api.Core.Middleware
public static class IpSecurityFilterExtension
{
public static IServiceCollection AddIpSecurityFilter(this IServiceCollection services)
public static DIHelper AddIpSecurityFilter(this DIHelper services)
{
return services
.AddSettingsManagerService()

View File

@ -1,13 +1,15 @@
using System.Linq;
using System.Net;
using System.Web;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Web.Api.Routing;
using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ASC.Api.Core.Middleware
@ -50,7 +52,7 @@ namespace ASC.Api.Core.Middleware
public static class PaymentFilterExtension
{
public static IServiceCollection AddPaymentFilter(this IServiceCollection services)
public static DIHelper AddPaymentFilter(this DIHelper services)
{
return services
.AddTenantExtraService();

View File

@ -2,15 +2,17 @@
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Notify.Engine;
using ASC.Core;
using ASC.Web.Core;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ASC.Api.Core.Middleware
@ -123,7 +125,7 @@ namespace ASC.Api.Core.Middleware
public static class ProductSecurityFilterExtension
{
public static IServiceCollection AddProductSecurityFilter(this IServiceCollection services)
public static DIHelper AddProductSecurityFilter(this DIHelper services)
{
return services
.AddUserManagerService()

View File

@ -1,10 +1,12 @@
using System.Net;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Tenants;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ASC.Api.Core.Middleware
@ -46,7 +48,7 @@ namespace ASC.Api.Core.Middleware
public static class TenantStatusFilterExtension
{
public static IServiceCollection AddTenantStatusFilter(this IServiceCollection services)
public static DIHelper AddTenantStatusFilter(this DIHelper services)
{
return services
.AddTenantManagerService();

View File

@ -26,12 +26,13 @@
using System;
using System.Runtime.Serialization;
using ASC.Api.Core;
using ASC.Common;
using ASC.Core;
using ASC.Core.Users;
using ASC.Web.Core.Users;
using ASC.Web.Studio.Utility;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Web.Api.Models
{
@ -67,18 +68,24 @@ namespace ASC.Web.Api.Models
public class EmployeeWraperHelper
{
public UserInfo UserInfo { get; set; }
public ApiContext HttpContext { get; }
public DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
public UserPhotoManager UserPhotoManager { get; }
public CommonLinkUtility CommonLinkUtility { get; }
private ApiContext HttpContext { get; }
private DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
protected UserPhotoManager UserPhotoManager { get; }
private CommonLinkUtility CommonLinkUtility { get; }
protected UserManager UserManager { get; }
public EmployeeWraperHelper(ApiContext httpContext, DisplayUserSettingsHelper displayUserSettingsHelper, UserPhotoManager userPhotoManager, CommonLinkUtility commonLinkUtility)
public EmployeeWraperHelper(
ApiContext httpContext,
DisplayUserSettingsHelper displayUserSettingsHelper,
UserPhotoManager userPhotoManager,
CommonLinkUtility commonLinkUtility,
UserManager userManager)
{
HttpContext = httpContext;
DisplayUserSettingsHelper = displayUserSettingsHelper;
UserPhotoManager = userPhotoManager;
CommonLinkUtility = commonLinkUtility;
UserManager = userManager;
}
public EmployeeWraper Get(UserInfo userInfo)
@ -86,6 +93,18 @@ namespace ASC.Web.Api.Models
return Init(new EmployeeWraper(), userInfo);
}
public EmployeeWraper Get(Guid userId)
{
try
{
return Get(UserManager.GetUsers(userId));
}
catch (Exception)
{
return Get(Constants.LostUser);
}
}
protected EmployeeWraper Init(EmployeeWraper result, UserInfo userInfo)
{
result.Id = userInfo.ID;
@ -114,7 +133,7 @@ namespace ASC.Web.Api.Models
public static class EmployeeWraperExtension
{
public static IServiceCollection AddEmployeeWraper(this IServiceCollection services)
public static DIHelper AddEmployeeWraper(this DIHelper services)
{
services.TryAddScoped<EmployeeWraperHelper>();

View File

@ -28,15 +28,14 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using ASC.Api.Core;
using ASC.Common.Utils;
using ASC.Common;
using ASC.Core;
using ASC.Core.Users;
using ASC.Web.Core;
using ASC.Web.Core.Users;
using ASC.Web.Studio.Utility;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Web.Api.Models
{
@ -160,28 +159,23 @@ namespace ASC.Web.Api.Models
public class EmployeeWraperFullHelper : EmployeeWraperHelper
{
public ApiContext Context { get; }
public UserManager UserManager { get; }
public WebItemSecurity WebItemSecurity { get; }
public TenantManager TenantManager { get; }
public TimeZoneConverter TimeZoneConverter { get; }
private ApiContext Context { get; }
private WebItemSecurity WebItemSecurity { get; }
private ApiDateTimeHelper ApiDateTimeHelper { get; }
public EmployeeWraperFullHelper(
ApiContext context,
UserManager userManager,
UserPhotoManager userPhotoManager,
WebItemSecurity webItemSecurity,
TenantManager tenantManager,
CommonLinkUtility commonLinkUtility,
DisplayUserSettingsHelper displayUserSettingsHelper,
TimeZoneConverter timeZoneConverter)
: base(context, displayUserSettingsHelper, userPhotoManager, commonLinkUtility)
ApiDateTimeHelper apiDateTimeHelper)
: base(context, displayUserSettingsHelper, userPhotoManager, commonLinkUtility, userManager)
{
Context = context;
UserManager = userManager;
WebItemSecurity = webItemSecurity;
TenantManager = tenantManager;
TimeZoneConverter = timeZoneConverter;
ApiDateTimeHelper = apiDateTimeHelper;
}
public EmployeeWraperFull GetFull(UserInfo userInfo)
@ -191,11 +185,11 @@ namespace ASC.Web.Api.Models
UserName = userInfo.UserName,
FirstName = userInfo.FirstName,
LastName = userInfo.LastName,
Birthday = ApiDateTime.FromDate(TenantManager, TimeZoneConverter, userInfo.BirthDate),
Birthday = ApiDateTimeHelper.Get(userInfo.BirthDate),
Status = userInfo.Status,
ActivationStatus = userInfo.ActivationStatus & ~EmployeeActivationStatus.AutoGenerated,
Terminated = ApiDateTime.FromDate(TenantManager, TimeZoneConverter, userInfo.TerminatedDate),
WorkFrom = ApiDateTime.FromDate(TenantManager, TimeZoneConverter, userInfo.WorkFromDate),
Terminated = ApiDateTimeHelper.Get(userInfo.TerminatedDate),
WorkFrom = ApiDateTimeHelper.Get(userInfo.WorkFromDate),
Email = userInfo.Email,
IsVisitor = userInfo.IsVisitor(UserManager),
IsAdmin = userInfo.IsAdmin(UserManager),
@ -303,7 +297,7 @@ namespace ASC.Web.Api.Models
public static class EmployeeWraperFullExtension
{
public static IServiceCollection AddEmployeeWraperFull(this IServiceCollection services)
public static DIHelper AddEmployeeWraperFull(this DIHelper services)
{
services.TryAddScoped<EmployeeWraperFullHelper>();
@ -311,7 +305,8 @@ namespace ASC.Web.Api.Models
.AddTenantManagerService()
.AddWebItemSecurity()
.AddUserManagerService()
.AddEmployeeWraper();
.AddEmployeeWraper()
.AddApiDateTimeHelper();
}
}
}

View File

@ -3,12 +3,17 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common.Logging;
using ASC.Common.Utils;
using Confluent.Kafka;
using Google.Protobuf;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Common.Caching
@ -235,4 +240,14 @@ namespace ASC.Common.Caching
return $"{typeof(T).Name}{cacheNotifyAction}";
}
}
public static class KafkaExtention
{
public static DIHelper AddKafkaService(this DIHelper services)
{
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));
return services;
}
}
}

View File

@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Common
{
public class DIHelper
{
public List<string> Singleton { get; set; }
public List<string> Scoped { get; set; }
public List<string> Transient { get; set; }
public List<string> Configured { get; set; }
public IServiceCollection ServiceCollection { get; }
public DIHelper(IServiceCollection serviceCollection)
{
Singleton = new List<string>();
Scoped = new List<string>();
Transient = new List<string>();
Configured = new List<string>();
ServiceCollection = serviceCollection;
}
public DIHelper TryAddScoped<TService>() where TService : class
{
var serviceName = $"{typeof(TService)}";
if (!Scoped.Contains(serviceName))
{
Scoped.Add(serviceName);
ServiceCollection.TryAddScoped<TService>();
}
return this;
}
public DIHelper TryAddScoped<TService, TImplementation>() where TService : class where TImplementation : class, TService
{
var serviceName = $"{typeof(TService)}{typeof(TImplementation)}";
if (!Scoped.Contains(serviceName))
{
Scoped.Add(serviceName);
ServiceCollection.TryAddScoped<TService, TImplementation>();
}
return this;
}
public DIHelper TryAddScoped<TService, TImplementation>(TService tservice, TImplementation tImplementation) where TService : Type where TImplementation : Type
{
var serviceName = $"{tservice}{tImplementation}";
if (!Scoped.Contains(serviceName))
{
Scoped.Add(serviceName);
ServiceCollection.TryAddScoped(tservice, tImplementation);
}
return this;
}
public DIHelper TryAddSingleton<TService>() where TService : class
{
var serviceName = $"{typeof(TService)}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.TryAddSingleton<TService>();
}
return this;
}
public DIHelper TryAddSingleton<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
var serviceName = $"{typeof(TService)}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.TryAddSingleton(implementationFactory);
}
return this;
}
public DIHelper TryAddSingleton<TService>(TService t) where TService : class
{
var serviceName = $"{typeof(TService)}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.TryAddSingleton(t);
}
return this;
}
public DIHelper TryAddSingleton<TService, TImplementation>() where TService : class where TImplementation : class, TService
{
var serviceName = $"{typeof(TService)}{typeof(TImplementation)}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.TryAddSingleton<TService, TImplementation>();
}
return this;
}
public DIHelper AddSingleton<TService, TImplementation>() where TService : class where TImplementation : class, TService
{
var serviceName = $"{typeof(TService)}{typeof(TImplementation)}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.AddSingleton<TService, TImplementation>();
}
return this;
}
public DIHelper TryAddSingleton<TService, TImplementation>(TService tservice, TImplementation tImplementation) where TService : Type where TImplementation : Type
{
var serviceName = $"{tservice}{tImplementation}";
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
ServiceCollection.TryAddSingleton(tservice, tImplementation);
}
return this;
}
public DIHelper TryAddTransient<TService>() where TService : class
{
var serviceName = $"{typeof(TService)}";
if (!Transient.Contains(serviceName))
{
Transient.Add(serviceName);
ServiceCollection.TryAddTransient<TService>();
}
return this;
}
public DIHelper Configure<TOptions>(Action<TOptions> configureOptions) where TOptions : class
{
var serviceName = $"{typeof(TOptions)}";
if (!Configured.Contains(serviceName))
{
Configured.Add(serviceName);
ServiceCollection.Configure(configureOptions);
}
return this;
}
public DIHelper Configure<TOptions>(string name, Action<TOptions> configureOptions) where TOptions : class
{
var serviceName = $"{typeof(TOptions)}{name}";
if (!Configured.Contains(serviceName))
{
Configured.Add(serviceName);
ServiceCollection.Configure(name, configureOptions);
}
return this;
}
}
}

View File

@ -107,7 +107,9 @@ namespace ASC.Common.DependencyInjection
AssemblyLoadContext.Default.Resolving += (c, n) =>
{
var path = GetFullPath(n.Name);
return c.LoadFromAssemblyPath(Path.Combine(Path.GetDirectoryName(path), $"{n.Name}.dll"));
return path != null ?
c.LoadFromAssemblyPath(Path.Combine(Path.GetDirectoryName(path), $"{n.Name}.dll")) :
null;
};
}
}

View File

@ -119,7 +119,7 @@ namespace ASC.Common.Logging
public static class LoggerExtension
{
public static IServiceCollection AddLoggerService(this IServiceCollection services)
public static DIHelper AddLoggerService(this DIHelper services)
{
services.TryAddScoped<EFLoggerFactory>();
services.TryAddScoped<EFLoggerProvider>();

View File

@ -28,13 +28,16 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using ASC.Common.Utils;
using log4net.Config;
using log4net.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using NLog;
namespace ASC.Common.Logging
@ -865,7 +868,7 @@ namespace ASC.Common.Logging
public static class StudioNotifyHelperExtension
{
public static IServiceCollection AddLogManager<T>(this IServiceCollection services, params string[] additionalLoggers) where T : class, ILog, new()
public static DIHelper AddLogManager<T>(this DIHelper services, params string[] additionalLoggers) where T : class, ILog, new()
{
const string baseName = "ASC";
var baseSqlName = $"{baseName}.SQL";
@ -882,7 +885,7 @@ namespace ASC.Common.Logging
return services;
}
public static IServiceCollection AddNLogManager(this IServiceCollection services, params string[] additionalLoggers)
public static DIHelper AddNLogManager(this DIHelper services, params string[] additionalLoggers)
{
services.TryAddSingleton<IConfigureOptions<LogNLog>, ConfigureLogNLog>();
return services.AddLogManager<LogNLog>(additionalLoggers);

View File

@ -29,8 +29,7 @@ using System.IO;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using ASC.Common;
namespace ASC.Security.Cryptography
{
@ -89,7 +88,7 @@ namespace ASC.Security.Cryptography
}
public static class InstanceCryptoExtension
{
public static IServiceCollection AddInstanceCryptoService(this IServiceCollection services)
public static DIHelper AddInstanceCryptoService(this DIHelper services)
{
services.TryAddSingleton<InstanceCrypto>();

View File

@ -28,10 +28,11 @@ using System;
using System.IO;
using System.Linq;
using System.Text;
using ASC.Common;
using ASC.Common.Security;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Security.Cryptography
{
@ -77,7 +78,7 @@ namespace ASC.Security.Cryptography
}
public static class MachinePseudoKeysExtension
{
public static IServiceCollection AddMachinePseudoKeysService(this IServiceCollection services)
public static DIHelper AddMachinePseudoKeysService(this DIHelper services)
{
services.TryAddSingleton<MachinePseudoKeys>();

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common.Caching;
namespace ASC.Common.Threading
@ -176,6 +177,21 @@ namespace ASC.Common.Threading
return task;
}
public void SetTask(DistributedTask task)
{
DistributedTaskCacheNotify.SetTask(task);
}
public void RemoveTask(string id)
{
DistributedTaskCacheNotify.RemoveTask(id, key);
}
public void CancelTask(string id)
{
DistributedTaskCacheNotify.CancelTask(id);
}
private void OnCompleted(Task task, string id)
{
var distributedTask = GetTask(id);

View File

@ -101,7 +101,7 @@ namespace ASC.Common.Utils
public static class SignatureExtension
{
public static IServiceCollection AddSignatureService(this IServiceCollection services)
public static DIHelper AddSignatureService(this DIHelper services)
{
services.TryAddSingleton<Signature>();
return services.AddMachinePseudoKeysService();

View File

@ -28,12 +28,14 @@ using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Web;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using HttpContext = Microsoft.AspNetCore.Http.HttpContext;
namespace ASC.Core.Common
@ -235,9 +237,9 @@ namespace ASC.Core.Common
public static class BaseCommonLinkUtilityExtension
{
public static IServiceCollection AddBaseCommonLinkUtilityService(this IServiceCollection services)
public static DIHelper AddBaseCommonLinkUtilityService(this DIHelper services)
{
services.TryAddScoped<BaseCommonLinkUtility>(); ;
services.TryAddScoped<BaseCommonLinkUtility>();
return services
.AddCoreBaseSettingsService()

View File

@ -30,13 +30,13 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Tenants;
using ASC.Core.Users;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Billing
@ -339,7 +339,7 @@ namespace ASC.Core.Billing
public static class LicenseReaderExtension
{
public static IServiceCollection AddLicenseReaderService(this IServiceCollection services)
public static DIHelper AddLicenseReaderService(this DIHelper services)
{
services.TryAddScoped<LicenseReader>();

View File

@ -31,6 +31,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core.Caching;
@ -38,8 +39,6 @@ using ASC.Core.Common.EF;
using ASC.Core.Tenants;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Billing
@ -687,7 +686,7 @@ namespace ASC.Core.Billing
public static class TariffConfigExtension
{
public static IServiceCollection AddTariffService(this IServiceCollection services)
public static DIHelper AddTariffService(this DIHelper services)
{
services.AddCoreDbContextService();

View File

@ -26,11 +26,11 @@
using System;
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core.Common.EF;
using ASC.Core.Data;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Caching
{
@ -121,7 +121,7 @@ namespace ASC.Core.Caching
public static class AzConfigExtension
{
public static IServiceCollection AddAzService(this IServiceCollection services)
public static DIHelper AddAzService(this DIHelper services)
{
services.AddCoreDbContextService();

View File

@ -28,13 +28,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core.Common.EF;
using ASC.Core.Data;
using ASC.Core.Tenants;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@ -241,7 +241,7 @@ namespace ASC.Core.Caching
public static class QuotaConfigExtension
{
public static IServiceCollection AddQuotaService(this IServiceCollection services)
public static DIHelper AddQuotaService(this DIHelper services)
{
services.AddCoreDbContextService();

View File

@ -27,11 +27,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core.Common.EF;
using ASC.Core.Data;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Caching
{
@ -288,7 +288,7 @@ namespace ASC.Core.Caching
public static class SubscriptionConfigExtension
{
public static IServiceCollection AddSubscriptionService(this IServiceCollection services)
public static DIHelper AddSubscriptionService(this DIHelper services)
{
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));

View File

@ -27,13 +27,13 @@
using System;
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Utils;
using ASC.Core.Common.EF.Context;
using ASC.Core.Data;
using ASC.Core.Tenants;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@ -306,7 +306,7 @@ namespace ASC.Core.Caching
public static class TenantConfigExtension
{
public static IServiceCollection AddTenantService(this IServiceCollection services)
public static DIHelper AddTenantService(this DIHelper services)
{
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));
services.TryAddSingleton<TenantDomainValidator>();

View File

@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core.Common.EF;
@ -36,7 +37,6 @@ using ASC.Core.Data;
using ASC.Core.Tenants;
using ASC.Core.Users;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@ -515,7 +515,7 @@ namespace ASC.Core.Caching
}
public static class UserConfigExtension
{
public static IServiceCollection AddUserService(this IServiceCollection services)
public static DIHelper AddUserService(this DIHelper services)
{
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));

View File

@ -29,14 +29,13 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core.Tenants;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Common.Configuration
{
@ -431,7 +430,7 @@ namespace ASC.Core.Common.Configuration
public static class ConsumerFactoryExtension
{
public static IServiceCollection AddConsumerFactoryService(this IServiceCollection services)
public static DIHelper AddConsumerFactoryService(this DIHelper services)
{
services.TryAddScoped<ConsumerFactory>();
return services;

View File

@ -27,15 +27,13 @@
using System;
using System.Linq;
using ASC.Common;
using ASC.Common.Security.Authentication;
using ASC.Core.Caching;
using ASC.Core.Security.Authentication;
using ASC.Core.Tenants;
using ASC.Core.Users;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core
{
public class AuthManager
@ -85,7 +83,7 @@ namespace ASC.Core
}
public static class AuthManagerExtension
{
public static IServiceCollection AddAuthManager(this IServiceCollection services)
public static DIHelper AddAuthManager(this DIHelper services)
{
services.TryAddScoped<AuthManager>();
return services

View File

@ -27,11 +27,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Security;
using ASC.Common.Security.Authorizing;
using ASC.Core.Caching;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core
{
@ -131,7 +131,7 @@ namespace ASC.Core
public static class AuthorizationManagerConfigExtension
{
public static IServiceCollection AddAuthorizationManagerService(this IServiceCollection services)
public static DIHelper AddAuthorizationManagerService(this DIHelper services)
{
services.TryAddScoped<AuthorizationManager>();
return services

View File

@ -27,14 +27,13 @@
using System;
using System.Text;
using ASC.Common;
using ASC.Core.Caching;
using ASC.Core.Common.Settings;
using ASC.Core.Configuration;
using ASC.Core.Tenants;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
@ -371,13 +370,13 @@ namespace ASC.Core
public static class CoreSettingsConfigExtension
{
public static IServiceCollection AddCoreBaseSettingsService(this IServiceCollection services)
public static DIHelper AddCoreBaseSettingsService(this DIHelper services)
{
services.TryAddSingleton<CoreBaseSettings>();
return services;
}
public static IServiceCollection AddCoreSettingsService(this IServiceCollection services)
public static DIHelper AddCoreSettingsService(this DIHelper services)
{
services.TryAddScoped<CoreSettings>();
services.TryAddScoped<CoreConfiguration>();
@ -387,7 +386,7 @@ namespace ASC.Core
.AddCoreBaseSettingsService()
.AddTenantService();
}
public static IServiceCollection AddCoreConfigurationService(this IServiceCollection services)
public static DIHelper AddCoreConfigurationService(this DIHelper services)
{
services.TryAddScoped<CoreConfiguration>();
return services

View File

@ -34,13 +34,12 @@ using System.Text;
using System.Threading;
using System.Web;
using ASC.Common;
using ASC.Core.Billing;
using ASC.Core.Caching;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Newtonsoft.Json;
@ -181,7 +180,7 @@ namespace ASC.Core
public static class PaymentManagerExtension
{
public static IServiceCollection AddPaymentManagerService(this IServiceCollection services)
public static DIHelper AddPaymentManagerService(this DIHelper services)
{
services.TryAddScoped<PaymentManager>();

View File

@ -26,9 +26,9 @@
using System;
using System.Linq;
using ASC.Common;
using ASC.Core.Caching;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core
{
@ -151,7 +151,7 @@ namespace ASC.Core
public static class SubscriptionConfigExtension
{
public static IServiceCollection AddSubscriptionManagerService(this IServiceCollection services)
public static DIHelper AddSubscriptionManagerService(this DIHelper services)
{
services.TryAddScoped<SubscriptionManager>();
return services

View File

@ -31,15 +31,13 @@ using System.Net;
using System.Threading;
using System.Web;
using ASC.Common;
using ASC.Common.Notify.Engine;
using ASC.Core.Billing;
using ASC.Core.Caching;
using ASC.Core.Tenants;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core
@ -340,7 +338,7 @@ namespace ASC.Core
public static class TenantManagerConfigExtension
{
public static IServiceCollection AddTenantManagerService(this IServiceCollection services)
public static DIHelper AddTenantManagerService(this DIHelper services)
{
services.TryAddScoped<TenantManager>();
services.TryAddScoped<IConfigureOptions<TenantManager>, ConfigureTenantManager>();

View File

@ -29,13 +29,12 @@ using System.Collections.Generic;
using System.Linq;
using ASC.Collections;
using ASC.Common;
using ASC.Core.Caching;
using ASC.Core.Tenants;
using ASC.Core.Users;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core
{
@ -68,6 +67,11 @@ namespace ASC.Core
private Tenant tenant;
private Tenant Tenant { get { return tenant ?? (tenant = TenantManager.GetCurrentTenant()); } }
public UserManager()
{
}
public UserManager(
IUserService service,
IHttpContextAccessor httpContextAccessor,
@ -634,7 +638,7 @@ namespace ASC.Core
public static class UserManagerConfigExtension
{
public static IServiceCollection AddUserManagerService(this IServiceCollection services)
public static DIHelper AddUserManagerService(this DIHelper services)
{
services.TryAddSingleton<UserManagerConstants>();
services.TryAddScoped<UserManager>();

View File

@ -33,6 +33,7 @@ using System.Security.Claims;
using System.Threading;
using System.Web;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Security;
using ASC.Common.Security.Authentication;
@ -46,8 +47,6 @@ using ASC.Core.Users;
using ASC.Security.Cryptography;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core
@ -265,7 +264,7 @@ namespace ASC.Core
public void Logout()
{
AuthContext.Principal = null;
AuthContext.Logout();
}
public void SetUserPassword(Guid userID, string password)
@ -320,6 +319,11 @@ namespace ASC.Core
{
private IHttpContextAccessor HttpContextAccessor { get; }
public AuthContext()
{
}
public AuthContext(IHttpContextAccessor httpContextAccessor)
{
HttpContextAccessor = httpContextAccessor;
@ -335,6 +339,11 @@ namespace ASC.Core
get { return CurrentAccount.IsAuthenticated; }
}
public void Logout()
{
Principal = null;
}
internal ClaimsPrincipal Principal
{
get => Thread.CurrentPrincipal as ClaimsPrincipal ?? HttpContextAccessor?.HttpContext?.User;
@ -348,7 +357,7 @@ namespace ASC.Core
public static class AuthContextConfigExtension
{
public static IServiceCollection AddSecurityContextService(this IServiceCollection services)
public static DIHelper AddSecurityContextService(this DIHelper services)
{
services.TryAddScoped<SecurityContext>();
@ -361,13 +370,13 @@ namespace ASC.Core
.AddUserManagerService()
.AddTenantManagerService();
}
public static IServiceCollection AddAuthContextService(this IServiceCollection services)
public static DIHelper AddAuthContextService(this DIHelper services)
{
services.TryAddScoped<AuthContext>();
return services;
}
public static IServiceCollection AddPermissionContextService(this IServiceCollection services)
public static DIHelper AddPermissionContextService(this DIHelper services)
{
services.TryAddScoped<PermissionContext>();

View File

@ -36,6 +36,7 @@ using System.Runtime.Caching;
using System.Text.RegularExpressions;
using System.Web;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Common.EF;
@ -43,8 +44,6 @@ using ASC.Core.Common.EF.Context;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace TMResourceData
@ -375,7 +374,7 @@ namespace TMResourceData
public static class WhiteLabelHelperExtension
{
public static IServiceCollection AddWhiteLabelHelperService(this IServiceCollection services)
public static DIHelper AddWhiteLabelHelperService(this DIHelper services)
{
services.TryAddSingleton<WhiteLabelHelper>();
return services;

View File

@ -31,6 +31,7 @@ using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core.Common.EF;
@ -39,8 +40,6 @@ using ASC.Core.Common.EF.Model;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Data
@ -349,7 +348,7 @@ namespace ASC.Core.Data
public static class DbSettingsManagerExtension
{
public static IServiceCollection AddDbSettingsManagerService(this IServiceCollection services)
public static DIHelper AddDbSettingsManagerService(this DIHelper services)
{
services.TryAddSingleton<DbSettingsManagerCache>();
services.TryAddScoped<DbSettingsManager>();

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -17,7 +17,7 @@ namespace ASC.Core.Common.EF.Context
public static class AccountLinkContextExtension
{
public static IServiceCollection AddAccountLinkContextService(this IServiceCollection services)
public static DIHelper AddAccountLinkContextService(this DIHelper services)
{
return services.AddDbContextManagerService<AccountLinkContext>();
}

View File

@ -1,6 +1,7 @@

using ASC.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF
{
@ -30,7 +31,7 @@ namespace ASC.Core.Common.EF
public static class CoreDbExtension
{
public static IServiceCollection AddCoreDbContextService(this IServiceCollection services)
public static DIHelper AddCoreDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<CoreDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -27,7 +27,7 @@ namespace ASC.Core.Common.EF.Context
public static class DbContextExtension
{
public static IServiceCollection AddDbContextService(this IServiceCollection services)
public static DIHelper AddDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<DbContext>();
}

View File

@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using ASC.Common;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@ -70,7 +71,7 @@ namespace ASC.Core.Common.EF
public static class DbContextManagerExtension
{
public static IServiceCollection AddDbContextManagerService<T>(this IServiceCollection services) where T : BaseDbContext, new()
public static DIHelper AddDbContextManagerService<T>(this DIHelper services) where T : BaseDbContext, new()
{
services.TryAddScoped<DbContextManager<T>>();
services.TryAddScoped<MultiRegionalDbContextManager<T>>();

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -22,7 +22,7 @@ namespace ASC.Core.Common.EF.Context
public static class FeedDbExtension
{
public static IServiceCollection AddFeedDbService(this IServiceCollection services)
public static DIHelper AddFeedDbService(this DIHelper services)
{
return services.AddDbContextManagerService<FeedDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -17,7 +17,7 @@ namespace ASC.Core.Common.EF.Context
public static class FilesDbExtension
{
public static IServiceCollection AddFilesDbContextService(this IServiceCollection services)
public static DIHelper AddFilesDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<FilesDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model.Mail;
using ASC.Common;
using ASC.Core.Common.EF.Model.Mail;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -22,7 +22,7 @@ namespace ASC.Core.Common.EF.Context
}
public static class MailDbExtension
{
public static IServiceCollection AddMailDbContextService(this IServiceCollection services)
public static DIHelper AddMailDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<MailDbContext>();
}

View File

@ -1,8 +1,8 @@

using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -22,7 +22,7 @@ namespace ASC.Core.Common.EF.Context
public static class MessagesContextExtension
{
public static IServiceCollection AddMessagesContextService(this IServiceCollection services)
public static DIHelper AddMessagesContextService(this DIHelper services)
{
return services.AddDbContextManagerService<MessagesContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -13,7 +13,7 @@ namespace ASC.Core.Common.EF.Context
public static class NotifyDbExtension
{
public static IServiceCollection AddNotifyDbContext(this IServiceCollection services)
public static DIHelper AddNotifyDbContext(this DIHelper services)
{
return services.AddDbContextManagerService<NotifyDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model.Resource;
using ASC.Common;
using ASC.Core.Common.EF.Model.Resource;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -25,7 +25,7 @@ namespace ASC.Core.Common.EF.Context
public static class ResourceDbExtension
{
public static IServiceCollection AddResourceDbService(this IServiceCollection services)
public static DIHelper AddResourceDbService(this DIHelper services)
{
return services.AddDbContextManagerService<ResourceDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -38,7 +38,7 @@ namespace ASC.Core.Common.EF.Context
public static class TenantDbExtension
{
public static IServiceCollection AddTenantDbContextService(this IServiceCollection services)
public static DIHelper AddTenantDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<TenantDbContext>();
}

View File

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using ASC.Common;
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF
{
@ -32,7 +33,7 @@ namespace ASC.Core.Common.EF
public static class UserDbExtension
{
public static IServiceCollection AddUserDbContextService(this IServiceCollection services)
public static DIHelper AddUserDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<UserDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -14,7 +14,7 @@ namespace ASC.Core.Common.EF.Context
public static class VoipDbExtension
{
public static IServiceCollection AddVoipDbContextService(this IServiceCollection services)
public static DIHelper AddVoipDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<VoipDbContext>();
}

View File

@ -1,7 +1,7 @@
using ASC.Core.Common.EF.Model;
using ASC.Common;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Core.Common.EF.Context
{
@ -9,6 +9,7 @@ namespace ASC.Core.Common.EF.Context
{
public DbSet<DbWebstudioSettings> WebstudioSettings { get; set; }
public DbSet<DbWebstudioUserVisit> WebstudioUserVisit { get; set; }
public DbSet<DbWebstudioIndex> WebstudioIndex { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@ -20,7 +21,7 @@ namespace ASC.Core.Common.EF.Context
public static class WebstudioDbExtension
{
public static IServiceCollection AddWebstudioDbContextService(this IServiceCollection services)
public static DIHelper AddWebstudioDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<WebstudioDbContext>();
}

View File

@ -0,0 +1,17 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ASC.Core.Common.EF.Model
{
[Table("webstudio_index")]
public class DbWebstudioIndex
{
[Key]
[Column("index_name")]
public string IndexName { get; set; }
[Column("last_modified")]
public DateTime LastModified { get; set; }
}
}

View File

@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Security;
using ASC.Common;
using ASC.Core.Billing;
using ASC.Core.Caching;
using ASC.Core.Data;
@ -37,7 +38,6 @@ using ASC.Core.Tenants;
using ASC.Core.Users;
using ASC.Security.Cryptography;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ASC.Core
@ -295,9 +295,9 @@ namespace ASC.Core
public static class HostedSolutionExtension
{
public static IServiceCollection AddHostedSolutionService(this IServiceCollection services)
public static DIHelper AddHostedSolutionService(this DIHelper services)
{
services.AddScoped<IConfigureOptions<HostedSolution>, ConfigureHostedSolution>();
services.TryAddScoped<IConfigureOptions<HostedSolution>, ConfigureHostedSolution>();
return services
.AddUserFormatter()

View File

@ -27,9 +27,9 @@
using System;
using System.Collections.Generic;
using System.ServiceModel;
using ASC.Common;
using ASC.Core.Common.Notify.Jabber;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Notify.Jabber
{
@ -242,7 +242,7 @@ namespace ASC.Core.Notify.Jabber
public static class JabberServiceClientExtension
{
public static IServiceCollection AddJabberServiceClient(this IServiceCollection services)
public static DIHelper AddJabberServiceClient(this DIHelper services)
{
services.TryAddScoped<JabberServiceClient>();
return services

View File

@ -27,9 +27,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Core.Users;
using ASC.Notify.Recipients;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Notify
@ -160,7 +162,7 @@ namespace ASC.Core.Notify
public static class RecipientProviderImplExtension
{
public static IServiceCollection AddRecipientProviderImplService(this IServiceCollection services)
public static DIHelper AddRecipientProviderImplService(this DIHelper services)
{
services.TryAddScoped(typeof(IRecipientProvider), typeof(RecipientProviderImpl));

View File

@ -29,16 +29,19 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Amazon;
using Amazon.Runtime;
using Amazon.SimpleEmail;
using Amazon.SimpleEmail.Model;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Notify.Messages;
using ASC.Notify.Patterns;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Notify.Senders
@ -230,7 +233,7 @@ namespace ASC.Core.Notify.Senders
public static class AWSSenderExtension
{
public static IServiceCollection AddAWSSenderService(this IServiceCollection services)
public static DIHelper AddAWSSenderService(this DIHelper services)
{
services.TryAddSingleton<AWSSender>();
return services

View File

@ -27,11 +27,13 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Notify.Jabber;
using ASC.Notify.Messages;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Notify.Senders
@ -77,7 +79,7 @@ namespace ASC.Core.Notify.Senders
public static class JabberSenderExtension
{
public static IServiceCollection AddJabberSenderService(this IServiceCollection services)
public static DIHelper AddJabberSenderService(this DIHelper services)
{
services.TryAddSingleton<JabberSender>();
return services.AddJabberServiceClient();

View File

@ -28,16 +28,20 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Notify.Messages;
using ASC.Notify.Patterns;
using MailKit;
using MailKit.Security;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using MimeKit;
namespace ASC.Core.Notify.Senders
@ -320,7 +324,7 @@ namespace ASC.Core.Notify.Senders
public static class SmtpSenderExtension
{
public static IServiceCollection AddSmtpSenderService(this IServiceCollection services)
public static DIHelper AddSmtpSenderService(this DIHelper services)
{
services.TryAddSingleton<SmtpSender>();
return services

View File

@ -31,58 +31,59 @@ using System.Net;
using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Common.Notify.Jabber;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace ASC.Core.Notify.Signalr
{
public class SignalrServiceClient
public class ConfigureSignalrServiceClient : IConfigureNamedOptions<SignalrServiceClient>
{
private static readonly TimeSpan Timeout;
private readonly ILog Log;
private static DateTime lastErrorTime;
public readonly bool EnableSignalr;
private readonly string CoreMachineKey;
private readonly string Url;
private readonly bool JabberReplaceDomain;
private readonly string JabberReplaceFromDomain;
private readonly string JabberReplaceToDomain;
private readonly string hub;
public TenantManager TenantManager { get; }
public CoreSettings CoreSettings { get; }
public IConfiguration Configuration { get; }
public IOptionsMonitor<ILog> Options { get; }
static SignalrServiceClient()
public ConfigureSignalrServiceClient(
TenantManager tenantManager,
CoreSettings coreSettings,
IConfiguration configuration,
IOptionsMonitor<ILog> options)
{
Timeout = TimeSpan.FromSeconds(1);
}
public SignalrServiceClient(string hub, TenantManager tenantManager, CoreSettings coreSettings, IConfiguration configuration, IOptionsMonitor<ILog> options)
{
Log = options.CurrentValue;
this.hub = hub.Trim('/');
TenantManager = tenantManager;
CoreSettings = coreSettings;
CoreMachineKey = configuration["core:machinekey"];
Url = configuration["web:hub:internal"];
EnableSignalr = !string.IsNullOrEmpty(Url);
Configuration = configuration;
Options = options;
}
public void Configure(string name, SignalrServiceClient options)
{
options.Log = Options.CurrentValue;
options.hub = name.Trim('/');
options.TenantManager = TenantManager;
options.CoreSettings = CoreSettings;
options.CoreMachineKey = Configuration["core:machinekey"];
options.Url = Configuration["web:hub:internal"];
options.EnableSignalr = !string.IsNullOrEmpty(options.Url);
try
{
var replaceSetting = configuration["jabber:replace-domain"];
var replaceSetting = Configuration["jabber:replace-domain"];
if (!string.IsNullOrEmpty(replaceSetting))
{
JabberReplaceDomain = true;
options.JabberReplaceDomain = true;
var q =
replaceSetting.Split(new[] { "->" }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim().ToLowerInvariant())
.ToList();
JabberReplaceFromDomain = q.ElementAt(0);
JabberReplaceToDomain = q.ElementAt(1);
options.JabberReplaceFromDomain = q.ElementAt(0);
options.JabberReplaceToDomain = q.ElementAt(1);
}
}
catch (Exception)
@ -90,6 +91,40 @@ namespace ASC.Core.Notify.Signalr
}
}
public void Configure(SignalrServiceClient options)
{
Configure("default", options);
}
}
public class SignalrServiceClient
{
private static readonly TimeSpan Timeout;
internal ILog Log;
private static DateTime lastErrorTime;
public bool EnableSignalr;
internal string CoreMachineKey;
internal string Url;
internal bool JabberReplaceDomain;
internal string JabberReplaceFromDomain;
internal string JabberReplaceToDomain;
internal string hub;
public TenantManager TenantManager { get; internal set; }
public CoreSettings CoreSettings { get; internal set; }
static SignalrServiceClient()
{
Timeout = TimeSpan.FromSeconds(1);
}
public SignalrServiceClient()
{
}
public void SendMessage(string callerUserName, string calleeUserName, string messageText, int tenantId,
string domain)
{
@ -355,4 +390,17 @@ namespace ASC.Core.Notify.Signalr
return string.Format("ASC {0}:{1}:{2}", pkey, now, hash);
}
}
public static class SignalrServiceClientExtension
{
public static DIHelper AddSignalrServiceClient(this DIHelper services)
{
services.TryAddScoped<SignalrServiceClient>();
services.TryAddScoped<IConfigureOptions<SignalrServiceClient>, ConfigureSignalrServiceClient>();
return services
.AddTenantManagerService()
.AddCoreSettingsService();
}
}
}

View File

@ -28,13 +28,12 @@ using System;
using System.Globalization;
using System.Web;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Tenants;
using ASC.Security.Cryptography;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Security.Authentication
@ -141,7 +140,7 @@ namespace ASC.Core.Security.Authentication
public static class CookieStorageExtension
{
public static IServiceCollection AddCookieStorageService(this IServiceCollection services)
public static DIHelper AddCookieStorageService(this DIHelper services)
{
services.TryAddScoped<CookieStorage>();

View File

@ -150,7 +150,7 @@ namespace ASC.Common.Security.Authorizing
public static class AzManagerConfigExtension
{
public static IServiceCollection AddAzManagerService(this IServiceCollection services)
public static DIHelper AddAzManagerService(this DIHelper services)
{
services.TryAddScoped<AzManager>();

View File

@ -27,9 +27,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Security;
using ASC.Common.Security.Authorizing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Security.Authorizing
@ -56,7 +58,7 @@ namespace ASC.Core.Security.Authorizing
public static class PermissionProviderConfigExtension
{
public static IServiceCollection AddPermissionProviderService(this IServiceCollection services)
public static DIHelper AddPermissionProviderService(this DIHelper services)
{
services.TryAddScoped(typeof(IPermissionProvider), typeof(PermissionProvider));
return services.AddAuthorizationManagerService();

View File

@ -27,11 +27,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Security;
using ASC.Common.Security.Authentication;
using ASC.Common.Security.Authorizing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Constants = ASC.Core.Configuration.Constants;
namespace ASC.Core.Security.Authorizing
@ -125,7 +128,7 @@ namespace ASC.Core.Security.Authorizing
public static class PermissionResolverConfigExtention
{
public static IServiceCollection AddPermissionResolverService(this IServiceCollection services)
public static DIHelper AddPermissionResolverService(this DIHelper services)
{
services.TryAddScoped(typeof(IPermissionResolver), typeof(PermissionResolver));
return services.AddAzManagerService();

View File

@ -27,10 +27,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Security;
using ASC.Common.Security.Authentication;
using ASC.Common.Security.Authorizing;
using ASC.Core.Users;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -86,7 +89,7 @@ namespace ASC.Core.Security.Authorizing
public static class RoleProviderConfigExtention
{
public static IServiceCollection AddRoleProviderService(this IServiceCollection services)
public static DIHelper AddRoleProviderService(this DIHelper services)
{
services.TryAddScoped(typeof(IRoleProvider), typeof(RoleProvider));
return services;

View File

@ -27,6 +27,7 @@
using System;
using System.Text;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Users;
@ -35,8 +36,6 @@ using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using static ASC.Security.Cryptography.EmailValidationKeyProvider;
@ -251,7 +250,7 @@ namespace ASC.Security.Cryptography
public static class EmailValidationKeyProviderExtension
{
public static IServiceCollection AddEmailValidationKeyProviderService(this IServiceCollection services)
public static DIHelper AddEmailValidationKeyProviderService(this DIHelper services)
{
services.TryAddScoped<EmailValidationKeyProvider>();

View File

@ -25,12 +25,13 @@
using System;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Common.EF;
using ASC.Core.Common.EF.Context;
using ASC.Core.Data;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Common.Settings
@ -52,7 +53,7 @@ namespace ASC.Core.Common.Settings
public static class SettingsManagerExtention
{
public static IServiceCollection AddSettingsManagerService(this IServiceCollection services)
public static DIHelper AddSettingsManagerService(this DIHelper services)
{
services.TryAddScoped<SettingsManager>();

View File

@ -27,10 +27,11 @@
using System;
using System.Linq;
using System.Runtime.Serialization;
using ASC.Common;
using ASC.Core.Common.Settings;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Tenants
{
@ -126,7 +127,7 @@ namespace ASC.Core.Tenants
public static class TenantCookieSettingsExtention
{
public static IServiceCollection AddTenantCookieSettingsService(this IServiceCollection services)
public static DIHelper AddTenantCookieSettingsService(this DIHelper services)
{
services.TryAddScoped<TenantCookieSettingsHelper>();
return services.AddSettingsManagerService();

View File

@ -26,10 +26,8 @@
using System;
using ASC.Common;
using ASC.Common.Utils;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Core.Tenants
@ -143,7 +141,7 @@ namespace ASC.Core.Tenants
public static class TenantUtilExtention
{
public static IServiceCollection AddTenantUtilService(this IServiceCollection services)
public static DIHelper AddTenantUtilService(this DIHelper services)
{
services.TryAddScoped<TenantUtil>();
services.TryAddScoped<IConfigureOptions<TenantUtil>, ConfigureTenantUtil>();

View File

@ -25,9 +25,11 @@
using System;
using ASC.Common;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Action = ASC.Common.Security.Authorizing.Action;
using AuthConst = ASC.Common.Security.Authorizing.Constants;
@ -145,7 +147,7 @@ namespace ASC.Core.Users
public static class ConstantsConfigFactory
{
public static IServiceCollection AddConstantsService(this IServiceCollection services)
public static DIHelper AddConstantsService(this DIHelper services)
{
services.TryAddSingleton<Constants>();
return services;

View File

@ -27,11 +27,11 @@
using System;
using System.Runtime.Serialization;
using System.Web;
using ASC.Common;
using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.Core.Users;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Web.Core.Users
{
@ -98,7 +98,7 @@ namespace ASC.Web.Core.Users
public static class DisplayUserSettingsExtention
{
public static IServiceCollection AddDisplayUserSettingsService(this IServiceCollection services)
public static DIHelper AddDisplayUserSettingsService(this DIHelper services)
{
services.TryAddScoped<DisplayUserSettingsHelper>();

View File

@ -29,9 +29,9 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using ASC.Common;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Core.Users
{
@ -149,7 +149,7 @@ namespace ASC.Core.Users
}
public static class UserFormatterExtension
{
public static IServiceCollection AddUserFormatter(this IServiceCollection services)
public static DIHelper AddUserFormatter(this DIHelper services)
{
services.TryAddSingleton<UserFormatter>();
return services;

View File

@ -26,11 +26,13 @@
using System;
using System.Runtime.Serialization;
using ASC.Common;
using ASC.Core.Common;
using ASC.Core.Common.Settings;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Web.Core.WhiteLabel
{
@ -165,7 +167,7 @@ namespace ASC.Web.Core.WhiteLabel
public static class MailWhiteLabelSettingsExtention
{
public static IServiceCollection AddMailWhiteLabelSettingsService(this IServiceCollection services)
public static DIHelper AddMailWhiteLabelSettingsService(this DIHelper services)
{
services.TryAddSingleton<MailWhiteLabelSettingsHelper>();
return services.AddSettingsManagerService();

View File

@ -28,12 +28,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Threading.Progress;
using ASC.Core.Users;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Reassigns
@ -143,7 +143,7 @@ namespace ASC.Data.Reassigns
public static class QueueExtension
{
public static IServiceCollection AddQueueWorkerRemoveService(this IServiceCollection services)
public static DIHelper AddQueueWorkerRemoveService(this DIHelper services)
{
services.TryAddSingleton<ProgressQueueOptionsManager<RemoveProgressItem>>();
services.TryAddSingleton<ProgressQueue<RemoveProgressItem>>();
@ -152,7 +152,7 @@ namespace ASC.Data.Reassigns
return services;
}
public static IServiceCollection AddQueueWorkerReassignService(this IServiceCollection services)
public static DIHelper AddQueueWorkerReassignService(this DIHelper services)
{
services.TryAddSingleton<ProgressQueueOptionsManager<ReassignProgressItem>>();
services.TryAddSingleton<ProgressQueue<ReassignProgressItem>>();

View File

@ -26,6 +26,8 @@
using System;
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Logging;
//using System.Web;
using ASC.Common.Threading.Progress;
@ -41,7 +43,6 @@ using ASC.Web.Studio.Core.Notify;
//using CrmDaoFactory = ASC.CRM.Core.Dao.DaoFactory;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Reassigns
@ -218,7 +219,7 @@ namespace ASC.Data.Reassigns
public static class ReassignProgressItemExtension
{
public static IServiceCollection AddReassignProgressItemService(this IServiceCollection services)
public static DIHelper AddReassignProgressItemService(this DIHelper services)
{
services.TryAddSingleton<ProgressQueueOptionsManager<ReassignProgressItem>>();
services.TryAddSingleton<ProgressQueue<ReassignProgressItem>>();

View File

@ -29,6 +29,8 @@ using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Threading.Progress;
using ASC.Core;
@ -43,7 +45,6 @@ using ASC.Web.Studio.Core.Notify;
//using CrmDaoFactory = ASC.CRM.Core.Dao.DaoFactory;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Reassigns
@ -254,7 +255,7 @@ namespace ASC.Data.Reassigns
public static class RemoveProgressItemExtension
{
public static IServiceCollection AddRemoveProgressItemService(this IServiceCollection services)
public static DIHelper AddRemoveProgressItemService(this DIHelper services)
{
services.TryAddSingleton<ProgressQueueOptionsManager<RemoveProgressItem>>();

View File

@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Utils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -10,7 +13,7 @@ namespace ASC.Data.Storage.Configuration
{
public static class StorageConfigExtension
{
public static IServiceCollection AddStorage(this IServiceCollection services)
public static DIHelper AddStorage(this DIHelper services)
{
services.TryAddSingleton(r => r.GetService<IConfiguration>().GetSetting<Storage>("Storage"));
return services;

View File

@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core;
@ -37,7 +38,6 @@ using ASC.Security.Cryptography;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Storage.Configuration
@ -206,7 +206,7 @@ namespace ASC.Data.Storage.Configuration
public static class StorageSettingsExtension
{
public static IServiceCollection AddBaseStorageSettingsService(this IServiceCollection services)
public static DIHelper AddBaseStorageSettingsService(this DIHelper services)
{
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));
services.TryAddSingleton<BaseStorageSettingsListener>();
@ -217,7 +217,7 @@ namespace ASC.Data.Storage.Configuration
.AddEmailValidationKeyProviderService();
}
public static IServiceCollection AddCdnStorageSettingsService(this IServiceCollection services)
public static DIHelper AddCdnStorageSettingsService(this DIHelper services)
{
services.TryAddScoped<StorageSettingsHelper>();
@ -227,7 +227,7 @@ namespace ASC.Data.Storage.Configuration
.AddConsumerFactoryService();
}
public static IServiceCollection AddStorageSettingsService(this IServiceCollection services)
public static DIHelper AddStorageSettingsService(this DIHelper services)
{
services.TryAddScoped<StorageSettingsHelper>();

View File

@ -25,6 +25,7 @@
using System.Collections.Generic;
using ASC.Data.Storage.Configuration;
namespace ASC.Data.Storage
@ -34,11 +35,18 @@ namespace ASC.Data.Storage
public DataList(Module config)
{
Add(string.Empty, config.Data);
if (config.Domain != null)
{
foreach (var domain in config.Domain)
{
Add(domain.Name, domain.Data);
}
}
else
{
config.Domain = new List<Module>();
}
}
public string GetData(string name)
{

View File

@ -27,10 +27,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using ASC.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
namespace ASC.Data.Storage
@ -119,7 +120,7 @@ namespace ASC.Data.Storage
public static class PathUtilsExtension
{
public static IServiceCollection AddPathUtilsService(this IServiceCollection services)
public static DIHelper AddPathUtilsService(this DIHelper services)
{
services.TryAddSingleton<PathUtils>();

View File

@ -31,6 +31,8 @@ using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Common.Threading;
@ -39,8 +41,8 @@ using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using ASC.Data.Storage.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Storage
@ -290,7 +292,7 @@ namespace ASC.Data.Storage
public static class StaticUploaderExtension
{
public static IServiceCollection AddStaticUploaderService(this IServiceCollection services)
public static DIHelper AddStaticUploaderService(this DIHelper services)
{
services.TryAddScoped<StaticUploader>();

View File

@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core;
@ -40,7 +41,6 @@ using ASC.Security.Cryptography;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.Data.Storage
@ -232,9 +232,10 @@ namespace ASC.Data.Storage
//Make tennant path
tenant = TenantPath.CreatePath(tenant);
var store = DataStoreCache.Get(tenant, module);
if (store == null)
{
//remove cache
//var store = DataStoreCache.Get(tenant, module);
//if (store == null)
//{
var section = StorageFactoryConfig.Section;
if (section == null)
{
@ -243,9 +244,8 @@ namespace ASC.Data.Storage
var settings = SettingsManager.LoadForTenant<StorageSettings>(tenantId);
store = GetStoreAndCache(tenant, module, StorageSettingsHelper.DataStoreConsumer(settings), controller);
}
return store;
//}
return GetDataStore(tenant, module, StorageSettingsHelper.DataStoreConsumer(settings), controller);
}
public IDataStore GetStorageFromConsumer(string configpath, string tenant, string module, DataStoreConsumer consumer)
@ -311,14 +311,14 @@ namespace ASC.Data.Storage
public static class StorageFactoryExtension
{
public static IServiceCollection AddStorageFactoryConfigService(this IServiceCollection services)
public static DIHelper AddStorageFactoryConfigService(this DIHelper services)
{
services.TryAddSingleton<StorageFactoryConfig>();
return services;
}
public static IServiceCollection AddStorageFactoryService(this IServiceCollection services)
public static DIHelper AddStorageFactoryService(this DIHelper services)
{
services.TryAddScoped<StorageFactory>();
services.TryAddSingleton<StorageFactoryListener>();

View File

@ -33,6 +33,7 @@ using System.Net;
using System.Threading.Tasks;
using System.Web;
using ASC.Common;
using ASC.Common.Web;
using ASC.Core;
using ASC.Security.Cryptography;
@ -172,7 +173,7 @@ namespace ASC.Data.Storage.DiscStorage
return builder;
}
public static IServiceCollection AddStorageHandlerService(this IServiceCollection services)
public static DIHelper AddStorageHandlerService(this DIHelper services)
{
return services
.AddTenantManagerService()

View File

@ -31,14 +31,13 @@ using System.IO;
using System.Linq;
using System.Net;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.Data.Storage.Configuration;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
@ -235,7 +234,7 @@ namespace ASC.Data.Storage
public static class WebPathExtension
{
public static IServiceCollection AddWebPathService(this IServiceCollection services)
public static DIHelper AddWebPathService(this DIHelper services)
{
services.TryAddScoped<WebPath>();
@ -245,7 +244,7 @@ namespace ASC.Data.Storage
.AddWebPathSettingsService()
.AddCoreBaseSettingsService();
}
public static IServiceCollection AddWebPathSettingsService(this IServiceCollection services)
public static DIHelper AddWebPathSettingsService(this DIHelper services)
{
services.TryAddSingleton<WebPathSettings>();

View File

@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Utils;
using ASC.Core.Common.EF;
@ -37,8 +38,6 @@ using ASC.FederatedLogin.Profile;
using ASC.Security.Cryptography;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace ASC.FederatedLogin
@ -218,7 +217,7 @@ namespace ASC.FederatedLogin
public static class AccountLinkerStorageExtension
{
public static IServiceCollection AddAccountLinkerStorageService(this IServiceCollection services)
public static DIHelper AddAccountLinkerStorageService(this DIHelper services)
{
services.TryAddSingleton<AccountLinkerStorage>();
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));
@ -229,7 +228,7 @@ namespace ASC.FederatedLogin
public static class AccountLinkerExtension
{
public static IServiceCollection AddAccountLinker(this IServiceCollection services)
public static DIHelper AddAccountLinker(this DIHelper services)
{
services.TryAddScoped<AccountLinker>();
services.TryAddScoped<IConfigureOptions<AccountLinker>, ConfigureAccountLinker>();

View File

@ -26,6 +26,7 @@
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core;
using ASC.Core.Common.Configuration;
@ -75,4 +76,18 @@ namespace ASC.FederatedLogin.LoginProviders
{
}
}
public static class BoxLoginProviderExtension
{
public static DIHelper AddBoxLoginProviderService(this DIHelper services)
{
services.TryAddScoped<BoxLoginProvider>();
return services
.AddConsumerFactoryService()
.AddKafkaService()
.AddTenantManagerService()
.AddCoreBaseSettingsService()
.AddCoreSettingsService();
}
}
}

View File

@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core;
using ASC.Core.Common.Configuration;
@ -133,4 +134,17 @@ namespace ASC.FederatedLogin.LoginProviders
return refreshed;
}
}
public static class DocuSignLoginProviderExtension
{
public static DIHelper AddDocuSignLoginProviderService(this DIHelper services)
{
services.TryAddScoped<DocuSignLoginProvider>();
return services
.AddConsumerFactoryService()
.AddKafkaService()
.AddTenantManagerService()
.AddCoreBaseSettingsService()
.AddCoreSettingsService();
}
}
}

View File

@ -26,6 +26,7 @@
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core;
using ASC.Core.Common.Configuration;
@ -72,4 +73,17 @@ namespace ASC.FederatedLogin.LoginProviders
{
}
}
public static class DropboxLoginProviderExtension
{
public static DIHelper AddDropboxLoginProviderService(this DIHelper services)
{
services.TryAddScoped<DropboxLoginProvider>();
return services
.AddConsumerFactoryService()
.AddKafkaService()
.AddTenantManagerService()
.AddCoreBaseSettingsService()
.AddCoreSettingsService();
}
}
}

View File

@ -28,6 +28,7 @@ using System;
using System.Linq;
using System.Security;
using ASC.Common;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Users;
@ -41,10 +42,16 @@ using SecurityContext = ASC.Core.SecurityContext;
namespace ASC.Web.Studio.Core
{
public static class BlockchainLoginProvider
public class EncryptionLoginProvider
{
public static void UpdateData(
string account,
public UserManager UserManager { get; }
public TenantManager TenantManager { get; }
public SecurityContext SecurityContext { get; }
public Signature Signature { get; }
public InstanceCrypto InstanceCrypto { get; }
public IOptionsSnapshot<AccountLinker> Snapshot { get; }
public EncryptionLoginProvider(
UserManager userManager,
TenantManager tenantManager,
SecurityContext securityContext,
@ -52,16 +59,26 @@ namespace ASC.Web.Studio.Core
InstanceCrypto instanceCrypto,
IOptionsSnapshot<AccountLinker> snapshot)
{
var tenant = tenantManager.GetCurrentTenant();
var user = userManager.GetUsers(securityContext.CurrentAccount.ID);
if (!securityContext.IsAuthenticated || user.IsVisitor(userManager)) throw new SecurityException();
UserManager = userManager;
TenantManager = tenantManager;
SecurityContext = securityContext;
Signature = signature;
InstanceCrypto = instanceCrypto;
Snapshot = snapshot;
}
var loginProfile = new LoginProfile(signature, instanceCrypto)
public void UpdateAddress(string account)
{
var tenant = TenantManager.GetCurrentTenant();
var user = UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
if (!SecurityContext.IsAuthenticated || user.IsVisitor(UserManager)) throw new SecurityException();
var loginProfile = new LoginProfile(Signature, InstanceCrypto)
{
Provider = ProviderConstants.Encryption,
};
var linker = snapshot.Get("webstudio");
var linker = Snapshot.Get("webstudio");
if (string.IsNullOrEmpty(account))
{
linker.RemoveLink(user.ID.ToString(), loginProfile);
@ -74,14 +91,14 @@ namespace ASC.Web.Studio.Core
}
public static string GetAddress(SecurityContext securityContext, IOptionsSnapshot<AccountLinker> snapshot)
public string GetAddress()
{
return GetAddress(securityContext.CurrentAccount.ID, snapshot);
return GetAddress(SecurityContext.CurrentAccount.ID);
}
public static string GetAddress(Guid userId, IOptionsSnapshot<AccountLinker> snapshot)
public string GetAddress(Guid userId)
{
var linker = snapshot.Get("webstudio");
var linker = Snapshot.Get("webstudio");
var profile = linker.GetLinkedProfiles(userId.ToString(), ProviderConstants.Encryption).FirstOrDefault();
if (profile == null) return null;
@ -89,4 +106,19 @@ namespace ASC.Web.Studio.Core
return account;
}
}
public static class EncryptionLoginProviderExtension
{
public static DIHelper AddEncryptionLoginProviderService(this DIHelper services)
{
services.TryAddScoped<EncryptionLoginProvider>();
return services
.AddUserManagerService()
.AddTenantManagerService()
.AddSecurityContextService()
.AddSignatureService()
.AddInstanceCryptoService()
.AddAccountLinker();
}
}
}

View File

@ -28,6 +28,7 @@ using System;
using System.Collections.Generic;
using System.Web;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.Utils;
using ASC.Core;
@ -180,4 +181,20 @@ namespace ASC.FederatedLogin.LoginProviders
public bool primary = false;
}
}
public static class GoogleLoginProviderExtension
{
public static DIHelper AddGoogleLoginProviderService(this DIHelper services)
{
services.TryAddScoped<GoogleLoginProvider>();
return services
.AddConsumerFactoryService()
.AddKafkaService()
.AddTenantManagerService()
.AddCoreBaseSettingsService()
.AddCoreSettingsService()
.AddSignatureService()
.AddInstanceCryptoService();
}
}
}

View File

@ -26,6 +26,7 @@
using System.Collections.Generic;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Core;
using ASC.Core.Common.Configuration;
@ -75,4 +76,18 @@ namespace ASC.FederatedLogin.LoginProviders
{
}
}
public static class OneDriveLoginProviderExtension
{
public static DIHelper AddOneDriveLoginProviderService(this DIHelper services)
{
services.TryAddScoped<OneDriveLoginProvider>();
return services
.AddConsumerFactoryService()
.AddKafkaService()
.AddTenantManagerService()
.AddCoreBaseSettingsService()
.AddCoreSettingsService();
}
}
}

Some files were not shown because too many files have changed in this diff Show More