Exemple #1
0
        public int InsertProductInfo(NetStructure.ProductInfo info)
        {
            int intRsp = 0;

            using (SqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "sp_Insert_ProductInfo";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MachineId", info.MachineId);
                cmd.Parameters.AddWithValue("@ScheduleNumber", info.ScheduleNumber);
                cmd.Parameters.AddWithValue("@ChannelCount", info.ChannelCount);
                cmd.Parameters.AddWithValue("@StaffNumber", info.StaffNumber);
                cmd.Parameters.AddWithValue("@StaffName", info.StaffName);
                cmd.Parameters.AddWithValue("@MsgStatus", (int)info.MsgStatus);
                cmd.Parameters.AddWithValue("@ChannelFinish1", info.ChannelFinish1);
                cmd.Parameters.AddWithValue("@ChannelFinish2", info.ChannelFinish2);
                cmd.Parameters.AddWithValue("@ChannelFinish3", info.ChannelFinish3);
                cmd.Parameters.AddWithValue("@ChannelFinish4", info.ChannelFinish4);
                cmd.Parameters.AddWithValue("@ChannelFinish5", info.ChannelFinish5);
                cmd.Parameters.AddWithValue("@ChannelFinish6", info.ChannelFinish6);
                cmd.Parameters.AddWithValue("@UnusualCount", info.UnusualCount);

                object objRsp = cmd.ExecuteScalar();
                intRsp = Convert.ToInt32(objRsp);
            }
            return(intRsp);
        }
Exemple #2
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]    buffResp = { 0 };
            DbHandler db       = new DbHandler();

            NetStructure.ProductInfo outInfo = this.DecodeData(buff);
            db.InsertProductInfo(outInfo);

            buffResp[0] = 0;
            return(buffResp);
        }
Exemple #3
0
        /// <summary>
        /// 上传生产情况解码
        /// </summary>
        /// <param name="buff"></param>
        /// <returns></returns>
        private NetStructure.ProductInfo DecodeData(byte[] buff)
        {
            NetStructure.ProductInfo info = new NetStructure.ProductInfo();
            byte[] tempData = buff;
            //机器码
            int locIdx = 0;

            info.MachineId = decodeByte2Int(tempData, ref locIdx, 2);
            //施工单编码
            int tempLen = tempData[locIdx++];

            byte[] scheduleByte = new byte[tempLen];
            Array.Copy(tempData, locIdx, scheduleByte, 0, tempLen);
            info.ScheduleNumber = Encoding.ASCII.GetString(scheduleByte);
            locIdx += tempLen;
            //通道数
            info.ChannelCount = tempData[locIdx++];
            //工号
            tempLen = tempData[locIdx++];
            byte[] numberByte = new byte[tempLen];
            Array.Copy(tempData, locIdx, numberByte, 0, tempLen);
            info.StaffNumber = Encoding.ASCII.GetString(numberByte);
            locIdx          += tempLen;
            //姓名
            tempLen = tempData[locIdx++];
            byte[] nameByte = new byte[tempLen];
            Array.Copy(tempData, locIdx, nameByte, 0, tempLen);
            info.StaffName = Encoding.GetEncoding("GBK").GetString(nameByte);
            locIdx        += tempLen;
            //状态标志位
            info.MsgStatus = (enumProductType)tempData[locIdx++];
            //各通道已完成数
            info.ChannelFinish1 = decodeByte2Int(tempData, ref locIdx, 4);
            info.ChannelFinish2 = decodeByte2Int(tempData, ref locIdx, 4);
            info.ChannelFinish3 = decodeByte2Int(tempData, ref locIdx, 4);
            info.ChannelFinish4 = decodeByte2Int(tempData, ref locIdx, 4);
            info.ChannelFinish5 = decodeByte2Int(tempData, ref locIdx, 4);
            info.ChannelFinish6 = decodeByte2Int(tempData, ref locIdx, 4);
            //异常数
            info.UnusualCount = decodeByte2Int(tempData, ref locIdx, 4);

            return(info);
        }
Exemple #4
0
        public void HandlerTest()
        {
            DbHandler db = new DbHandler();

            NetStructure.ProductInfo outInfo = new NetStructure.ProductInfo()
            {
                ChannelCount   = 6,
                ChannelFinish1 = 50944,
                ChannelFinish2 = 52079,
                ChannelFinish3 = 51180,
                ChannelFinish4 = 51909,
                ChannelFinish5 = 5,
                ChannelFinish6 = 3,
                UnusualCount   = 10,
                StaffNumber    = "111",
                StaffName      = "咦咦咦",
                MsgStatus      = enumProductType.LoginIn,
                ScheduleNumber = "11111-0012",
                MachineId      = 15
            };
            db.InsertProductInfo(outInfo);
        }