public new object FromBytes(byte[] messagebytes)
        {
            if (messagebytes != null && messagebytes.Length > 0)
            {
                bool lastFlag = false;
                int len = messagebytes.Length;
                int offset = 0;
                while (messagebytes.Length > 0 && !lastFlag)
                {
                    byte[] buffer = new byte[CoreMessageHeader.TOTAL_WIDTH];
                    if (messagebytes.Length >= buffer.Length)
                    {
                        Array.Copy(messagebytes, buffer, buffer.Length);
                    }
                    else
                    {
                        return null;
                    }
                    CoreMessageHeader msgHeader = new CoreMessageHeader();
                    msgHeader.FromBytes(buffer);
                    lastFlag = msgHeader.MH_LAST_FLAG;

                    int mbLen = (int)(msgHeader.MH_MESSAGE_LENGTH - CoreMessageHeader.TOTAL_WIDTH);
                    buffer = new byte[mbLen];

                    Array.Copy(messagebytes, CoreMessageHeader.TOTAL_WIDTH, buffer, 0, mbLen);

                    offset = (int)msgHeader.MH_MESSAGE_LENGTH;
                    //len -= offset;

                    DetailFromBytes(buffer);
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
                }
            }
            
            return this;
        }
        public static BizMsgDataBase BytesToCoreMsgData(byte[] recbytes, IMessageRespHandler dataref)
        {
            if (recbytes != null && recbytes.Length > 0)
            {
                byte[] buffer = new byte[CoreMessageHeader.TOTAL_WIDTH];
                if (recbytes.Length >= buffer.Length)
                {
                    Array.Copy(recbytes, buffer, buffer.Length);
                }
                else
                {
                    return null;
                }
                CoreMessageHeader msgHeader = new CoreMessageHeader();
                msgHeader.FromBytes(buffer);

                UInt32 mbLen = msgHeader.MH_MESSAGE_LENGTH - CoreMessageHeader.TOTAL_WIDTH;
                buffer = new byte[mbLen];

                //Assembly asm = Assembly.GetExecutingAssembly();
                //object dataobj = asm.CreateInstance(type.ToString(), false);
                //IMessageRespHandler bizMsgData = dataref as IMessageRespHandler;
                if (dataref != null)
                {
                    Array.Copy(recbytes, CoreMessageHeader.TOTAL_WIDTH, buffer, 0, mbLen);
                    dataref.FromBytes(buffer);
                }
                return dataref as CoreBizMsgDataBase;
            }
            else
            {
                return null;
            }
        }
        public object FromBytes(byte[] messagebytes)
        {
            // MessageHeader
            byte[] buffer = new byte[CoreMessageHeader.TOTAL_WIDTH];
            if (messagebytes.Length >= buffer.Length)
            {
                Array.Copy(messagebytes, buffer, buffer.Length);
            }
            else
            {
                return null;
            }
            CoreMessageHeader msgHeader = new CoreMessageHeader();
            msgHeader.FromBytes(buffer);

            UInt32 mbLen = msgHeader.MH_MESSAGE_LENGTH - CoreMessageHeader.TOTAL_WIDTH;
            messagebytes = CommonDataHelper.SubBytes(messagebytes, (int)CoreMessageHeader.TOTAL_WIDTH, (int)mbLen);

            // MessageBody
            int len = messagebytes.Length;
            int offset = 0;

            while (len > 0)
            {
                buffer = new byte[CoreDataBlockHeader.TOTAL_WIDTH];
                Array.Copy(messagebytes, offset, buffer, 0, CoreDataBlockHeader.TOTAL_WIDTH);
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(buffer);
                len -= CoreDataBlockHeader.TOTAL_WIDTH;
                offset += CoreDataBlockHeader.TOTAL_WIDTH;
                if (len > 0)
                {
                    switch (dbhdr1.DBH_DB_ID.Trim())
                    {
                        case "@RPHDR":
                            buffer = new byte[RPHDR_MsgHandler.TOTAL_WIDTH];
                            Array.Copy(messagebytes, offset, buffer, 0, RPHDR_MsgHandler.TOTAL_WIDTH);
                            RPhdrHandler = (RPHDR_MsgHandler)RPhdrHandler.FromBytes(buffer);
                            len -= RPHDR_MsgHandler.TOTAL_WIDTH;
                            offset += RPHDR_MsgHandler.TOTAL_WIDTH;
                            break;

                        case "@ODATA":
                            //buffer = new byte[GetODATALen()];
                            UInt16 odataLen = (UInt16)(dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH);
                            buffer = new byte[odataLen];
                            Array.Copy(messagebytes, offset, buffer, 0, odataLen);
                            //Array.Copy(messagebytes, offset, buffer, 0, GetODATALen());
                            //OData = (RetrieveCstmODATA)OData.FromBytes(buffer);
                            ODATA_FromBytes(buffer);
                            len -= odataLen;
                            offset += odataLen;
                            //len -= GetODATALen();
                            //offset += GetODATALen();
                            break;
                        //case "@OBDATA":
                        //    UInt32 obdataLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                        //    buffer = new byte[obdataLen];
                        //    Array.Copy(messagebytes, offset, buffer, 0, obdataLen);
                        //    OBDATA_FromBytes(buffer);
                        //    len -= (Int32)obdataLen;
                        //    offset += (Int32)obdataLen;
                        //    break;

                        case "@OMSG":
                            UInt32 omsgLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[omsgLen];
                            Array.Copy(messagebytes, offset, buffer, 0, omsgLen);
                            OmsgHandler = (OMSG_MsgHandler)OmsgHandler.FromBytes(buffer);
                            len -= (int)omsgLen;
                            offset += (int)omsgLen;
                            break;

                        case "@SYSERR":
                            int syserrLen = (int)dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[syserrLen];
                            //ms.Read(buffer, offset, (int)syserrLen);
                            Array.Copy(messagebytes, offset, buffer, 0, syserrLen);
                            SyserrHandler = (SYSERR_MsgHandler)SyserrHandler.FromBytes(buffer);
                            len -= (int)syserrLen;
                            offset += (int)syserrLen;
                            break;
                        default:
                            len--;
                            break;

                    }
                }
            }

            return this;
        }