Example #1
0
        /// <summary>
        /// 施工单操作编码
        /// </summary>
        /// <param name="schedule"></param>
        /// <param name="buff"></param>
        public static void EncodeScheHandler(ZdflCount.Models.Schedules schedule, enumCommandType command, out byte[] buff)
        {
            byte[] content = new byte[1024];
            int    locIdx = 0, tempLen = 2;

            //机器码
            byte[] machineBytes = ConvertHelper.Int16ToBytes(schedule.MachineId, true);
            Array.Copy(machineBytes, content, tempLen);
            locIdx += tempLen;
            //施工单编号
            byte[] numberBytes = Encoding.ASCII.GetBytes(schedule.Number);
            tempLen           = numberBytes.Length;
            content[locIdx++] = (byte)tempLen;
            Array.Copy(numberBytes, 0, content, locIdx, tempLen);
            locIdx += tempLen;

            NormalDataStruct data = new NormalDataStruct()
            {
                Code       = command,
                contentLen = locIdx,
                Content    = content
            };

            EncodeData(data, out buff);
        }
Example #2
0
        /// <summary>
        /// 下派施工单编码
        /// </summary>
        /// <param name="buff"></param>
        public static void EncodeSchedule(ZdflCount.Models.Schedules schedule, out byte[] buff)
        {
            byte[] content = new  byte[1024];
            int    locIdx = 0, tempLen = 2;

            //机器码
            byte[] machineBytes = ConvertHelper.Int16ToBytes(schedule.MachineId, true);
            Array.Copy(machineBytes, content, tempLen);
            locIdx += tempLen;
            //施工单编号
            byte[] numberBytes = Encoding.ASCII.GetBytes(schedule.Number);
            tempLen           = numberBytes.Length;
            content[locIdx++] = (byte)tempLen;
            Array.Copy(numberBytes, 0, content, locIdx, tempLen);
            locIdx += tempLen;
            //施工单商品总数量
            byte[] countByte = ConvertHelper.Int32ToBytes(schedule.ProductCount, true);
            Array.Copy(countByte, 0, content, locIdx, 4);
            locIdx += 4;
            //上跳持续数量
            countByte = ConvertHelper.Int16ToBytes(schedule.UpContinueCount, true);
            Array.Copy(countByte, 0, content, locIdx, 2);
            locIdx += 2;
            //落下持续数量
            countByte = ConvertHelper.Int16ToBytes(schedule.DownContinueCount, true);
            Array.Copy(countByte, 0, content, locIdx, 2);
            locIdx += 2;
            //详细信息
            byte[] detailBytes = Encoding.GetEncoding("GBK").GetBytes(schedule.DetailInfo);
            tempLen = detailBytes.Length;
            byte[] lengthByte = ConvertHelper.Int16ToBytes(tempLen, true);
            Array.Copy(lengthByte, 0, content, locIdx, 2);
            locIdx += 2;
            Array.Copy(detailBytes, 0, content, locIdx, tempLen);
            locIdx += tempLen;
            //注意事项
            byte[] noticeBytes = Encoding.GetEncoding("GBK").GetBytes(schedule.NoticeInfo);
            tempLen    = noticeBytes.Length;
            lengthByte = ConvertHelper.Int16ToBytes(tempLen, true);
            Array.Copy(lengthByte, 0, content, locIdx, 2);
            locIdx += 2;
            Array.Copy(noticeBytes, 0, content, locIdx, tempLen);
            locIdx += tempLen;

            NormalDataStruct data = new NormalDataStruct()
            {
                Code       = enumCommandType.DOWN_SHEDULE_SEND,
                contentLen = locIdx,
                Content    = content
            };

            EncodeData(data, out buff);
        }