示例#1
0
        public SensorSetStatusResponse SendToBus(SensorSetStatusRequest sensorSetStatusRequest)
        {
            var factory = new ConnectionFactory() {
                HostName = this._hostName
            };

            using (var connection = factory.CreateConnection()) {
                using (var channel = connection.CreateModel()) {

                    channel.QueueDeclare(this._queueName, true, false, false, null);

                    string message = Newtonsoft.Json.JsonConvert.SerializeObject(sensorSetStatusRequest);

                    var body = Encoding.UTF8.GetBytes(message);

                    channel.BasicPublish(exchange: "",
                                         routingKey: this._queueName,
                                         basicProperties: null,
                                         body: body);
                }
            }

            return new SensorSetStatusResponse() {
                success = true
            };
        }
 public IHttpActionResult SetStatusAsync(SensorSetStatusRequest sensorSetStatusRequest)
 {
     try {
         //Retorno
         return Ok(this.ManagerMsg.Execute(sensorSetStatusRequest));
     } catch (Exception ex) {
         //Informa o erro interno
         return InternalServerError(ex);
     }
 }
示例#3
0
 public SensorSetStatusResponse Execute(SensorSetStatusRequest sensorSetStatusRequest)
 {
     return this.ProcessMsg.SendToBus(sensorSetStatusRequest);
 }