Пример #1
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]    buffResp = { 1 };
            DbHandler db       = new DbHandler();

            NetStructure.DeviceMaterial outInfo = this.DecodeData(buff);
            Machines            machine         = db.SelectMachine(outInfo.MachineId);
            Schedules           schedule        = db.SelectSchedule(outInfo.ScheduleNumber);
            MachineCallMaterial innerInfo       = this.exchangeData(machine, schedule);

            //记录原始数据
            db.InsertMachineCallMaterial(innerInfo);

            buffResp[0] = 0;

            return(buffResp);
        }
Пример #2
0
        /// <summary>
        /// 客户端返回消息解码
        /// </summary>
        /// <param name="buff"></param>
        /// <returns></returns>
        private NetStructure.DeviceMaterial DecodeData(byte[] buff)
        {
            NetStructure.DeviceMaterial info = new NetStructure.DeviceMaterial();
            byte[] tempData = buff;
            //机器码
            int locIdx = 2;

            info.MachineId = ConvertHelper.BytesToInt16(tempData, 0, true);
            //施工单编码
            int tempLen = tempData[locIdx++];

            byte[] scheduleByte = new byte[tempLen];
            Array.Copy(tempData, locIdx, scheduleByte, 0, tempLen);
            info.ScheduleNumber = Encoding.ASCII.GetString(scheduleByte);

            return(info);
        }