Skip to content

Commit

Permalink
Merge branch 'feature/accessRightSelect' of github.com:ONLYOFFICE/App…
Browse files Browse the repository at this point in the history
…Server into feature/accessRightSelect
  • Loading branch information
Yaroslavna-Gaivoronyuk committed Jan 27, 2022
2 parents ee37530 + 4355430 commit bb6c826
Show file tree
Hide file tree
Showing 1,643 changed files with 14,241 additions and 13,570 deletions.
2 changes: 1 addition & 1 deletion common/ASC.Common/Caching/KafkaCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void action()

private string GetChannelName(CacheNotifyAction cacheNotifyAction)
{
return $"asc:channel:{cacheNotifyAction}:{typeof(T).FullName}".ToLower();
return $"ascchannel{cacheNotifyAction}{typeof(T).FullName}".ToLower();
}

public void Unsubscribe(CacheNotifyAction action)
Expand Down
10 changes: 7 additions & 3 deletions common/ASC.Common/Utils/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public IEnumerable<T> GetSettings<T>(string section) where T : new()
}

public T GetSetting<T>(string section) where T : new()
{
return GetSetting(section, new T());
}

public T GetSetting<T>(string section, T instance)
{
var sectionSettings = Configuration.GetSection(section);

var cs = new T();
sectionSettings.Bind(cs);
sectionSettings.Bind(instance);

return cs;
return instance;
}

public ConnectionStringCollection GetConnectionStrings()
Expand Down
2 changes: 2 additions & 0 deletions common/ASC.Core.Common/EF/Context/AuditTrailContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class PostgreSqlAuditTrailContext : AuditTrailContext { }
public class AuditTrailContext : BaseDbContext
{
public DbSet<AuditEvent> AuditEvents { get; set; }
public DbSet<User> Users { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddAuditEvent()
.AddUser()
.AddDbFunction();
}

Expand Down
2 changes: 2 additions & 0 deletions common/ASC.Core.Common/EF/Context/MessagesContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class PostgreSqlMessagesContext : MessagesContext { }
public class MessagesContext : BaseDbContext
{
public DbSet<LoginEvents> LoginEvents { get; set; }
public DbSet<User> Users { get; set; }

protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
Expand All @@ -31,6 +32,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddLoginEvents()
.AddUser()
.AddDbFunction();
}
}
Expand Down
5 changes: 2 additions & 3 deletions common/ASC.Data.Backup.Core/EF/BackupsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BackupsContext : BaseDbContext
{
public DbSet<BackupRecord> Backups { get; set; }
public DbSet<BackupSchedule> Schedules { get; set; }

public DbSet<DbTenant> Tenants { get; set; }
public BackupsContext() { }
public BackupsContext(DbContextOptions<BackupsContext> options)
: base(options)
Expand All @@ -23,8 +23,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddDbTenant()
.AddDbTariff();
.AddDbTenant();
}
}

Expand Down
53 changes: 26 additions & 27 deletions common/ASC.Data.Backup.Core/Storage/BackupRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,80 +34,79 @@
using ASC.Core.Tenants;
using ASC.Data.Backup.EF.Context;
using ASC.Data.Backup.EF.Model;

using Microsoft.EntityFrameworkCore;

namespace ASC.Data.Backup.Storage
{
[Scope]
public class BackupRepository : IBackupRepository
{
private Lazy<BackupsContext> LazyBackupsContext { get; }
private BackupsContext BackupContext { get => LazyBackupsContext.Value; }
private Lazy<TenantDbContext> LazyTenantDbContext { get; }
private TenantDbContext TenantDbContext { get => LazyTenantDbContext.Value; }

public BackupRepository(DbContextManager<BackupsContext> backupContext, DbContextManager<TenantDbContext> tenantDbContext)
{
LazyBackupsContext = new Lazy<BackupsContext>(() => backupContext.Value);
LazyTenantDbContext = new Lazy<TenantDbContext>(() => tenantDbContext.Value);
private readonly Lazy<BackupsContext> _backupContext;
public BackupRepository(DbContextManager<BackupsContext> dbContactManager)
{
_backupContext = new Lazy<BackupsContext>(() => dbContactManager.Value);
}

public void SaveBackupRecord(BackupRecord backup)
{
BackupContext.AddOrUpdate(r => r.Backups, backup);
BackupContext.SaveChanges();
_backupContext.Value.AddOrUpdate(r => r.Backups, backup);
_backupContext.Value.SaveChanges();
}

public BackupRecord GetBackupRecord(Guid id)
{
return BackupContext.Backups.SingleOrDefault(b => b.Id == id);
return _backupContext.Value.Backups.Find(id);
}

public BackupRecord GetBackupRecord(string hash, int tenant)
{
return BackupContext.Backups.SingleOrDefault(b => b.Hash == hash && b.TenantId == tenant);
return _backupContext.Value.Backups.AsNoTracking().SingleOrDefault(b => b.Hash == hash && b.TenantId == tenant);
}

public List<BackupRecord> GetExpiredBackupRecords()
{
return BackupContext.Backups.Where(b => b.ExpiresOn != DateTime.MinValue && b.ExpiresOn <= DateTime.UtcNow).ToList();
return _backupContext.Value.Backups.AsNoTracking().Where(b => b.ExpiresOn != DateTime.MinValue && b.ExpiresOn <= DateTime.UtcNow).ToList();
}

public List<BackupRecord> GetScheduledBackupRecords()
{
return BackupContext.Backups.Where(b => b.IsScheduled == true).ToList();
return _backupContext.Value.Backups.AsNoTracking().Where(b => b.IsScheduled == true).ToList();
}

public List<BackupRecord> GetBackupRecordsByTenantId(int tenantId)
{
return BackupContext.Backups.Where(b => b.TenantId == tenantId).ToList();
return _backupContext.Value.Backups.AsNoTracking().Where(b => b.TenantId == tenantId).ToList();
}

public void DeleteBackupRecord(Guid id)
{

var backup = BackupContext.Backups.FirstOrDefault(b => b.Id == id);
var backup = _backupContext.Value.Backups.Find(id);

if (backup != null)
{
BackupContext.Backups.Remove(backup);
BackupContext.SaveChanges();
_backupContext.Value.Backups.Remove(backup);
_backupContext.Value.SaveChanges();
}
}

public void SaveBackupSchedule(BackupSchedule schedule)
{
BackupContext.AddOrUpdate(r => r.Schedules, schedule);
BackupContext.SaveChanges();
_backupContext.Value.AddOrUpdate(r => r.Schedules, schedule);
_backupContext.Value.SaveChanges();
}

public void DeleteBackupSchedule(int tenantId)
{
var shedule = BackupContext.Schedules.Where(s => s.TenantId == tenantId).ToList();
BackupContext.Schedules.RemoveRange(shedule);
BackupContext.SaveChanges();
var shedule = _backupContext.Value.Schedules.Where(s => s.TenantId == tenantId).ToList();

_backupContext.Value.Schedules.RemoveRange(shedule);
_backupContext.Value.SaveChanges();
}

public List<BackupSchedule> GetBackupSchedules()
{
var query = BackupContext.Schedules.Join(TenantDbContext.Tenants,
var query = _backupContext.Value.Schedules.Join(_backupContext.Value.Tenants,
s => s.TenantId,
t => t.Id,
(s, t) => new { schedule = s, tenant = t })
Expand All @@ -119,7 +118,7 @@ public List<BackupSchedule> GetBackupSchedules()

public BackupSchedule GetBackupSchedule(int tenantId)
{
return BackupContext.Schedules.SingleOrDefault(s => s.TenantId == tenantId);
return _backupContext.Value.Schedules.AsNoTracking().SingleOrDefault(s => s.TenantId == tenantId);
}
}
}
3 changes: 2 additions & 1 deletion common/ASC.FederatedLogin/Helpers/RequestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

namespace ASC.FederatedLogin.Helpers
Expand Down Expand Up @@ -59,7 +60,7 @@ public static string PerformRequest(string uri, string contentType = "", string
request.Content = new ByteArrayContent(bytes, 0, bytes.Length);
if (!string.IsNullOrEmpty(contentType))
{
request.Headers.Add("Content-Type", contentType);
request.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>

<Configurations>Debug;Release;SORT</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend.Translations.Tests", "Frontend.Translations.Tests.csproj", "{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frontend.Translations.Tests", "Frontend.Translations.Tests.csproj", "{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
SORT|Any CPU = SORT|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.Release|Any CPU.Build.0 = Release|Any CPU
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.SORT|Any CPU.ActiveCfg = SORT|Any CPU
{FFE0FBAD-0966-4B98-BCFF-7EA864ED8D67}.SORT|Any CPU.Build.0 = SORT|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit bb6c826

Please sign in to comment.