Files: used file-scoped namespaces
This commit is contained in:
parent
7a610d5ad2
commit
26fdc40f84
@ -23,43 +23,42 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem.DbSender
|
||||
namespace ASC.MessagingSystem.DbSender;
|
||||
|
||||
[Singletone]
|
||||
public class DbMessageSender : IMessageSender
|
||||
{
|
||||
[Singletone]
|
||||
public class DbMessageSender : IMessageSender
|
||||
private readonly ILog _logger;
|
||||
private readonly MessagesRepository _messagesRepository;
|
||||
private bool _messagingEnabled;
|
||||
|
||||
public DbMessageSender(IConfiguration configuration, MessagesRepository messagesRepository, IOptionsMonitor<ILog> options)
|
||||
{
|
||||
private readonly ILog _logger;
|
||||
private readonly MessagesRepository _messagesRepository;
|
||||
private bool _messagingEnabled;
|
||||
var setting = configuration["messaging:enabled"];
|
||||
_messagingEnabled = !string.IsNullOrEmpty(setting) && setting == "true";
|
||||
_messagesRepository = messagesRepository;
|
||||
_logger = options.Get("ASC.Messaging");
|
||||
}
|
||||
|
||||
public DbMessageSender(IConfiguration configuration, MessagesRepository messagesRepository, IOptionsMonitor<ILog> options)
|
||||
public void Send(EventMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
var setting = configuration["messaging:enabled"];
|
||||
_messagingEnabled = !string.IsNullOrEmpty(setting) && setting == "true";
|
||||
_messagesRepository = messagesRepository;
|
||||
_logger = options.Get("ASC.Messaging");
|
||||
if (!_messagingEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (message == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_messagesRepository.Add(message);
|
||||
}
|
||||
|
||||
public void Send(EventMessage message)
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_messagingEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (message == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_messagesRepository.Add(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error("Failed to send a message", ex);
|
||||
}
|
||||
_logger.Error("Failed to send a message", ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -26,247 +26,246 @@
|
||||
|
||||
using IsolationLevel = System.Data.IsolationLevel;
|
||||
|
||||
namespace ASC.MessagingSystem.DbSender
|
||||
namespace ASC.MessagingSystem.DbSender;
|
||||
|
||||
[Singletone(Additional = typeof(MessagesRepositoryExtension))]
|
||||
public class MessagesRepository : IDisposable
|
||||
{
|
||||
[Singletone(Additional = typeof(MessagesRepositoryExtension))]
|
||||
public class MessagesRepository : IDisposable
|
||||
private DateTime _lastSave = DateTime.UtcNow;
|
||||
private readonly TimeSpan _cacheTime;
|
||||
private readonly IDictionary<string, EventMessage> _cache;
|
||||
private Parser _parser;
|
||||
|
||||
private readonly Timer _timer;
|
||||
private bool _timerStarted;
|
||||
|
||||
public ILog Logger { get; set; }
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public MessagesRepository(IServiceProvider serviceProvider, IOptionsMonitor<ILog> options)
|
||||
{
|
||||
private DateTime _lastSave = DateTime.UtcNow;
|
||||
private readonly TimeSpan _cacheTime;
|
||||
private readonly IDictionary<string, EventMessage> _cache;
|
||||
private Parser _parser;
|
||||
_cacheTime = TimeSpan.FromMinutes(1);
|
||||
_cache = new Dictionary<string, EventMessage>();
|
||||
_timerStarted = false;
|
||||
|
||||
private readonly Timer _timer;
|
||||
private bool _timerStarted;
|
||||
Logger = options.CurrentValue;
|
||||
_serviceProvider = serviceProvider;
|
||||
|
||||
public ILog Logger { get; set; }
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
_timer = new Timer(FlushCache);
|
||||
}
|
||||
|
||||
public MessagesRepository(IServiceProvider serviceProvider, IOptionsMonitor<ILog> options)
|
||||
public void Add(EventMessage message)
|
||||
{
|
||||
// messages with action code < 2000 are related to login-history
|
||||
if ((int)message.Action < 2000)
|
||||
{
|
||||
_cacheTime = TimeSpan.FromMinutes(1);
|
||||
_cache = new Dictionary<string, EventMessage>();
|
||||
_timerStarted = false;
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
using var ef = scope.ServiceProvider.GetService<DbContextManager<MessagesContext>>().Get("messages");
|
||||
|
||||
Logger = options.CurrentValue;
|
||||
_serviceProvider = serviceProvider;
|
||||
AddLoginEvent(message, ef);
|
||||
|
||||
_timer = new Timer(FlushCache);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Add(EventMessage message)
|
||||
var now = DateTime.UtcNow;
|
||||
var key = string.Format("{0}|{1}|{2}|{3}", message.TenantId, message.UserId, message.Id, now.Ticks);
|
||||
|
||||
lock (_cache)
|
||||
{
|
||||
// messages with action code < 2000 are related to login-history
|
||||
if ((int)message.Action < 2000)
|
||||
_cache[key] = message;
|
||||
|
||||
if (!_timerStarted)
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
using var ef = scope.ServiceProvider.GetService<DbContextManager<MessagesContext>>().Get("messages");
|
||||
|
||||
AddLoginEvent(message, ef);
|
||||
|
||||
return;
|
||||
_timer.Change(0, 100);
|
||||
_timerStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
var key = string.Format("{0}|{1}|{2}|{3}", message.TenantId, message.UserId, message.Id, now.Ticks);
|
||||
}
|
||||
|
||||
private void FlushCache(object state)
|
||||
{
|
||||
List<EventMessage> events = null;
|
||||
|
||||
if (_cacheTime < DateTime.UtcNow - _lastSave || _cache.Count > 100)
|
||||
{
|
||||
lock (_cache)
|
||||
{
|
||||
_cache[key] = message;
|
||||
_timer.Change(-1, -1);
|
||||
_timerStarted = false;
|
||||
|
||||
if (!_timerStarted)
|
||||
{
|
||||
_timer.Change(0, 100);
|
||||
_timerStarted = true;
|
||||
}
|
||||
events = new List<EventMessage>(_cache.Values);
|
||||
_cache.Clear();
|
||||
_lastSave = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void FlushCache(object state)
|
||||
if (events == null)
|
||||
{
|
||||
List<EventMessage> events = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cacheTime < DateTime.UtcNow - _lastSave || _cache.Count > 100)
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
using var ef = scope.ServiceProvider.GetService<DbContextManager<Messages>>().Get("messages");
|
||||
using var tx = ef.Database.BeginTransaction(IsolationLevel.ReadUncommitted);
|
||||
var dict = new Dictionary<string, ClientInfo>();
|
||||
|
||||
foreach (var message in events)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message.UAHeader))
|
||||
{
|
||||
lock (_cache)
|
||||
try
|
||||
{
|
||||
_timer.Change(-1, -1);
|
||||
_timerStarted = false;
|
||||
|
||||
events = new List<EventMessage>(_cache.Values);
|
||||
_cache.Clear();
|
||||
_lastSave = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
ClientInfo clientInfo;
|
||||
|
||||
if (events == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
using var ef = scope.ServiceProvider.GetService<DbContextManager<Messages>>().Get("messages");
|
||||
using var tx = ef.Database.BeginTransaction(IsolationLevel.ReadUncommitted);
|
||||
var dict = new Dictionary<string, ClientInfo>();
|
||||
|
||||
foreach (var message in events)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message.UAHeader))
|
||||
{
|
||||
try
|
||||
if (dict.TryGetValue(message.UAHeader, out clientInfo))
|
||||
{
|
||||
|
||||
ClientInfo clientInfo;
|
||||
|
||||
if (dict.TryGetValue(message.UAHeader, out clientInfo))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_parser = _parser ?? Parser.GetDefault();
|
||||
clientInfo = _parser.Parse(message.UAHeader);
|
||||
dict.Add(message.UAHeader, clientInfo);
|
||||
}
|
||||
|
||||
if (clientInfo != null)
|
||||
{
|
||||
message.Browser = GetBrowser(clientInfo);
|
||||
message.Platform = GetPlatform(clientInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
Logger.Error("FlushCache " + message.Id, e);
|
||||
_parser = _parser ?? Parser.GetDefault();
|
||||
clientInfo = _parser.Parse(message.UAHeader);
|
||||
dict.Add(message.UAHeader, clientInfo);
|
||||
}
|
||||
|
||||
if (clientInfo != null)
|
||||
{
|
||||
message.Browser = GetBrowser(clientInfo);
|
||||
message.Platform = GetPlatform(clientInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// messages with action code < 2000 are related to login-history
|
||||
if ((int)message.Action >= 2000)
|
||||
catch (Exception e)
|
||||
{
|
||||
AddAuditEvent(message, ef);
|
||||
Logger.Error("FlushCache " + message.Id, e);
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit();
|
||||
}
|
||||
|
||||
private static void AddLoginEvent(EventMessage message, MessagesContext dbContext)
|
||||
{
|
||||
var le = new LoginEvent
|
||||
// messages with action code < 2000 are related to login-history
|
||||
if ((int)message.Action >= 2000)
|
||||
{
|
||||
Ip = message.IP,
|
||||
Login = message.Initiator,
|
||||
Browser = message.Browser,
|
||||
Platform = message.Platform,
|
||||
Date = message.Date,
|
||||
TenantId = message.TenantId,
|
||||
UserId = message.UserId,
|
||||
Page = message.Page,
|
||||
Action = (int)message.Action
|
||||
};
|
||||
|
||||
if (message.Description != null && message.Description.Count > 0)
|
||||
{
|
||||
le.DescriptionRaw =
|
||||
JsonConvert.SerializeObject(message.Description, new JsonSerializerSettings
|
||||
{
|
||||
DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
});
|
||||
}
|
||||
|
||||
dbContext.LoginEvents.Add(le);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private static void AddAuditEvent(EventMessage message, Messages dbContext)
|
||||
{
|
||||
var ae = new AuditEvent
|
||||
{
|
||||
Ip = message.IP,
|
||||
Initiator = message.Initiator,
|
||||
Browser = message.Browser,
|
||||
Platform = message.Platform,
|
||||
Date = message.Date,
|
||||
TenantId = message.TenantId,
|
||||
UserId = message.UserId,
|
||||
Page = message.Page,
|
||||
Action = (int)message.Action,
|
||||
Target = message.Target?.ToString()
|
||||
};
|
||||
|
||||
if (message.Description != null && message.Description.Count > 0)
|
||||
{
|
||||
ae.DescriptionRaw =
|
||||
JsonConvert.SerializeObject(GetSafeDescription(message.Description), new JsonSerializerSettings
|
||||
{
|
||||
DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
});
|
||||
}
|
||||
|
||||
dbContext.AuditEvents.Add(ae);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private static IList<string> GetSafeDescription(IEnumerable<string> description)
|
||||
{
|
||||
const int maxLength = 15000;
|
||||
|
||||
var currentLength = 0;
|
||||
var safe = new List<string>();
|
||||
|
||||
foreach (var d in description.Where(r => r != null))
|
||||
{
|
||||
if (currentLength + d.Length <= maxLength)
|
||||
{
|
||||
currentLength += d.Length;
|
||||
safe.Add(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
safe.Add(d.Substring(0, maxLength - currentLength - 3) + "...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return safe;
|
||||
}
|
||||
|
||||
private static string GetBrowser(ClientInfo clientInfo)
|
||||
{
|
||||
return clientInfo == null
|
||||
? null
|
||||
: $"{clientInfo.UA.Family} {clientInfo.UA.Major}";
|
||||
}
|
||||
|
||||
private static string GetPlatform(ClientInfo clientInfo)
|
||||
{
|
||||
return clientInfo == null
|
||||
? null
|
||||
: $"{clientInfo.OS.Family} {clientInfo.OS.Major}";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_timer != null)
|
||||
{
|
||||
_timer.Dispose();
|
||||
AddAuditEvent(message, ef);
|
||||
}
|
||||
}
|
||||
|
||||
tx.Commit();
|
||||
}
|
||||
|
||||
public class Messages : MessagesContext
|
||||
private static void AddLoginEvent(EventMessage message, MessagesContext dbContext)
|
||||
{
|
||||
public DbSet<DbTenant> Tenants { get; set; }
|
||||
public DbSet<DbWebstudioSettings> WebstudioSettings { get; set; }
|
||||
var le = new LoginEvent
|
||||
{
|
||||
Ip = message.IP,
|
||||
Login = message.Initiator,
|
||||
Browser = message.Browser,
|
||||
Platform = message.Platform,
|
||||
Date = message.Date,
|
||||
TenantId = message.TenantId,
|
||||
UserId = message.UserId,
|
||||
Page = message.Page,
|
||||
Action = (int)message.Action
|
||||
};
|
||||
|
||||
if (message.Description != null && message.Description.Count > 0)
|
||||
{
|
||||
le.DescriptionRaw =
|
||||
JsonConvert.SerializeObject(message.Description, new JsonSerializerSettings
|
||||
{
|
||||
DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
});
|
||||
}
|
||||
|
||||
dbContext.LoginEvents.Add(le);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public static class MessagesRepositoryExtension
|
||||
private static void AddAuditEvent(EventMessage message, Messages dbContext)
|
||||
{
|
||||
public static void Register(DIHelper services)
|
||||
var ae = new AuditEvent
|
||||
{
|
||||
services.TryAdd<DbContextManager<MessagesContext>>();
|
||||
Ip = message.IP,
|
||||
Initiator = message.Initiator,
|
||||
Browser = message.Browser,
|
||||
Platform = message.Platform,
|
||||
Date = message.Date,
|
||||
TenantId = message.TenantId,
|
||||
UserId = message.UserId,
|
||||
Page = message.Page,
|
||||
Action = (int)message.Action,
|
||||
Target = message.Target?.ToString()
|
||||
};
|
||||
|
||||
if (message.Description != null && message.Description.Count > 0)
|
||||
{
|
||||
ae.DescriptionRaw =
|
||||
JsonConvert.SerializeObject(GetSafeDescription(message.Description), new JsonSerializerSettings
|
||||
{
|
||||
DateTimeZoneHandling = DateTimeZoneHandling.Utc
|
||||
});
|
||||
}
|
||||
|
||||
dbContext.AuditEvents.Add(ae);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private static IList<string> GetSafeDescription(IEnumerable<string> description)
|
||||
{
|
||||
const int maxLength = 15000;
|
||||
|
||||
var currentLength = 0;
|
||||
var safe = new List<string>();
|
||||
|
||||
foreach (var d in description.Where(r => r != null))
|
||||
{
|
||||
if (currentLength + d.Length <= maxLength)
|
||||
{
|
||||
currentLength += d.Length;
|
||||
safe.Add(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
safe.Add(d.Substring(0, maxLength - currentLength - 3) + "...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return safe;
|
||||
}
|
||||
|
||||
private static string GetBrowser(ClientInfo clientInfo)
|
||||
{
|
||||
return clientInfo == null
|
||||
? null
|
||||
: $"{clientInfo.UA.Family} {clientInfo.UA.Major}";
|
||||
}
|
||||
|
||||
private static string GetPlatform(ClientInfo clientInfo)
|
||||
{
|
||||
return clientInfo == null
|
||||
? null
|
||||
: $"{clientInfo.OS.Family} {clientInfo.OS.Major}";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_timer != null)
|
||||
{
|
||||
_timer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Messages : MessagesContext
|
||||
{
|
||||
public DbSet<DbTenant> Tenants { get; set; }
|
||||
public DbSet<DbWebstudioSettings> WebstudioSettings { get; set; }
|
||||
}
|
||||
|
||||
public static class MessagesRepositoryExtension
|
||||
{
|
||||
public static void Register(DIHelper services)
|
||||
{
|
||||
services.TryAdd<DbContextManager<MessagesContext>>();
|
||||
}
|
||||
}
|
||||
|
@ -23,22 +23,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
public class EventMessage
|
||||
{
|
||||
public class EventMessage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string IP { get; set; }
|
||||
public string Initiator { get; set; }
|
||||
public string Browser { get; set; }
|
||||
public string Platform { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Page { get; set; }
|
||||
public MessageAction Action { get; set; }
|
||||
public IList<string> Description { get; set; }
|
||||
public MessageTarget Target { get; set; }
|
||||
public string UAHeader { get; set; }
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public string IP { get; set; }
|
||||
public string Initiator { get; set; }
|
||||
public string Browser { get; set; }
|
||||
public string Platform { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Page { get; set; }
|
||||
public MessageAction Action { get; set; }
|
||||
public IList<string> Description { get; set; }
|
||||
public MessageTarget Target { get; set; }
|
||||
public string UAHeader { get; set; }
|
||||
}
|
@ -24,10 +24,9 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
public interface IMessageSender
|
||||
{
|
||||
public interface IMessageSender
|
||||
{
|
||||
void Send(EventMessage message);
|
||||
}
|
||||
void Send(EventMessage message);
|
||||
}
|
@ -24,524 +24,523 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
public enum MessageAction
|
||||
{
|
||||
public enum MessageAction
|
||||
{
|
||||
None = -1,
|
||||
|
||||
#region Login
|
||||
|
||||
LoginSuccess = 1000,
|
||||
LoginSuccessViaSocialAccount = 1001,
|
||||
LoginSuccessViaSms = 1007,
|
||||
LoginSuccessViaApi = 1010,
|
||||
LoginSuccessViaSocialApp = 1011,
|
||||
LoginSuccessViaApiSms = 1012,
|
||||
LoginSuccessViaApiTfa = 1024,
|
||||
LoginSuccessViaApiSocialAccount = 1019,
|
||||
LoginSuccessViaSSO = 1015,
|
||||
LoginSuccesViaTfaApp = 1021,
|
||||
LoginFailViaSSO = 1018,
|
||||
LoginFailInvalidCombination = 1002,
|
||||
LoginFailSocialAccountNotFound = 1003,
|
||||
LoginFailDisabledProfile = 1004,
|
||||
LoginFail = 1005,
|
||||
LoginFailViaSms = 1008,
|
||||
LoginFailViaApi = 1013,
|
||||
LoginFailViaApiSms = 1014,
|
||||
LoginFailViaApiTfa = 1025,
|
||||
LoginFailViaApiSocialAccount = 1020,
|
||||
LoginFailViaTfaApp = 1022,
|
||||
LoginFailIpSecurity = 1009,
|
||||
LoginFailBruteForce = 1023,
|
||||
LoginFailRecaptcha = 1026, // last login
|
||||
Logout = 1006,
|
||||
|
||||
SessionStarted = 1016,
|
||||
SessionCompleted = 1017,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Projects
|
||||
|
||||
ProjectCreated = 2000,
|
||||
ProjectCreatedFromTemplate = 2001,
|
||||
ProjectUpdated = 2002,
|
||||
ProjectUpdatedStatus = 2003,
|
||||
ProjectFollowed = 2004,
|
||||
ProjectUnfollowed = 2005,
|
||||
ProjectDeleted = 2006,
|
||||
|
||||
ProjectDeletedMember = 2007,
|
||||
ProjectUpdatedTeam = 2008,
|
||||
ProjectUpdatedMemberRights = 2009,
|
||||
|
||||
ProjectLinkedCompany = 2010,
|
||||
ProjectUnlinkedCompany = 2011,
|
||||
ProjectLinkedPerson = 2012,
|
||||
ProjectUnlinkedPerson = 2013,
|
||||
ProjectLinkedContacts = 2014,
|
||||
|
||||
MilestoneCreated = 2015,
|
||||
MilestoneUpdated = 2016,
|
||||
MilestoneUpdatedStatus = 2017,
|
||||
MilestoneDeleted = 2018,
|
||||
|
||||
TaskCreated = 2019,
|
||||
TaskCreatedFromDiscussion = 2020,
|
||||
TaskUpdated = 2021,
|
||||
TaskUpdatedStatus = 2022,
|
||||
TaskMovedToMilestone = 2023,
|
||||
TaskUnlinkedMilestone = 2024,
|
||||
TaskUpdatedFollowing = 2025,
|
||||
TaskAttachedFiles = 2026,
|
||||
TaskDetachedFile = 2027,
|
||||
TasksLinked = 2028,
|
||||
TasksUnlinked = 2029,
|
||||
TaskDeleted = 2030,
|
||||
|
||||
TaskCommentCreated = 2031,
|
||||
TaskCommentUpdated = 2032,
|
||||
TaskCommentDeleted = 2033,
|
||||
|
||||
SubtaskCreated = 2034,
|
||||
SubtaskUpdated = 2035,
|
||||
SubtaskUpdatedStatus = 2036,
|
||||
SubtaskDeleted = 2037,
|
||||
|
||||
DiscussionCreated = 2038,
|
||||
DiscussionUpdated = 2039,
|
||||
DiscussionUpdatedFollowing = 2040,
|
||||
DiscussionAttachedFiles = 2041,
|
||||
DiscussionDetachedFile = 2042,
|
||||
DiscussionDeleted = 2043,
|
||||
|
||||
DiscussionCommentCreated = 2044,
|
||||
DiscussionCommentUpdated = 2045,
|
||||
DiscussionCommentDeleted = 2046,
|
||||
|
||||
TaskTimeCreated = 2047,
|
||||
TaskTimeUpdated = 2048,
|
||||
TaskTimesUpdatedStatus = 2049,
|
||||
TaskTimesDeleted = 2050,
|
||||
|
||||
ReportTemplateCreated = 2051,
|
||||
ReportTemplateUpdated = 2052,
|
||||
ReportTemplateDeleted = 2053,
|
||||
|
||||
ProjectTemplateCreated = 2054,
|
||||
ProjectTemplateUpdated = 2055,
|
||||
ProjectTemplateDeleted = 2056,
|
||||
|
||||
ProjectsImportedFromBasecamp = 2057,
|
||||
|
||||
#endregion
|
||||
|
||||
#region CRM
|
||||
|
||||
CompanyCreated = 3000,
|
||||
CompanyCreatedWithWebForm = 3157,
|
||||
CompanyUpdated = 3001,
|
||||
CompanyUpdatedPrincipalInfo = 3002,
|
||||
CompanyUpdatedPhoto = 3003,
|
||||
CompanyUpdatedTemperatureLevel = 3004,
|
||||
CompanyUpdatedPersonsTemperatureLevel = 3005,
|
||||
CompanyCreatedTag = 3006,
|
||||
CompanyCreatedPersonsTag = 3007,
|
||||
CompanyDeletedTag = 3008,
|
||||
CompanyCreatedHistoryEvent = 3009,
|
||||
CompanyDeletedHistoryEvent = 3010,
|
||||
CompanyLinkedPerson = 3011,
|
||||
CompanyUnlinkedPerson = 3012,
|
||||
CompanyLinkedProject = 3013,
|
||||
CompanyUnlinkedProject = 3014,
|
||||
CompanyAttachedFiles = 3015,
|
||||
CompanyDetachedFile = 3159,
|
||||
CompaniesMerged = 3016,
|
||||
CompanyDeleted = 3017,
|
||||
|
||||
PersonCreated = 3018,
|
||||
PersonCreatedWithWebForm = 3158,
|
||||
PersonsCreated = 3019,
|
||||
PersonUpdated = 3020,
|
||||
PersonUpdatedPrincipalInfo = 3021,
|
||||
PersonUpdatedPhoto = 3022,
|
||||
PersonUpdatedTemperatureLevel = 3023,
|
||||
PersonUpdatedCompanyTemperatureLevel = 3024,
|
||||
PersonCreatedTag = 3025,
|
||||
PersonCreatedCompanyTag = 3026,
|
||||
PersonDeletedTag = 3027,
|
||||
PersonCreatedHistoryEvent = 3028,
|
||||
PersonDeletedHistoryEvent = 3029,
|
||||
PersonLinkedProject = 3030,
|
||||
PersonUnlinkedProject = 3031,
|
||||
PersonAttachedFiles = 3032,
|
||||
PersonDetachedFile = 3160,
|
||||
PersonsMerged = 3033,
|
||||
PersonDeleted = 3034,
|
||||
|
||||
ContactsDeleted = 3035,
|
||||
|
||||
CrmTaskCreated = 3036,
|
||||
ContactsCreatedCrmTasks = 3037,
|
||||
CrmTaskUpdated = 3038,
|
||||
CrmTaskOpened = 3039,
|
||||
CrmTaskClosed = 3040,
|
||||
CrmTaskDeleted = 3041,
|
||||
|
||||
OpportunityCreated = 3042,
|
||||
OpportunityUpdated = 3043,
|
||||
OpportunityUpdatedStage = 3044,
|
||||
OpportunityCreatedTag = 3045,
|
||||
OpportunityDeletedTag = 3046,
|
||||
OpportunityCreatedHistoryEvent = 3047,
|
||||
OpportunityDeletedHistoryEvent = 3048,
|
||||
OpportunityLinkedCompany = 3049,
|
||||
OpportunityUnlinkedCompany = 3050,
|
||||
OpportunityLinkedPerson = 3051,
|
||||
OpportunityUnlinkedPerson = 3052,
|
||||
OpportunityAttachedFiles = 3053,
|
||||
OpportunityDetachedFile = 3161,
|
||||
OpportunityOpenedAccess = 3054,
|
||||
OpportunityRestrictedAccess = 3055,
|
||||
OpportunityDeleted = 3056,
|
||||
OpportunitiesDeleted = 3057,
|
||||
|
||||
InvoiceCreated = 3058,
|
||||
InvoiceUpdated = 3059,
|
||||
InvoicesUpdatedStatus = 3060,
|
||||
InvoiceDeleted = 3061,
|
||||
InvoicesDeleted = 3062,
|
||||
|
||||
CaseCreated = 3063,
|
||||
CaseUpdated = 3064,
|
||||
CaseOpened = 3065,
|
||||
CaseClosed = 3066,
|
||||
CaseCreatedTag = 3067,
|
||||
CaseDeletedTag = 3068,
|
||||
CaseCreatedHistoryEvent = 3069,
|
||||
CaseDeletedHistoryEvent = 3070,
|
||||
CaseLinkedCompany = 3071,
|
||||
CaseUnlinkedCompany = 3072,
|
||||
CaseLinkedPerson = 3073,
|
||||
CaseUnlinkedPerson = 3074,
|
||||
CaseAttachedFiles = 3075,
|
||||
CaseDetachedFile = 3162,
|
||||
CaseOpenedAccess = 3076,
|
||||
CaseRestrictedAccess = 3077,
|
||||
CaseDeleted = 3078,
|
||||
CasesDeleted = 3079,
|
||||
|
||||
CrmSmtpSettingsUpdated = 3080,
|
||||
CrmTestMailSent = 3081,
|
||||
CrmDefaultCurrencyUpdated = 3082,
|
||||
CrmAllDataExported = 3083,
|
||||
|
||||
ContactTemperatureLevelCreated = 3084,
|
||||
ContactTemperatureLevelUpdated = 3085,
|
||||
ContactTemperatureLevelUpdatedColor = 3086,
|
||||
ContactTemperatureLevelsUpdatedOrder = 3087,
|
||||
ContactTemperatureLevelDeleted = 3088,
|
||||
ContactTemperatureLevelSettingsUpdated = 3089,
|
||||
|
||||
ContactTypeCreated = 3090,
|
||||
ContactTypeUpdated = 3091,
|
||||
ContactTypesUpdatedOrder = 3092,
|
||||
ContactTypeDeleted = 3093,
|
||||
|
||||
InvoiceItemCreated = 3094,
|
||||
InvoiceItemUpdated = 3095,
|
||||
InvoiceItemDeleted = 3096,
|
||||
InvoiceItemsDeleted = 3097,
|
||||
|
||||
InvoiceTaxCreated = 3098,
|
||||
InvoiceTaxUpdated = 3099,
|
||||
InvoiceTaxDeleted = 3100,
|
||||
|
||||
CurrencyRateUpdated = 3163,
|
||||
InvoiceDefaultTermsUpdated = 3164,
|
||||
InvoiceDownloaded = 3165,
|
||||
CrmSmtpMailSent = 3166,
|
||||
|
||||
OrganizationProfileUpdatedCompanyName = 3101,
|
||||
OrganizationProfileUpdatedInvoiceLogo = 3102,
|
||||
OrganizationProfileUpdatedAddress = 3103,
|
||||
|
||||
InvoiceNumberFormatUpdated = 3104,
|
||||
|
||||
ContactUserFieldCreated = 3105,
|
||||
ContactUserFieldUpdated = 3106,
|
||||
ContactUserFieldsUpdatedOrder = 3107,
|
||||
ContactUserFieldDeleted = 3108,
|
||||
CompanyUserFieldCreated = 3109,
|
||||
CompanyUserFieldUpdated = 3110,
|
||||
CompanyUserFieldsUpdatedOrder = 3111,
|
||||
CompanyUserFieldDeleted = 3112,
|
||||
PersonUserFieldCreated = 3113,
|
||||
PersonUserFieldUpdated = 3114,
|
||||
PersonUserFieldsUpdatedOrder = 3115,
|
||||
PersonUserFieldDeleted = 3116,
|
||||
OpportunityUserFieldCreated = 3117,
|
||||
OpportunityUserFieldUpdated = 3118,
|
||||
OpportunityUserFieldsUpdatedOrder = 3119,
|
||||
OpportunityUserFieldDeleted = 3120,
|
||||
CaseUserFieldCreated = 3121,
|
||||
CaseUserFieldUpdated = 3122,
|
||||
CaseUserFieldsUpdatedOrder = 3123,
|
||||
CaseUserFieldDeleted = 3124,
|
||||
|
||||
HistoryEventCategoryCreated = 3125,
|
||||
HistoryEventCategoryUpdated = 3126,
|
||||
HistoryEventCategoryUpdatedIcon = 3127,
|
||||
HistoryEventCategoriesUpdatedOrder = 3128,
|
||||
HistoryEventCategoryDeleted = 3129,
|
||||
|
||||
CrmTaskCategoryCreated = 3130,
|
||||
CrmTaskCategoryUpdated = 3131,
|
||||
CrmTaskCategoryUpdatedIcon = 3132,
|
||||
CrmTaskCategoriesUpdatedOrder = 3133,
|
||||
CrmTaskCategoryDeleted = 3134,
|
||||
|
||||
OpportunityStageCreated = 3135,
|
||||
OpportunityStageUpdated = 3136,
|
||||
OpportunityStageUpdatedColor = 3137,
|
||||
OpportunityStagesUpdatedOrder = 3138,
|
||||
OpportunityStageDeleted = 3139,
|
||||
|
||||
ContactsCreatedTag = 3140,
|
||||
ContactsDeletedTag = 3141,
|
||||
OpportunitiesCreatedTag = 3142,
|
||||
OpportunitiesDeletedTag = 3143,
|
||||
CasesCreatedTag = 3144,
|
||||
CasesDeletedTag = 3145,
|
||||
ContactsTagSettingsUpdated = 3146,
|
||||
|
||||
WebsiteContactFormUpdatedKey = 3147,
|
||||
|
||||
ContactsImportedFromCSV = 3148,
|
||||
CrmTasksImportedFromCSV = 3149,
|
||||
OpportunitiesImportedFromCSV = 3150,
|
||||
CasesImportedFromCSV = 3151,
|
||||
|
||||
ContactsExportedToCsv = 3152,
|
||||
CrmTasksExportedToCsv = 3153,
|
||||
OpportunitiesExportedToCsv = 3154,
|
||||
CasesExportedToCsv = 3155,
|
||||
|
||||
#endregion
|
||||
|
||||
#region People
|
||||
|
||||
UserCreated = 4000,
|
||||
GuestCreated = 4001,
|
||||
UserCreatedViaInvite = 4002,
|
||||
GuestCreatedViaInvite = 4003,
|
||||
|
||||
UserActivated = 4004,
|
||||
GuestActivated = 4005,
|
||||
|
||||
UserUpdated = 4006,
|
||||
UserUpdatedMobileNumber = 4029,
|
||||
UserUpdatedLanguage = 4007,
|
||||
UserAddedAvatar = 4008,
|
||||
UserDeletedAvatar = 4009,
|
||||
UserUpdatedAvatarThumbnails = 4010,
|
||||
|
||||
UserLinkedSocialAccount = 4011,
|
||||
UserUnlinkedSocialAccount = 4012,
|
||||
|
||||
UserConnectedTfaApp = 4032,
|
||||
UserDisconnectedTfaApp = 4033,
|
||||
|
||||
UserSentActivationInstructions = 4013,
|
||||
UserSentEmailChangeInstructions = 4014,
|
||||
UserSentPasswordChangeInstructions = 4015,
|
||||
UserSentDeleteInstructions = 4016,
|
||||
|
||||
UserUpdatedEmail = 5047,
|
||||
UserUpdatedPassword = 4017,
|
||||
UserDeleted = 4018,
|
||||
|
||||
UsersUpdatedType = 4019,
|
||||
UsersUpdatedStatus = 4020,
|
||||
UsersSentActivationInstructions = 4021,
|
||||
UsersDeleted = 4022,
|
||||
SentInviteInstructions = 4023,
|
||||
|
||||
UserImported = 4024,
|
||||
GuestImported = 4025,
|
||||
|
||||
GroupCreated = 4026,
|
||||
GroupUpdated = 4027,
|
||||
GroupDeleted = 4028,
|
||||
|
||||
UserDataReassigns = 4030,
|
||||
UserDataRemoving = 4031,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Documents
|
||||
|
||||
FileCreated = 5000,
|
||||
FileRenamed = 5001,
|
||||
FileUpdated = 5002,
|
||||
UserFileUpdated = 5034,
|
||||
FileCreatedVersion = 5003,
|
||||
FileDeletedVersion = 5004,
|
||||
FileRestoreVersion = 5044,
|
||||
FileUpdatedRevisionComment = 5005,
|
||||
FileLocked = 5006,
|
||||
FileUnlocked = 5007,
|
||||
FileUpdatedAccess = 5008,
|
||||
FileSendAccessLink = 5036, // not used
|
||||
None = -1,
|
||||
|
||||
#region Login
|
||||
|
||||
LoginSuccess = 1000,
|
||||
LoginSuccessViaSocialAccount = 1001,
|
||||
LoginSuccessViaSms = 1007,
|
||||
LoginSuccessViaApi = 1010,
|
||||
LoginSuccessViaSocialApp = 1011,
|
||||
LoginSuccessViaApiSms = 1012,
|
||||
LoginSuccessViaApiTfa = 1024,
|
||||
LoginSuccessViaApiSocialAccount = 1019,
|
||||
LoginSuccessViaSSO = 1015,
|
||||
LoginSuccesViaTfaApp = 1021,
|
||||
LoginFailViaSSO = 1018,
|
||||
LoginFailInvalidCombination = 1002,
|
||||
LoginFailSocialAccountNotFound = 1003,
|
||||
LoginFailDisabledProfile = 1004,
|
||||
LoginFail = 1005,
|
||||
LoginFailViaSms = 1008,
|
||||
LoginFailViaApi = 1013,
|
||||
LoginFailViaApiSms = 1014,
|
||||
LoginFailViaApiTfa = 1025,
|
||||
LoginFailViaApiSocialAccount = 1020,
|
||||
LoginFailViaTfaApp = 1022,
|
||||
LoginFailIpSecurity = 1009,
|
||||
LoginFailBruteForce = 1023,
|
||||
LoginFailRecaptcha = 1026, // last login
|
||||
Logout = 1006,
|
||||
|
||||
SessionStarted = 1016,
|
||||
SessionCompleted = 1017,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Projects
|
||||
|
||||
ProjectCreated = 2000,
|
||||
ProjectCreatedFromTemplate = 2001,
|
||||
ProjectUpdated = 2002,
|
||||
ProjectUpdatedStatus = 2003,
|
||||
ProjectFollowed = 2004,
|
||||
ProjectUnfollowed = 2005,
|
||||
ProjectDeleted = 2006,
|
||||
|
||||
ProjectDeletedMember = 2007,
|
||||
ProjectUpdatedTeam = 2008,
|
||||
ProjectUpdatedMemberRights = 2009,
|
||||
|
||||
ProjectLinkedCompany = 2010,
|
||||
ProjectUnlinkedCompany = 2011,
|
||||
ProjectLinkedPerson = 2012,
|
||||
ProjectUnlinkedPerson = 2013,
|
||||
ProjectLinkedContacts = 2014,
|
||||
|
||||
MilestoneCreated = 2015,
|
||||
MilestoneUpdated = 2016,
|
||||
MilestoneUpdatedStatus = 2017,
|
||||
MilestoneDeleted = 2018,
|
||||
|
||||
TaskCreated = 2019,
|
||||
TaskCreatedFromDiscussion = 2020,
|
||||
TaskUpdated = 2021,
|
||||
TaskUpdatedStatus = 2022,
|
||||
TaskMovedToMilestone = 2023,
|
||||
TaskUnlinkedMilestone = 2024,
|
||||
TaskUpdatedFollowing = 2025,
|
||||
TaskAttachedFiles = 2026,
|
||||
TaskDetachedFile = 2027,
|
||||
TasksLinked = 2028,
|
||||
TasksUnlinked = 2029,
|
||||
TaskDeleted = 2030,
|
||||
|
||||
TaskCommentCreated = 2031,
|
||||
TaskCommentUpdated = 2032,
|
||||
TaskCommentDeleted = 2033,
|
||||
|
||||
SubtaskCreated = 2034,
|
||||
SubtaskUpdated = 2035,
|
||||
SubtaskUpdatedStatus = 2036,
|
||||
SubtaskDeleted = 2037,
|
||||
|
||||
DiscussionCreated = 2038,
|
||||
DiscussionUpdated = 2039,
|
||||
DiscussionUpdatedFollowing = 2040,
|
||||
DiscussionAttachedFiles = 2041,
|
||||
DiscussionDetachedFile = 2042,
|
||||
DiscussionDeleted = 2043,
|
||||
|
||||
DiscussionCommentCreated = 2044,
|
||||
DiscussionCommentUpdated = 2045,
|
||||
DiscussionCommentDeleted = 2046,
|
||||
|
||||
TaskTimeCreated = 2047,
|
||||
TaskTimeUpdated = 2048,
|
||||
TaskTimesUpdatedStatus = 2049,
|
||||
TaskTimesDeleted = 2050,
|
||||
|
||||
ReportTemplateCreated = 2051,
|
||||
ReportTemplateUpdated = 2052,
|
||||
ReportTemplateDeleted = 2053,
|
||||
|
||||
ProjectTemplateCreated = 2054,
|
||||
ProjectTemplateUpdated = 2055,
|
||||
ProjectTemplateDeleted = 2056,
|
||||
|
||||
ProjectsImportedFromBasecamp = 2057,
|
||||
|
||||
#endregion
|
||||
|
||||
#region CRM
|
||||
|
||||
CompanyCreated = 3000,
|
||||
CompanyCreatedWithWebForm = 3157,
|
||||
CompanyUpdated = 3001,
|
||||
CompanyUpdatedPrincipalInfo = 3002,
|
||||
CompanyUpdatedPhoto = 3003,
|
||||
CompanyUpdatedTemperatureLevel = 3004,
|
||||
CompanyUpdatedPersonsTemperatureLevel = 3005,
|
||||
CompanyCreatedTag = 3006,
|
||||
CompanyCreatedPersonsTag = 3007,
|
||||
CompanyDeletedTag = 3008,
|
||||
CompanyCreatedHistoryEvent = 3009,
|
||||
CompanyDeletedHistoryEvent = 3010,
|
||||
CompanyLinkedPerson = 3011,
|
||||
CompanyUnlinkedPerson = 3012,
|
||||
CompanyLinkedProject = 3013,
|
||||
CompanyUnlinkedProject = 3014,
|
||||
CompanyAttachedFiles = 3015,
|
||||
CompanyDetachedFile = 3159,
|
||||
CompaniesMerged = 3016,
|
||||
CompanyDeleted = 3017,
|
||||
|
||||
PersonCreated = 3018,
|
||||
PersonCreatedWithWebForm = 3158,
|
||||
PersonsCreated = 3019,
|
||||
PersonUpdated = 3020,
|
||||
PersonUpdatedPrincipalInfo = 3021,
|
||||
PersonUpdatedPhoto = 3022,
|
||||
PersonUpdatedTemperatureLevel = 3023,
|
||||
PersonUpdatedCompanyTemperatureLevel = 3024,
|
||||
PersonCreatedTag = 3025,
|
||||
PersonCreatedCompanyTag = 3026,
|
||||
PersonDeletedTag = 3027,
|
||||
PersonCreatedHistoryEvent = 3028,
|
||||
PersonDeletedHistoryEvent = 3029,
|
||||
PersonLinkedProject = 3030,
|
||||
PersonUnlinkedProject = 3031,
|
||||
PersonAttachedFiles = 3032,
|
||||
PersonDetachedFile = 3160,
|
||||
PersonsMerged = 3033,
|
||||
PersonDeleted = 3034,
|
||||
|
||||
ContactsDeleted = 3035,
|
||||
|
||||
CrmTaskCreated = 3036,
|
||||
ContactsCreatedCrmTasks = 3037,
|
||||
CrmTaskUpdated = 3038,
|
||||
CrmTaskOpened = 3039,
|
||||
CrmTaskClosed = 3040,
|
||||
CrmTaskDeleted = 3041,
|
||||
|
||||
OpportunityCreated = 3042,
|
||||
OpportunityUpdated = 3043,
|
||||
OpportunityUpdatedStage = 3044,
|
||||
OpportunityCreatedTag = 3045,
|
||||
OpportunityDeletedTag = 3046,
|
||||
OpportunityCreatedHistoryEvent = 3047,
|
||||
OpportunityDeletedHistoryEvent = 3048,
|
||||
OpportunityLinkedCompany = 3049,
|
||||
OpportunityUnlinkedCompany = 3050,
|
||||
OpportunityLinkedPerson = 3051,
|
||||
OpportunityUnlinkedPerson = 3052,
|
||||
OpportunityAttachedFiles = 3053,
|
||||
OpportunityDetachedFile = 3161,
|
||||
OpportunityOpenedAccess = 3054,
|
||||
OpportunityRestrictedAccess = 3055,
|
||||
OpportunityDeleted = 3056,
|
||||
OpportunitiesDeleted = 3057,
|
||||
|
||||
InvoiceCreated = 3058,
|
||||
InvoiceUpdated = 3059,
|
||||
InvoicesUpdatedStatus = 3060,
|
||||
InvoiceDeleted = 3061,
|
||||
InvoicesDeleted = 3062,
|
||||
|
||||
CaseCreated = 3063,
|
||||
CaseUpdated = 3064,
|
||||
CaseOpened = 3065,
|
||||
CaseClosed = 3066,
|
||||
CaseCreatedTag = 3067,
|
||||
CaseDeletedTag = 3068,
|
||||
CaseCreatedHistoryEvent = 3069,
|
||||
CaseDeletedHistoryEvent = 3070,
|
||||
CaseLinkedCompany = 3071,
|
||||
CaseUnlinkedCompany = 3072,
|
||||
CaseLinkedPerson = 3073,
|
||||
CaseUnlinkedPerson = 3074,
|
||||
CaseAttachedFiles = 3075,
|
||||
CaseDetachedFile = 3162,
|
||||
CaseOpenedAccess = 3076,
|
||||
CaseRestrictedAccess = 3077,
|
||||
CaseDeleted = 3078,
|
||||
CasesDeleted = 3079,
|
||||
|
||||
CrmSmtpSettingsUpdated = 3080,
|
||||
CrmTestMailSent = 3081,
|
||||
CrmDefaultCurrencyUpdated = 3082,
|
||||
CrmAllDataExported = 3083,
|
||||
|
||||
ContactTemperatureLevelCreated = 3084,
|
||||
ContactTemperatureLevelUpdated = 3085,
|
||||
ContactTemperatureLevelUpdatedColor = 3086,
|
||||
ContactTemperatureLevelsUpdatedOrder = 3087,
|
||||
ContactTemperatureLevelDeleted = 3088,
|
||||
ContactTemperatureLevelSettingsUpdated = 3089,
|
||||
|
||||
ContactTypeCreated = 3090,
|
||||
ContactTypeUpdated = 3091,
|
||||
ContactTypesUpdatedOrder = 3092,
|
||||
ContactTypeDeleted = 3093,
|
||||
|
||||
InvoiceItemCreated = 3094,
|
||||
InvoiceItemUpdated = 3095,
|
||||
InvoiceItemDeleted = 3096,
|
||||
InvoiceItemsDeleted = 3097,
|
||||
|
||||
InvoiceTaxCreated = 3098,
|
||||
InvoiceTaxUpdated = 3099,
|
||||
InvoiceTaxDeleted = 3100,
|
||||
|
||||
CurrencyRateUpdated = 3163,
|
||||
InvoiceDefaultTermsUpdated = 3164,
|
||||
InvoiceDownloaded = 3165,
|
||||
CrmSmtpMailSent = 3166,
|
||||
|
||||
OrganizationProfileUpdatedCompanyName = 3101,
|
||||
OrganizationProfileUpdatedInvoiceLogo = 3102,
|
||||
OrganizationProfileUpdatedAddress = 3103,
|
||||
|
||||
InvoiceNumberFormatUpdated = 3104,
|
||||
|
||||
ContactUserFieldCreated = 3105,
|
||||
ContactUserFieldUpdated = 3106,
|
||||
ContactUserFieldsUpdatedOrder = 3107,
|
||||
ContactUserFieldDeleted = 3108,
|
||||
CompanyUserFieldCreated = 3109,
|
||||
CompanyUserFieldUpdated = 3110,
|
||||
CompanyUserFieldsUpdatedOrder = 3111,
|
||||
CompanyUserFieldDeleted = 3112,
|
||||
PersonUserFieldCreated = 3113,
|
||||
PersonUserFieldUpdated = 3114,
|
||||
PersonUserFieldsUpdatedOrder = 3115,
|
||||
PersonUserFieldDeleted = 3116,
|
||||
OpportunityUserFieldCreated = 3117,
|
||||
OpportunityUserFieldUpdated = 3118,
|
||||
OpportunityUserFieldsUpdatedOrder = 3119,
|
||||
OpportunityUserFieldDeleted = 3120,
|
||||
CaseUserFieldCreated = 3121,
|
||||
CaseUserFieldUpdated = 3122,
|
||||
CaseUserFieldsUpdatedOrder = 3123,
|
||||
CaseUserFieldDeleted = 3124,
|
||||
|
||||
HistoryEventCategoryCreated = 3125,
|
||||
HistoryEventCategoryUpdated = 3126,
|
||||
HistoryEventCategoryUpdatedIcon = 3127,
|
||||
HistoryEventCategoriesUpdatedOrder = 3128,
|
||||
HistoryEventCategoryDeleted = 3129,
|
||||
|
||||
CrmTaskCategoryCreated = 3130,
|
||||
CrmTaskCategoryUpdated = 3131,
|
||||
CrmTaskCategoryUpdatedIcon = 3132,
|
||||
CrmTaskCategoriesUpdatedOrder = 3133,
|
||||
CrmTaskCategoryDeleted = 3134,
|
||||
|
||||
OpportunityStageCreated = 3135,
|
||||
OpportunityStageUpdated = 3136,
|
||||
OpportunityStageUpdatedColor = 3137,
|
||||
OpportunityStagesUpdatedOrder = 3138,
|
||||
OpportunityStageDeleted = 3139,
|
||||
|
||||
ContactsCreatedTag = 3140,
|
||||
ContactsDeletedTag = 3141,
|
||||
OpportunitiesCreatedTag = 3142,
|
||||
OpportunitiesDeletedTag = 3143,
|
||||
CasesCreatedTag = 3144,
|
||||
CasesDeletedTag = 3145,
|
||||
ContactsTagSettingsUpdated = 3146,
|
||||
|
||||
WebsiteContactFormUpdatedKey = 3147,
|
||||
|
||||
ContactsImportedFromCSV = 3148,
|
||||
CrmTasksImportedFromCSV = 3149,
|
||||
OpportunitiesImportedFromCSV = 3150,
|
||||
CasesImportedFromCSV = 3151,
|
||||
|
||||
ContactsExportedToCsv = 3152,
|
||||
CrmTasksExportedToCsv = 3153,
|
||||
OpportunitiesExportedToCsv = 3154,
|
||||
CasesExportedToCsv = 3155,
|
||||
|
||||
#endregion
|
||||
|
||||
#region People
|
||||
|
||||
UserCreated = 4000,
|
||||
GuestCreated = 4001,
|
||||
UserCreatedViaInvite = 4002,
|
||||
GuestCreatedViaInvite = 4003,
|
||||
|
||||
UserActivated = 4004,
|
||||
GuestActivated = 4005,
|
||||
|
||||
UserUpdated = 4006,
|
||||
UserUpdatedMobileNumber = 4029,
|
||||
UserUpdatedLanguage = 4007,
|
||||
UserAddedAvatar = 4008,
|
||||
UserDeletedAvatar = 4009,
|
||||
UserUpdatedAvatarThumbnails = 4010,
|
||||
|
||||
UserLinkedSocialAccount = 4011,
|
||||
UserUnlinkedSocialAccount = 4012,
|
||||
|
||||
UserConnectedTfaApp = 4032,
|
||||
UserDisconnectedTfaApp = 4033,
|
||||
|
||||
UserSentActivationInstructions = 4013,
|
||||
UserSentEmailChangeInstructions = 4014,
|
||||
UserSentPasswordChangeInstructions = 4015,
|
||||
UserSentDeleteInstructions = 4016,
|
||||
|
||||
UserUpdatedEmail = 5047,
|
||||
UserUpdatedPassword = 4017,
|
||||
UserDeleted = 4018,
|
||||
|
||||
UsersUpdatedType = 4019,
|
||||
UsersUpdatedStatus = 4020,
|
||||
UsersSentActivationInstructions = 4021,
|
||||
UsersDeleted = 4022,
|
||||
SentInviteInstructions = 4023,
|
||||
|
||||
UserImported = 4024,
|
||||
GuestImported = 4025,
|
||||
|
||||
GroupCreated = 4026,
|
||||
GroupUpdated = 4027,
|
||||
GroupDeleted = 4028,
|
||||
|
||||
UserDataReassigns = 4030,
|
||||
UserDataRemoving = 4031,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Documents
|
||||
|
||||
FileCreated = 5000,
|
||||
FileRenamed = 5001,
|
||||
FileUpdated = 5002,
|
||||
UserFileUpdated = 5034,
|
||||
FileCreatedVersion = 5003,
|
||||
FileDeletedVersion = 5004,
|
||||
FileRestoreVersion = 5044,
|
||||
FileUpdatedRevisionComment = 5005,
|
||||
FileLocked = 5006,
|
||||
FileUnlocked = 5007,
|
||||
FileUpdatedAccess = 5008,
|
||||
FileSendAccessLink = 5036, // not used
|
||||
|
||||
FileDownloaded = 5009,
|
||||
FileDownloadedAs = 5010,
|
||||
FileDownloaded = 5009,
|
||||
FileDownloadedAs = 5010,
|
||||
|
||||
FileUploaded = 5011,
|
||||
FileImported = 5012,
|
||||
FileUploaded = 5011,
|
||||
FileImported = 5012,
|
||||
|
||||
FileCopied = 5013,
|
||||
FileCopiedWithOverwriting = 5014,
|
||||
FileMoved = 5015,
|
||||
FileMovedWithOverwriting = 5016,
|
||||
FileMovedToTrash = 5017,
|
||||
FileDeleted = 5018, // not used
|
||||
FileCopied = 5013,
|
||||
FileCopiedWithOverwriting = 5014,
|
||||
FileMoved = 5015,
|
||||
FileMovedWithOverwriting = 5016,
|
||||
FileMovedToTrash = 5017,
|
||||
FileDeleted = 5018, // not used
|
||||
|
||||
FolderCreated = 5019,
|
||||
FolderRenamed = 5020,
|
||||
FolderUpdatedAccess = 5021,
|
||||
FolderCreated = 5019,
|
||||
FolderRenamed = 5020,
|
||||
FolderUpdatedAccess = 5021,
|
||||
|
||||
FolderCopied = 5022,
|
||||
FolderCopiedWithOverwriting = 5023,
|
||||
FolderMoved = 5024,
|
||||
FolderMovedWithOverwriting = 5025,
|
||||
FolderMovedToTrash = 5026,
|
||||
FolderDeleted = 5027, // not used
|
||||
FolderCopied = 5022,
|
||||
FolderCopiedWithOverwriting = 5023,
|
||||
FolderMoved = 5024,
|
||||
FolderMovedWithOverwriting = 5025,
|
||||
FolderMovedToTrash = 5026,
|
||||
FolderDeleted = 5027, // not used
|
||||
|
||||
ThirdPartyCreated = 5028,
|
||||
ThirdPartyUpdated = 5029,
|
||||
ThirdPartyDeleted = 5030,
|
||||
ThirdPartyCreated = 5028,
|
||||
ThirdPartyUpdated = 5029,
|
||||
ThirdPartyDeleted = 5030,
|
||||
|
||||
DocumentsThirdPartySettingsUpdated = 5031,
|
||||
DocumentsOverwritingSettingsUpdated = 5032,
|
||||
DocumentsForcesave = 5049, // last
|
||||
DocumentsStoreForcesave = 5048,
|
||||
DocumentsUploadingFormatsSettingsUpdated = 5033,
|
||||
DocumentsThirdPartySettingsUpdated = 5031,
|
||||
DocumentsOverwritingSettingsUpdated = 5032,
|
||||
DocumentsForcesave = 5049, // last
|
||||
DocumentsStoreForcesave = 5048,
|
||||
DocumentsUploadingFormatsSettingsUpdated = 5033,
|
||||
|
||||
FileConverted = 5035,
|
||||
FileConverted = 5035,
|
||||
|
||||
FileChangeOwner = 5043,
|
||||
FileChangeOwner = 5043,
|
||||
|
||||
DocumentSignComplete = 5046,
|
||||
DocumentSendToSign = 5045,
|
||||
DocumentSignComplete = 5046,
|
||||
DocumentSendToSign = 5045,
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Settings
|
||||
#region Settings
|
||||
|
||||
LanguageSettingsUpdated = 6000,
|
||||
TimeZoneSettingsUpdated = 6001,
|
||||
DnsSettingsUpdated = 6002,
|
||||
TrustedMailDomainSettingsUpdated = 6003,
|
||||
PasswordStrengthSettingsUpdated = 6004,
|
||||
TwoFactorAuthenticationSettingsUpdated = 6005, // deprecated - use 6036-6038 instead
|
||||
AdministratorMessageSettingsUpdated = 6006,
|
||||
DefaultStartPageSettingsUpdated = 6007,
|
||||
LanguageSettingsUpdated = 6000,
|
||||
TimeZoneSettingsUpdated = 6001,
|
||||
DnsSettingsUpdated = 6002,
|
||||
TrustedMailDomainSettingsUpdated = 6003,
|
||||
PasswordStrengthSettingsUpdated = 6004,
|
||||
TwoFactorAuthenticationSettingsUpdated = 6005, // deprecated - use 6036-6038 instead
|
||||
AdministratorMessageSettingsUpdated = 6006,
|
||||
DefaultStartPageSettingsUpdated = 6007,
|
||||
|
||||
ProductsListUpdated = 6008,
|
||||
ProductsListUpdated = 6008,
|
||||
|
||||
AdministratorAdded = 6009,
|
||||
AdministratorOpenedFullAccess = 6010,
|
||||
AdministratorDeleted = 6011,
|
||||
AdministratorAdded = 6009,
|
||||
AdministratorOpenedFullAccess = 6010,
|
||||
AdministratorDeleted = 6011,
|
||||
|
||||
UsersOpenedProductAccess = 6012,
|
||||
GroupsOpenedProductAccess = 6013,
|
||||
UsersOpenedProductAccess = 6012,
|
||||
GroupsOpenedProductAccess = 6013,
|
||||
|
||||
ProductAccessOpened = 6014,
|
||||
ProductAccessRestricted = 6015, // not used
|
||||
ProductAccessOpened = 6014,
|
||||
ProductAccessRestricted = 6015, // not used
|
||||
|
||||
ProductAddedAdministrator = 6016,
|
||||
ProductDeletedAdministrator = 6017,
|
||||
ProductAddedAdministrator = 6016,
|
||||
ProductDeletedAdministrator = 6017,
|
||||
|
||||
GreetingSettingsUpdated = 6018,
|
||||
TeamTemplateChanged = 6019,
|
||||
ColorThemeChanged = 6020,
|
||||
GreetingSettingsUpdated = 6018,
|
||||
TeamTemplateChanged = 6019,
|
||||
ColorThemeChanged = 6020,
|
||||
|
||||
OwnerSentChangeOwnerInstructions = 6021,
|
||||
OwnerUpdated = 6022,
|
||||
OwnerSentChangeOwnerInstructions = 6021,
|
||||
OwnerUpdated = 6022,
|
||||
|
||||
OwnerSentPortalDeactivationInstructions = 6023,
|
||||
OwnerSentPortalDeleteInstructions = 6024,
|
||||
OwnerSentPortalDeactivationInstructions = 6023,
|
||||
OwnerSentPortalDeleteInstructions = 6024,
|
||||
|
||||
PortalDeactivated = 6025,
|
||||
PortalDeleted = 6026,
|
||||
PortalDeactivated = 6025,
|
||||
PortalDeleted = 6026,
|
||||
|
||||
LoginHistoryReportDownloaded = 6027,
|
||||
AuditTrailReportDownloaded = 6028,
|
||||
LoginHistoryReportDownloaded = 6027,
|
||||
AuditTrailReportDownloaded = 6028,
|
||||
|
||||
SSOEnabled = 6029,
|
||||
SSODisabled = 6030,
|
||||
SSOEnabled = 6029,
|
||||
SSODisabled = 6030,
|
||||
|
||||
PortalAccessSettingsUpdated = 6031,
|
||||
PortalAccessSettingsUpdated = 6031,
|
||||
|
||||
CookieSettingsUpdated = 6032,
|
||||
MailServiceSettingsUpdated = 6033,
|
||||
CookieSettingsUpdated = 6032,
|
||||
MailServiceSettingsUpdated = 6033,
|
||||
|
||||
CustomNavigationSettingsUpdated = 6034,
|
||||
CustomNavigationSettingsUpdated = 6034,
|
||||
|
||||
AuditSettingsUpdated = 6035,
|
||||
AuditSettingsUpdated = 6035,
|
||||
|
||||
TwoFactorAuthenticationDisabled = 6036,
|
||||
TwoFactorAuthenticationEnabledBySms = 6037,
|
||||
TwoFactorAuthenticationEnabledByTfaApp = 6038,
|
||||
TwoFactorAuthenticationDisabled = 6036,
|
||||
TwoFactorAuthenticationEnabledBySms = 6037,
|
||||
TwoFactorAuthenticationEnabledByTfaApp = 6038,
|
||||
|
||||
DocumentServiceLocationSetting = 5037,
|
||||
AuthorizationKeysSetting = 5038,
|
||||
FullTextSearchSetting = 5039,
|
||||
DocumentServiceLocationSetting = 5037,
|
||||
AuthorizationKeysSetting = 5038,
|
||||
FullTextSearchSetting = 5039,
|
||||
|
||||
StartTransferSetting = 5040,
|
||||
StartBackupSetting = 5041,
|
||||
StartTransferSetting = 5040,
|
||||
StartBackupSetting = 5041,
|
||||
|
||||
LicenseKeyUploaded = 5042,
|
||||
LicenseKeyUploaded = 5042,
|
||||
|
||||
StartStorageEncryption = 5050,
|
||||
StartStorageEncryption = 5050,
|
||||
|
||||
PrivacyRoomEnable = 5051,
|
||||
PrivacyRoomDisable = 5052,
|
||||
PrivacyRoomEnable = 5051,
|
||||
PrivacyRoomDisable = 5052,
|
||||
|
||||
StartStorageDecryption = 5053,
|
||||
StartStorageDecryption = 5053,
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region others
|
||||
#region others
|
||||
|
||||
ContactAdminMailSent = 7000,
|
||||
ContactAdminMailSent = 7000,
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Partners
|
||||
#region Partners
|
||||
|
||||
AcceptRequest = 8000,
|
||||
RejectRequest = 8001,
|
||||
BlockPartner = 8002,
|
||||
UnblockPartner = 8003,
|
||||
DeletePartner = 8004,
|
||||
ChangePartner = 8005,
|
||||
ConfirmPortal = 8006,
|
||||
MarkInvoicePaid = 8007,
|
||||
MarkInvoiceUnpaid = 8008,
|
||||
AddHostedPartner = 8009,
|
||||
RemoveHostedPartner = 8010,
|
||||
MarkPartnerAuthorized = 8011,
|
||||
MarkPartnerNotAuthorized = 8012,
|
||||
ChangePartnerLevel = 8013,
|
||||
ChangeHostedPartnerQuotas = 8014,
|
||||
ChangeHostedPartner = 8015,
|
||||
BillLumpSumInvoice = 8016,
|
||||
AcceptRequest = 8000,
|
||||
RejectRequest = 8001,
|
||||
BlockPartner = 8002,
|
||||
UnblockPartner = 8003,
|
||||
DeletePartner = 8004,
|
||||
ChangePartner = 8005,
|
||||
ConfirmPortal = 8006,
|
||||
MarkInvoicePaid = 8007,
|
||||
MarkInvoiceUnpaid = 8008,
|
||||
AddHostedPartner = 8009,
|
||||
RemoveHostedPartner = 8010,
|
||||
MarkPartnerAuthorized = 8011,
|
||||
MarkPartnerNotAuthorized = 8012,
|
||||
ChangePartnerLevel = 8013,
|
||||
ChangeHostedPartnerQuotas = 8014,
|
||||
ChangeHostedPartner = 8015,
|
||||
BillLumpSumInvoice = 8016,
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -23,109 +23,108 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
[Scope]
|
||||
public class MessageFactory
|
||||
{
|
||||
[Scope]
|
||||
public class MessageFactory
|
||||
private readonly ILog _logger;
|
||||
private const string UserAgentHeader = "User-Agent";
|
||||
private const string ForwardedHeader = "X-Forwarded-For";
|
||||
private const string HostHeader = "Host";
|
||||
private const string RefererHeader = "Referer";
|
||||
|
||||
private readonly AuthContext _authContext;
|
||||
private readonly TenantManager _tenantManager;
|
||||
|
||||
public MessageFactory(AuthContext authContext, TenantManager tenantManager, IOptionsMonitor<ILog> options)
|
||||
{
|
||||
private readonly ILog _logger;
|
||||
private const string UserAgentHeader = "User-Agent";
|
||||
private const string ForwardedHeader = "X-Forwarded-For";
|
||||
private const string HostHeader = "Host";
|
||||
private const string RefererHeader = "Referer";
|
||||
_authContext = authContext;
|
||||
_tenantManager = tenantManager;
|
||||
_logger = options.CurrentValue;
|
||||
}
|
||||
|
||||
private readonly AuthContext _authContext;
|
||||
private readonly TenantManager _tenantManager;
|
||||
|
||||
public MessageFactory(AuthContext authContext, TenantManager tenantManager, IOptionsMonitor<ILog> options)
|
||||
public EventMessage Create(HttpRequest request, string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
try
|
||||
{
|
||||
_authContext = authContext;
|
||||
_tenantManager = tenantManager;
|
||||
_logger = options.CurrentValue;
|
||||
return new EventMessage
|
||||
{
|
||||
IP = request != null ? request.Headers[ForwardedHeader].ToString() ?? request.GetUserHostAddress() : null,
|
||||
Initiator = initiator,
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = _tenantManager.GetCurrentTenant().TenantId,
|
||||
UserId = _authContext.CurrentAccount.ID,
|
||||
Page = request?.GetTypedHeaders().Referer?.ToString(),
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target,
|
||||
UAHeader = request?.Headers[UserAgentHeader].FirstOrDefault()
|
||||
};
|
||||
}
|
||||
|
||||
public EventMessage Create(HttpRequest request, string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new EventMessage
|
||||
{
|
||||
IP = request != null ? request.Headers[ForwardedHeader].ToString() ?? request.GetUserHostAddress() : null,
|
||||
Initiator = initiator,
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = _tenantManager.GetCurrentTenant().TenantId,
|
||||
UserId = _authContext.CurrentAccount.ID,
|
||||
Page = request?.GetTypedHeaders().Referer?.ToString(),
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target,
|
||||
UAHeader = request?.Headers[UserAgentHeader].FirstOrDefault()
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorFormat("Error while parse Http Request for {0} type of event: {1}", action, ex);
|
||||
_logger.ErrorFormat("Error while parse Http Request for {0} type of event: {1}", action, ex);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public EventMessage Create(MessageUserData userData, IDictionary<string, StringValues> headers, MessageAction action, MessageTarget target, params string[] description)
|
||||
public EventMessage Create(MessageUserData userData, IDictionary<string, StringValues> headers, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
var message = new EventMessage
|
||||
{
|
||||
var message = new EventMessage
|
||||
{
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = userData == null ? _tenantManager.GetCurrentTenant().TenantId : userData.TenantId,
|
||||
UserId = userData == null ? _authContext.CurrentAccount.ID : userData.UserId,
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target
|
||||
};
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = userData == null ? _tenantManager.GetCurrentTenant().TenantId : userData.TenantId,
|
||||
UserId = userData == null ? _authContext.CurrentAccount.ID : userData.UserId,
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target
|
||||
};
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
var userAgent = headers.ContainsKey(UserAgentHeader) ? headers[UserAgentHeader].ToString() : null;
|
||||
var forwarded = headers.ContainsKey(ForwardedHeader) ? headers[ForwardedHeader].ToString() : null;
|
||||
var host = headers.ContainsKey(HostHeader) ? headers[HostHeader].ToString() : null;
|
||||
var referer = headers.ContainsKey(RefererHeader) ? headers[RefererHeader].ToString() : null;
|
||||
|
||||
message.IP = forwarded ?? host;
|
||||
message.UAHeader = userAgent;
|
||||
message.Page = referer;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
catch (Exception ex)
|
||||
if (headers != null)
|
||||
{
|
||||
_logger.Error(string.Format("Error while parse Http Message for \"{0}\" type of event: {1}", action, ex));
|
||||
var userAgent = headers.ContainsKey(UserAgentHeader) ? headers[UserAgentHeader].ToString() : null;
|
||||
var forwarded = headers.ContainsKey(ForwardedHeader) ? headers[ForwardedHeader].ToString() : null;
|
||||
var host = headers.ContainsKey(HostHeader) ? headers[HostHeader].ToString() : null;
|
||||
var referer = headers.ContainsKey(RefererHeader) ? headers[RefererHeader].ToString() : null;
|
||||
|
||||
return null;
|
||||
message.IP = forwarded ?? host;
|
||||
message.UAHeader = userAgent;
|
||||
message.Page = referer;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public EventMessage Create(string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new EventMessage
|
||||
{
|
||||
Initiator = initiator,
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = _tenantManager.GetCurrentTenant().TenantId,
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(string.Format("Error while parse Initiator Message for \"{0}\" type of event: {1}", action, ex));
|
||||
_logger.Error(string.Format("Error while parse Http Message for \"{0}\" type of event: {1}", action, ex));
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public EventMessage Create(string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new EventMessage
|
||||
{
|
||||
Initiator = initiator,
|
||||
Date = DateTime.UtcNow,
|
||||
TenantId = _tenantManager.GetCurrentTenant().TenantId,
|
||||
Action = action,
|
||||
Description = description,
|
||||
Target = target
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(string.Format("Error while parse Initiator Message for \"{0}\" type of event: {1}", action, ex));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -24,12 +24,11 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
public enum MessageInitiator
|
||||
{
|
||||
public enum MessageInitiator
|
||||
{
|
||||
System,
|
||||
DocsService,
|
||||
ThirdPartyProvider,
|
||||
}
|
||||
System,
|
||||
DocsService,
|
||||
ThirdPartyProvider,
|
||||
}
|
@ -23,48 +23,47 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
[Singletone]
|
||||
public class MessagePolicy
|
||||
{
|
||||
[Singletone]
|
||||
public class MessagePolicy
|
||||
private readonly IEnumerable<string> _secretIps;
|
||||
|
||||
public MessagePolicy(IConfiguration configuration)
|
||||
{
|
||||
private readonly IEnumerable<string> _secretIps;
|
||||
_secretIps =
|
||||
configuration["messaging.secret-ips"] == null
|
||||
? Array.Empty<string>()
|
||||
: configuration["messaging.secret-ips"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public MessagePolicy(IConfiguration configuration)
|
||||
public bool Check(EventMessage message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
_secretIps =
|
||||
configuration["messaging.secret-ips"] == null
|
||||
? Array.Empty<string>()
|
||||
: configuration["messaging.secret-ips"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Check(EventMessage message)
|
||||
if (string.IsNullOrEmpty(message.IP))
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(message.IP))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var ip = GetIpWithoutPort(message.IP);
|
||||
|
||||
return _secretIps.All(x => x != ip);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string GetIpWithoutPort(string ip)
|
||||
var ip = GetIpWithoutPort(message.IP);
|
||||
|
||||
return _secretIps.All(x => x != ip);
|
||||
}
|
||||
|
||||
private static string GetIpWithoutPort(string ip)
|
||||
{
|
||||
if (ip == null)
|
||||
{
|
||||
if (ip == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var portIdx = ip.IndexOf(':');
|
||||
|
||||
return portIdx > -1 ? ip.Substring(0, portIdx) : ip;
|
||||
return null;
|
||||
}
|
||||
|
||||
var portIdx = ip.IndexOf(':');
|
||||
|
||||
return portIdx > -1 ? ip.Substring(0, portIdx) : ip;
|
||||
}
|
||||
}
|
@ -23,284 +23,283 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
[Scope]
|
||||
public class MessageService
|
||||
{
|
||||
[Scope]
|
||||
public class MessageService
|
||||
private readonly ILog _logger;
|
||||
private readonly IMessageSender _sender;
|
||||
private readonly HttpRequest _request;
|
||||
private readonly MessageFactory _messageFactory;
|
||||
private readonly MessagePolicy _messagePolicy;
|
||||
|
||||
public MessageService(
|
||||
IConfiguration configuration,
|
||||
MessageFactory messageFactory,
|
||||
DbMessageSender sender,
|
||||
MessagePolicy messagePolicy,
|
||||
IOptionsMonitor<ILog> options)
|
||||
{
|
||||
private readonly ILog _logger;
|
||||
private readonly IMessageSender _sender;
|
||||
private readonly HttpRequest _request;
|
||||
private readonly MessageFactory _messageFactory;
|
||||
private readonly MessagePolicy _messagePolicy;
|
||||
|
||||
public MessageService(
|
||||
IConfiguration configuration,
|
||||
MessageFactory messageFactory,
|
||||
DbMessageSender sender,
|
||||
MessagePolicy messagePolicy,
|
||||
IOptionsMonitor<ILog> options)
|
||||
if (configuration["messaging:enabled"] != "true")
|
||||
{
|
||||
if (configuration["messaging:enabled"] != "true")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sender = sender;
|
||||
_messagePolicy = messagePolicy;
|
||||
_messageFactory = messageFactory;
|
||||
_logger = options.CurrentValue;
|
||||
return;
|
||||
}
|
||||
|
||||
public MessageService(
|
||||
IConfiguration configuration,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
MessageFactory messageFactory,
|
||||
DbMessageSender sender,
|
||||
MessagePolicy messagePolicy,
|
||||
IOptionsMonitor<ILog> options)
|
||||
: this(configuration, messageFactory, sender, messagePolicy, options)
|
||||
_sender = sender;
|
||||
_messagePolicy = messagePolicy;
|
||||
_messageFactory = messageFactory;
|
||||
_logger = options.CurrentValue;
|
||||
}
|
||||
|
||||
public MessageService(
|
||||
IConfiguration configuration,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
MessageFactory messageFactory,
|
||||
DbMessageSender sender,
|
||||
MessagePolicy messagePolicy,
|
||||
IOptionsMonitor<ILog> options)
|
||||
: this(configuration, messageFactory, sender, messagePolicy, options)
|
||||
{
|
||||
_request = httpContextAccessor?.HttpContext?.Request;
|
||||
}
|
||||
|
||||
#region HttpRequest
|
||||
|
||||
public void Send(MessageAction action)
|
||||
{
|
||||
SendRequestMessage(null, action, null);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, string d3)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, d3);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, string d3, string d4)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, d3, d4);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, IEnumerable<string> d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, null, string.Join(", ", d1), d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, IEnumerable<string> d2)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, string.Join(", ", d2));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, IEnumerable<string> d3)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, string.Join(", ", d3));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, IEnumerable<string> d1)
|
||||
{
|
||||
SendRequestMessage(null, action, null, string.Join(", ", d1));
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action)
|
||||
{
|
||||
SendRequestMessage(loginName, action, null);
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, string d1)
|
||||
{
|
||||
SendRequestMessage(loginName, action, null, d1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HttpRequest & Target
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendRequestMessage(null, action, target);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, string d3)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, d3);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, string d3, string d4)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, d3, d4);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, IEnumerable<string> d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, string.Join(", ", d1), d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, IEnumerable<string> d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, string.Join(", ", d2));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, IEnumerable<string> d3)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, string.Join(", ", d3));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, IEnumerable<string> d1)
|
||||
{
|
||||
SendRequestMessage(null, action, target, string.Join(", ", d1));
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendRequestMessage(loginName, action, target);
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendRequestMessage(loginName, action, target, d1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendRequestMessage(string loginName, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
_request = httpContextAccessor?.HttpContext?.Request;
|
||||
return;
|
||||
}
|
||||
|
||||
#region HttpRequest
|
||||
|
||||
public void Send(MessageAction action)
|
||||
if (_request == null)
|
||||
{
|
||||
SendRequestMessage(null, action, null);
|
||||
_logger.Debug(string.Format("Empty Http Request for \"{0}\" type of event", action));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1)
|
||||
var message = _messageFactory.Create(_request, loginName, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2)
|
||||
_sender.Send(message);
|
||||
}
|
||||
|
||||
#region HttpHeaders
|
||||
|
||||
public void Send(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action)
|
||||
{
|
||||
SendHeadersMessage(userData, httpHeaders, action, null);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, string d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null, d1);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, IEnumerable<string> d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null, d1?.ToArray());
|
||||
}
|
||||
|
||||
public void Send(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendHeadersMessage(userData, httpHeaders, action, target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HttpHeaders & Target
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target, d1);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, IEnumerable<string> d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target, d1?.ToArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendHeadersMessage(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, string d3)
|
||||
var message = _messageFactory.Create(userData, httpHeaders, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, d3);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, string d3, string d4)
|
||||
_sender.Send(message);
|
||||
}
|
||||
|
||||
#region Initiator
|
||||
|
||||
public void Send(MessageInitiator initiator, MessageAction action, params string[] description)
|
||||
{
|
||||
SendInitiatorMessage(initiator.ToString(), action, null, description);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initiator & Target
|
||||
|
||||
public void Send(MessageInitiator initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
SendInitiatorMessage(initiator.ToString(), action, target, description);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendInitiatorMessage(string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, d3, d4);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, IEnumerable<string> d1, string d2)
|
||||
var message = _messageFactory.Create(_request, initiator, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
SendRequestMessage(null, action, null, string.Join(", ", d1), d2);
|
||||
return;
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, IEnumerable<string> d2)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, string.Join(", ", d2));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, string d1, string d2, IEnumerable<string> d3)
|
||||
{
|
||||
SendRequestMessage(null, action, null, d1, d2, string.Join(", ", d3));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, IEnumerable<string> d1)
|
||||
{
|
||||
SendRequestMessage(null, action, null, string.Join(", ", d1));
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action)
|
||||
{
|
||||
SendRequestMessage(loginName, action, null);
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, string d1)
|
||||
{
|
||||
SendRequestMessage(loginName, action, null, d1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HttpRequest & Target
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendRequestMessage(null, action, target);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, string d3)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, d3);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, string d3, string d4)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, d3, d4);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, IEnumerable<string> d1, string d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, string.Join(", ", d1), d2);
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, IEnumerable<string> d2)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, string.Join(", ", d2));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, string d1, string d2, IEnumerable<string> d3)
|
||||
{
|
||||
SendRequestMessage(null, action, target, d1, d2, string.Join(", ", d3));
|
||||
}
|
||||
|
||||
public void Send(MessageAction action, MessageTarget target, IEnumerable<string> d1)
|
||||
{
|
||||
SendRequestMessage(null, action, target, string.Join(", ", d1));
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendRequestMessage(loginName, action, target);
|
||||
}
|
||||
|
||||
public void Send(string loginName, MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendRequestMessage(loginName, action, target, d1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendRequestMessage(string loginName, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_request == null)
|
||||
{
|
||||
_logger.Debug(string.Format("Empty Http Request for \"{0}\" type of event", action));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var message = _messageFactory.Create(_request, loginName, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sender.Send(message);
|
||||
}
|
||||
|
||||
#region HttpHeaders
|
||||
|
||||
public void Send(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action)
|
||||
{
|
||||
SendHeadersMessage(userData, httpHeaders, action, null);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, string d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null, d1);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, IEnumerable<string> d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, null, d1?.ToArray());
|
||||
}
|
||||
|
||||
public void Send(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendHeadersMessage(userData, httpHeaders, action, target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HttpHeaders & Target
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, string d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target, d1);
|
||||
}
|
||||
|
||||
public void Send(IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, IEnumerable<string> d1)
|
||||
{
|
||||
SendHeadersMessage(null, httpHeaders, action, target, d1?.ToArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendHeadersMessage(MessageUserData userData, IDictionary<string, StringValues> httpHeaders, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = _messageFactory.Create(userData, httpHeaders, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sender.Send(message);
|
||||
}
|
||||
|
||||
#region Initiator
|
||||
|
||||
public void Send(MessageInitiator initiator, MessageAction action, params string[] description)
|
||||
{
|
||||
SendInitiatorMessage(initiator.ToString(), action, null, description);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initiator & Target
|
||||
|
||||
public void Send(MessageInitiator initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
SendInitiatorMessage(initiator.ToString(), action, target, description);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SendInitiatorMessage(string initiator, MessageAction action, MessageTarget target, params string[] description)
|
||||
{
|
||||
if (_sender == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = _messageFactory.Create(_request, initiator, action, target, description);
|
||||
if (!_messagePolicy.Check(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sender.Send(message);
|
||||
}
|
||||
_sender.Send(message);
|
||||
}
|
||||
}
|
@ -23,91 +23,90 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
[Singletone]
|
||||
public class MessageTarget
|
||||
{
|
||||
[Singletone]
|
||||
public class MessageTarget
|
||||
private IEnumerable<string> _items;
|
||||
|
||||
public ILog Log { get; set; }
|
||||
private readonly IOptionsMonitor<ILog> _option;
|
||||
|
||||
public MessageTarget(IOptionsMonitor<ILog> option)
|
||||
{
|
||||
private IEnumerable<string> _items;
|
||||
Log = option.Get("ASC.Messaging");
|
||||
_option = option;
|
||||
}
|
||||
|
||||
public ILog Log { get; set; }
|
||||
private readonly IOptionsMonitor<ILog> _option;
|
||||
|
||||
public MessageTarget(IOptionsMonitor<ILog> option)
|
||||
public MessageTarget Create<T>(T value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log = option.Get("ASC.Messaging");
|
||||
_option = option;
|
||||
}
|
||||
var res = new List<string>();
|
||||
|
||||
public MessageTarget Create<T>(T value)
|
||||
{
|
||||
try
|
||||
if (value is System.Collections.IEnumerable ids)
|
||||
{
|
||||
var res = new List<string>();
|
||||
|
||||
if (value is System.Collections.IEnumerable ids)
|
||||
{
|
||||
res.AddRange(from object id in ids select id.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Add(value.ToString());
|
||||
}
|
||||
|
||||
return new MessageTarget(_option)
|
||||
{
|
||||
_items = res.Distinct()
|
||||
};
|
||||
res.AddRange(from object id in ids select id.ToString());
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
Log.Error("EventMessageTarget exception", e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MessageTarget Create(IEnumerable<string> value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new MessageTarget(_option)
|
||||
{
|
||||
_items = value.Distinct()
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("EventMessageTarget exception", e);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public MessageTarget Parse(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var items = value.Split(',');
|
||||
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return null;
|
||||
res.Add(value.ToString());
|
||||
}
|
||||
|
||||
return new MessageTarget(_option)
|
||||
{
|
||||
_items = items
|
||||
_items = res.Distinct()
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
catch (Exception e)
|
||||
{
|
||||
return string.Join(",", _items);
|
||||
Log.Error("EventMessageTarget exception", e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MessageTarget Create(IEnumerable<string> value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new MessageTarget(_option)
|
||||
{
|
||||
_items = value.Distinct()
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("EventMessageTarget exception", e);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public MessageTarget Parse(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var items = value.Split(',');
|
||||
|
||||
if (items.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new MessageTarget(_option)
|
||||
{
|
||||
_items = items
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", _items);
|
||||
}
|
||||
}
|
@ -23,17 +23,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.MessagingSystem
|
||||
{
|
||||
public class MessageUserData
|
||||
{
|
||||
public int TenantId { get; private set; }
|
||||
public Guid UserId { get; private set; }
|
||||
namespace ASC.MessagingSystem;
|
||||
|
||||
public MessageUserData(int tenentId, Guid userId)
|
||||
{
|
||||
TenantId = tenentId;
|
||||
UserId = userId;
|
||||
}
|
||||
public class MessageUserData
|
||||
{
|
||||
public int TenantId { get; private set; }
|
||||
public Guid UserId { get; private set; }
|
||||
|
||||
public MessageUserData(int tenentId, Guid userId)
|
||||
{
|
||||
TenantId = tenentId;
|
||||
UserId = userId;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user