Merge branch 'develop' into feature/thirdparty-integrations
This commit is contained in:
commit
462bd090d1
@ -61,7 +61,6 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference> -->
|
||||
<PackageReference Include="MySql.Data" Version="8.0.21" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NLog" Version="4.7.5" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -114,17 +114,17 @@ namespace ASC.Common.Caching
|
||||
}
|
||||
|
||||
|
||||
public IDictionary<string, T> HashGetAll<T>(string key)
|
||||
public ConcurrentDictionary<string, T> HashGetAll<T>(string key)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
return dic != null ? new Dictionary<string, T>(dic) : new Dictionary<string, T>();
|
||||
var dic = (ConcurrentDictionary<string, T>)cache.Get(key);
|
||||
return dic != null ? dic : new ConcurrentDictionary<string, T>();
|
||||
}
|
||||
|
||||
public T HashGet<T>(string key, string field)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
var dic = (ConcurrentDictionary<string, T>)cache.Get(key);
|
||||
if (dic != null && dic.TryGetValue(field, out var value))
|
||||
{
|
||||
return value;
|
||||
@ -135,19 +135,15 @@ namespace ASC.Common.Caching
|
||||
public void HashSet<T>(string key, string field, T value)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
var dic = HashGetAll<T>(key);
|
||||
if (value != null)
|
||||
{
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, T>();
|
||||
}
|
||||
dic[field] = value;
|
||||
{
|
||||
dic.AddOrUpdate(field, value, (k, v) => value);
|
||||
cache.Set(key, dic, null);
|
||||
}
|
||||
else if (dic != null)
|
||||
{
|
||||
dic.Remove(field);
|
||||
dic.TryRemove(field, out _);
|
||||
if (dic.Count == 0)
|
||||
{
|
||||
cache.Remove(key);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
@ -43,7 +43,7 @@ namespace ASC.Common.Caching
|
||||
void Remove(Regex pattern);
|
||||
|
||||
|
||||
IDictionary<string, T> HashGetAll<T>(string key);
|
||||
ConcurrentDictionary<string, T> HashGetAll<T>(string key);
|
||||
|
||||
T HashGet<T>(string key, string field);
|
||||
|
||||
|
@ -11,7 +11,6 @@ using Confluent.Kafka;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
@ -32,7 +31,7 @@ namespace ASC.Common.Caching
|
||||
private IProducer<AscCacheItem, T> Producer { get; set; }
|
||||
private Guid Key { get; set; }
|
||||
|
||||
public KafkaCache(IConfiguration configuration, IOptionsMonitor<ILog> options)
|
||||
public KafkaCache(ConfigurationExtension configuration, IOptionsMonitor<ILog> options)
|
||||
{
|
||||
Log = options.CurrentValue;
|
||||
Cts = new ConcurrentDictionary<string, CancellationTokenSource>();
|
||||
|
@ -375,20 +375,22 @@ namespace ASC.Common.Logging
|
||||
|
||||
[Singletone]
|
||||
public class ConfigureLogNLog : IConfigureNamedOptions<LogNLog>
|
||||
{
|
||||
public ConfigureLogNLog(IConfiguration configuration)
|
||||
{
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension ConfigurationExtension { get; }
|
||||
|
||||
public ConfigureLogNLog(IConfiguration configuration, ConfigurationExtension configurationExtension)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
private IConfiguration Configuration { get; }
|
||||
|
||||
Configuration = configuration;
|
||||
ConfigurationExtension = configurationExtension;
|
||||
}
|
||||
|
||||
public void Configure(LogNLog options)
|
||||
{
|
||||
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(Path.Combine(Configuration["pathToConf"], "nlog.config"));
|
||||
LogManager.ThrowConfigExceptions = false;
|
||||
|
||||
var settings = Configuration.GetSetting<NLogSettings>("log");
|
||||
var settings = ConfigurationExtension.GetSetting<NLogSettings>("log");
|
||||
if (!string.IsNullOrEmpty(settings.Name))
|
||||
{
|
||||
LogManager.Configuration.Variables["name"] = settings.Name;
|
||||
|
@ -25,10 +25,9 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ASC.Common.Threading
|
||||
{
|
||||
public class DistributedTask
|
||||
@ -37,7 +36,7 @@ namespace ASC.Common.Threading
|
||||
|
||||
public DistributedTaskCache DistributedTaskCache { get; internal set; }
|
||||
|
||||
public string InstanceId
|
||||
public int InstanceId
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -45,7 +44,7 @@ namespace ASC.Common.Threading
|
||||
}
|
||||
set
|
||||
{
|
||||
DistributedTaskCache.InstanceId = value?.ToString() ?? "";
|
||||
DistributedTaskCache.InstanceId = value;
|
||||
}
|
||||
}
|
||||
public string Id
|
||||
@ -98,10 +97,14 @@ namespace ASC.Common.Threading
|
||||
|
||||
|
||||
public T GetProperty<T>(string name)
|
||||
{
|
||||
return DistributedTaskCache.Props.Any(r => r.Key == name) ?
|
||||
JsonConvert.DeserializeObject<T>(DistributedTaskCache.Props.Single(r => r.Key == name).Value) :
|
||||
default;
|
||||
{
|
||||
if (!DistributedTaskCache.Props.Any(r => r.Key == name)) return default;
|
||||
|
||||
var val = DistributedTaskCache.Props.SingleOrDefault(r => r.Key == name);
|
||||
|
||||
if (val == null) return default;
|
||||
|
||||
return JsonSerializer.Deserialize<T>(val.Value);
|
||||
}
|
||||
|
||||
public void SetProperty(string name, object value)
|
||||
@ -109,7 +112,7 @@ namespace ASC.Common.Threading
|
||||
var prop = new DistributedTaskCache.Types.DistributedTaskCacheProp()
|
||||
{
|
||||
Key = name,
|
||||
Value = JsonConvert.SerializeObject(value)
|
||||
Value = JsonSerializer.Serialize(value)
|
||||
};
|
||||
|
||||
var current = DistributedTaskCache.Props.SingleOrDefault(r => r.Key == name);
|
||||
|
@ -91,7 +91,7 @@ namespace ASC.Common.Threading
|
||||
|
||||
public class DistributedTaskQueue
|
||||
{
|
||||
public static readonly string InstanceId;
|
||||
public static readonly int InstanceId;
|
||||
|
||||
private readonly string key;
|
||||
private readonly ICache cache;
|
||||
@ -102,7 +102,7 @@ namespace ASC.Common.Threading
|
||||
|
||||
static DistributedTaskQueue()
|
||||
{
|
||||
InstanceId = Process.GetCurrentProcess().Id.ToString();
|
||||
InstanceId = Process.GetCurrentProcess().Id;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
@ -32,13 +33,23 @@ namespace ASC.Common.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfigurationExtension
|
||||
[Singletone]
|
||||
public class ConfigurationExtension
|
||||
{
|
||||
public static IEnumerable<T> GetSettings<T>(this IConfiguration configuration, string section) where T : new()
|
||||
private IConfiguration Configuration { get; }
|
||||
private Lazy<ConnectionStringCollection> ConnectionStringSettings { get; }
|
||||
|
||||
public ConfigurationExtension(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
ConnectionStringSettings = new Lazy<ConnectionStringCollection>(new ConnectionStringCollection(GetSettings<ConnectionStringSettings>("ConnectionStrings")));
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetSettings<T>(string section) where T : new()
|
||||
{
|
||||
var result = new List<T>();
|
||||
|
||||
var sectionSettings = configuration.GetSection(section);
|
||||
var sectionSettings = Configuration.GetSection(section);
|
||||
|
||||
foreach (var ch in sectionSettings.GetChildren())
|
||||
{
|
||||
@ -49,9 +60,10 @@ namespace ASC.Common.Utils
|
||||
|
||||
return result;
|
||||
}
|
||||
public static T GetSetting<T>(this IConfiguration configuration, string section) where T : new()
|
||||
|
||||
public T GetSetting<T>(string section) where T : new()
|
||||
{
|
||||
var sectionSettings = configuration.GetSection(section);
|
||||
var sectionSettings = Configuration.GetSection(section);
|
||||
|
||||
var cs = new T();
|
||||
sectionSettings.Bind(cs);
|
||||
@ -59,13 +71,14 @@ namespace ASC.Common.Utils
|
||||
return cs;
|
||||
}
|
||||
|
||||
public static ConnectionStringCollection GetConnectionStrings(this IConfiguration configuration)
|
||||
public ConnectionStringCollection GetConnectionStrings()
|
||||
{
|
||||
return new ConnectionStringCollection(configuration.GetSettings<ConnectionStringSettings>("ConnectionStrings"));
|
||||
return ConnectionStringSettings.Value;
|
||||
}
|
||||
public static ConnectionStringSettings GetConnectionStrings(this IConfiguration configuration, string key)
|
||||
|
||||
public ConnectionStringSettings GetConnectionStrings(string key)
|
||||
{
|
||||
return configuration.GetConnectionStrings()[key];
|
||||
return GetConnectionStrings()[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package ASC.Common.Threading;
|
||||
|
||||
message DistributedTaskCache {
|
||||
string Id = 1;
|
||||
string InstanceId = 2;
|
||||
int32 InstanceId = 2;
|
||||
string Status = 3;
|
||||
string Exception = 4;
|
||||
repeated DistributedTaskCacheProp Props = 5;
|
||||
|
@ -35,7 +35,6 @@ using ASC.Common.Utils;
|
||||
using ASC.Core.Data;
|
||||
using ASC.Core.Tenants;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
@ -51,7 +50,7 @@ namespace ASC.Core.Billing
|
||||
|
||||
public TariffSyncService(
|
||||
IServiceProvider serviceProvider,
|
||||
IConfiguration configuration,
|
||||
ConfigurationExtension configuration,
|
||||
DbQuotaService dbQuotaService,
|
||||
IOptionsMonitor<ILog> options)
|
||||
{
|
||||
@ -86,7 +85,7 @@ namespace ASC.Core.Billing
|
||||
}
|
||||
|
||||
private IServiceProvider ServiceProvider { get; }
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
private DbQuotaService DbQuotaService { get; }
|
||||
|
||||
public void Start()
|
||||
|
@ -76,14 +76,14 @@ namespace ASC.Core.Data
|
||||
private List<string> forbiddenDomains;
|
||||
|
||||
internal TenantDomainValidator TenantDomainValidator { get; set; }
|
||||
public MachinePseudoKeys MachinePseudoKeys { get; }
|
||||
private MachinePseudoKeys MachinePseudoKeys { get; }
|
||||
internal TenantDbContext TenantDbContext { get => LazyTenantDbContext.Value; }
|
||||
internal Lazy<TenantDbContext> LazyTenantDbContext { get; set; }
|
||||
|
||||
public Expression<Func<DbTenant, Tenant>> FromDbTenantToTenant { get; set; }
|
||||
public Expression<Func<TenantUserSecurity, Tenant>> FromTenantUserToTenant { get; set; }
|
||||
private static Expression<Func<DbTenant, Tenant>> FromDbTenantToTenant { get; set; }
|
||||
private static Expression<Func<TenantUserSecurity, Tenant>> FromTenantUserToTenant { get; set; }
|
||||
|
||||
public DbTenantService()
|
||||
static DbTenantService()
|
||||
{
|
||||
FromDbTenantToTenant = r => new Tenant
|
||||
{
|
||||
@ -105,21 +105,25 @@ namespace ASC.Core.Data
|
||||
VersionChanged = r.VersionChanged,
|
||||
TrustedDomainsRaw = r.TrustedDomains,
|
||||
TrustedDomainsType = r.TrustedDomainsEnabled,
|
||||
AffiliateId = r.Partner != null ? r.Partner.AffiliateId : null,
|
||||
PartnerId = r.Partner != null ? r.Partner.PartnerId : null,
|
||||
//AffiliateId = r.Partner != null ? r.Partner.AffiliateId : null,
|
||||
//PartnerId = r.Partner != null ? r.Partner.PartnerId : null,
|
||||
TimeZone = r.TimeZone,
|
||||
Campaign = r.Partner != null ? r.Partner.Campaign : null
|
||||
//Campaign = r.Partner != null ? r.Partner.Campaign : null
|
||||
};
|
||||
|
||||
var fromDbTenantToTenant = FromDbTenantToTenant.Compile();
|
||||
FromTenantUserToTenant = r => fromDbTenantToTenant(r.DbTenant);
|
||||
}
|
||||
|
||||
public DbTenantService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DbTenantService(
|
||||
DbContextManager<TenantDbContext> dbContextManager,
|
||||
TenantDomainValidator tenantDomainValidator,
|
||||
MachinePseudoKeys machinePseudoKeys)
|
||||
: this()
|
||||
{
|
||||
LazyTenantDbContext = new Lazy<TenantDbContext>(() => dbContextManager.Value);
|
||||
TenantDomainValidator = tenantDomainValidator;
|
||||
@ -454,8 +458,7 @@ namespace ASC.Core.Data
|
||||
|
||||
private IQueryable<DbTenant> TenantsQuery()
|
||||
{
|
||||
return TenantDbContext.Tenants
|
||||
.Include(r => r.Partner);
|
||||
return TenantDbContext.Tenants;
|
||||
}
|
||||
|
||||
private void ValidateDomain(string domain, int tenantId, bool validateCharacters)
|
||||
|
@ -68,12 +68,12 @@ namespace ASC.Core.Data
|
||||
[Scope]
|
||||
public class EFUserService : IUserService
|
||||
{
|
||||
public Expression<Func<User, UserInfo>> FromUserToUserInfo { get; set; }
|
||||
public Func<UserInfo, User> FromUserInfoToUser { get; set; }
|
||||
public Expression<Func<DbGroup, Group>> FromDbGroupToGroup { get; set; }
|
||||
public Func<Group, DbGroup> FromGroupToDbGroup { get; set; }
|
||||
public Expression<Func<UserGroup, UserGroupRef>> FromUserGroupToUserGroupRef { get; set; }
|
||||
public Func<UserGroupRef, UserGroup> FromUserGroupRefToUserGroup { get; set; }
|
||||
private static Expression<Func<User, UserInfo>> FromUserToUserInfo { get; set; }
|
||||
private static Func<UserInfo, User> FromUserInfoToUser { get; set; }
|
||||
private static Expression<Func<DbGroup, Group>> FromDbGroupToGroup { get; set; }
|
||||
private static Func<Group, DbGroup> FromGroupToDbGroup { get; set; }
|
||||
private static Expression<Func<UserGroup, UserGroupRef>> FromUserGroupToUserGroupRef { get; set; }
|
||||
private static Func<UserGroupRef, UserGroup> FromUserGroupRefToUserGroup { get; set; }
|
||||
|
||||
internal UserDbContext UserDbContext { get => LazyUserDbContext.Value; }
|
||||
internal Lazy<UserDbContext> LazyUserDbContext { get; set; }
|
||||
@ -82,7 +82,7 @@ namespace ASC.Core.Data
|
||||
public MachinePseudoKeys MachinePseudoKeys { get; }
|
||||
internal string DbId { get; set; }
|
||||
|
||||
public EFUserService()
|
||||
static EFUserService()
|
||||
{
|
||||
FromUserToUserInfo = user => new UserInfo
|
||||
{
|
||||
@ -187,7 +187,12 @@ namespace ASC.Core.Data
|
||||
};
|
||||
}
|
||||
|
||||
public EFUserService(DbContextManager<UserDbContext> userDbContextManager, PasswordHasher passwordHasher, MachinePseudoKeys machinePseudoKeys) : this()
|
||||
public EFUserService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EFUserService(DbContextManager<UserDbContext> userDbContextManager, PasswordHasher passwordHasher, MachinePseudoKeys machinePseudoKeys)
|
||||
{
|
||||
UserDbContextManager = userDbContextManager;
|
||||
PasswordHasher = passwordHasher;
|
||||
|
@ -5,7 +5,6 @@ using ASC.Common;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ASC.Core.Common.EF
|
||||
@ -15,9 +14,9 @@ namespace ASC.Core.Common.EF
|
||||
{
|
||||
public const string baseName = "default";
|
||||
private EFLoggerFactory LoggerFactory { get; }
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
|
||||
public ConfigureDbContext(EFLoggerFactory loggerFactory, IConfiguration configuration)
|
||||
public ConfigureDbContext(EFLoggerFactory loggerFactory, ConfigurationExtension configuration)
|
||||
{
|
||||
LoggerFactory = loggerFactory;
|
||||
Configuration = configuration;
|
||||
@ -38,10 +37,10 @@ namespace ASC.Core.Common.EF
|
||||
public class ConfigureMultiRegionalDbContext<T> : IConfigureNamedOptions<MultiRegionalDbContext<T>> where T : BaseDbContext, new()
|
||||
{
|
||||
public string baseName = "default";
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
private DbContextManager<T> DbContext { get; }
|
||||
|
||||
public ConfigureMultiRegionalDbContext(IConfiguration configuration, DbContextManager<T> dbContext)
|
||||
public ConfigureMultiRegionalDbContext(ConfigurationExtension configuration, DbContextManager<T> dbContext)
|
||||
{
|
||||
Configuration = configuration;
|
||||
DbContext = dbContext;
|
||||
|
@ -49,7 +49,7 @@ namespace ASC.Core.Common.EF.Model
|
||||
public bool Spam { get; set; }
|
||||
public bool Calls { get; set; }
|
||||
|
||||
public DbTenantPartner Partner { get; set; }
|
||||
// public DbTenantPartner Partner { get; set; }
|
||||
}
|
||||
|
||||
public static class DbTenantExtension
|
||||
@ -74,10 +74,10 @@ namespace ASC.Core.Common.EF.Model
|
||||
|
||||
public static void MySqlAddDbTenant(this ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<DbTenant>()
|
||||
.HasOne(r => r.Partner)
|
||||
.WithOne(r => r.Tenant)
|
||||
.HasPrincipalKey<DbTenant>(r => new { r.Id });
|
||||
//modelBuilder.Entity<DbTenant>()
|
||||
// .HasOne(r => r.Partner)
|
||||
// .WithOne(r => r.Tenant)
|
||||
// .HasPrincipalKey<DbTenant>(r => new { r.Id });
|
||||
|
||||
modelBuilder.Entity<DbTenant>(entity =>
|
||||
{
|
||||
|
@ -50,21 +50,24 @@ namespace ASC.Core
|
||||
private readonly Dictionary<string, HostedSolution> regions = new Dictionary<string, HostedSolution>();
|
||||
private readonly string dbid;
|
||||
|
||||
private IConfiguration Configuraion { get; }
|
||||
private IConfiguration Configuraion { get; }
|
||||
public ConfigurationExtension ConfigurationExtension { get; }
|
||||
private CookieStorage CookieStorage { get; }
|
||||
private EFLoggerFactory LoggerFactory { get; }
|
||||
private PasswordHasher PasswordHasher { get; }
|
||||
private IOptionsSnapshot<HostedSolution> HostedSolutionOptions { get; }
|
||||
|
||||
public MultiRegionHostedSolution(string dbid,
|
||||
IConfiguration configuraion,
|
||||
IConfiguration configuraion,
|
||||
ConfigurationExtension configurationExtension,
|
||||
CookieStorage cookieStorage,
|
||||
EFLoggerFactory loggerFactory,
|
||||
PasswordHasher passwordHasher,
|
||||
IOptionsSnapshot<HostedSolution> hostedSolutionOptions)
|
||||
{
|
||||
this.dbid = dbid;
|
||||
Configuraion = configuraion;
|
||||
Configuraion = configuraion;
|
||||
ConfigurationExtension = configurationExtension;
|
||||
CookieStorage = cookieStorage;
|
||||
LoggerFactory = loggerFactory;
|
||||
PasswordHasher = passwordHasher;
|
||||
@ -200,12 +203,12 @@ namespace ASC.Core
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
var connectionStrings = Configuraion.GetConnectionStrings();
|
||||
var dbConnectionStrings = Configuraion.GetConnectionStrings(dbid);
|
||||
var connectionStrings = ConfigurationExtension.GetConnectionStrings();
|
||||
var dbConnectionStrings = ConfigurationExtension.GetConnectionStrings(dbid);
|
||||
|
||||
if (Convert.ToBoolean(Configuraion["core.multi-hosted.config-only"] ?? "false"))
|
||||
{
|
||||
foreach (var cs in Configuraion.GetConnectionStrings())
|
||||
foreach (var cs in ConfigurationExtension.GetConnectionStrings())
|
||||
{
|
||||
if (cs.Name.StartsWith(dbid + "."))
|
||||
{
|
||||
|
@ -31,8 +31,6 @@ namespace ASC.Core.Common.Tests
|
||||
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
public class DbBaseTest<TDbService>
|
||||
{
|
||||
protected TDbService Service
|
||||
@ -47,7 +45,7 @@ namespace ASC.Core.Common.Tests
|
||||
private set;
|
||||
}
|
||||
|
||||
internal IConfiguration Configuration { get; set; }
|
||||
internal ConfigurationExtension Configuration { get; set; }
|
||||
|
||||
protected DbBaseTest()
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using ASC.Common;
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ASC.Data.Storage.Configuration
|
||||
@ -14,7 +13,7 @@ namespace ASC.Data.Storage.Configuration
|
||||
{
|
||||
public static void Register(DIHelper services)
|
||||
{
|
||||
services.TryAddSingleton(r => r.GetService<IConfiguration>().GetSetting<Storage>("Storage"));
|
||||
services.TryAddSingleton(r => r.GetService<ConfigurationExtension>().GetSetting<Storage>("Storage"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
using ASC.Core;
|
||||
using ASC.Core.Tenants;
|
||||
@ -36,7 +35,24 @@ namespace ASC.Data.Storage
|
||||
public class TenantQuotaController : IQuotaController
|
||||
{
|
||||
private readonly int tenant;
|
||||
private Lazy<long> lazyCurrentSize;
|
||||
|
||||
private long currentSize;
|
||||
private long CurrentSize {
|
||||
get
|
||||
{
|
||||
if (!lazyCurrentSize.IsValueCreated)
|
||||
{
|
||||
return currentSize = lazyCurrentSize.Value;
|
||||
}
|
||||
|
||||
return currentSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
currentSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
private TenantManager TenantManager { get; }
|
||||
|
||||
@ -44,9 +60,9 @@ namespace ASC.Data.Storage
|
||||
{
|
||||
this.tenant = tenant;
|
||||
TenantManager = tenantManager;
|
||||
currentSize = TenantManager.FindTenantQuotaRows(new TenantQuotaRowQuery(tenant))
|
||||
lazyCurrentSize = new Lazy<long>(() => TenantManager.FindTenantQuotaRows(new TenantQuotaRowQuery(tenant))
|
||||
.Where(r => UsedInQuota(r.Tag))
|
||||
.Sum(r => r.Counter);
|
||||
.Sum(r => r.Counter));
|
||||
}
|
||||
|
||||
#region IQuotaController Members
|
||||
@ -57,7 +73,7 @@ namespace ASC.Data.Storage
|
||||
if (UsedInQuota(dataTag))
|
||||
{
|
||||
QuotaUsedCheck(size);
|
||||
Interlocked.Add(ref currentSize, size);
|
||||
CurrentSize += size;
|
||||
}
|
||||
SetTenantQuotaRow(module, domain, size, dataTag, true);
|
||||
}
|
||||
@ -67,7 +83,7 @@ namespace ASC.Data.Storage
|
||||
size = -Math.Abs(size);
|
||||
if (UsedInQuota(dataTag))
|
||||
{
|
||||
Interlocked.Add(ref currentSize, size);
|
||||
CurrentSize += size;
|
||||
}
|
||||
SetTenantQuotaRow(module, domain, size, dataTag, true);
|
||||
}
|
||||
@ -77,7 +93,7 @@ namespace ASC.Data.Storage
|
||||
size = Math.Max(0, size);
|
||||
if (UsedInQuota(dataTag))
|
||||
{
|
||||
Interlocked.Exchange(ref currentSize, size);
|
||||
CurrentSize += size;
|
||||
}
|
||||
SetTenantQuotaRow(module, domain, size, dataTag, false);
|
||||
}
|
||||
@ -99,7 +115,7 @@ namespace ASC.Data.Storage
|
||||
{
|
||||
throw new TenantQuotaException(string.Format("Exceeds the maximum file size ({0}MB)", BytesToMegabytes(quota.MaxFileSize)));
|
||||
}
|
||||
if (quota.MaxTotalSize != 0 && quota.MaxTotalSize < currentSize + size)
|
||||
if (quota.MaxTotalSize != 0 && quota.MaxTotalSize < CurrentSize + size)
|
||||
{
|
||||
throw new TenantQuotaException(string.Format("Exceeded maximum amount of disk quota ({0}MB)", BytesToMegabytes(quota.MaxTotalSize)));
|
||||
}
|
||||
@ -110,7 +126,7 @@ namespace ASC.Data.Storage
|
||||
|
||||
public long QuotaCurrentGet()
|
||||
{
|
||||
return currentSize;
|
||||
return CurrentSize;
|
||||
}
|
||||
|
||||
private void SetTenantQuotaRow(string module, string domain, long size, string dataTag, bool exchange)
|
||||
|
@ -31,7 +31,6 @@ using System.Linq;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.FederatedLogin.Profile;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ASC.FederatedLogin
|
||||
@ -55,7 +54,7 @@ namespace ASC.FederatedLogin
|
||||
}
|
||||
|
||||
|
||||
public MultiRegionAccountLinker(string databaseId, IConfiguration configuration, IOptionsSnapshot<AccountLinker> snapshot)
|
||||
public MultiRegionAccountLinker(string databaseId, ConfigurationExtension configuration, IOptionsSnapshot<AccountLinker> snapshot)
|
||||
{
|
||||
foreach (var connection in configuration.GetConnectionStrings())
|
||||
{
|
||||
|
@ -32,7 +32,6 @@ using ASC.Common.Utils;
|
||||
using ASC.Data.Backup.Listerners;
|
||||
using ASC.Web.Studio.Core.Notify;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace ASC.Data.Backup.Service
|
||||
@ -43,7 +42,7 @@ namespace ASC.Data.Backup.Service
|
||||
private BackupCleanerService CleanerService { get; set; }
|
||||
private BackupSchedulerService SchedulerService { get; set; }
|
||||
private BackupWorker BackupWorker { get; set; }
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private ConfigurationExtension Configuration { get; set; }
|
||||
private BackupListener BackupListener { get; set; }
|
||||
public NotifyConfiguration NotifyConfiguration { get; }
|
||||
|
||||
@ -51,7 +50,7 @@ namespace ASC.Data.Backup.Service
|
||||
BackupCleanerService cleanerService,
|
||||
BackupSchedulerService schedulerService,
|
||||
BackupWorker backupWorker,
|
||||
IConfiguration configuration,
|
||||
ConfigurationExtension configuration,
|
||||
BackupListener backupListener,
|
||||
NotifyConfiguration notifyConfiguration)
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ using ASC.Data.Backup.EF.Model;
|
||||
using ASC.Data.Backup.Storage;
|
||||
using ASC.Data.Backup.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
@ -93,7 +92,7 @@ namespace ASC.Data.Backup.Service
|
||||
private BackupWorker BackupWorker { get; set; }
|
||||
private BackupRepository BackupRepository { get; }
|
||||
private BackupServiceNotifier BackupServiceNotifier { get; }
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
|
||||
public BackupService(
|
||||
IOptionsMonitor<ILog> options,
|
||||
@ -101,7 +100,7 @@ namespace ASC.Data.Backup.Service
|
||||
BackupWorker backupWorker,
|
||||
BackupRepository backupRepository,
|
||||
BackupServiceNotifier backupServiceNotifier,
|
||||
IConfiguration configuration)
|
||||
ConfigurationExtension configuration)
|
||||
{
|
||||
Log = options.CurrentValue;
|
||||
BackupStorageFactory = backupStorageFactory;
|
||||
@ -185,7 +184,7 @@ namespace ASC.Data.Backup.Service
|
||||
|
||||
public void StartRestore(StartRestoreRequest request)
|
||||
{
|
||||
if ((BackupStorageType)request.StorageType == BackupStorageType.Local)
|
||||
if (request.StorageType == BackupStorageType.Local)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.FilePathOrId) || !File.Exists(request.FilePathOrId))
|
||||
{
|
||||
|
@ -35,8 +35,6 @@ using ASC.Data.Backup.EF.Model;
|
||||
using ASC.Data.Backup.Service;
|
||||
using ASC.Data.Backup.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ASC.Data.Backup.Storage
|
||||
@ -44,14 +42,20 @@ namespace ASC.Data.Backup.Storage
|
||||
[Scope]
|
||||
public class BackupStorageFactory
|
||||
{
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
private DocumentsBackupStorage DocumentsBackupStorage { get; }
|
||||
private DataStoreBackupStorage DataStoreBackupStorage { get; }
|
||||
private LocalBackupStorage LocalBackupStorage { get; }
|
||||
private ConsumerBackupStorage ConsumerBackupStorage { get; }
|
||||
private TenantManager TenantManager { get; }
|
||||
|
||||
public BackupStorageFactory(ConsumerBackupStorage consumerBackupStorage, LocalBackupStorage localBackupStorage, IConfiguration configuration, DocumentsBackupStorage documentsBackupStorage, TenantManager tenantManager, DataStoreBackupStorage dataStoreBackupStorage)
|
||||
public BackupStorageFactory(
|
||||
ConsumerBackupStorage consumerBackupStorage,
|
||||
LocalBackupStorage localBackupStorage,
|
||||
ConfigurationExtension configuration,
|
||||
DocumentsBackupStorage documentsBackupStorage,
|
||||
TenantManager tenantManager,
|
||||
DataStoreBackupStorage dataStoreBackupStorage)
|
||||
{
|
||||
Configuration = configuration;
|
||||
DocumentsBackupStorage = documentsBackupStorage;
|
||||
|
@ -45,7 +45,8 @@ namespace ASC.Data.Backup.Tasks
|
||||
|
||||
|
||||
private DbProviderFactory dbProviderFactory;
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private ConfigurationExtension ConfigurationExtension { get; set; }
|
||||
private string ConnectionString { get; set; }
|
||||
private string Path { get; set; }
|
||||
|
||||
@ -56,11 +57,11 @@ namespace ASC.Data.Backup.Tasks
|
||||
|
||||
if (string.IsNullOrEmpty(ConnectionString))
|
||||
{
|
||||
return ConfigurationExtension.GetConnectionStrings(Configuration, DefaultConnectionStringName);
|
||||
return ConfigurationExtension.GetConnectionStrings(DefaultConnectionStringName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConfigurationExtension.GetConnectionStrings(Configuration, ConnectionString);
|
||||
return ConfigurationExtension.GetConnectionStrings(ConnectionString);
|
||||
}
|
||||
|
||||
}
|
||||
@ -79,9 +80,10 @@ namespace ASC.Data.Backup.Tasks
|
||||
}
|
||||
}
|
||||
|
||||
public DbFactory(IConfiguration configuration)
|
||||
public DbFactory(IConfiguration configuration, ConfigurationExtension configurationExtension)
|
||||
{
|
||||
Configuration = configuration;
|
||||
Configuration = configuration;
|
||||
ConfigurationExtension = configurationExtension;
|
||||
}
|
||||
|
||||
public DbConnection OpenConnection(string path = "default", string connectionString = DefaultConnectionStringName)//TODO
|
||||
|
@ -79,8 +79,8 @@ namespace ASC.Data.Backup.Tasks
|
||||
public override void RunJob()
|
||||
{
|
||||
Logger.DebugFormat("begin transfer {0}", TenantId);
|
||||
var fromDbFactory = new DbFactory(null);
|
||||
var toDbFactory = new DbFactory(null);
|
||||
var fromDbFactory = new DbFactory(null, null);
|
||||
var toDbFactory = new DbFactory(null, null);
|
||||
var tenantAlias = GetTenantAlias(fromDbFactory);
|
||||
var backupFilePath = GetBackupFilePath(tenantAlias);
|
||||
var columnMapper = new ColumnMapper();
|
||||
|
@ -329,40 +329,40 @@ namespace ASC.ElasticSearch
|
||||
}
|
||||
}
|
||||
|
||||
public Task<bool> IndexAsync(T data, bool immediately = true)
|
||||
public async Task<bool> IndexAsync(T data, bool immediately = true)
|
||||
{
|
||||
var t = ServiceProvider.GetService<T>();
|
||||
if (!Support(t)) return Task.FromResult(false);
|
||||
return Queue(() => Indexer.Index(data, immediately));
|
||||
if (!await SupportAsync(t)) return false;
|
||||
return await Queue(() => Indexer.Index(data, immediately));
|
||||
}
|
||||
|
||||
public Task<bool> IndexAsync(List<T> data, bool immediately = true)
|
||||
public async Task<bool> IndexAsync(List<T> data, bool immediately = true)
|
||||
{
|
||||
var t = ServiceProvider.GetService<T>();
|
||||
if (!Support(t)) return Task.FromResult(false);
|
||||
return Queue(() => Indexer.Index(data, immediately));
|
||||
if (!await SupportAsync(t)) return false;
|
||||
return await Queue(() => Indexer.Index(data, immediately));
|
||||
}
|
||||
|
||||
public Task<bool> UpdateAsync(T data, bool immediately = true, params Expression<Func<T, object>>[] fields)
|
||||
public async Task<bool> UpdateAsync(T data, bool immediately = true, params Expression<Func<T, object>>[] fields)
|
||||
{
|
||||
var t = ServiceProvider.GetService<T>();
|
||||
if (!Support(t)) return Task.FromResult(false);
|
||||
return Queue(() => Indexer.Update(data, immediately, fields));
|
||||
if (!await SupportAsync(t)) return false;
|
||||
return await Queue(() => Indexer.Update(data, immediately, fields));
|
||||
}
|
||||
|
||||
public Task<bool> DeleteAsync(T data, bool immediately = true)
|
||||
public async Task<bool> DeleteAsync(T data, bool immediately = true)
|
||||
{
|
||||
var t = ServiceProvider.GetService<T>();
|
||||
if (!Support(t)) return Task.FromResult(false);
|
||||
return Queue(() => Indexer.Delete(data, immediately));
|
||||
if (!await SupportAsync(t)) return false;
|
||||
return await Queue(() => Indexer.Delete(data, immediately));
|
||||
}
|
||||
|
||||
public Task<bool> DeleteAsync(Expression<Func<Selector<T>, Selector<T>>> expression, bool immediately = true)
|
||||
public async Task<bool> DeleteAsync(Expression<Func<Selector<T>, Selector<T>>> expression, bool immediately = true)
|
||||
{
|
||||
var t = ServiceProvider.GetService<T>();
|
||||
if (!Support(t)) return Task.FromResult(false);
|
||||
if (!await SupportAsync(t)) return false;
|
||||
var tenant = TenantManager.GetCurrentTenant().TenantId;
|
||||
return Queue(() => Indexer.Delete(expression, tenant, immediately));
|
||||
return await Queue(() => Indexer.Delete(expression, tenant, immediately));
|
||||
}
|
||||
|
||||
|
||||
@ -445,6 +445,11 @@ namespace ASC.ElasticSearch
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SupportAsync(T t)
|
||||
{
|
||||
return await FactoryIndexerCommon.CheckStateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
[Scope]
|
||||
@ -526,6 +531,50 @@ namespace ASC.ElasticSearch
|
||||
cache.Insert(key, "false", cacheTime);
|
||||
}
|
||||
|
||||
Log.Error("Ping false", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> CheckStateAsync(bool cacheState = true)
|
||||
{
|
||||
if (!Init) return false;
|
||||
|
||||
const string key = "elasticsearch";
|
||||
|
||||
if (cacheState)
|
||||
{
|
||||
var cacheValue = cache.Get<string>(key);
|
||||
if (!string.IsNullOrEmpty(cacheValue))
|
||||
{
|
||||
return Convert.ToBoolean(cacheValue);
|
||||
}
|
||||
}
|
||||
|
||||
var cacheTime = DateTime.UtcNow.AddMinutes(15);
|
||||
|
||||
try
|
||||
{
|
||||
var result = await Client.Instance.PingAsync(new PingRequest());
|
||||
|
||||
var isValid = result.IsValid;
|
||||
|
||||
Log.DebugFormat("CheckState ping {0}", result.DebugInformation);
|
||||
|
||||
if (cacheState)
|
||||
{
|
||||
cache.Insert(key, isValid.ToString(CultureInfo.InvariantCulture).ToLower(), cacheTime);
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (cacheState)
|
||||
{
|
||||
cache.Insert(key, "false", cacheTime);
|
||||
}
|
||||
|
||||
Log.Error("Ping false", e);
|
||||
return false;
|
||||
}
|
||||
|
@ -27,8 +27,6 @@
|
||||
using ASC.Common;
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ASC.ElasticSearch.Service
|
||||
{
|
||||
[Singletone]
|
||||
@ -39,7 +37,7 @@ namespace ASC.ElasticSearch.Service
|
||||
|
||||
}
|
||||
|
||||
public Settings(IConfiguration configuration)
|
||||
public Settings(ConfigurationExtension configuration)
|
||||
{
|
||||
var cfg = configuration.GetSetting<Settings>("elastic");
|
||||
Scheme = cfg.Scheme ?? "http";
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ASC.Feed.Configuration
|
||||
{
|
||||
public class FeedSettings
|
||||
@ -16,7 +14,7 @@ namespace ASC.Feed.Configuration
|
||||
|
||||
public TimeSpan RemovePeriod { get; set; }
|
||||
|
||||
public static FeedSettings GetInstance(IConfiguration configuration)
|
||||
public static FeedSettings GetInstance(ConfigurationExtension configuration)
|
||||
{
|
||||
var result = configuration.GetSetting<FeedSettings>("feed");
|
||||
|
||||
|
@ -33,6 +33,7 @@ using System.Threading.Tasks;
|
||||
using ASC.Common;
|
||||
using ASC.Common.Caching;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Common;
|
||||
using ASC.Core.Notify.Signalr;
|
||||
@ -42,7 +43,6 @@ using ASC.Feed.Data;
|
||||
|
||||
using Autofac;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
@ -62,12 +62,12 @@ namespace ASC.Feed.Aggregator
|
||||
private readonly object aggregateLock = new object();
|
||||
private readonly object removeLock = new object();
|
||||
|
||||
private IConfiguration Configuration { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
private IServiceProvider ServiceProvider { get; }
|
||||
public ILifetimeScope Container { get; }
|
||||
|
||||
public FeedAggregatorService(
|
||||
IConfiguration configuration,
|
||||
ConfigurationExtension configuration,
|
||||
IServiceProvider serviceProvider,
|
||||
ILifetimeScope container,
|
||||
IOptionsMonitor<ILog> optionsMonitor,
|
||||
|
@ -34,7 +34,6 @@ using ASC.Common;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Notify.Signalr;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@ -45,7 +44,7 @@ namespace ASC.Socket.IO.Svc
|
||||
[Scope]
|
||||
public class SocketServiceLauncher : IHostedService
|
||||
{
|
||||
private const int PingInterval = 10000;
|
||||
//private const int PingInterval = 10000;
|
||||
|
||||
private Process Proc { get; set; }
|
||||
private ProcessStartInfo StartInfo { get; set; }
|
||||
@ -53,23 +52,26 @@ namespace ASC.Socket.IO.Svc
|
||||
// private CancellationTokenSource CancellationTokenSource { get; set; }
|
||||
private ILog Logger { get; set; }
|
||||
private string LogDir { get; set; }
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private ConfigurationExtension ConfigurationExtension { get; }
|
||||
private CoreBaseSettings CoreBaseSettings { get; set; }
|
||||
private SignalrServiceClient SignalrServiceClient { get; set; }
|
||||
//private SignalrServiceClient SignalrServiceClient { get; set; }
|
||||
private IHostEnvironment HostEnvironment { get; set; }
|
||||
|
||||
public SocketServiceLauncher(
|
||||
IOptionsMonitor<ILog> options,
|
||||
IConfiguration configuration,
|
||||
ConfigurationExtension configurationExtension,
|
||||
CoreBaseSettings coreBaseSettings,
|
||||
IOptionsSnapshot<SignalrServiceClient> signalrServiceClient,
|
||||
//IOptionsSnapshot<SignalrServiceClient> signalrServiceClient,
|
||||
IHostEnvironment hostEnvironment)
|
||||
{
|
||||
Logger = options.CurrentValue;
|
||||
//CancellationTokenSource = new CancellationTokenSource();
|
||||
Configuration = configuration;
|
||||
Configuration = configuration;
|
||||
ConfigurationExtension = configurationExtension;
|
||||
CoreBaseSettings = coreBaseSettings;
|
||||
SignalrServiceClient = signalrServiceClient.Value;
|
||||
//SignalrServiceClient = signalrServiceClient.Value;
|
||||
HostEnvironment = hostEnvironment;
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ namespace ASC.Socket.IO.Svc
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = Configuration.GetSetting<SocketSettings>("socket");
|
||||
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
|
||||
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
|
@ -32,9 +32,8 @@ using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using ASC.Common.Utils;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
@ -46,10 +45,10 @@ namespace ASC.Thumbnails.Svc
|
||||
private ProcessStartInfo StartInfo { get; set; }
|
||||
private Process Proc { get; set; }
|
||||
private ILog Logger { get; set; }
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private ConfigurationExtension Configuration { get; set; }
|
||||
private IHostEnvironment HostEnvironment { get; set; }
|
||||
|
||||
public ThumbnailsServiceLauncher(IOptionsMonitor<ILog> options, IConfiguration configuration, IHostEnvironment hostEnvironment)
|
||||
public ThumbnailsServiceLauncher(IOptionsMonitor<ILog> options, ConfigurationExtension configuration, IHostEnvironment hostEnvironment)
|
||||
{
|
||||
Logger = options.CurrentValue;
|
||||
Configuration = configuration;
|
||||
|
@ -48,19 +48,24 @@ namespace ASC.UrlShortener.Svc
|
||||
|
||||
private readonly IConfiguration configuration;
|
||||
|
||||
private readonly IHostEnvironment hostEnvironment;
|
||||
|
||||
private readonly IHostEnvironment hostEnvironment;
|
||||
private readonly ConfigurationExtension configurationExtension;
|
||||
private ProcessStartInfo processStartInfo;
|
||||
|
||||
private Process process;
|
||||
|
||||
public UrlShortenerService(IOptionsMonitor<ILog> options, IConfiguration config, IHostEnvironment host)
|
||||
public UrlShortenerService(
|
||||
IOptionsMonitor<ILog> options,
|
||||
IConfiguration config,
|
||||
IHostEnvironment host,
|
||||
ConfigurationExtension configurationExtension)
|
||||
{
|
||||
log = options.Get("ASC.UrlShortener.Svc");
|
||||
|
||||
configuration = config;
|
||||
|
||||
hostEnvironment = host;
|
||||
hostEnvironment = host;
|
||||
this.configurationExtension = configurationExtension;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@ -119,7 +124,7 @@ namespace ASC.UrlShortener.Svc
|
||||
|
||||
startInfo.EnvironmentVariables.Add("port", port);
|
||||
|
||||
var conString = ConfigurationExtension.GetConnectionStrings(configuration)["default"].ConnectionString;
|
||||
var conString = configurationExtension.GetConnectionStrings()["default"].ConnectionString;
|
||||
|
||||
var dict = new Dictionary<string, string>
|
||||
{
|
||||
|
@ -108,11 +108,11 @@ namespace ASC.Files.Core.Data
|
||||
.Where(where);
|
||||
}
|
||||
|
||||
protected void GetRecalculateFilesCountUpdate(object folderId)
|
||||
protected void GetRecalculateFilesCountUpdate(int folderId)
|
||||
{
|
||||
var folders = FilesDbContext.Folders
|
||||
.Where(r => r.TenantId == TenantID)
|
||||
.Where(r => FilesDbContext.Tree.Where(r => r.FolderId.ToString() == folderId.ToString()).Select(r => r.ParentId).Any(a => a == r.Id))
|
||||
.Where(r => FilesDbContext.Tree.Where(r => r.FolderId == folderId).Select(r => r.ParentId).Any(a => a == r.Id))
|
||||
.ToList();
|
||||
|
||||
foreach (var f in folders)
|
||||
|
@ -123,13 +123,18 @@ namespace ASC.Files.Core.Data
|
||||
public File<int> GetFile(int fileId)
|
||||
{
|
||||
var query = GetFileQuery(r => r.Id == fileId && r.CurrentVersion).AsNoTracking();
|
||||
return ToFile(FromQueryWithShared(query).SingleOrDefault());
|
||||
return ToFile(
|
||||
FromQueryWithShared(query)
|
||||
.Take(1)
|
||||
.SingleOrDefault());
|
||||
}
|
||||
|
||||
public File<int> GetFile(int fileId, int fileVersion)
|
||||
{
|
||||
var query = GetFileQuery(r => r.Id == fileId && r.Version == fileVersion).AsNoTracking();
|
||||
return ToFile(FromQueryWithShared(query).SingleOrDefault());
|
||||
return ToFile(FromQueryWithShared(query)
|
||||
.Take(1)
|
||||
.SingleOrDefault());
|
||||
}
|
||||
|
||||
public File<int> GetFile(int parentId, string title)
|
||||
@ -943,7 +948,7 @@ namespace ASC.Files.Core.Data
|
||||
: null;
|
||||
}
|
||||
|
||||
private void RecalculateFilesCount(object folderId)
|
||||
private void RecalculateFilesCount(int folderId)
|
||||
{
|
||||
GetRecalculateFilesCountUpdate(folderId);
|
||||
}
|
||||
@ -1328,9 +1333,11 @@ namespace ASC.Files.Core.Data
|
||||
.Where(x => x.tree.FolderId == r.FolderId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault(),
|
||||
Shared =
|
||||
FilesDbContext.Security
|
||||
.Where(x=> x.TenantId == TenantID)
|
||||
.Where(x => x.EntryType == FileEntryType.File)
|
||||
.Where(x => x.EntryId == r.Id.ToString())
|
||||
.Any()
|
||||
@ -1349,6 +1356,7 @@ namespace ASC.Files.Core.Data
|
||||
.Where(x => x.tree.FolderId == r.FolderId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault(),
|
||||
Shared = true
|
||||
});
|
||||
|
@ -353,13 +353,13 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
//full path to root
|
||||
var oldTree = FilesDbContext.Tree
|
||||
.Where(r => r.FolderId == (int)folder.ParentFolderID);
|
||||
.Where(r => r.FolderId == folder.ParentFolderID);
|
||||
|
||||
foreach (var o in oldTree)
|
||||
{
|
||||
var treeToAdd = new DbFolderTree
|
||||
{
|
||||
FolderId = (int)folder.ID,
|
||||
FolderId = folder.ID,
|
||||
ParentId = o.ParentId,
|
||||
Level = o.Level + 1
|
||||
};
|
||||
@ -1049,7 +1049,8 @@ namespace ASC.Files.Core.Data
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault(),
|
||||
Shared = FilesDbContext.Security
|
||||
Shared = FilesDbContext.Security
|
||||
.Where(x => x.TenantId == TenantID)
|
||||
.Where(r => r.EntryType == FileEntryType.Folder)
|
||||
.Where(x => x.EntryId == r.Id.ToString())
|
||||
.Any()
|
||||
|
@ -28,7 +28,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Common.EF;
|
||||
@ -457,15 +458,15 @@ namespace ASC.Files.Core.Data
|
||||
var shareQuery =
|
||||
new Func<IQueryable<TagLinkData>>(() => getBaseSqlQuery().Where(
|
||||
r => FilesDbContext.Security
|
||||
.Where(a => a.TenantId == r.Link.TenantId)
|
||||
.Where(a => a.TenantId == TenantID)
|
||||
.Where(a => a.EntryId == r.Link.EntryId)
|
||||
.Where(a => a.EntryType == r.Link.EntryType)
|
||||
.Any()));
|
||||
|
||||
var tmpShareFileTags =
|
||||
shareQuery()
|
||||
.Join(FilesDbContext.Files, r => r.Link.EntryId, f => f.Id.ToString(), (tagLink, file) => new { tagLink, file })
|
||||
.Where(r => r.file.TenantId == r.tagLink.Link.TenantId)
|
||||
.Join(FilesDbContext.Files, r => Regex.IsMatch(r.Link.EntryId, "^[0-9]+$") ? Convert.ToInt32(r.Link.EntryId) : -1, f => f.Id, (tagLink, file) => new { tagLink, file })
|
||||
.Where(r => r.file.TenantId == TenantID)
|
||||
.Where(r => r.file.CreateBy != subject)
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.File)
|
||||
.Select(r => new
|
||||
@ -473,10 +474,11 @@ namespace ASC.Files.Core.Data
|
||||
r.tagLink,
|
||||
root = FilesDbContext.Folders
|
||||
.Join(FilesDbContext.Tree, a => a.Id, b => b.ParentId, (folder, tree) => new { folder, tree })
|
||||
.Where(x => x.folder.TenantId == r.file.TenantId)
|
||||
.Where(x => x.folder.TenantId == TenantID)
|
||||
.Where(x => x.tree.FolderId == r.file.FolderId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault()
|
||||
})
|
||||
.Where(r => r.root.FolderType == FolderType.USER)
|
||||
@ -487,8 +489,8 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
var tmpShareFolderTags =
|
||||
shareQuery()
|
||||
.Join(FilesDbContext.Folders, r => r.Link.EntryId, f => f.Id.ToString(), (tagLink, folder) => new { tagLink, folder })
|
||||
.Where(r => r.folder.TenantId == r.tagLink.Link.TenantId)
|
||||
.Join(FilesDbContext.Folders, r => Regex.IsMatch(r.Link.EntryId, "^[0-9]+$") ? Convert.ToInt32(r.Link.EntryId) : -1, f => f.Id, (tagLink, folder) => new { tagLink, folder })
|
||||
.Where(r => r.folder.TenantId == TenantID)
|
||||
.Where(r => r.folder.CreateBy != subject)
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.Folder)
|
||||
.Select(r => new
|
||||
@ -496,10 +498,11 @@ namespace ASC.Files.Core.Data
|
||||
r.tagLink,
|
||||
root = FilesDbContext.Folders
|
||||
.Join(FilesDbContext.Tree, a => a.Id, b => b.ParentId, (folder, tree) => new { folder, tree })
|
||||
.Where(x => x.folder.TenantId == r.folder.TenantId)
|
||||
.Where(x => x.folder.TenantId ==TenantID)
|
||||
.Where(x => x.tree.FolderId == r.folder.ParentId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault()
|
||||
})
|
||||
.Where(r => r.root.FolderType == FolderType.USER)
|
||||
@ -531,15 +534,15 @@ namespace ASC.Files.Core.Data
|
||||
var shareQuery =
|
||||
new Func<IQueryable<TagLinkData>>(() => getBaseSqlQuery().Where(
|
||||
r => FilesDbContext.Security
|
||||
.Where(a => a.TenantId == r.Link.TenantId)
|
||||
.Where(a => a.TenantId == TenantID)
|
||||
.Where(a => a.EntryId == r.Link.EntryId)
|
||||
.Where(a => a.EntryType == r.Link.EntryType)
|
||||
.Any()));
|
||||
|
||||
var tmpShareFileTags =
|
||||
shareQuery()
|
||||
.Join(FilesDbContext.Files, r => r.Link.EntryId, f => f.Id.ToString(), (tagLink, file) => new { tagLink, file })
|
||||
.Where(r => r.file.TenantId == r.tagLink.Link.TenantId)
|
||||
.Join(FilesDbContext.Files, r => Regex.IsMatch(r.Link.EntryId, "^[0-9]+$") ? Convert.ToInt32(r.Link.EntryId) : -1, f => f.Id, (tagLink, file) => new { tagLink, file })
|
||||
.Where(r => r.file.TenantId == TenantID)
|
||||
.Where(r => r.file.CreateBy != subject)
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.File)
|
||||
.Select(r => new
|
||||
@ -547,10 +550,11 @@ namespace ASC.Files.Core.Data
|
||||
r.tagLink,
|
||||
root = FilesDbContext.Folders
|
||||
.Join(FilesDbContext.Tree, a => a.Id, b => b.ParentId, (folder, tree) => new { folder, tree })
|
||||
.Where(x => x.folder.TenantId == r.file.TenantId)
|
||||
.Where(x => x.folder.TenantId == TenantID)
|
||||
.Where(x => x.tree.FolderId == r.file.FolderId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault()
|
||||
})
|
||||
.Where(r => r.root.FolderType == FolderType.Privacy)
|
||||
@ -561,8 +565,8 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
var tmpShareFolderTags =
|
||||
shareQuery()
|
||||
.Join(FilesDbContext.Folders, r => r.Link.EntryId, f => f.Id.ToString(), (tagLink, folder) => new { tagLink, folder })
|
||||
.Where(r => r.folder.TenantId == r.tagLink.Link.TenantId)
|
||||
.Join(FilesDbContext.Folders, r => Regex.IsMatch(r.Link.EntryId, "^[0-9]+$") ? Convert.ToInt32(r.Link.EntryId) : -1, f => f.Id, (tagLink, folder) => new { tagLink, folder })
|
||||
.Where(r => r.folder.TenantId == TenantID)
|
||||
.Where(r => r.folder.CreateBy != subject)
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.Folder)
|
||||
.Select(r => new
|
||||
@ -570,10 +574,11 @@ namespace ASC.Files.Core.Data
|
||||
r.tagLink,
|
||||
root = FilesDbContext.Folders
|
||||
.Join(FilesDbContext.Tree, a => a.Id, b => b.ParentId, (folder, tree) => new { folder, tree })
|
||||
.Where(x => x.folder.TenantId == r.folder.TenantId)
|
||||
.Where(x => x.folder.TenantId == TenantID)
|
||||
.Where(x => x.tree.FolderId == r.folder.ParentId)
|
||||
.OrderByDescending(r => r.tree.Level)
|
||||
.Select(r => r.folder)
|
||||
.Take(1)
|
||||
.FirstOrDefault()
|
||||
})
|
||||
.Where(r => r.root.FolderType == FolderType.Privacy)
|
||||
@ -626,7 +631,7 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
var newTagsForFiles =
|
||||
getBaseSqlQuery()
|
||||
.Join(FilesDbContext.Files, r => r.Link.EntryId, r => r.Id.ToString(), (tagLink, file) => new { tagLink, file })
|
||||
.Join(FilesDbContext.Files, r => Regex.IsMatch(r.Link.EntryId, "^[0-9]+$") ? Convert.ToInt32(r.Link.EntryId) : -1, r => r.Id, (tagLink, file) => new { tagLink, file })
|
||||
.Where(r => r.file.TenantId == r.tagLink.Link.TenantId)
|
||||
.Where(r => where.Any(a => r.file.FolderId.ToString() == a))
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.File)
|
||||
@ -657,7 +662,7 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
var newTagsForSBox = getBaseSqlQuery()
|
||||
.Join(FilesDbContext.ThirdpartyIdMapping, r => r.Link.EntryId, r => r.HashId, (tagLink, mapping) => new { tagLink, mapping })
|
||||
.Where(r => r.mapping.TenantId == r.tagLink.Link.TenantId)
|
||||
.Where(r => r.mapping.TenantId == TenantID)
|
||||
.Where(r => thirdpartyFolderIds.Any(a => r.mapping.Id == a))
|
||||
.Where(r => r.tagLink.Tag.Owner == subject)
|
||||
.Where(r => r.tagLink.Link.EntryType == FileEntryType.Folder)
|
||||
|
@ -24,10 +24,10 @@ namespace ASC.Files.Core.EF
|
||||
public string EntryId { get; set; }
|
||||
|
||||
[Column("create_by")]
|
||||
public Guid CreateBy { get; set; }
|
||||
public Guid? CreateBy { get; set; }
|
||||
|
||||
[Column("create_on")]
|
||||
public DateTime CreateOn { get; set; }
|
||||
public DateTime? CreateOn { get; set; }
|
||||
|
||||
[Column("tag_count")]
|
||||
public int TagCount { get; set; }
|
||||
|
@ -57,8 +57,7 @@ namespace ASC.Web.Files.Services.WCFService.FileOperations
|
||||
var operations = tasks.GetTasks();
|
||||
var processlist = Process.GetProcesses();
|
||||
|
||||
foreach (var o in operations.Where(o => string.IsNullOrEmpty(o.InstanceId)
|
||||
|| processlist.All(p => p.Id != int.Parse(o.InstanceId))))
|
||||
foreach (var o in operations.Where(o => processlist.All(p => p.Id != o.InstanceId)))
|
||||
{
|
||||
o.SetProperty(FileOperation.PROGRESS, 100);
|
||||
tasks.RemoveTask(o.Id);
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using ASC.Api.Core;
|
||||
using ASC.Api.Utils;
|
||||
using ASC.Common;
|
||||
using ASC.Common.Web;
|
||||
@ -21,6 +22,7 @@ namespace ASC.Employee.Core.Controllers
|
||||
[ApiController]
|
||||
public class GroupController : ControllerBase
|
||||
{
|
||||
public ApiContext ApiContext { get; }
|
||||
private MessageService MessageService { get; }
|
||||
|
||||
private UserManager UserManager { get; }
|
||||
@ -29,12 +31,14 @@ namespace ASC.Employee.Core.Controllers
|
||||
private GroupWraperFullHelper GroupWraperFullHelper { get; }
|
||||
|
||||
public GroupController(
|
||||
ApiContext apiContext,
|
||||
MessageService messageService,
|
||||
UserManager userManager,
|
||||
PermissionContext permissionContext,
|
||||
MessageTarget messageTarget,
|
||||
GroupWraperFullHelper groupWraperFullHelper)
|
||||
{
|
||||
ApiContext = apiContext;
|
||||
MessageService = messageService;
|
||||
UserManager = userManager;
|
||||
PermissionContext = permissionContext;
|
||||
@ -45,7 +49,12 @@ namespace ASC.Employee.Core.Controllers
|
||||
[Read]
|
||||
public IEnumerable<GroupWrapperSummary> GetAll()
|
||||
{
|
||||
return UserManager.GetDepartments().Select(x => new GroupWrapperSummary(x, UserManager));
|
||||
var result = UserManager.GetDepartments().Select(r => r);
|
||||
if (!string.IsNullOrEmpty(ApiContext.FilterValue))
|
||||
{
|
||||
result = result.Where(r => r.Name.Contains(ApiContext.FilterValue));
|
||||
}
|
||||
return result.Select(x => new GroupWrapperSummary(x, UserManager));
|
||||
}
|
||||
|
||||
[Read("{groupid}")]
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "asc-web-common",
|
||||
"version": "1.0.277",
|
||||
"version": "1.0.279",
|
||||
"description": "Ascensio System SIA common components and solutions library",
|
||||
"license": "AGPL-3.0",
|
||||
"files": [
|
||||
|
@ -754,6 +754,10 @@ class FilterInput extends React.Component {
|
||||
} = this.state;
|
||||
|
||||
const smallSectionWidth = sectionWidth ? sectionWidth <= 500 : false;
|
||||
const isAllItemsHide =
|
||||
openFilterItems.length === 0 && hiddenFilterItems.length > 0
|
||||
? true
|
||||
: false;
|
||||
|
||||
let iconSize = 30;
|
||||
switch (size) {
|
||||
@ -776,6 +780,7 @@ class FilterInput extends React.Component {
|
||||
className={className}
|
||||
id={id}
|
||||
style={style}
|
||||
isAllItemsHide={isAllItemsHide}
|
||||
>
|
||||
<div className="styled-search-input test" ref={this.searchWrapper}>
|
||||
<SearchInput
|
||||
|
@ -91,6 +91,12 @@ const StyledFilterInput = styled.div`
|
||||
.styled-hide-filter {
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
|
||||
.hide-filter-drop-down {
|
||||
.combo-button-label {
|
||||
${(props) => (props.isAllItemsHide ? "margin-top: 2px;" : null)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-style {
|
||||
|
@ -54,7 +54,7 @@ class HideFilter extends React.Component {
|
||||
|
||||
<div className="dropdown-style" ref={this.dropDownRef}>
|
||||
<DropDown
|
||||
className="drop-down"
|
||||
className="drop-down hide-filter-drop-down"
|
||||
clickOutsideAction={this.handleClickOutside}
|
||||
manualY="8px"
|
||||
open={popoverOpen}
|
||||
|
@ -100,7 +100,7 @@ class NavMenu extends React.Component {
|
||||
render() {
|
||||
const { isBackdropVisible, isNavOpened, isAsideVisible } = this.state;
|
||||
|
||||
const { isAuthenticated, isLoaded, asideContent } = this.props;
|
||||
const { isAuthenticated, isLoaded, asideContent, history } = this.props;
|
||||
|
||||
const isAsideAvailable = !!asideContent;
|
||||
|
||||
@ -114,7 +114,7 @@ class NavMenu extends React.Component {
|
||||
|
||||
{isLoaded && isAuthenticated ? (
|
||||
<>
|
||||
<HeaderNav />
|
||||
<HeaderNav history={history} />
|
||||
<Header
|
||||
isNavOpened={isNavOpened}
|
||||
onClick={this.showNav}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "asc-web-components",
|
||||
"version": "1.0.485",
|
||||
"version": "1.0.486",
|
||||
"description": "Ascensio System SIA component library",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "dist/asc-web-components.js",
|
||||
|
@ -40,17 +40,23 @@ const RoleWrapper = styled.div`
|
||||
left: ${(props) =>
|
||||
(props.size === "max" && "0px") ||
|
||||
(props.size === "big" && "0px") ||
|
||||
(props.size === "medium" && "-2px") ||
|
||||
(props.size === "medium" && "-4px") ||
|
||||
(props.size === "small" && "-2px") ||
|
||||
(props.size === "min" && "-2px")};
|
||||
bottom: ${(props) =>
|
||||
(props.size === "max" && "0px") ||
|
||||
(props.size === "big" && "5px") ||
|
||||
(props.size === "medium" && "3px") ||
|
||||
(props.size === "medium" && "6px") ||
|
||||
(props.size === "small" && "3px") ||
|
||||
(props.size === "min" && "3px")};
|
||||
width: ${(props) => (props.size === "max" && "24px") || "12px"};
|
||||
height: ${(props) => (props.size === "max" && "24px") || "12px"};
|
||||
width: ${(props) =>
|
||||
(props.size === "max" && "24px") ||
|
||||
(props.size === "medium" && "14px") ||
|
||||
"12px"};
|
||||
height: ${(props) =>
|
||||
(props.size === "max" && "24px") ||
|
||||
(props.size === "medium" && "14px") ||
|
||||
"12px"};
|
||||
`;
|
||||
|
||||
const ImageStyled = styled.img`
|
||||
|
Loading…
Reference in New Issue
Block a user