public static byte[] MarksMsgDataToBytes(IMessageReqHandler data) { return data.ToBytes(); }
/// <summary> /// 核心编码组织 /// </summary> /// <param name="data"></param> /// <param name="codemsg"></param> /// <returns></returns> public static Guid CodeMsgToBinary(IMessageReqHandler data, ref byte[] codemsg) { try { ((BizMsgDataBase)data).OnArgumentsValidation(); if (data is EncryptTellerAuth) { EncryptTellerAuth authdata = data as EncryptTellerAuth; if (authdata != null) { codemsg = authdata.AfterEncrypt ? data.ToBytes() : (data as EncryptTellerAuth).TellerEncrypt.ToBytes(); } else { throw new Exception(MESSAGE_ENCODE_EXCEPTION); } } else { codemsg = data.ToBytes(); } Guid msgID = Guid.NewGuid(); InsertMsgList(msgID, data); return msgID; } catch (BizArgumentsException bizex) { throw bizex; } catch (Exception ex) { xQuant.Log4.LogHelper.Write(xQuant.Log4.LogLevel.Error, string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace)); throw new Exception(MESSAGE_ENCODE_EXCEPTION, ex); } }
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; }