public byte[] ToBytes()
        {
            //统一编码消息头 MH

            CoreMessageHeader msgHeader = new CoreMessageHeader();
            msgHeader.MH_MESSAGE_LENGTH = CoreMessageHeader.TOTAL_WIDTH + RQ_TOTAL_WIDTH;
            msgHeader.MH_LAST_FLAG = MessageHeaderLastFlag;
            byte[] buffer = new byte[msgHeader.MH_MESSAGE_LENGTH];
            Array.Copy(msgHeader.ToBytes(), buffer, CoreMessageHeader.TOTAL_WIDTH);

            byte[] rqtotal = new byte[RQ_TOTAL_WIDTH];
            CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
            dbhdr1.DBH_DB_LENGTH = CoreDataBlockHeader.TOTAL_WIDTH + RQHDR_MsgHandler.TOTAL_WIDTH;
            dbhdr1.DBH_DB_ID = "@RQHDR";
            Array.Copy(dbhdr1.ToBytes(), rqtotal, CoreDataBlockHeader.TOTAL_WIDTH);
            Array.Copy(RQhdrHandler.ToBytes(), 0, rqtotal, CoreDataBlockHeader.TOTAL_WIDTH, RQHDR_MsgHandler.TOTAL_WIDTH);

            if (GetRQDTLLen() > 0)
            {
                CoreDataBlockHeader dbhdr2 = new CoreDataBlockHeader();
                dbhdr2.DBH_DB_LENGTH = (UInt32)(CoreDataBlockHeader.TOTAL_WIDTH + GetRQDTLLen());
                dbhdr2.DBH_DB_ID = "@RQDTL";
                Array.Copy(dbhdr2.ToBytes(), 0, rqtotal, CoreDataBlockHeader.TOTAL_WIDTH + RQHDR_MsgHandler.TOTAL_WIDTH, CoreDataBlockHeader.TOTAL_WIDTH);
                rqtotal = RQDTL_ToBytes(rqtotal);
            }
            Array.Copy(rqtotal, 0, buffer, CoreMessageHeader.TOTAL_WIDTH, RQ_TOTAL_WIDTH);
            return buffer;
        }
        public new byte[] ToBytes()
        {

            if (IBDATACollection == null || IBDATACollection.Count == 0)
            {
                base.MessageHeaderLastFlag = true;
                return base.ToBytes();
            }
            else
            {
                base.MessageHeaderLastFlag = false;
                byte[] regularBytes = base.ToBytes();
                int index = 0;
                
                int ibdataLength = (from ibdata in IBDATACollection
                                   where ibdata != null && ibdata.TOTAL_WIDTH > 0
                                    select ibdata.TOTAL_WIDTH).Sum() + IBDATACollection.Count * (CoreDataBlockHeader.TOTAL_WIDTH + CoreMessageHeader.TOTAL_WIDTH);
                byte [] result = new byte[ibdataLength + regularBytes.Length];
                Array.Copy(regularBytes, result, regularBytes.Length);
                int offset = regularBytes.Length;
                foreach (var ibdata in IBDATACollection)
                {
                    CoreMessageHeader msgHeader = new CoreMessageHeader();
                    msgHeader.MH_MESSAGE_LENGTH = (uint)(CoreMessageHeader.TOTAL_WIDTH + CoreDataBlockHeader.TOTAL_WIDTH + ibdata.TOTAL_WIDTH);
                    msgHeader.MH_LAST_FLAG = (++index == IBDATACollection.Count) ? true : false;
                    Array.Copy(msgHeader.ToBytes(), 0, result, offset,  CoreMessageHeader.TOTAL_WIDTH);
                    offset += CoreMessageHeader.TOTAL_WIDTH;
                    
                    CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                    dbhdr.DBH_DB_LENGTH = (uint)(CoreDataBlockHeader.TOTAL_WIDTH + ibdata.TOTAL_WIDTH);
                    dbhdr.DBH_DB_ID = "@IBDATA";
                    Array.Copy(dbhdr.ToBytes(), 0, result, offset, CoreDataBlockHeader.TOTAL_WIDTH);
                    offset += CoreDataBlockHeader.TOTAL_WIDTH;
                    Array.Copy(ibdata.ToBytes(), 0, result, offset, ibdata.TOTAL_WIDTH);
                    offset += ibdata.TOTAL_WIDTH;
                }

                return result;                
            }
        }
        public static byte[] CoreMsgDataToBytes(IMessageReqHandler data)
        {
            if (data != null)
            {
                //统一编码消息头 MH

                CoreMessageHeader msgHeader = new CoreMessageHeader();
                msgHeader.MH_MESSAGE_LENGTH = CoreMessageHeader.TOTAL_WIDTH + ((CoreBizMsgDataBase)data).RQ_TOTAL_WIDTH;
                byte[] buffer = new byte[msgHeader.MH_MESSAGE_LENGTH];
                Array.Copy(msgHeader.ToBytes(), buffer, CoreMessageHeader.TOTAL_WIDTH);

                Array.Copy(data.ToBytes(), 0, buffer, CoreMessageHeader.TOTAL_WIDTH, ((CoreBizMsgDataBase)data).RQ_TOTAL_WIDTH);
                return buffer;
            }
            return null;
        }