/// <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; } }
private void ReleaseAsyncTimeout(Guid id, string error, MsgLogState state) { if (id != Guid.Empty) { string dbexception = ""; MQMsgCommonHelper.UpdateMQLog(id, error, state, out dbexception); _receiverManager.RemoveSemaphore(id); } }
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; } }
private void AfterReceivedAsync(MessageData data, string error, MsgLogState state) { if (data == null || data.MessageID == Guid.Empty) { return; } string dbexception = ""; // 先更新数据库再释放等待信号量,保证多线程更新数据库前后顺序 MQMsgCommonHelper.UpdateMQLog(data, "", error, state, out dbexception); _receiverManager.InsertAsyncResult(data.MessageID, state == MsgLogState.RecvSucceed? (object)data : (object)error); _receiverManager.ReleaseSemaphore(data.MessageID); }
private static void OnUpdateDBLog(MessageData msgdata, string flowno, string msg, MsgLogState state, out string dbexception) { dbexception = ""; MQMsgCommonHelper.UpdateMQLog(msgdata, flowno, msg, state, out dbexception); }
private static void OnUpdateDBLog(Guid guid, string msg, MsgLogState state, out string dbexception) { dbexception = ""; MQMsgCommonHelper.UpdateMQLog(guid, msg, state, out dbexception); }
public static int UpdateMQMsgLog(MessageData msgdata, string hostflow, string error, MsgLogState state, out string dbexception) { return MQMsgCommonHelper.UpdateMQLog(msgdata, hostflow, error, state, out dbexception); }
public static int AddMQMsgLog(MessageData msgdata, byte[] senddata, MsgLogState state, out string dbexception) { return MQMsgCommonHelper.AddMQLog(msgdata, senddata, state, out dbexception); }