Merge branch 'develop' into feature/mobile-main-button
This commit is contained in:
commit
ec3c7ad4d2
8
build/Jenkinsfile
vendored
8
build/Jenkinsfile
vendored
@ -13,7 +13,7 @@ pipeline {
|
||||
}
|
||||
stage('Backend') {
|
||||
steps {
|
||||
sh 'dotnet build -c Release ASC.Web.sln'
|
||||
sh 'dotnet build -c Release ASC.Web.slnf'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ pipeline {
|
||||
}
|
||||
stage('Backend') {
|
||||
steps {
|
||||
bat 'dotnet build -c Release ASC.Web.sln'
|
||||
bat 'dotnet build -c Release ASC.Web.slnf'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,7 +62,7 @@ pipeline {
|
||||
}
|
||||
stage('Files') {
|
||||
steps {
|
||||
sh "git submodule update --progress --init -- products/ASC.Files/Server/DocStore && dotnet build ASC.Web.sln && cd ${env.WORKSPACE}/products/ASC.Files/Tests/ && dotnet test ASC.Files.Tests.csproj -r linux-x64 -l \"console;verbosity=detailed\""
|
||||
sh "git submodule update --progress --init -- products/ASC.Files/Server/DocStore && dotnet build ASC.Web.slnf && cd ${env.WORKSPACE}/products/ASC.Files/Tests/ && dotnet test ASC.Files.Tests.csproj -r linux-x64 -l \"console;verbosity=detailed\""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ pipeline {
|
||||
}
|
||||
stage('Files') {
|
||||
steps {
|
||||
bat "git submodule update --progress --init -- products\\ASC.Files\\Server\\DocStore && dotnet build ASC.Web.sln && cd ${env.WORKSPACE}\\products\\ASC.Files\\Tests\\ && dotnet test ASC.Files.Tests.csproj"
|
||||
bat "git submodule update --progress --init -- products\\ASC.Files\\Server\\DocStore && dotnet build ASC.Web.slnf && cd ${env.WORKSPACE}\\products\\ASC.Files\\Tests\\ && dotnet test ASC.Files.Tests.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,15 @@ namespace ASC.Api.Core.Middleware
|
||||
base.OnResultExecuted(context);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = (ObjectResult)context.Result;
|
||||
var resultContent = JsonSerializer.Serialize(result.Value, jsonSerializerOptions);
|
||||
|
||||
var eventName = $"method: {method}, route: {routePattern}";
|
||||
|
||||
WebhookPublisher.Publish(eventName, resultContent);
|
||||
|
||||
if (context.Result is ObjectResult objectResult)
|
||||
{
|
||||
var resultContent = JsonSerializer.Serialize(objectResult.Value, jsonSerializerOptions);
|
||||
|
||||
var eventName = $"method: {method}, route: {routePattern}";
|
||||
|
||||
WebhookPublisher.Publish(eventName, resultContent);
|
||||
}
|
||||
|
||||
base.OnResultExecuted(context);
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ namespace ASC.Security.Cryptography
|
||||
[Singletone]
|
||||
public class InstanceCrypto
|
||||
{
|
||||
private MachinePseudoKeys MachinePseudoKeys { get; }
|
||||
private byte[] EKey { get; }
|
||||
|
||||
public InstanceCrypto(MachinePseudoKeys machinePseudoKeys)
|
||||
{
|
||||
MachinePseudoKeys = machinePseudoKeys;
|
||||
EKey = machinePseudoKeys.GetMachineConstant(32);
|
||||
}
|
||||
|
||||
public string Encrypt(string data)
|
||||
@ -50,8 +50,8 @@ namespace ASC.Security.Cryptography
|
||||
|
||||
public byte[] Encrypt(byte[] data)
|
||||
{
|
||||
var hasher = Aes.Create();
|
||||
hasher.Key = EKey();
|
||||
using var hasher = Aes.Create();
|
||||
hasher.Key = EKey;
|
||||
hasher.IV = new byte[hasher.BlockSize >> 3];
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
@ -70,24 +70,17 @@ namespace ASC.Security.Cryptography
|
||||
|
||||
public string Decrypt(byte[] data)
|
||||
{
|
||||
var hasher = Aes.Create();
|
||||
hasher.Key = EKey();
|
||||
using var hasher = Aes.Create();
|
||||
hasher.Key = EKey;
|
||||
hasher.IV = new byte[hasher.BlockSize >> 3];
|
||||
|
||||
using (MemoryStream msDecrypt = new MemoryStream(data))
|
||||
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, hasher.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
|
||||
{
|
||||
using var msDecrypt = new MemoryStream(data);
|
||||
using var csDecrypt = new CryptoStream(msDecrypt, hasher.CreateDecryptor(), CryptoStreamMode.Read);
|
||||
using var srDecrypt = new StreamReader(csDecrypt);
|
||||
|
||||
// Read the decrypted bytes from the decrypting stream
|
||||
// and place them in a string.
|
||||
return srDecrypt.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] EKey()
|
||||
{
|
||||
return MachinePseudoKeys.GetMachineConstant(32);
|
||||
// Read the decrypted bytes from the decrypting stream
|
||||
// and place them in a string.
|
||||
return srDecrypt.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
@ -62,12 +62,12 @@ namespace ASC.Core.Data
|
||||
[Scope]
|
||||
class DbQuotaService : IQuotaService
|
||||
{
|
||||
private Expression<Func<DbQuota, TenantQuota>> FromDbQuotaToTenantQuota { get; set; }
|
||||
private Expression<Func<DbQuotaRow, TenantQuotaRow>> FromDbQuotaRowToTenantQuotaRow { get; set; }
|
||||
private static Expression<Func<DbQuota, TenantQuota>> FromDbQuotaToTenantQuota { get; set; }
|
||||
private static Expression<Func<DbQuotaRow, TenantQuotaRow>> FromDbQuotaRowToTenantQuotaRow { get; set; }
|
||||
internal CoreDbContext CoreDbContext { get => LazyCoreDbContext.Value; }
|
||||
internal Lazy<CoreDbContext> LazyCoreDbContext { get; set; }
|
||||
|
||||
public DbQuotaService()
|
||||
static DbQuotaService()
|
||||
{
|
||||
FromDbQuotaToTenantQuota = r => new TenantQuota()
|
||||
{
|
||||
@ -91,7 +91,7 @@ namespace ASC.Core.Data
|
||||
};
|
||||
}
|
||||
|
||||
public DbQuotaService(DbContextManager<CoreDbContext> dbContextManager) : this()
|
||||
public DbQuotaService(DbContextManager<CoreDbContext> dbContextManager)
|
||||
{
|
||||
LazyCoreDbContext = new Lazy<CoreDbContext>(() => dbContextManager.Value);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace ASC.Core.Common.EF
|
||||
{
|
||||
optionsBuilder.UseLoggerFactory(LoggerFactory);
|
||||
optionsBuilder.EnableSensitiveDataLogging();
|
||||
Provider = GetProviderByConnectionString();
|
||||
Provider = GetProviderByConnectionString();
|
||||
switch (Provider)
|
||||
{
|
||||
case Provider.MySql:
|
||||
|
@ -15,18 +15,20 @@ namespace ASC.Core.Common.EF
|
||||
public const string baseName = "default";
|
||||
private EFLoggerFactory LoggerFactory { get; }
|
||||
private ConfigurationExtension Configuration { get; }
|
||||
private string MigrateAssembly { get; }
|
||||
|
||||
public ConfigureDbContext(EFLoggerFactory loggerFactory, ConfigurationExtension configuration)
|
||||
{
|
||||
LoggerFactory = loggerFactory;
|
||||
Configuration = configuration;
|
||||
MigrateAssembly = Configuration["testAssembly"];
|
||||
}
|
||||
|
||||
public void Configure(string name, T context)
|
||||
{
|
||||
context.LoggerFactory = LoggerFactory;
|
||||
context.ConnectionStringSettings = Configuration.GetConnectionStrings(name) ?? Configuration.GetConnectionStrings(baseName);
|
||||
context.MigrateAssembly = Configuration["testAssembly"];
|
||||
context.MigrateAssembly = MigrateAssembly;
|
||||
}
|
||||
|
||||
public void Configure(T context)
|
||||
|
@ -83,7 +83,7 @@ namespace ASC.Data.Storage
|
||||
virtPath = "";
|
||||
}
|
||||
|
||||
if (virtPath.StartsWith("~") && !Uri.IsWellFormedUriString(virtPath, UriKind.Absolute))
|
||||
if (virtPath.StartsWith('~') && !Uri.IsWellFormedUriString(virtPath, UriKind.Absolute))
|
||||
{
|
||||
var rootPath = "/";
|
||||
if (!string.IsNullOrEmpty(WebHostEnvironment?.WebRootPath) && WebHostEnvironment?.WebRootPath.Length > 1)
|
||||
|
@ -26,30 +26,37 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ASC.FederatedLogin
|
||||
{
|
||||
[DebuggerDisplay("{AccessToken} (expired: {IsExpired})")]
|
||||
public class OAuth20Token
|
||||
{
|
||||
[JsonPropertyName("access_token")]
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
[JsonPropertyName("refresh_token")]
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
[JsonPropertyName("expires_in")]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
||||
public long ExpiresIn { get; set; }
|
||||
|
||||
[JsonPropertyName("client_id")]
|
||||
public string ClientID { get; set; }
|
||||
|
||||
[JsonPropertyName("client_secret")]
|
||||
public string ClientSecret { get; set; }
|
||||
|
||||
[JsonPropertyName("redirect_uri")]
|
||||
public string RedirectUri { get; set; }
|
||||
|
||||
[JsonPropertyName("timestamp")]
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string OriginJson { get; set; }
|
||||
|
||||
public OAuth20Token()
|
||||
@ -92,55 +99,19 @@ namespace ASC.FederatedLogin
|
||||
public static OAuth20Token FromJson(string json)
|
||||
{
|
||||
if (string.IsNullOrEmpty(json)) return null;
|
||||
var parser = JObject.Parse(json);
|
||||
if (parser == null) return null;
|
||||
|
||||
var accessToken = parser.Value<string>("access_token");
|
||||
|
||||
if (string.IsNullOrEmpty(accessToken))
|
||||
return null;
|
||||
|
||||
var token = new OAuth20Token
|
||||
{
|
||||
AccessToken = accessToken,
|
||||
RefreshToken = parser.Value<string>("refresh_token"),
|
||||
ClientID = parser.Value<string>("client_id"),
|
||||
ClientSecret = parser.Value<string>("client_secret"),
|
||||
RedirectUri = parser.Value<string>("redirect_uri"),
|
||||
OriginJson = json,
|
||||
};
|
||||
|
||||
if (long.TryParse(parser.Value<string>("expires_in"), out var expiresIn))
|
||||
token.ExpiresIn = expiresIn;
|
||||
|
||||
try
|
||||
{
|
||||
token.Timestamp =
|
||||
!string.IsNullOrEmpty(parser.Value<string>("timestamp"))
|
||||
? parser.Value<DateTime>("timestamp")
|
||||
: DateTime.UtcNow;
|
||||
return JsonSerializer.Deserialize<OAuth20Token>(json);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
token.Timestamp = DateTime.MinValue;
|
||||
return null;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("{");
|
||||
sb.AppendFormat(" \"access_token\": \"{0}\"", AccessToken);
|
||||
sb.AppendFormat(", \"refresh_token\": \"{0}\"", RefreshToken);
|
||||
sb.AppendFormat(", \"expires_in\": \"{0}\"", ExpiresIn);
|
||||
sb.AppendFormat(", \"client_id\": \"{0}\"", ClientID);
|
||||
sb.AppendFormat(", \"client_secret\": \"{0}\"", ClientSecret);
|
||||
sb.AppendFormat(", \"redirect_uri\": \"{0}\"", RedirectUri);
|
||||
sb.AppendFormat(", \"timestamp\": \"{0}\"", Timestamp.ToString("o", new CultureInfo("en-US")));
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
@ -36,7 +36,6 @@ 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.EF;
|
||||
using ASC.Core.Common.EF.Context;
|
||||
@ -103,14 +102,14 @@ namespace ASC.ElasticSearch
|
||||
DbContextManager<WebstudioDbContext> dbContextManager,
|
||||
TenantManager tenantManager,
|
||||
BaseIndexerHelper baseIndexerHelper,
|
||||
ConfigurationExtension configurationExtension,
|
||||
SettingsHelper settingsHelper,
|
||||
IServiceProvider serviceProvider)
|
||||
{
|
||||
Client = client;
|
||||
Log = log.CurrentValue;
|
||||
TenantManager = tenantManager;
|
||||
BaseIndexerHelper = baseIndexerHelper;
|
||||
Settings = Settings.GetInstance(configurationExtension);
|
||||
Settings = settingsHelper.Settings;
|
||||
ServiceProvider = serviceProvider;
|
||||
LazyWebstudioDbContext = new Lazy<WebstudioDbContext>(() => dbContextManager.Value);
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ using System.Text;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Tenants;
|
||||
using ASC.ElasticSearch.Service;
|
||||
@ -54,11 +53,11 @@ namespace ASC.ElasticSearch
|
||||
private CoreConfiguration CoreConfiguration { get; }
|
||||
private Settings Settings { get; }
|
||||
|
||||
public Client(IOptionsMonitor<ILog> option, CoreConfiguration coreConfiguration, ConfigurationExtension configurationExtension)
|
||||
public Client(IOptionsMonitor<ILog> option, CoreConfiguration coreConfiguration, SettingsHelper settingsHelper)
|
||||
{
|
||||
Log = option.Get("ASC.Indexer");
|
||||
CoreConfiguration = coreConfiguration;
|
||||
Settings = Settings.GetInstance(configurationExtension);
|
||||
Settings = settingsHelper.Settings;
|
||||
}
|
||||
|
||||
public ElasticClient Instance
|
||||
|
@ -32,7 +32,6 @@ using System.Threading.Tasks;
|
||||
using ASC.Common;
|
||||
using ASC.Common.Caching;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.ElasticSearch.Service;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -58,14 +57,14 @@ namespace ASC.ElasticSearch
|
||||
ICacheNotify<AscCacheItem> notify,
|
||||
ICacheNotify<IndexAction> indexNotify,
|
||||
IServiceProvider serviceProvider,
|
||||
ConfigurationExtension configurationExtension)
|
||||
SettingsHelper settingsHelper)
|
||||
{
|
||||
Log = options.Get("ASC.Indexer");
|
||||
Notify = notify;
|
||||
IndexNotify = indexNotify;
|
||||
ServiceProvider = serviceProvider;
|
||||
CancellationTokenSource = new CancellationTokenSource();
|
||||
var settings = Settings.GetInstance(configurationExtension);
|
||||
var settings = settingsHelper.Settings;
|
||||
Period = TimeSpan.FromMinutes(settings.Period.Value);
|
||||
}
|
||||
|
||||
|
@ -30,23 +30,29 @@ using ASC.Common.Utils;
|
||||
namespace ASC.ElasticSearch.Service
|
||||
{
|
||||
[Singletone]
|
||||
public class SettingsHelper
|
||||
{
|
||||
public Settings Settings { get; set; }
|
||||
public SettingsHelper(ConfigurationExtension configuration)
|
||||
{
|
||||
var cfg = configuration.GetSetting<Settings>("elastic");
|
||||
|
||||
Settings = new Settings
|
||||
{
|
||||
Scheme = cfg.Scheme ?? "http",
|
||||
Host = cfg.Host ?? "localhost",
|
||||
Port = cfg.Port ?? 9200,
|
||||
Period = cfg.Period ?? 1,
|
||||
MaxContentLength = cfg.MaxContentLength ?? 100 * 1024 * 1024L,
|
||||
MaxFileSize = cfg.MaxFileSize ?? 10 * 1024 * 1024L,
|
||||
Threads = cfg.Threads ?? 1,
|
||||
HttpCompression = cfg.HttpCompression ?? true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class Settings
|
||||
{
|
||||
public static Settings GetInstance(ConfigurationExtension configuration)
|
||||
{
|
||||
var result = new Settings();
|
||||
var cfg = configuration.GetSetting<Settings>("elastic");
|
||||
result.Scheme = cfg.Scheme ?? "http";
|
||||
result.Host = cfg.Host ?? "localhost";
|
||||
result.Port = cfg.Port ?? 9200;
|
||||
result.Period = cfg.Period ?? 1;
|
||||
result.MaxContentLength = cfg.MaxContentLength ?? 100 * 1024 * 1024L;
|
||||
result.MaxFileSize = cfg.MaxFileSize ?? 10 * 1024 * 1024L;
|
||||
result.Threads = cfg.Threads ?? 1;
|
||||
result.HttpCompression = cfg.HttpCompression ?? true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string Host { get; set; }
|
||||
|
||||
public int? Port { get; set; }
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
<extensions>
|
||||
<add assembly="NLog.Web.AspNetCore"/>
|
||||
<add assembly="ASC.Common"/>
|
||||
</extensions>
|
||||
|
||||
<variable name="dir" value="..\Logs\"/>
|
||||
@ -11,9 +10,9 @@
|
||||
<conversionPattern value=""/>
|
||||
|
||||
<targets async="true">
|
||||
<default-target-parameters type="SelfCleaning" encoding="utf-8" archiveNumbering="DateAndSequence" archiveEvery="Day" enableArchiveFileCompression="true" archiveAboveSize="52428800" keepFileOpen="true" archiveDateFormat="MM-dd" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}"/>
|
||||
<target name="web" type="SelfCleaning" fileName="${var:dir}${var:name}.log" />
|
||||
<target name="sql" type="SelfCleaning" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=elapsed}|${message}|${replace:inner=${event-properties:item=commandText}:searchFor=\\r\\n|\\s:replaceWith= :regex=true}|${event-properties:item=parameters}"/>
|
||||
<default-target-parameters type="File" encoding="utf-8" maxArchiveDays="30" archiveNumbering="DateAndSequence" archiveEvery="Day" enableArchiveFileCompression="true" archiveAboveSize="52428800" keepFileOpen="true" archiveDateFormat="MM-dd" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}"/>
|
||||
<target name="web" type="File" fileName="${var:dir}${var:name}.log" />
|
||||
<target name="sql" type="File" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=elapsed}|${message}|${replace:inner=${event-properties:item=commandText}:searchFor=\\r\\n|\\s:replaceWith= :regex=true}|${event-properties:item=parameters}"/>
|
||||
<target name="ownFile-web" type="File" fileName="${var:dir}${var:name}.asp.log" layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
|
||||
</targets>
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace ASC.Files.Core.Data
|
||||
CoreConfiguration coreConfiguration,
|
||||
SettingsManager settingsManager,
|
||||
AuthContext authContext,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache cache)
|
||||
{
|
||||
this.cache = cache;
|
||||
@ -128,7 +128,7 @@ namespace ASC.Files.Core.Data
|
||||
.Join(FilesDbContext.Tree, a => a.FolderId, b => b.FolderId, (file, tree) => new { file, tree })
|
||||
.Where(r => r.file.TenantId == f.TenantId)
|
||||
.Where(r => r.tree.ParentId == f.Id)
|
||||
.Select(r=> r.file.Id)
|
||||
.Select(r => r.file.Id)
|
||||
.Distinct()
|
||||
.Count();
|
||||
|
||||
@ -191,7 +191,7 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
internal static IQueryable<T> BuildSearch<T>(IQueryable<T> query, string text, SearhTypeEnum searhTypeEnum) where T : IDbSearch
|
||||
{
|
||||
var lowerText = text.ToLower().Trim().Replace("%", "\\%").Replace("_", "\\_");
|
||||
var lowerText = GetSearchText(text);
|
||||
|
||||
return searhTypeEnum switch
|
||||
{
|
||||
@ -200,7 +200,9 @@ namespace ASC.Files.Core.Data
|
||||
SearhTypeEnum.Any => query.Where(r => r.Title.ToLower().Contains(lowerText)),
|
||||
_ => query,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetSearchText(string text) => (text ?? "").ToLower().Trim().Replace("%", "\\%").Replace("_", "\\_");
|
||||
|
||||
internal enum SearhTypeEnum
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Common.Caching;
|
||||
using ASC.Common.Utils;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Common.EF;
|
||||
using ASC.Core.Common.EF.Context;
|
||||
@ -100,7 +99,7 @@ namespace ASC.Files.Core.Data
|
||||
ChunkedUploadSessionHolder chunkedUploadSessionHolder,
|
||||
ProviderFolderDao providerFolderDao,
|
||||
CrossDao crossDao,
|
||||
ConfigurationExtension configurationExtension)
|
||||
SettingsHelper settingsHelper)
|
||||
: base(
|
||||
dbContextManager,
|
||||
dbContextManager1,
|
||||
@ -126,7 +125,7 @@ namespace ASC.Files.Core.Data
|
||||
ChunkedUploadSessionHolder = chunkedUploadSessionHolder;
|
||||
ProviderFolderDao = providerFolderDao;
|
||||
CrossDao = crossDao;
|
||||
Settings = Settings.GetInstance(configurationExtension);
|
||||
Settings = settingsHelper.Settings;
|
||||
}
|
||||
|
||||
public void InvalidateCache(int fileId)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,6 @@ 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.EF.Model;
|
||||
using ASC.ElasticSearch;
|
||||
@ -60,11 +59,11 @@ namespace ASC.Web.Files.Core.Search
|
||||
IServiceProvider serviceProvider,
|
||||
IDaoFactory daoFactory,
|
||||
ICache cache,
|
||||
ConfigurationExtension configurationExtension)
|
||||
SettingsHelper settingsHelper)
|
||||
: base(options, tenantManager, searchSettingsHelper, factoryIndexer, baseIndexer, serviceProvider, cache)
|
||||
{
|
||||
DaoFactory = daoFactory;
|
||||
Settings = Settings.GetInstance(configurationExtension);
|
||||
Settings = settingsHelper.Settings;
|
||||
}
|
||||
|
||||
public override void IndexAll()
|
||||
|
@ -32,7 +32,6 @@ 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.EF.Model;
|
||||
using ASC.ElasticSearch;
|
||||
@ -61,11 +60,11 @@ namespace ASC.Web.Files.Core.Search
|
||||
IServiceProvider serviceProvider,
|
||||
IDaoFactory daoFactory,
|
||||
ICache cache,
|
||||
ConfigurationExtension configurationExtension)
|
||||
SettingsHelper settingsHelper)
|
||||
: base(options, tenantManager, searchSettingsHelper, factoryIndexer, baseIndexer, serviceProvider, cache)
|
||||
{
|
||||
DaoFactory = daoFactory;
|
||||
Settings = Settings.GetInstance(configurationExtension);
|
||||
Settings = settingsHelper.Settings;
|
||||
}
|
||||
|
||||
public override void IndexAll()
|
||||
|
@ -53,6 +53,7 @@ using ASC.Security.Cryptography;
|
||||
using ASC.Web.Files.Classes;
|
||||
using ASC.Web.Files.Helpers;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
@ -136,7 +137,7 @@ namespace ASC.Files.Thirdparty
|
||||
return FilesDbContext.ThirdpartyAccount
|
||||
.Where(r => r.TenantId == TenantID)
|
||||
.Where(r => r.UserId == userId)
|
||||
.ToList()
|
||||
.AsEnumerable()
|
||||
.Select(ToProviderInfo)
|
||||
.ToList();
|
||||
}
|
||||
@ -145,35 +146,25 @@ namespace ASC.Files.Thirdparty
|
||||
Logger.Error(string.Format("GetProvidersInfoInternal: user = {0}", userId), e);
|
||||
return new List<IProviderInfo>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Func<FilesDbContext, int, int, FolderType, Guid, string, IEnumerable<DbFilesThirdpartyAccount>> getProvidersInfoQuery =
|
||||
EF.CompileQuery((FilesDbContext ctx, int tenantId, int linkId, FolderType folderType, Guid userId, string searchText) =>
|
||||
ctx.ThirdpartyAccount
|
||||
.AsNoTracking()
|
||||
.Where(r => r.TenantId == tenantId)
|
||||
.Where(r => !(folderType == FolderType.USER || folderType == FolderType.DEFAULT && linkId == -1) || r.UserId == userId)
|
||||
.Where(r => linkId == -1 || r.Id == linkId)
|
||||
.Where(r => folderType == FolderType.DEFAULT || r.FolderType == folderType)
|
||||
.Where(r => searchText == "" || r.Title.ToLower().Contains(searchText))
|
||||
);
|
||||
|
||||
private List<IProviderInfo> GetProvidersInfoInternal(int linkId = -1, FolderType folderType = FolderType.DEFAULT, string searchText = null)
|
||||
{
|
||||
var querySelect = FilesDbContext.ThirdpartyAccount.Where(r => r.TenantId == TenantID);
|
||||
|
||||
if (folderType == FolderType.USER || folderType == FolderType.DEFAULT && linkId == -1)
|
||||
{
|
||||
querySelect = querySelect.Where(r => r.UserId == SecurityContext.CurrentAccount.ID);
|
||||
}
|
||||
|
||||
if (linkId != -1)
|
||||
{
|
||||
querySelect = querySelect.Where(r => r.Id == linkId);
|
||||
}
|
||||
|
||||
if (folderType != FolderType.DEFAULT)
|
||||
{
|
||||
querySelect = querySelect.Where(r => r.FolderType == folderType);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
{
|
||||
querySelect = BuildSearch(querySelect, searchText, SearhTypeEnum.Any);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return querySelect.ToList()
|
||||
return getProvidersInfoQuery(FilesDbContext, TenantID, linkId, folderType, SecurityContext.CurrentAccount.ID, GetSearchText(searchText))
|
||||
.AsEnumerable()
|
||||
.Select(ToProviderInfo)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -46,7 +46,20 @@ namespace ASC.Files.Thirdparty.ProviderDao
|
||||
{
|
||||
internal class ProviderDaoBase : ThirdPartyProviderDao, IDisposable
|
||||
{
|
||||
private readonly List<IDaoSelector> Selectors;
|
||||
private List<IDaoSelector> selectors;
|
||||
private List<IDaoSelector> Selectors
|
||||
{
|
||||
get => selectors ??= new List<IDaoSelector>
|
||||
{
|
||||
//Fill in selectors
|
||||
ServiceProvider.GetService<SharpBoxDaoSelector>(),
|
||||
ServiceProvider.GetService<SharePointDaoSelector>(),
|
||||
ServiceProvider.GetService<GoogleDriveDaoSelector>(),
|
||||
ServiceProvider.GetService<BoxDaoSelector>(),
|
||||
ServiceProvider.GetService<DropboxDaoSelector>(),
|
||||
ServiceProvider.GetService<OneDriveDaoSelector>()
|
||||
};
|
||||
}
|
||||
|
||||
private int tenantID;
|
||||
private int TenantID { get => tenantID != 0 ? tenantID : (tenantID = TenantManager.GetCurrentTenant().TenantId); }
|
||||
@ -63,17 +76,6 @@ namespace ASC.Files.Thirdparty.ProviderDao
|
||||
SecurityDao = securityDao;
|
||||
TagDao = tagDao;
|
||||
CrossDao = crossDao;
|
||||
|
||||
Selectors = new List<IDaoSelector>
|
||||
{
|
||||
//Fill in selectors
|
||||
ServiceProvider.GetService<SharpBoxDaoSelector>(),
|
||||
ServiceProvider.GetService<SharePointDaoSelector>(),
|
||||
ServiceProvider.GetService<GoogleDriveDaoSelector>(),
|
||||
ServiceProvider.GetService<BoxDaoSelector>(),
|
||||
ServiceProvider.GetService<DropboxDaoSelector>(),
|
||||
ServiceProvider.GetService<OneDriveDaoSelector>()
|
||||
};
|
||||
}
|
||||
|
||||
protected IServiceProvider ServiceProvider { get; }
|
||||
@ -160,8 +162,11 @@ namespace ASC.Files.Thirdparty.ProviderDao
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Selectors.ForEach(r => r.Dispose());
|
||||
{
|
||||
if (selectors != null)
|
||||
{
|
||||
selectors.ForEach(r => r.Dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -40,9 +40,10 @@ namespace ASC.Files.Thirdparty
|
||||
{
|
||||
private IServiceProvider ServiceProvider { get; }
|
||||
private IDaoFactory DaoFactory { get; }
|
||||
public Regex Selector { get; set; }
|
||||
protected internal abstract string Name { get; }
|
||||
protected internal abstract string Id { get; }
|
||||
protected internal abstract string Id { get; }
|
||||
public Regex Selector { get => selector ??= new Regex(@"^" + Id + @"-(?'id'\d+)(-(?'path'.*)){0,1}$", RegexOptions.Singleline | RegexOptions.Compiled); }
|
||||
private Regex selector;
|
||||
|
||||
private Dictionary<string, ThirdPartyProviderDao<T>> Providers { get; set; }
|
||||
|
||||
@ -52,7 +53,6 @@ namespace ASC.Files.Thirdparty
|
||||
{
|
||||
ServiceProvider = serviceProvider;
|
||||
DaoFactory = daoFactory;
|
||||
Selector = new Regex(@"^" + Id + @"-(?'id'\d+)(-(?'path'.*)){0,1}$", RegexOptions.Singleline | RegexOptions.Compiled);
|
||||
Providers = new Dictionary<string, ThirdPartyProviderDao<T>>();
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,29 @@ using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
[Singletone]
|
||||
public class ThirdpartyConfigurationData
|
||||
{
|
||||
private IConfiguration Configuration { get; }
|
||||
|
||||
private List<string> thirdPartyProviders;
|
||||
public List<string> ThirdPartyProviders
|
||||
{
|
||||
get
|
||||
{
|
||||
return thirdPartyProviders ??= (Configuration.GetSection("files:thirdparty:enable").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
public ThirdpartyConfigurationData(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
}
|
||||
|
||||
[Scope(Additional = typeof(BaseLoginProviderExtension))]
|
||||
public class ThirdpartyConfiguration
|
||||
{
|
||||
private IConfiguration Configuration { get; }
|
||||
private ThirdpartyConfigurationData Configuration { get; }
|
||||
private Lazy<BoxLoginProvider> BoxLoginProvider { get; }
|
||||
private Lazy<DropboxLoginProvider> DropboxLoginProvider { get; }
|
||||
private Lazy<OneDriveLoginProvider> OneDriveLoginProvider { get; }
|
||||
@ -48,7 +67,7 @@ namespace ASC.Web.Files.Helpers
|
||||
private Lazy<GoogleLoginProvider> GoogleLoginProvider { get; }
|
||||
|
||||
public ThirdpartyConfiguration(
|
||||
IConfiguration configuration,
|
||||
ThirdpartyConfigurationData configuration,
|
||||
ConsumerFactory consumerFactory)
|
||||
{
|
||||
Configuration = configuration;
|
||||
@ -58,14 +77,10 @@ namespace ASC.Web.Files.Helpers
|
||||
DocuSignLoginProvider = new Lazy<DocuSignLoginProvider>(() => consumerFactory.Get<DocuSignLoginProvider>());
|
||||
GoogleLoginProvider = new Lazy<GoogleLoginProvider>(() => consumerFactory.Get<GoogleLoginProvider>());
|
||||
}
|
||||
|
||||
private IEnumerable<string> thirdPartyProviders;
|
||||
public IEnumerable<string> ThirdPartyProviders
|
||||
|
||||
public List<string> ThirdPartyProviders
|
||||
{
|
||||
get
|
||||
{
|
||||
return thirdPartyProviders ??= (Configuration.GetSection("files:thirdparty:enable").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
get => Configuration.ThirdPartyProviders;
|
||||
}
|
||||
|
||||
public bool SupportInclusion(IDaoFactory daoFactory)
|
||||
@ -80,7 +95,7 @@ namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ThirdPartyProviders.Contains("box") && BoxLoginProvider.Value.IsEnabled;
|
||||
return ThirdPartyProviders.Exists(r => r == "box") && BoxLoginProvider.Value.IsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +103,7 @@ namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ThirdPartyProviders.Contains("dropboxv2") && DropboxLoginProvider.Value.IsEnabled;
|
||||
return ThirdPartyProviders.Exists(r => r == "dropboxv2") && DropboxLoginProvider.Value.IsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,38 +111,38 @@ namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ThirdPartyProviders.Contains("onedrive") && OneDriveLoginProvider.Value.IsEnabled;
|
||||
return ThirdPartyProviders.Exists(r => r == "onedrive") && OneDriveLoginProvider.Value.IsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SupportSharePointInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("sharepoint"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "sharepoint"); }
|
||||
}
|
||||
|
||||
public bool SupportWebDavInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("webdav"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "webdav"); }
|
||||
}
|
||||
|
||||
public bool SupportNextcloudInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("nextcloud"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "nextcloud"); }
|
||||
}
|
||||
|
||||
public bool SupportOwncloudInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("owncloud"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "owncloud"); }
|
||||
}
|
||||
|
||||
public bool SupportkDriveInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("kdrive"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "kdrive"); }
|
||||
}
|
||||
|
||||
public bool SupportYandexInclusion
|
||||
{
|
||||
get { return ThirdPartyProviders.Contains("yandex"); }
|
||||
get { return ThirdPartyProviders.Exists(r => r == "yandex"); }
|
||||
}
|
||||
|
||||
public string DropboxAppKey
|
||||
@ -144,7 +159,7 @@ namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ThirdPartyProviders.Contains("docusign") && DocuSignLoginProvider.Value.IsEnabled;
|
||||
return ThirdPartyProviders.Exists(r => r == "docusign") && DocuSignLoginProvider.Value.IsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +167,7 @@ namespace ASC.Web.Files.Helpers
|
||||
{
|
||||
get
|
||||
{
|
||||
return ThirdPartyProviders.Contains("google") && GoogleLoginProvider.Value.IsEnabled;
|
||||
return ThirdPartyProviders.Exists(r => r == "google") && GoogleLoginProvider.Value.IsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,143 @@ using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace ASC.Web.Core.Files
|
||||
{
|
||||
[Singletone]
|
||||
public class FileUtilityConfiguration
|
||||
{
|
||||
private IConfiguration Configuration { get; }
|
||||
|
||||
public FileUtilityConfiguration(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
private List<string> extsIndexing;
|
||||
public List<string> ExtsIndexing { get => extsIndexing ??= (Configuration.GetSection("files:index").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
|
||||
private List<string> extsImagePreviewed;
|
||||
public List<string> ExtsImagePreviewed { get => extsImagePreviewed ??= (Configuration.GetSection("files:viewed-images").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
|
||||
private List<string> extsMediaPreviewed;
|
||||
public List<string> ExtsMediaPreviewed { get => extsMediaPreviewed ??= (Configuration.GetSection("files:viewed-media").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
|
||||
private List<string> extsWebPreviewed;
|
||||
public List<string> ExtsWebPreviewed
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebPreviewed ??= (Configuration.GetSection("files:docservice:viewed-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebEdited;
|
||||
public List<string> ExtsWebEdited
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebEdited ??= (Configuration.GetSection("files:docservice:edited-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebEncrypt;
|
||||
public List<string> ExtsWebEncrypt { get => extsWebEncrypt ??= (Configuration.GetSection("files:docservice:encrypted-docs").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
|
||||
private List<string> extsWebReviewed;
|
||||
public List<string> ExtsWebReviewed
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebReviewed ??= (Configuration.GetSection("files:docservice:reviewed-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebCustomFilterEditing;
|
||||
public List<string> ExtsWebCustomFilterEditing
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebCustomFilterEditing ??= (Configuration.GetSection("files:docservice:customfilter-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebRestrictedEditing;
|
||||
public List<string> ExtsWebRestrictedEditing
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebRestrictedEditing ??= (Configuration.GetSection("files:docservice:formfilling-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebCommented;
|
||||
public List<string> ExtsWebCommented
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebCommented ??= (Configuration.GetSection("files:docservice:commented-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebTemplate;
|
||||
public List<string> ExtsWebTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebTemplate ??= (Configuration.GetSection("files:docservice:template-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsMustConvert;
|
||||
public List<string> ExtsMustConvert
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsMustConvert ??= (Configuration.GetSection("files:docservice:convert-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsCoAuthoring;
|
||||
public List<string> ExtsCoAuthoring
|
||||
{
|
||||
get => extsCoAuthoring ??= (Configuration.GetSection("files:docservice:coauthor-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
|
||||
public Dictionary<FileType, string> InternalExtension
|
||||
{
|
||||
get => new Dictionary<FileType, string>
|
||||
{
|
||||
{ FileType.Document, Configuration["files:docservice:internal-doc"] ?? ".docx" },
|
||||
{ FileType.Spreadsheet, Configuration["files:docservice:internal-xls"] ?? ".xlsx" },
|
||||
{ FileType.Presentation, Configuration["files:docservice:internal-ppt"] ?? ".pptx" }
|
||||
};
|
||||
}
|
||||
|
||||
internal string GetSignatureSecret()
|
||||
{
|
||||
var result = Configuration["files:docservice:secret:value"] ?? "";
|
||||
|
||||
var regex = new Regex(@"^\s+$");
|
||||
|
||||
if (regex.IsMatch(result))
|
||||
result = "";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal string GetSignatureHeader()
|
||||
{
|
||||
var result = (Configuration["files:docservice:secret:header"] ?? "").Trim();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = "Authorization";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
internal bool GetCanForcesave()
|
||||
{
|
||||
return !bool.TryParse(Configuration["files:docservice:forcesave"] ?? "", out var canForcesave) || canForcesave;
|
||||
}
|
||||
}
|
||||
|
||||
[Scope]
|
||||
public class FileUtility
|
||||
{
|
||||
@ -45,11 +182,11 @@ namespace ASC.Web.Core.Files
|
||||
private FilesDbContext FilesDbContext { get => LazyFilesDbContext.Value; }
|
||||
|
||||
public FileUtility(
|
||||
IConfiguration configuration,
|
||||
FileUtilityConfiguration fileUtilityConfiguration,
|
||||
FilesLinkUtility filesLinkUtility,
|
||||
DbContextManager<FilesDbContext> dbContextManager)
|
||||
{
|
||||
Configuration = configuration;
|
||||
FileUtilityConfiguration = fileUtilityConfiguration;
|
||||
FilesLinkUtility = filesLinkUtility;
|
||||
LazyFilesDbContext = new Lazy<FilesDbContext>(() => dbContextManager.Get("files"));
|
||||
CanForcesave = GetCanForcesave();
|
||||
@ -117,52 +254,62 @@ namespace ASC.Web.Core.Files
|
||||
|
||||
public bool CanImageView(string fileName)
|
||||
{
|
||||
return ExtsImagePreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsImagePreviewed.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanMediaView(string fileName)
|
||||
{
|
||||
return ExtsMediaPreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsMediaPreviewed.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebView(string fileName)
|
||||
{
|
||||
return ExtsWebPreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebPreviewed.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebEdit(string fileName)
|
||||
{
|
||||
return ExtsWebEdited.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebEdited.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebReview(string fileName)
|
||||
{
|
||||
return ExtsWebReviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebReviewed.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebCustomFilterEditing(string fileName)
|
||||
{
|
||||
return ExtsWebCustomFilterEditing.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebCustomFilterEditing.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebRestrictedEditing(string fileName)
|
||||
{
|
||||
return ExtsWebRestrictedEditing.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebRestrictedEditing.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanWebComment(string fileName)
|
||||
{
|
||||
return ExtsWebCommented.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsWebCommented.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanCoAuhtoring(string fileName)
|
||||
{
|
||||
return ExtsCoAuthoring.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsCoAuthoring.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool CanIndex(string fileName)
|
||||
{
|
||||
return ExtsIndexing.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
||||
var ext = GetFileExtension(fileName);
|
||||
return ExtsIndexing.Exists(r => r.Equals(ext, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -219,16 +366,12 @@ namespace ASC.Web.Core.Files
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsIndexing;
|
||||
private List<string> ExtsIndexing { get => extsIndexing ??= (Configuration.GetSection("files:index").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
private List<string> ExtsIndexing { get => FileUtilityConfiguration.ExtsIndexing; }
|
||||
|
||||
private List<string> extsImagePreviewed;
|
||||
public List<string> ExtsImagePreviewed { get => extsImagePreviewed ??= (Configuration.GetSection("files:viewed-images").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
public List<string> ExtsImagePreviewed { get => FileUtilityConfiguration.ExtsImagePreviewed; }
|
||||
|
||||
private List<string> extsMediaPreviewed;
|
||||
public List<string> ExtsMediaPreviewed { get => extsMediaPreviewed ??= (Configuration.GetSection("files:viewed-media").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
public List<string> ExtsMediaPreviewed { get => FileUtilityConfiguration.ExtsMediaPreviewed; }
|
||||
|
||||
private List<string> extsWebPreviewed;
|
||||
public List<string> ExtsWebPreviewed
|
||||
{
|
||||
get
|
||||
@ -238,11 +381,10 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebPreviewed ??= (Configuration.GetSection("files:docservice:viewed-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebPreviewed;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebEdited;
|
||||
public List<string> ExtsWebEdited
|
||||
{
|
||||
get
|
||||
@ -252,14 +394,12 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebEdited ??= (Configuration.GetSection("files:docservice:edited-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebEdited;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebEncrypt;
|
||||
public List<string> ExtsWebEncrypt { get => extsWebEncrypt ??= (Configuration.GetSection("files:docservice:encrypted-docs").Get<string[]>() ?? new string[] { }).ToList(); }
|
||||
public List<string> ExtsWebEncrypt { get => FileUtilityConfiguration.ExtsWebEncrypt; }
|
||||
|
||||
private List<string> extsWebReviewed;
|
||||
public List<string> ExtsWebReviewed
|
||||
{
|
||||
get
|
||||
@ -269,11 +409,10 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebReviewed ??= (Configuration.GetSection("files:docservice:reviewed-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebReviewed;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebCustomFilterEditing;
|
||||
public List<string> ExtsWebCustomFilterEditing
|
||||
{
|
||||
get
|
||||
@ -283,11 +422,10 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebCustomFilterEditing ??= (Configuration.GetSection("files:docservice:customfilter-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebCustomFilterEditing;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebRestrictedEditing;
|
||||
public List<string> ExtsWebRestrictedEditing
|
||||
{
|
||||
get
|
||||
@ -297,11 +435,10 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebRestrictedEditing ??= (Configuration.GetSection("files:docservice:formfilling-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebRestrictedEditing;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebCommented;
|
||||
public List<string> ExtsWebCommented
|
||||
{
|
||||
get
|
||||
@ -311,20 +448,15 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsWebCommented ??= (Configuration.GetSection("files:docservice:commented-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsWebCommented;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsWebTemplate;
|
||||
public List<string> ExtsWebTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return extsWebTemplate ??= (Configuration.GetSection("files:docservice:template-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
}
|
||||
get => FileUtilityConfiguration.ExtsWebTemplate;
|
||||
}
|
||||
|
||||
private List<string> extsMustConvert;
|
||||
public List<string> ExtsMustConvert
|
||||
{
|
||||
get
|
||||
@ -334,17 +466,16 @@ namespace ASC.Web.Core.Files
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return extsMustConvert ??= (Configuration.GetSection("files:docservice:convert-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
return FileUtilityConfiguration.ExtsMustConvert;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> extsCoAuthoring;
|
||||
public List<string> ExtsCoAuthoring
|
||||
{
|
||||
get => extsCoAuthoring ??= (Configuration.GetSection("files:docservice:coauthor-docs").Get<string[]>() ?? new string[] { }).ToList();
|
||||
get => FileUtilityConfiguration.ExtsCoAuthoring;
|
||||
}
|
||||
|
||||
private IConfiguration Configuration { get; }
|
||||
private FileUtilityConfiguration FileUtilityConfiguration { get; }
|
||||
private FilesLinkUtility FilesLinkUtility { get; }
|
||||
|
||||
public static readonly List<string> ExtsArchive = new List<string>
|
||||
@ -419,15 +550,7 @@ namespace ASC.Web.Core.Files
|
||||
".xlt", ".xltm", ".xltx",
|
||||
".pot", ".potm", ".potx",
|
||||
};
|
||||
public Dictionary<FileType, string> InternalExtension
|
||||
{
|
||||
get => new Dictionary<FileType, string>
|
||||
{
|
||||
{ FileType.Document, Configuration["files:docservice:internal-doc"] ?? ".docx" },
|
||||
{ FileType.Spreadsheet, Configuration["files:docservice:internal-xls"] ?? ".xlsx" },
|
||||
{ FileType.Presentation, Configuration["files:docservice:internal-ppt"] ?? ".pptx" }
|
||||
};
|
||||
}
|
||||
public Dictionary<FileType, string> InternalExtension => FileUtilityConfiguration.InternalExtension;
|
||||
|
||||
public enum CsvDelimiter
|
||||
{
|
||||
@ -441,32 +564,13 @@ namespace ASC.Web.Core.Files
|
||||
public string SignatureSecret { get => GetSignatureSecret(); }
|
||||
public string SignatureHeader { get => GetSignatureHeader(); }
|
||||
|
||||
private string GetSignatureSecret()
|
||||
{
|
||||
var result = Configuration["files:docservice:secret:value"] ?? "";
|
||||
private string GetSignatureSecret() => FileUtilityConfiguration.GetSignatureSecret();
|
||||
|
||||
var regex = new Regex(@"^\s+$");
|
||||
|
||||
if (regex.IsMatch(result))
|
||||
result = "";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetSignatureHeader()
|
||||
{
|
||||
var result = (Configuration["files:docservice:secret:header"] ?? "").Trim();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = "Authorization";
|
||||
return result;
|
||||
}
|
||||
private string GetSignatureHeader() => FileUtilityConfiguration.GetSignatureHeader();
|
||||
|
||||
public readonly bool CanForcesave;
|
||||
|
||||
private bool GetCanForcesave()
|
||||
{
|
||||
return !bool.TryParse(Configuration["files:docservice:forcesave"] ?? "", out var canForcesave) || canForcesave;
|
||||
}
|
||||
private bool GetCanForcesave() => FileUtilityConfiguration.GetCanForcesave();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user