Пример #1
0
        public byte[] HandlerClientData(byte[] buff)
        {
            byte[]           buffResp = { 0 };
            DbTableDbContext db       = new DbTableDbContext();
            ProductInfo      outInfo  = this.DecodeData(buff);

            Models.ProductInfo lastInfo = db.ProductInfo.OrderByDescending(tmpItem => tmpItem.ID).FirstOrDefault(item => item.MachineId == outInfo.MachineId);
            Machines           machine  = db.Machines.Find(outInfo.MachineId);

            Models.ProductInfo innerInfo = this.exchangeData(outInfo, machine);
            //记录原始数据
            db.ProductInfo.Add(innerInfo);
            db.SaveChanges();
            //记录统计表
            if (outInfo.MsgStatus == enumProductType.LoginOut)
            {
                if (lastInfo == null || lastInfo.MsgType != (byte)enumProductType.LoginIn)
                {
                    db.RecordErrorInfo(enumSystemErrorCode.ProductOutWithoutIn, innerInfo.ToString(), null);
                    return(buffResp);
                }
                if (lastInfo.staffNumber != outInfo.StaffNumber)
                {
                    db.RecordErrorInfo(enumSystemErrorCode.ProductOutInDiff, lastInfo.ToString() + "\r\n" + innerInfo.ToString(), null);
                }
                int currentFinishCount = (outInfo.ChannelFinish1 + outInfo.ChannelFinish2 + outInfo.ChannelFinish3 +
                                          outInfo.ChannelFinish4 + outInfo.ChannelFinish5 + outInfo.ChannelFinish6 - lastInfo.ChannelFinish1 -
                                          lastInfo.ChannelFinish2 - lastInfo.ChannelFinish3 - lastInfo.ChannelFinish4 - lastInfo.ChannelFinish5 -
                                          lastInfo.ChannelFinish6);
                RecordStatisticsInfo(lastInfo, innerInfo.ID, outInfo, machine, currentFinishCount, db);
            }
            buffResp[0] = 0;
            return(buffResp);
        }
Пример #2
0
        public byte[] HandlerClientData(byte[] buff)
        {
            DbTableDbContext db = new DbTableDbContext();

            db.RecordErrorInfo(enumSystemErrorCode.TcpDefaultHandlerErr, "", buff);

            return(null);
        }