Esempio n. 1
0
 /// <summary>
 /// 内外部数据转换
 /// </summary>
 /// <param name="info"></param>
 /// <param name="machine"></param>
 /// <returns></returns>
 private Models.HeartBreak exchangeData(HeartBreak info, Machines machine)
 {
     return(new Models.HeartBreak()
     {
         DateCreate = DateTime.Now,
         ChannelInfo = info.ChannelInfo,
         MachineId = machine.ID,
         MachineName = machine.Number
     });
 }
Esempio n. 2
0
        /// <summary>
        /// 客户端返回消息解码
        /// </summary>
        /// <param name="buff"></param>
        /// <returns></returns>
        private HeartBreak DecodeData(byte[] buff)
        {
            HeartBreak info = new HeartBreak();

            byte[] tempData = buff;
            info.MachineId   = ConvertHelper.BytesToInt16(tempData, true);
            info.ChannelInfo = tempData[2];

            return(info);
        }
Esempio n. 3
0
        public byte[] HandlerClientData(byte[] buff)
        {
            DbTableDbContext db      = new DbTableDbContext();
            HeartBreak       outInfo = this.DecodeData(buff);
            Machines         machine = db.Machines.Find(outInfo.MachineId);

            Models.HeartBreak innerInfo = this.exchangeData(outInfo, machine);
            //记录原始数据
            db.HeartBreak.Add(innerInfo);
            //记录设备状态
            RefreshOnlineInfo(machine, db);

            db.SaveChanges();
            byte[] resp = {};
            return(resp);
        }