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