// 只适合更新日志状态
 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;
     }
 }
        /// <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 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;
     }
 }
Esempio n. 4
0
        public void Transaction()
        {
            using (TransactionScope scope = new TransactionScope(Book.ConnectionStringSettings.Key))
            {
                var bookContext = Book.CreateContext(false);
                Book obj = new Book();
                obj.Author = "123";
                bookContext.Add(obj);

                obj = new Book();
                obj.Author = "456";
                bookContext.Add(obj);

                bookContext.SubmitChanges(true);

                var libraryContext = Library.CreateContext(false);

                Library obj2 = new Library();
                obj2.Floor = "123";

                libraryContext.Add(obj2);
                libraryContext.SubmitChanges();

                scope.Complete();
            }

            Assert.AreEqual((from q in Library.CreateContext(false)
                             where q.Floor == "123"
                             select q).Count(), 1);
        }
 /// <summary>
 /// 核心钆账
 /// </summary>
 /// <param name="tellerno"></param>
 /// <param name="orgno"></param>
 /// <param name="tradedate"></param>
 /// <param name="querydate"></param>
 /// <param name="flowNO"></param>
 /// <param name="queryOrgNO"></param>
 /// <param name="outmsg"></param>
 /// <returns></returns>
 public static bool CoreRollingAcct(String tellerno, String orgno, DateTime tradedate, DateTime querydate, String flowNO, String queryOrgNO, out String outmsg)
 {
     List<CoreCheckAcctInfo> outData;
     if (!CoreAcctChecking(tellerno, orgno, tradedate, querydate, flowNO, queryOrgNO, out outData, out outmsg))
     {
         //outmsg = string.Format("{0}{1}", MsgHandlerEntry.Info_Return_Core, outmsg);
         return false;
     }
     try
     {
         if (string.IsNullOrEmpty(queryOrgNO))
         {
             queryOrgNO = orgno;
         }
         
         using (TransactionScope trans = new TransactionScope())
         {
             TTRD_ZJAA_Controller.Delete(queryOrgNO, querydate.ToString("yyyyMMdd"));
             //TTRD_ZJAA_Controller.Clear();
             if (outData != null)
             {
                 
                 TTRD_ZJAA_Controller.Insert(outData);
             }                    
             trans.Complete();
         }
         return true;
     }
     catch (Exception ex)
     {
         outmsg = ex.Message;
         return false;
     }
 }
 /// <summary>
 /// 支付平台钆账
 /// </summary>
 /// <param name="queryDate"></param>
 /// <param name="outmsg"></param>
 /// <returns></returns>
 public static bool PayRollingAcct(DateTime queryDate, out string outmsg)
 {
     List<PayCheckAcct> outData;
     if (!PayCheckAccount(queryDate, out outData, out outmsg))
     {
         //outmsg = string.Format("{0}{1}", MsgHandlerEntry.Info_Return_Core, outmsg);
         return false;
     }
     try
     {
         using (TransactionScope trans = new TransactionScope())
         {
             TTRD_PAY_Controller.Delete(queryDate.ToString("yyyyMMdd"));
             if (outData != null)
             {
                 TTRD_PAY_Controller.Insert(outData);
             }
             trans.Complete();
         }
         return true;
     }
     catch (Exception ex)
     {
         outmsg = ex.Message;
         return false;
     }
 }