Exemple #1
0
 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;
 }
        private static void SendInitiatorMessage(HttpRequest request, 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);
        }
        private static void SendHeadersMessage(MessageUserData userData, Dictionary <string, string> 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);
        }
Exemple #4
0
        public MessageService(
            IConfiguration configuration,
            MessageFactory messageFactory,
            DbMessageSender sender,
            MessagePolicy messagePolicy,
            IOptionsMonitor <ILog> options)
        {
            if (configuration["messaging:enabled"] != "true")
            {
                return;
            }

            this.sender    = sender;
            MessagePolicy  = messagePolicy;
            MessageFactory = messageFactory;
            log            = options.CurrentValue;
        }
Exemple #5
0
        public static int SendLoginMessage(HttpRequest request, MessageUserData userData, MessageAction action)
        {
            if (sender == null)
            {
                return(0);
            }

            var message = MessageFactory.Create(request, userData, action);

            if (!MessagePolicy.Check(message))
            {
                return(0);
            }

            var id = sender.Send(message);

            return(id);
        }
Exemple #6
0
        public MessageService(
            IConfiguration configuration,
            IHttpContextAccessor httpContextAccessor,
            MessageFactory messageFactory,
            DbMessageSender sender,
            MessagePolicy messagePolicy,
            IOptionsMonitor <ILog> options)
        {
            if (configuration["messaging:enabled"] != "true")
            {
                return;
            }

            this.sender    = sender;
            MessagePolicy  = messagePolicy;
            request        = httpContextAccessor?.HttpContext?.Request;
            MessageFactory = messageFactory;
            log            = options.CurrentValue;
        }
        private static void SendRequestMessage(HttpRequest request, string loginName, MessageAction action, MessageTarget target, params string[] description)
        {
            if (sender == null)
            {
                return;
            }

            if (request == null)
            {
                log.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);
        }
        private static void SendHeadersMessage(Dictionary <string, string> httpHeaders, MessageAction action, params string[] description)
        {
            if (sender == null)
            {
                return;
            }

            if (httpHeaders == null)
            {
                log.Debug(string.Format("Empty Request Headers for \"{0}\" type of event", action));
                return;
            }

            var message = MessageFactory.Create(httpHeaders, action, description);

            if (!MessagePolicy.Check(message))
            {
                return;
            }

            sender.Send(message);
        }
        private static void SendApiMessage(ApiContext context, string loginName, MessageAction action, params string[] description)
        {
            if (sender == null)
            {
                return;
            }

            if (context == null)
            {
                log.Debug(string.Format("Empty Api Context for \"{0}\" type of event", action));
                return;
            }

            var message = MessageFactory.Create(context, loginName, action, description);

            if (!MessagePolicy.Check(message))
            {
                return;
            }

            sender.Send(message);
        }