Beispiel #1
0
 public void SendCommand(ToggleDoorCommand command)
 {
     if (!IsConnected())
     {
         Connect();
     }
     if (IsConnected())
     {
         var messageBody = SerializeToggleDoorCommand(command);
         var messageProperties = GetMessageProperties(command.DoorNumber, command.GetType().Name);
         _model.BasicPublish(_config.RabbitMqExchangeName, _config.RabbitMqRoutingKey, messageProperties, messageBody);
     }
 }
Beispiel #2
0
        private void btnRight_Click(object sender, RoutedEventArgs e)
        {
            var cmd = new ToggleDoorCommand
            {
                DoorNumber = 2,
                Created = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                Expiry = DateTime.Now.AddSeconds(30).ToString(CultureInfo.InvariantCulture),
                SessionId = Guid.NewGuid().ToString(),
                Signature = string.Empty
            };

            SendCommand(cmd);
        }
Beispiel #3
0
 //private static byte[] SerializeToggleDoorCommand(ToggleDoorCommand command)
 //{
 //    byte[] serialized;
 //    using (var mso = new MemoryStream())
 //    {
 //        ProtoBuf.Serializer.Serialize(mso, command);
 //        mso.Position = 0;
 //        serialized = mso.ToArray();
 //    }
 //    return serialized;
 //}
 private static byte[] SerializeToggleDoorCommand(ToggleDoorCommand command)
 {
     var text = JsonConvert.SerializeObject(command);
     return System.Text.Encoding.UTF8.GetBytes(text);
 }