2020-09-18 17:57:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2020-09-23 10:55:39 +00:00
|
|
|
|
using ASC.Common;
|
2020-09-18 17:57:51 +00:00
|
|
|
|
using ASC.Common.Caching;
|
|
|
|
|
|
|
|
|
|
namespace ASC.Data.Storage.Encryption
|
|
|
|
|
{
|
2020-10-19 15:53:15 +00:00
|
|
|
|
[Singletone]
|
2020-09-18 17:57:51 +00:00
|
|
|
|
public class EncryptionServiceNotifier
|
|
|
|
|
{
|
|
|
|
|
private ICacheNotify<ProgressEncryption> СacheBackupProgress { get; }
|
|
|
|
|
private ICache Cache { get; }
|
|
|
|
|
|
|
|
|
|
public EncryptionServiceNotifier(ICacheNotify<ProgressEncryption> сacheBackupProgress)
|
|
|
|
|
{
|
|
|
|
|
Cache = AscCache.Memory;
|
|
|
|
|
СacheBackupProgress = сacheBackupProgress;
|
|
|
|
|
|
|
|
|
|
СacheBackupProgress.Subscribe((a) =>
|
|
|
|
|
{
|
|
|
|
|
Cache.Insert(GetCacheKey(a.TenantId), a, DateTime.UtcNow.AddDays(1));
|
|
|
|
|
},
|
|
|
|
|
CacheNotifyAction.InsertOrUpdate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProgressEncryption GetEncryptionProgress(int tenantId)
|
|
|
|
|
{
|
|
|
|
|
return Cache.Get<ProgressEncryption>(GetCacheKey(tenantId));
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 14:47:42 +00:00
|
|
|
|
private string GetCacheKey(int tenantId)
|
|
|
|
|
{
|
|
|
|
|
return $"encryption{tenantId}";
|
|
|
|
|
}
|
2020-09-18 17:57:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|