Merge branch 'develop' into feature/catalog
This commit is contained in:
commit
31a8b00313
@ -169,7 +169,7 @@ namespace ASC.Common.Caching
|
||||
|
||||
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)
|
||||
|
@ -14,12 +14,14 @@ namespace ASC.Core.Common.EF.Context
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace ASC.Core.Common.EF.Context
|
||||
public class MessagesContext : BaseDbContext
|
||||
{
|
||||
public DbSet<LoginEvents> LoginEvents { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
||||
{
|
||||
@ -31,6 +32,7 @@ namespace ASC.Core.Common.EF.Context
|
||||
ModelBuilderWrapper
|
||||
.From(modelBuilder, Provider)
|
||||
.AddLoginEvents()
|
||||
.AddUser()
|
||||
.AddDbFunction();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace ASC.Data.Backup.EF.Context
|
||||
{
|
||||
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)
|
||||
@ -23,8 +23,7 @@ namespace ASC.Data.Backup.EF.Context
|
||||
{
|
||||
ModelBuilderWrapper
|
||||
.From(modelBuilder, Provider)
|
||||
.AddDbTenant()
|
||||
.AddDbTariff();
|
||||
.AddDbTenant();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,80 +34,79 @@ using ASC.Core.Common.EF.Context;
|
||||
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 })
|
||||
@ -119,7 +118,7 @@ namespace ASC.Data.Backup.Storage
|
||||
|
||||
public BackupSchedule GetBackupSchedule(int tenantId)
|
||||
{
|
||||
return BackupContext.Schedules.SingleOrDefault(s => s.TenantId == tenantId);
|
||||
return _backupContext.Value.Schedules.AsNoTracking().SingleOrDefault(s => s.TenantId == tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.FederatedLogin.Helpers
|
||||
@ -59,7 +60,7 @@ namespace ASC.FederatedLogin.Helpers
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,17 +45,14 @@ namespace ASC.AuditTrail
|
||||
private MessageTarget MessageTarget { get; set; }
|
||||
private UserFormatter UserFormatter { get; set; }
|
||||
private Lazy<AuditTrailContext> LazyAuditTrailContext { get; }
|
||||
private Lazy<UserDbContext> LazyUserDbContext { get; }
|
||||
private AuditTrailContext AuditTrailContext { get => LazyAuditTrailContext.Value; }
|
||||
private UserDbContext UserDbContext { get => LazyUserDbContext.Value; }
|
||||
private AuditActionMapper AuditActionMapper { get; }
|
||||
|
||||
public AuditEventsRepository(MessageTarget messageTarget, UserFormatter userFormatter, DbContextManager<AuditTrailContext> dbContextManager, AuditActionMapper auditActionMapper, DbContextManager<UserDbContext> DbContextManager)
|
||||
public AuditEventsRepository(MessageTarget messageTarget, UserFormatter userFormatter, DbContextManager<AuditTrailContext> dbContextManager, AuditActionMapper auditActionMapper)
|
||||
{
|
||||
MessageTarget = messageTarget;
|
||||
UserFormatter = userFormatter;
|
||||
LazyAuditTrailContext = new Lazy<AuditTrailContext>(() => dbContextManager.Value );
|
||||
LazyUserDbContext = new Lazy<UserDbContext>(() => DbContextManager.Value);
|
||||
AuditActionMapper = auditActionMapper;
|
||||
}
|
||||
|
||||
@ -79,7 +76,7 @@ namespace ASC.AuditTrail
|
||||
{
|
||||
var query =
|
||||
from q in AuditTrailContext.AuditEvents
|
||||
from p in UserDbContext.Users.Where(p => q.UserId == p.Id).DefaultIfEmpty()
|
||||
from p in AuditTrailContext.Users.Where(p => q.UserId == p.Id).DefaultIfEmpty()
|
||||
where q.TenantId == tenant
|
||||
orderby q.Date descending
|
||||
select new Query { AuditEvent = q, User = p };
|
||||
|
@ -44,19 +44,13 @@ namespace ASC.AuditTrail.Data
|
||||
public class LoginEventsRepository
|
||||
{
|
||||
private UserFormatter UserFormatter { get; }
|
||||
private Lazy<AuditTrailContext> LazyAuditTrailContext { get; }
|
||||
private AuditTrailContext AuditTrailContext { get => LazyAuditTrailContext.Value; }
|
||||
private AuditActionMapper AuditActionMapper { get; }
|
||||
private UserDbContext UserDbContext { get => LazyUserDbContext.Value; }
|
||||
private Lazy<UserDbContext> LazyUserDbContext { get; }
|
||||
private MessagesContext MessagesContext { get => LazyMessagesContext.Value; }
|
||||
private Lazy<MessagesContext> LazyMessagesContext { get; }
|
||||
|
||||
public LoginEventsRepository(UserFormatter userFormatter, DbContextManager<AuditTrailContext> dbContextManager, AuditActionMapper auditActionMapper, DbContextManager<UserDbContext> DbContextManager, DbContextManager<MessagesContext> dbMessagesContext)
|
||||
public LoginEventsRepository(UserFormatter userFormatter, AuditActionMapper auditActionMapper, DbContextManager<MessagesContext> dbMessagesContext)
|
||||
{
|
||||
UserFormatter = userFormatter;
|
||||
LazyAuditTrailContext = new Lazy<AuditTrailContext>(() => dbContextManager.Value);
|
||||
LazyUserDbContext = new Lazy<UserDbContext>(() => DbContextManager.Value);
|
||||
AuditActionMapper = auditActionMapper;
|
||||
LazyMessagesContext = new Lazy<MessagesContext>(() => dbMessagesContext.Value);
|
||||
}
|
||||
@ -71,7 +65,7 @@ namespace ASC.AuditTrail.Data
|
||||
{
|
||||
var query =
|
||||
(from b in MessagesContext.LoginEvents
|
||||
from p in UserDbContext.Users.Where(p => b.UserId == p.Id).DefaultIfEmpty()
|
||||
from p in MessagesContext.Users.Where(p => b.UserId == p.Id).DefaultIfEmpty()
|
||||
where b.TenantId == tenant
|
||||
orderby b.Date descending
|
||||
select new Query { LoginEvents = b, User = p })
|
||||
@ -84,7 +78,7 @@ namespace ASC.AuditTrail.Data
|
||||
{
|
||||
var query =
|
||||
from q in MessagesContext.LoginEvents
|
||||
from p in UserDbContext.Users.Where(p => q.UserId == p.Id).DefaultIfEmpty()
|
||||
from p in MessagesContext.Users.Where(p => q.UserId == p.Id).DefaultIfEmpty()
|
||||
where q.TenantId == tenant
|
||||
where q.Date >= fromDate
|
||||
where q.Date <= to
|
||||
|
@ -1,7 +1,15 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
using Microsoft.Extensions.Hosting.WindowsServices;
|
||||
|
||||
var options = new WebApplicationOptions
|
||||
{
|
||||
Args = args,
|
||||
ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
|
||||
};
|
||||
|
||||
var builder = WebApplication.CreateBuilder(options);
|
||||
|
||||
builder.Host.UseSystemd();
|
||||
builder.Host.UseWindowsService();
|
||||
builder.Host.UseSystemd();
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
|
||||
builder.WebHost.ConfigureKestrel((hostingContext, serverOptions) =>
|
||||
|
@ -50,8 +50,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
private Lazy<CrmDbContext> LazyCrmDbContext { get; }
|
||||
public CrmDbContext CrmDbContext { get => LazyCrmDbContext.Value; }
|
||||
private Lazy<TenantDbContext> LazyTenantDbContext { get; }
|
||||
public TenantDbContext TenantDbContext { get => LazyTenantDbContext.Value; }
|
||||
protected readonly SecurityContext _securityContext;
|
||||
protected readonly ICache _cache;
|
||||
protected ILog _logger;
|
||||
@ -59,7 +57,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public AbstractDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
@ -73,7 +70,6 @@ namespace ASC.CRM.Core.Dao
|
||||
_cache = ascCache;
|
||||
|
||||
LazyCrmDbContext = new Lazy<CrmDbContext>(() => dbContextManager.Get(CrmConstants.DatabaseId));
|
||||
LazyTenantDbContext = new Lazy<TenantDbContext>(() => dbContextManager1.Get(CrmConstants.DatabaseId));
|
||||
TenantID = tenantManager.GetCurrentTenant().TenantId;
|
||||
_securityContext = securityContext;
|
||||
|
||||
|
@ -65,7 +65,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public CasesDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
CrmSecurity crmSecurity,
|
||||
@ -77,8 +76,7 @@ namespace ASC.CRM.Core.Dao
|
||||
BundleSearch bundleSearch,
|
||||
IMapper mapper
|
||||
) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
base(dbContextManager,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -67,7 +67,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public ContactDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
CrmSecurity crmSecurity,
|
||||
@ -83,7 +82,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -54,7 +54,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public ContactInfoDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
TenantUtil tenantUtil,
|
||||
@ -63,7 +62,6 @@ namespace ASC.CRM.Core.Dao
|
||||
FactoryIndexerContactInfo factoryIndexerContactInfo,
|
||||
IMapper mapper)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -46,14 +46,12 @@ namespace ASC.CRM.Core.Dao
|
||||
public class CurrencyInfoDao : AbstractDao
|
||||
{
|
||||
public CurrencyInfoDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -47,14 +47,12 @@ namespace ASC.CRM.Core.Dao
|
||||
{
|
||||
public CurrencyRateDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -58,7 +58,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public CustomFieldDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
TenantUtil tenantUtil,
|
||||
@ -68,7 +67,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -65,7 +65,6 @@ namespace ASC.CRM.Core.Dao
|
||||
private readonly AuthorizationManager _authorizationManager;
|
||||
|
||||
public DealDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
CrmSecurity crmSecurity,
|
||||
@ -78,7 +77,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper,
|
||||
BundleSearch bundleSearch) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -54,14 +54,12 @@ namespace ASC.CRM.Core.Dao
|
||||
{
|
||||
|
||||
public DealMilestoneDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -50,14 +50,12 @@ namespace ASC.CRM.Core.Dao
|
||||
private FilesIntegration _filesIntegration;
|
||||
public FileDao(FilesIntegration filesIntegration,
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -76,7 +76,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public InvoiceDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
FactoryIndexerInvoice factoryIndexer,
|
||||
@ -89,7 +88,6 @@ namespace ASC.CRM.Core.Dao
|
||||
TenantUtil tenantUtil,
|
||||
IMapper mapper)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -54,7 +54,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public InvoiceItemDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
CrmSecurity crmSecurity,
|
||||
@ -62,7 +61,6 @@ namespace ASC.CRM.Core.Dao
|
||||
ICache ascCache,
|
||||
IMapper mapper
|
||||
) : base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -51,14 +51,12 @@ namespace ASC.CRM.Core.Dao
|
||||
public class InvoiceLineDao : AbstractDao
|
||||
{
|
||||
public InvoiceLineDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -51,7 +51,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
public InvoiceTaxDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
@ -59,7 +58,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -53,14 +53,12 @@ namespace ASC.CRM.Core.Dao
|
||||
public ListItemDao(
|
||||
CrmSecurity crmSecurity,
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -62,7 +62,6 @@ namespace ASC.CRM.Core.Dao
|
||||
private readonly FactoryIndexerEvents _factoryIndexer;
|
||||
|
||||
public RelationshipEventDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
FilesIntegration filesIntegration,
|
||||
@ -74,7 +73,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -79,7 +79,6 @@ namespace ASC.CRM.Core.Dao
|
||||
#region Constructor
|
||||
|
||||
public ReportDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
FilesIntegration filesIntegration,
|
||||
@ -95,7 +94,6 @@ namespace ASC.CRM.Core.Dao
|
||||
DisplayUserSettingsHelper displayUserSettingsHelper,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -73,7 +73,6 @@ namespace ASC.CRM.Core.Dao
|
||||
|
||||
|
||||
public SearchDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
DaoFactory daoFactory,
|
||||
SecurityContext securityContext,
|
||||
@ -89,7 +88,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -50,13 +50,12 @@ namespace ASC.CRM.Core.Dao
|
||||
public class TagDao : AbstractDao
|
||||
{
|
||||
public TagDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache ascCache,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,dbContextManager1,
|
||||
base(dbContextManager,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -61,7 +61,6 @@ namespace ASC.CRM.Core.Dao
|
||||
private UserDbContext _userDbContext { get => LazyUserDbContext.Value; }
|
||||
|
||||
public TaskDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
CrmSecurity crmSecurity,
|
||||
@ -72,7 +71,6 @@ namespace ASC.CRM.Core.Dao
|
||||
DbContextManager<UserDbContext> userDbContext,
|
||||
IMapper mapper) :
|
||||
base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -49,7 +49,6 @@ namespace ASC.CRM.Core.Dao
|
||||
{
|
||||
public TaskTemplateContainerDao(
|
||||
DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
@ -57,7 +56,6 @@ namespace ASC.CRM.Core.Dao
|
||||
IMapper mapper
|
||||
)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
@ -123,14 +121,12 @@ namespace ASC.CRM.Core.Dao
|
||||
public class TaskTemplateDao : AbstractDao
|
||||
{
|
||||
public TaskTemplateDao(DbContextManager<CrmDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
SecurityContext securityContext,
|
||||
IOptionsMonitor<ILog> logger,
|
||||
ICache cache,
|
||||
IMapper mapper)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
tenantManager,
|
||||
securityContext,
|
||||
logger,
|
||||
|
@ -35,6 +35,7 @@ namespace ASC.CRM.Core.EF
|
||||
public virtual DbSet<DbTaskTemplateTask> TaskTemplateTask { get; set; }
|
||||
public virtual DbSet<DbVoipCalls> VoipCalls { get; set; }
|
||||
public virtual DbSet<DbVoipNumber> VoipNumber { get; set; }
|
||||
public virtual DbSet<DbTenant> Tenants { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -45,7 +46,8 @@ namespace ASC.CRM.Core.EF
|
||||
.AddDbCase()
|
||||
.AddDbRelationshipEvent()
|
||||
.AddDbDeal()
|
||||
.AddDbTask();
|
||||
.AddDbTask()
|
||||
.AddDbTenant();
|
||||
|
||||
modelBuilder.Entity<DbCurrencyInfo>(entity =>
|
||||
{
|
||||
|
@ -46,39 +46,48 @@ namespace ASC.Web.CRM.Classes
|
||||
[Scope]
|
||||
public class CurrencyProvider
|
||||
{
|
||||
private readonly ILog _log;
|
||||
private readonly ILog _logger;
|
||||
private readonly object _syncRoot = new object();
|
||||
private readonly Dictionary<String, CurrencyInfo> _currencies;
|
||||
private Dictionary<string, decimal> _exchangeRates;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly SettingsManager _settingsManager;
|
||||
private Dictionary<string, decimal> _exchangeRates;
|
||||
private DateTime _publisherDate;
|
||||
private const String _formatDate = "yyyy-MM-ddTHH:mm:ss.fffffffK";
|
||||
private Dictionary<String, CurrencyInfo> _currencies;
|
||||
private readonly DaoFactory _daoFactory;
|
||||
|
||||
public CurrencyProvider(IOptionsMonitor<ILog> logger,
|
||||
IConfiguration configuration,
|
||||
SettingsManager settingsManager,
|
||||
DaoFactory daoFactory)
|
||||
IConfiguration configuration,
|
||||
DaoFactory daoFactory,
|
||||
SettingsManager settingsManager)
|
||||
{
|
||||
_log = logger.Get("ASC");
|
||||
Configuration = configuration;
|
||||
SettingsManager = settingsManager;
|
||||
|
||||
var daocur = daoFactory.GetCurrencyInfoDao();
|
||||
var currencies = daocur.GetAll();
|
||||
|
||||
if (currencies == null || currencies.Count == 0)
|
||||
{
|
||||
currencies = new List<CurrencyInfo>
|
||||
{
|
||||
new CurrencyInfo("Currency_UnitedStatesDollar", "USD", "$", "US", true, true)
|
||||
};
|
||||
}
|
||||
|
||||
_currencies = currencies.ToDictionary(c => c.Abbreviation);
|
||||
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
public SettingsManager SettingsManager { get; }
|
||||
_logger = logger.Get("ASC");
|
||||
_daoFactory = daoFactory;
|
||||
_configuration = configuration;
|
||||
_settingsManager = settingsManager;
|
||||
}
|
||||
|
||||
public Dictionary<String, CurrencyInfo> Currencies
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_currencies != null) return _currencies;
|
||||
|
||||
var currencies = _daoFactory.GetCurrencyInfoDao().GetAll();
|
||||
|
||||
if (currencies == null || currencies.Count == 0)
|
||||
{
|
||||
currencies = new List<CurrencyInfo>
|
||||
{
|
||||
new CurrencyInfo("Currency_UnitedStatesDollar", "USD", "$", "US", true, true)
|
||||
};
|
||||
}
|
||||
|
||||
_currencies = currencies.ToDictionary(c => c.Abbreviation);
|
||||
|
||||
return _currencies;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime GetPublisherDate
|
||||
{
|
||||
@ -91,31 +100,31 @@ namespace ASC.Web.CRM.Classes
|
||||
|
||||
public CurrencyInfo Get(string currencyAbbreviation)
|
||||
{
|
||||
if (!_currencies.ContainsKey(currencyAbbreviation))
|
||||
if (!Currencies.ContainsKey(currencyAbbreviation))
|
||||
return null;
|
||||
|
||||
return _currencies[currencyAbbreviation];
|
||||
return Currencies[currencyAbbreviation];
|
||||
}
|
||||
|
||||
public List<CurrencyInfo> GetAll()
|
||||
{
|
||||
return _currencies.Values.OrderBy(v => v.Abbreviation).ToList();
|
||||
return Currencies.Values.OrderBy(v => v.Abbreviation).ToList();
|
||||
}
|
||||
|
||||
public List<CurrencyInfo> GetBasic()
|
||||
{
|
||||
return _currencies.Values.Where(c => c.IsBasic).OrderBy(v => v.Abbreviation).ToList();
|
||||
return Currencies.Values.Where(c => c.IsBasic).OrderBy(v => v.Abbreviation).ToList();
|
||||
}
|
||||
|
||||
public List<CurrencyInfo> GetOther()
|
||||
{
|
||||
return _currencies.Values.Where(c => !c.IsBasic).OrderBy(v => v.Abbreviation).ToList();
|
||||
return Currencies.Values.Where(c => !c.IsBasic).OrderBy(v => v.Abbreviation).ToList();
|
||||
}
|
||||
|
||||
public Dictionary<CurrencyInfo, Decimal> MoneyConvert(CurrencyInfo baseCurrency)
|
||||
{
|
||||
if (baseCurrency == null) throw new ArgumentNullException("baseCurrency");
|
||||
if (!_currencies.ContainsKey(baseCurrency.Abbreviation)) throw new ArgumentOutOfRangeException("baseCurrency", "Not found.");
|
||||
if (!Currencies.ContainsKey(baseCurrency.Abbreviation)) throw new ArgumentOutOfRangeException("baseCurrency", "Not found.");
|
||||
|
||||
var result = new Dictionary<CurrencyInfo, Decimal>();
|
||||
var rates = GetExchangeRates();
|
||||
@ -142,12 +151,12 @@ namespace ASC.Web.CRM.Classes
|
||||
|
||||
public bool IsConvertable(String abbreviation)
|
||||
{
|
||||
var findedItem = _currencies.Keys.ToList().Find(item => String.Compare(abbreviation, item) == 0);
|
||||
var findedItem = Currencies.Keys.ToList().Find(item => String.Compare(abbreviation, item) == 0);
|
||||
|
||||
if (findedItem == null)
|
||||
throw new ArgumentException(abbreviation);
|
||||
|
||||
return _currencies[findedItem].IsConvertable;
|
||||
return Currencies[findedItem].IsConvertable;
|
||||
}
|
||||
|
||||
public Decimal MoneyConvert(decimal amount, string from, string to)
|
||||
@ -166,7 +175,7 @@ namespace ASC.Web.CRM.Classes
|
||||
public decimal MoneyConvertToDefaultCurrency(decimal amount, string from)
|
||||
{
|
||||
|
||||
var crmSettings = SettingsManager.Load<CrmSettings>();
|
||||
var crmSettings = _settingsManager.Load<CrmSettings>();
|
||||
var defaultCurrency = Get(crmSettings.DefaultCurrency);
|
||||
|
||||
return MoneyConvert(amount, from, defaultCurrency.Abbreviation);
|
||||
@ -202,10 +211,10 @@ namespace ASC.Web.CRM.Classes
|
||||
|
||||
|
||||
|
||||
var updateEnable = Configuration["crm:update:currency:info:enable"] != "false";
|
||||
var updateEnable = _configuration["crm:update:currency:info:enable"] != "false";
|
||||
var ratesUpdatedFlag = false;
|
||||
|
||||
foreach (var ci in _currencies.Values.Where(c => c.IsConvertable))
|
||||
foreach (var ci in Currencies.Values.Where(c => c.IsConvertable))
|
||||
{
|
||||
var filepath = Path.Combine(tmppath, ci.Abbreviation + ".html");
|
||||
|
||||
@ -242,7 +251,7 @@ namespace ASC.Web.CRM.Classes
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
_log.Error(error);
|
||||
_logger.Error(error);
|
||||
_publisherDate = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@ -297,7 +306,7 @@ namespace ASC.Web.CRM.Classes
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
_log.Error(err);
|
||||
_logger.Error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -311,7 +320,7 @@ namespace ASC.Web.CRM.Classes
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
_log.Error(err);
|
||||
_logger.Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +359,7 @@ namespace ASC.Web.CRM.Classes
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
_log.Error(error);
|
||||
_logger.Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
@ -205,9 +206,9 @@ namespace ASC.Calendar.BusinessObjects
|
||||
|
||||
public List<Calendar> LoadiCalStreamsForUser(Guid userId)
|
||||
{
|
||||
var calIds = CalendarDb.CalendarCalendars.Where(p =>
|
||||
p.Tenant == TenantManager.GetCurrentTenant().TenantId &&
|
||||
p.OwnerId == userId.ToString() &&
|
||||
var calIds = CalendarDb.CalendarCalendars.Where(p =>
|
||||
p.Tenant == TenantManager.GetCurrentTenant().TenantId &&
|
||||
p.OwnerId == userId.ToString() &&
|
||||
p.IcalUrl != null)
|
||||
.Select(s => s.Id).ToArray();
|
||||
var calendars = GetCalendarsByIds(calIds.ToArray());
|
||||
@ -256,31 +257,31 @@ namespace ASC.Calendar.BusinessObjects
|
||||
|
||||
return data.FirstOrDefault().calUsrTimeZone == null ? TimeZoneConverter.GetTimeZone(data.FirstOrDefault().calTimeZone) : TimeZoneConverter.GetTimeZone(data.FirstOrDefault().calUsrTimeZone);
|
||||
|
||||
}
|
||||
|
||||
public List<object[]> GetCalendarIdByCaldavGuid(string caldavGuid)
|
||||
{
|
||||
}
|
||||
|
||||
public List<object[]> GetCalendarIdByCaldavGuid(string caldavGuid)
|
||||
{
|
||||
var data = CalendarDb.CalendarCalendars
|
||||
.Where(p => p.CaldavGuid == caldavGuid)
|
||||
.Select(s => new object[]{
|
||||
.Select(s => new object[]{
|
||||
s.Id,
|
||||
s.OwnerId,
|
||||
s.Tenant
|
||||
}).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
public Event GetEventIdByUid(string uid, int calendarId)
|
||||
{
|
||||
}).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
public Event GetEventIdByUid(string uid, int calendarId)
|
||||
{
|
||||
var eventId = CalendarDb.CalendarEvents
|
||||
.Where(p =>
|
||||
.Where(p =>
|
||||
uid.Contains(p.Uid) &&
|
||||
p.CalendarId == calendarId
|
||||
)
|
||||
.Select(s => s.Id).FirstOrDefault();
|
||||
|
||||
return eventId == 0 ? null : GetEventById(eventId);
|
||||
}
|
||||
.Select(s => s.Id).FirstOrDefault();
|
||||
|
||||
return eventId == 0 ? null : GetEventById(eventId);
|
||||
}
|
||||
|
||||
public Event GetEventIdOnlyByUid(string uid)
|
||||
{
|
||||
@ -482,8 +483,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
{
|
||||
var dataCaldavGuid = CalendarDb.CalendarCalendars.Where(p => p.Id.ToString() == id).Select(s => s.CaldavGuid).FirstOrDefault();
|
||||
|
||||
return dataCaldavGuid;
|
||||
|
||||
return dataCaldavGuid;
|
||||
|
||||
}
|
||||
public Calendar UpdateCalendar(int calendarId, string name, string description, List<SharingOptions.PublicItem> publicItems, List<UserViewSettings> viewSettings)
|
||||
{
|
||||
@ -750,8 +751,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
{
|
||||
var dataCaldavGuid = CalendarDb.CalendarCalendars.Where(p => p.Id == calendarId).Select(s => s.CaldavGuid).ToArray();
|
||||
|
||||
if (dataCaldavGuid[0] != null)
|
||||
caldavGuid = Guid.Parse(dataCaldavGuid[0].ToString());
|
||||
if (dataCaldavGuid[0] != null)
|
||||
caldavGuid = Guid.Parse(dataCaldavGuid[0].ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -794,7 +795,7 @@ namespace ASC.Calendar.BusinessObjects
|
||||
|
||||
public void RemoveCaldavCalendar(string currentUserName, string email, string calDavGuid, Uri myUri, bool isShared = false)
|
||||
{
|
||||
var calDavServerUrl = myUri.Scheme + "://" + myUri.Host + "/caldav";
|
||||
var calDavServerUrl = myUri.Scheme + "://" + myUri.Host + "/caldav";
|
||||
var requestUrl = calDavServerUrl + "/" + HttpUtility.UrlEncode(currentUserName) + "/" + (isShared ? calDavGuid + "-shared" : calDavGuid);
|
||||
|
||||
try
|
||||
@ -805,8 +806,11 @@ namespace ASC.Calendar.BusinessObjects
|
||||
|
||||
var authorization = isShared ? GetSystemAuthorization() : GetUserAuthorization(email);
|
||||
|
||||
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(authorization)));
|
||||
request.Headers.Add("Content-Type", "text/xml; charset=utf-8");
|
||||
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(authorization)));
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/xml")
|
||||
{
|
||||
CharSet = Encoding.UTF8.WebName
|
||||
};
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
httpClient.Send(request);
|
||||
@ -818,8 +822,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
}
|
||||
public void RemoveExternalCalendarData(string calendarId)
|
||||
{
|
||||
using var tx = CalendarDb.Database.BeginTransaction();
|
||||
|
||||
using var tx = CalendarDb.Database.BeginTransaction();
|
||||
|
||||
var ccu = CalendarDb.CalendarCalendarUser.Where(r => r.ExtCalendarId == calendarId).SingleOrDefault();
|
||||
|
||||
if (ccu != null)
|
||||
@ -1021,20 +1025,20 @@ namespace ASC.Calendar.BusinessObjects
|
||||
var groups = UserManager.GetUserGroups(userId).Select(g => g.ID).ToList();
|
||||
groups.AddRange(UserManager.GetUserGroups(userId, Constants.SysGroupCategoryId).Select(g => g.ID));
|
||||
|
||||
var evIds = from events in CalendarDb.CalendarEvents
|
||||
join eventItem in CalendarDb.CalendarEventItem on events.Id equals eventItem.EventId
|
||||
where
|
||||
events.Tenant == tenantId &&
|
||||
(
|
||||
eventItem.ItemId == userId || (groups.Contains(eventItem.ItemId) && eventItem.IsGroup == 1) &&
|
||||
events.Tenant == tenantId &&
|
||||
((events.StartDate >= utcStartDate && events.StartDate <= utcEndDate && events.Rrule == "") || events.Rrule != "") &&
|
||||
events.OwnerId != userId &&
|
||||
!(from calEventUser in CalendarDb.CalendarEventUser
|
||||
where calEventUser.EventId == events.Id && calEventUser.UserId == userId && calEventUser.IsUnsubscribe == 1
|
||||
select calEventUser.EventId).Any()
|
||||
)
|
||||
select events.Id;
|
||||
var evIds = from events in CalendarDb.CalendarEvents
|
||||
join eventItem in CalendarDb.CalendarEventItem on events.Id equals eventItem.EventId
|
||||
where
|
||||
events.Tenant == tenantId &&
|
||||
(
|
||||
eventItem.ItemId == userId || (groups.Contains(eventItem.ItemId) && eventItem.IsGroup == 1) &&
|
||||
events.Tenant == tenantId &&
|
||||
((events.StartDate >= utcStartDate && events.StartDate <= utcEndDate && events.Rrule == "") || events.Rrule != "") &&
|
||||
events.OwnerId != userId &&
|
||||
!(from calEventUser in CalendarDb.CalendarEventUser
|
||||
where calEventUser.EventId == events.Id && calEventUser.UserId == userId && calEventUser.IsUnsubscribe == 1
|
||||
select calEventUser.EventId).Any()
|
||||
)
|
||||
select events.Id;
|
||||
return GetEventsByIds(evIds.ToArray(), userId, tenantId);
|
||||
}
|
||||
|
||||
@ -1058,8 +1062,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
)
|
||||
)
|
||||
)
|
||||
.Select(s => s.Id).ToList();
|
||||
|
||||
.Select(s => s.Id).ToList();
|
||||
|
||||
return GetEventsByIds(evIds.ToArray(), userId, tenantId);
|
||||
}
|
||||
|
||||
@ -1264,7 +1268,7 @@ namespace ASC.Calendar.BusinessObjects
|
||||
{
|
||||
CalendarDb.CalendarEventItem.Remove(cei);
|
||||
}
|
||||
else if(!userNoSubscibe)
|
||||
else if (!userNoSubscibe)
|
||||
{
|
||||
var newEventUser = new CalendarEventUser
|
||||
{
|
||||
@ -1453,8 +1457,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
}
|
||||
|
||||
CalendarDb.SaveChanges();
|
||||
tx.Commit();
|
||||
|
||||
tx.Commit();
|
||||
|
||||
return GetEventById(eventId);
|
||||
}
|
||||
|
||||
@ -1606,8 +1610,8 @@ namespace ASC.Calendar.BusinessObjects
|
||||
|
||||
CalendarDb.SaveChanges();
|
||||
tx.Commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string GetEventUid(string uid, string id = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(uid))
|
||||
|
@ -31,6 +31,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
@ -1030,7 +1031,10 @@ namespace ASC.Calendar.Controllers
|
||||
var request = new HttpRequestMessage();
|
||||
request.Method = HttpMethod.Get;
|
||||
request.RequestUri = new Uri(calUrl);
|
||||
request.Headers.Add("Content-Type", "text/xml; charset=utf-8");
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/xml")
|
||||
{
|
||||
CharSet = Encoding.UTF8.WebName
|
||||
};
|
||||
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(authorization)));
|
||||
|
||||
try
|
||||
@ -4188,8 +4192,11 @@ namespace ASC.Calendar.Controllers
|
||||
var _email = UserManager.GetUsers(ownerId).Email;
|
||||
var authorization = sharedPostfixIndex != -1 ? DataProvider.GetSystemAuthorization() : DataProvider.GetUserAuthorization(_email);
|
||||
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(authorization)));
|
||||
request.Headers.Add("Content-Type", "text/calendar; charset=utf-8");
|
||||
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/calendar")
|
||||
{
|
||||
CharSet = Encoding.UTF8.WebName
|
||||
};
|
||||
|
||||
Log.Info(String.Format("UpdateCalDavEvent eventURl: {0}", eventURl));
|
||||
|
||||
string ics = "";
|
||||
|
@ -51,10 +51,7 @@ namespace ASC.Files.Core.Data
|
||||
protected readonly ICache cache;
|
||||
|
||||
private Lazy<EF.FilesDbContext> LazyFilesDbContext { get; }
|
||||
public EF.FilesDbContext FilesDbContext { get => LazyFilesDbContext.Value; }
|
||||
private Lazy<TenantDbContext> LazyTenantDbContext { get; }
|
||||
public TenantDbContext TenantDbContext { get => LazyTenantDbContext.Value; }
|
||||
|
||||
public EF.FilesDbContext FilesDbContext { get => LazyFilesDbContext.Value; }
|
||||
private int tenantID;
|
||||
protected internal int TenantID { get => tenantID != 0 ? tenantID : (tenantID = TenantManager.GetCurrentTenant().TenantId); }
|
||||
protected UserManager UserManager { get; }
|
||||
@ -71,7 +68,6 @@ namespace ASC.Files.Core.Data
|
||||
|
||||
protected AbstractDao(
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
UserManager userManager,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
@ -87,7 +83,6 @@ namespace ASC.Files.Core.Data
|
||||
{
|
||||
this.cache = cache;
|
||||
LazyFilesDbContext = new Lazy<EF.FilesDbContext>(() => dbContextManager.Get(FileConstant.DatabaseId));
|
||||
LazyTenantDbContext = new Lazy<TenantDbContext>(() => dbContextManager1.Get(FileConstant.DatabaseId));
|
||||
UserManager = userManager;
|
||||
TenantManager = tenantManager;
|
||||
TenantUtil = tenantUtil;
|
||||
|
@ -79,7 +79,6 @@ namespace ASC.Files.Core.Data
|
||||
FactoryIndexerFile factoryIndexer,
|
||||
UserManager userManager,
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
SetupInfo setupInfo,
|
||||
@ -102,7 +101,6 @@ namespace ASC.Files.Core.Data
|
||||
Settings settings)
|
||||
: base(
|
||||
dbContextManager,
|
||||
dbContextManager1,
|
||||
userManager,
|
||||
tenantManager,
|
||||
tenantUtil,
|
||||
|
@ -78,7 +78,6 @@ namespace ASC.Files.Core.Data
|
||||
FactoryIndexerFolder factoryIndexer,
|
||||
UserManager userManager,
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
SetupInfo setupInfo,
|
||||
@ -96,7 +95,6 @@ namespace ASC.Files.Core.Data
|
||||
CrossDao crossDao)
|
||||
: base(
|
||||
dbContextManager,
|
||||
dbContextManager1,
|
||||
userManager,
|
||||
tenantManager,
|
||||
tenantUtil,
|
||||
|
@ -40,7 +40,6 @@ namespace ASC.Files.Core.Data
|
||||
public LinkDao(
|
||||
UserManager userManager,
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
SetupInfo setupInfo,
|
||||
@ -54,7 +53,6 @@ namespace ASC.Files.Core.Data
|
||||
ICache cache)
|
||||
: base(
|
||||
dbContextManager,
|
||||
dbContextManager1,
|
||||
userManager,
|
||||
tenantManager,
|
||||
tenantUtil,
|
||||
|
@ -49,7 +49,6 @@ namespace ASC.Files.Core.Data
|
||||
{
|
||||
public SecurityDao(UserManager userManager,
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
SetupInfo setupInfo,
|
||||
@ -62,7 +61,6 @@ namespace ASC.Files.Core.Data
|
||||
IServiceProvider serviceProvider,
|
||||
ICache cache)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
userManager,
|
||||
tenantManager,
|
||||
tenantUtil,
|
||||
|
@ -54,7 +54,6 @@ namespace ASC.Files.Core.Data
|
||||
public TagDao(
|
||||
UserManager userManager,
|
||||
DbContextManager<EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> dbContextManager1,
|
||||
TenantManager tenantManager,
|
||||
TenantUtil tenantUtil,
|
||||
SetupInfo setupInfo,
|
||||
@ -67,7 +66,6 @@ namespace ASC.Files.Core.Data
|
||||
IServiceProvider serviceProvider,
|
||||
ICache cache)
|
||||
: base(dbContextManager,
|
||||
dbContextManager1,
|
||||
userManager,
|
||||
tenantManager,
|
||||
tenantUtil,
|
||||
|
@ -22,8 +22,11 @@ namespace ASC.Files.Core.EF
|
||||
public DbSet<DbFilesTagLink> TagLink { get; set; }
|
||||
public DbSet<DbFilesTag> Tag { get; set; }
|
||||
public DbSet<DbFilesThirdpartyApp> ThirdpartyApp { get; set; }
|
||||
|
||||
public DbSet<DbFilesLink> FilesLink { get; set; }
|
||||
public DbSet<DbFilesLink> FilesLink { get; set; }
|
||||
public DbSet<DbTariff> Tariffs { get; set; }
|
||||
public DbSet<DbQuota> Quotas { get; set; }
|
||||
public DbSet<DbTenant> Tenants { get; set; }
|
||||
|
||||
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
||||
{
|
||||
get
|
||||
@ -48,7 +51,11 @@ namespace ASC.Files.Core.EF
|
||||
.AddDbFilesThirdpartyIdMapping()
|
||||
.AddDbFilesTagLink()
|
||||
.AddDbFilesTag()
|
||||
.AddDbDbFilesThirdpartyApp() .AddDbFilesLink();
|
||||
.AddDbDbFilesThirdpartyApp()
|
||||
.AddDbFilesLink()
|
||||
.AddDbTariff()
|
||||
.AddDbQuota()
|
||||
.AddDbTenant();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace ASC.Web.Files.Core.Search
|
||||
|
||||
IQueryable<FileTenant> GetBaseQuery(DateTime lastIndexed) => fileDao.FilesDbContext.Files
|
||||
.Where(r => r.ModifiedOn >= lastIndexed)
|
||||
.Join(fileDao.TenantDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FileTenant { DbFile = f, DbTenant = t })
|
||||
.Join(fileDao.FilesDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FileTenant { DbFile = f, DbTenant = t })
|
||||
.Where(r => r.DbTenant.Status == ASC.Core.Tenants.TenantStatus.Active);
|
||||
|
||||
try
|
||||
|
@ -128,7 +128,7 @@ namespace ASC.Web.Files.Core.Search
|
||||
|
||||
IQueryable<FolderTenant> GetBaseQuery(DateTime lastIndexed) => folderDao.FilesDbContext.Folders
|
||||
.Where(r => r.ModifiedOn >= lastIndexed)
|
||||
.Join(folderDao.TenantDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FolderTenant { DbFolder = f, DbTenant = t })
|
||||
.Join(folderDao.FilesDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FolderTenant { DbFolder = f, DbTenant = t })
|
||||
.Where(r => r.DbTenant.Status == ASC.Core.Tenants.TenantStatus.Active);
|
||||
|
||||
try
|
||||
|
@ -30,9 +30,10 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Core.Common.Configuration;
|
||||
using ASC.FederatedLogin;
|
||||
@ -261,8 +262,11 @@ namespace ASC.Files.Thirdparty.OneDrive
|
||||
var request = new HttpRequestMessage();
|
||||
request.RequestUri = uploadUriBuilder.Uri;
|
||||
request.Method = HttpMethod.Post;
|
||||
request.Headers.Add("Authorization", "Bearer " + AccessToken);
|
||||
request.Headers.Add("Content-Type", "application/json; charset=UTF-8");
|
||||
request.Headers.Add("Authorization", "Bearer " + AccessToken);
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json")
|
||||
{
|
||||
CharSet = Encoding.UTF8.WebName
|
||||
};
|
||||
|
||||
var uploadSession = new ResumableUploadSession(onedriveFile.Id, folderId, contentLength);
|
||||
|
||||
|
@ -30,6 +30,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -343,7 +344,7 @@ namespace ASC.Web.Files.ThirdPartyApp
|
||||
|
||||
request.Method = HttpMethod.Post;
|
||||
request.Headers.Add("Authorization", "Bearer " + token);
|
||||
request.Headers.Add("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data; boundary=" + boundary);
|
||||
Logger.Debug("BoxApp: save file totalSize - " + tmpStream.Length);
|
||||
|
||||
tmpStream.Seek(0, SeekOrigin.Begin);
|
||||
|
@ -30,6 +30,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -321,7 +322,7 @@ namespace ASC.Web.Files.ThirdPartyApp
|
||||
request.RequestUri = new Uri(GoogleLoginProvider.GoogleUrlFileUpload + "/{fileId}?uploadType=media".Replace("{fileId}", fileId));
|
||||
request.Method = HttpMethod.Patch;
|
||||
request.Headers.Add("Authorization", "Bearer " + token);
|
||||
request.Headers.Add("Content-Type", MimeMapping.GetMimeMapping(currentType));
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping(currentType));
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
@ -769,7 +770,7 @@ namespace ASC.Web.Files.ThirdPartyApp
|
||||
|
||||
request.Method = HttpMethod.Post;
|
||||
request.Headers.Add("Authorization", "Bearer " + token);
|
||||
request.Headers.Add("Content-Type", "multipart/related; boundary=" + boundary);
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/related; boundary=" + boundary);
|
||||
|
||||
Logger.Debug("GoogleDriveApp: create file totalSize - " + tmpStream.Length);
|
||||
|
||||
|
@ -28,10 +28,10 @@ using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Common.Web;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Common;
|
||||
using ASC.Web.Studio.Core;
|
||||
@ -137,7 +137,7 @@ namespace ASC.Web.Files.Utils
|
||||
request.RequestUri = new Uri(BaseCommonLinkUtility.GetFullAbsolutePath(apiUrlAttach));
|
||||
request.Method = HttpMethod.Post;
|
||||
request.Headers.Add("Authorization", SecurityContext.AuthenticateMe(SecurityContext.CurrentAccount.ID));
|
||||
request.Headers.Add("Content-Type", MimeMapping.GetMimeMapping(mailMergeTask.AttachTitle));
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue(mailMergeTask.AttachTitle);
|
||||
request.Content = new StreamContent(mailMergeTask.Attach);
|
||||
|
||||
// hack. http://ubuntuforums.org/showthread.php?t=1841740
|
||||
|
@ -38,25 +38,16 @@ namespace ASC.Files.ThumbnailBuilder
|
||||
private readonly ICache cache;
|
||||
private Lazy<Core.EF.FilesDbContext> LazyFilesDbContext { get; }
|
||||
private Core.EF.FilesDbContext filesDbContext { get => LazyFilesDbContext.Value; }
|
||||
private Lazy<TenantDbContext> LazyTenantDbContext { get; }
|
||||
private TenantDbContext TenantDbContext { get => LazyTenantDbContext.Value; }
|
||||
private Lazy<CoreDbContext> LazyCoreDbContext { get; }
|
||||
private CoreDbContext coreDbContext { get => LazyCoreDbContext.Value; }
|
||||
private readonly string cacheKey;
|
||||
|
||||
public FileDataProvider(
|
||||
ThumbnailSettings settings,
|
||||
ICache ascCache,
|
||||
DbContextManager<Core.EF.FilesDbContext> dbContextManager,
|
||||
DbContextManager<TenantDbContext> tenantdbContextManager,
|
||||
DbContextManager<CoreDbContext> coredbContextManager
|
||||
)
|
||||
DbContextManager<Core.EF.FilesDbContext> dbContextManager)
|
||||
{
|
||||
thumbnailSettings = settings;
|
||||
cache = ascCache;
|
||||
LazyFilesDbContext = new Lazy<Core.EF.FilesDbContext>(() => dbContextManager.Get(thumbnailSettings.ConnectionStringName));
|
||||
LazyTenantDbContext = new Lazy<TenantDbContext>(() => tenantdbContextManager.Get(thumbnailSettings.ConnectionStringName));
|
||||
LazyCoreDbContext = new Lazy<CoreDbContext>(() => coredbContextManager.Get(thumbnailSettings.ConnectionStringName));
|
||||
cacheKey = "PremiumTenants";
|
||||
}
|
||||
|
||||
@ -97,8 +88,8 @@ namespace ASC.Files.ThumbnailBuilder
|
||||
*/
|
||||
|
||||
var search =
|
||||
coreDbContext.Tariffs
|
||||
.Join(coreDbContext.Quotas.DefaultIfEmpty(), a => a.Tariff, b => b.Tenant, (tariff, quota) => new { tariff, quota })
|
||||
filesDbContext.Tariffs
|
||||
.Join(filesDbContext.Quotas.DefaultIfEmpty(), a => a.Tariff, b => b.Tenant, (tariff, quota) => new { tariff, quota })
|
||||
.Where(r =>
|
||||
(
|
||||
r.tariff.Comment == null ||
|
||||
@ -139,7 +130,7 @@ namespace ASC.Files.ThumbnailBuilder
|
||||
}
|
||||
|
||||
return search
|
||||
.Join(TenantDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FileTenant { DbFile = f, DbTenant = t })
|
||||
.Join(filesDbContext.Tenants, r => r.TenantId, r => r.Id, (f, t) => new FileTenant { DbFile = f, DbTenant = t })
|
||||
.Where(r => r.DbTenant.Status == TenantStatus.Active)
|
||||
.Select(r => new FileData<int>(r.DbFile.TenantId, r.DbFile.Id, ""))
|
||||
.ToList();
|
||||
|
@ -29,6 +29,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
@ -169,7 +170,7 @@ namespace ASC.Web.Core.Sms
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
request.RequestUri = new Uri(url);
|
||||
request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
httpClient.Timeout = TimeSpan.FromMilliseconds(15000);
|
||||
@ -263,7 +264,7 @@ namespace ASC.Web.Core.Sms
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
request.RequestUri = new Uri(url);
|
||||
request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
httpClient.Timeout = TimeSpan.FromMilliseconds(1000);
|
||||
|
Loading…
Reference in New Issue
Block a user