public static DataTable QueryMQLog(string condition, out string exception)
 {
     exception = "";
     try
     {
         TTRD_SET_MSG_LOG_Manager manager = new TTRD_SET_MSG_LOG_Manager();
         return manager.LogQuery(condition);
     }
     catch (Exception ex)
     {
         exception = ex.Message;
         xQuant.Log4.LogHelper.Write(xQuant.Log4.LogLevel.Error, string.Format("<MQMsgCommonHelper-QueryMQLog> Exception:{0}; StatkTrace:{1}.", ex.Message, ex.StackTrace));
         return null;
     }
 }
        /// <summary>
        /// 把支付交易序号更新为资金流水号,只适用来账销账
        /// </summary>
        /// <param name="msgdata"></param>
        /// <param name="paysn"></param>
        /// <param name="hostflow"></param>
        /// <param name="error"></param>
        /// <param name="state"></param>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static int UpdateMQLog(MessageData msgdata, string paysn, string hostflow, string error, MsgLogState state, out string exception)
        {
            exception = "";
            try
            {
                TTRD_SET_MSG_LOG log = new TTRD_SET_MSG_LOG();
                log.GUID = msgdata.MessageID.ToString();
                log.FLOW_NO = paysn;
                log.USER_CODE = msgdata.TellerNO;
                log.INS_ID = msgdata.OrgNO;
                //log.IS_MUL_PKG = msgdata.IsMultiPackage ? "1" : "0";
                log.HOSTFLOW_NO = hostflow;
                log.MSGTYPE = msgdata.MsgBizType;
                log.PLATFORMTYPE = (int)msgdata.TragetPlatform;
                log.RESP_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                log.RECV_CONTENT = msgdata.CurrentRespPackage.PackageMessage;
                log.STATE = (int)state;
                if (!string.IsNullOrEmpty(error))
                {
                    log.ERRINFO = error;
                }
 
                int count = 0;
                using (TransactionScope trans = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    TTRD_SET_MSG_LOG_Manager manager = new TTRD_SET_MSG_LOG_Manager();
                    count = manager.LogUpdate(log);
                    trans.Complete();
                }
                return count;
            }
            catch (Exception ex)
            {
                exception = ex.Message;
                xQuant.Log4.LogHelper.Write(xQuant.Log4.LogLevel.Error, string.Format("<MQMsgCommonHelper-UpdateMQLog> Exception:{0}; StatkTrace:{1}.", ex.Message, ex.StackTrace));
                return 0;
                //throw ex;
            }
        }
 // 只适合更新日志状态
 public static int UpdateMQLog(Guid guid,  string error, MsgLogState state, out string exception)
 {
     exception = "";
     try
     {
         TTRD_SET_MSG_LOG log = new TTRD_SET_MSG_LOG();
         log.GUID = guid.ToString();              
         log.STATE = (int)state;
         if (!string.IsNullOrEmpty(error))
         {
             log.ERRINFO = error;
         }
         int count = 0;
         using (TransactionScope trans = new TransactionScope(TransactionScopeOption.RequiresNew))
         {
             TTRD_SET_MSG_LOG_Manager manager = new TTRD_SET_MSG_LOG_Manager();
             count = manager.LogUpdate(log);
             trans.Complete();
         }
         return count;
     }
     catch (Exception ex)
     {
         exception = ex.Message;
         xQuant.Log4.LogHelper.Write(xQuant.Log4.LogLevel.Error, string.Format("<MQMsgCommonHelper-UpdateMQLog> Exception:{0}; StatkTrace:{1}.", ex.Message, ex.StackTrace));
         return 0;
         //throw ex;
     }
 }
 public static int AddMQLog(MessageData msgdata, byte[] senddata, MsgLogState state, out string exception)
 {
     exception = "";
     try
     {
         TTRD_SET_MSG_LOG log = new TTRD_SET_MSG_LOG();
         log.GUID = msgdata.MessageID.ToString();
         log.FLOW_NO = msgdata.BizMsgID??"";
         log.USER_CODE = msgdata.TellerNO;
         log.INS_ID = msgdata.OrgNO;
         log.IS_MUL_PKG = msgdata.IsMultiPackage ? "1" : "0";
         log.MSGTYPE = msgdata.MsgBizType;
         log.PLATFORMTYPE = (int)msgdata.TragetPlatform;
         log.SEND_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         log.SEND_CONTENT = senddata;
         log.STATE = (int)state;
         int count = 0;
         using (TransactionScope trans = new TransactionScope(TransactionScopeOption.RequiresNew))
         {
             TTRD_SET_MSG_LOG_Manager manager = new TTRD_SET_MSG_LOG_Manager();
             count = manager.LogInsert(log);
             trans.Complete();
         }
         return count;
     }
     catch(Exception ex)
     {
         exception = ex.Message;
         xQuant.Log4.LogHelper.Write(xQuant.Log4.LogLevel.Error, string.Format("<MQMsgCommonHelper-AddMQLog> Exception:{0}; StatkTrace:{1}.", ex.Message, ex.StackTrace));
         return 0;
     }
 }