Exemplo n.º 1
0
        public async Task Publish(IExternalCommand command)
        {
            var factory = new ConnectionFactory {
                HostName = config.HostName, UserName = "******", Password = "******"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: command.GetType().Name, durable: true, exclusive: false, autoDelete: false,
                                         arguments: null);

                    var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(command));
                    channel.BasicPublish(exchange: "", routingKey: command.GetType().Name, basicProperties: null, body: body);
                }
            //_channel.BasicPublish("logs", routingKey: "Commands.ValidUser", basicProperties: null, body: body);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a push button data.
        /// </summary>
        /// <returns></returns>
        public static PushButtonData CreatePushButtonData(this IExternalCommand cmd, string text, ImageSource image, bool isAvailable = false)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            var type = cmd.GetType();

            return(new PushButtonData(type.Name, text, type.Assembly.Location, type.FullName)
            {
                LargeImage = image,
                AvailabilityClassName = isAvailable ? type.FullName : null
            });
        }