Beispiel #1
0
        private async Task RecevicedMyTopic(MqttApplicationMessageReceivedEventArgs e)
        {
            var    payload = e.ApplicationMessage.Payload;
            string result  = System.Text.Encoding.UTF8.GetString(payload);
            var    MyTopic = JsonConvert.DeserializeObject <MyTopic>(result);

            Console.WriteLine($"Raw data = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}");
            try
            {
                using (var context = new DBContext())
                {
                    var results = new RawDatas()
                    {
                        TimeRecieve = Convert.ToDateTime(MyTopic.Timestamp),
                        Count       = MyTopic.boxCount.ToInt(),
                        Camera      = MyTopic.Cam,
                        Line        = MyTopic.Line
                    };
                    context.RawDatas.Add(results);
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
 private PartialRawData BaseArray()
 {
     return(RawDatas.FirstOrDefault(o => (o.Code == 0xD0) || (o.Code == 0xf8)));
 }