TransactionHelper
public class TransactionHelper
{
public static OracleTransaction ora_Transaction = null;
public static OracleCommand ora_Command { get; set; }
public static OracleConnection ora_Conn = null;
private static string ls_XMLFile = "SysInfo.xml";//配置文檔
private static string ls_SectionName = "";
private static Action initAction = () =>
{
#region 初始化Transaction
if (string.IsNullOrEmpty(ls_SectionName)) ls_SectionName = "DBConn_EMES";
ora_Command = new OracleCommand();
ora_Conn = OracleHelper.DBOpen_Ora(ls_SectionName);
ora_Conn.Open();
ora_Command.Connection = ora_Conn;
ora_Transaction = ora_Conn.BeginTransaction();
ora_Command.Transaction = ora_Transaction;
#endregion
};
private static Action disAction = () =>
{
#region 銷毀 Transaction
if (ora_Command != null) ora_Command.Dispose();
ora_Command = null; ora_Transaction = null;
if (ora_Conn != null)
{
if (ora_Conn.State == ConnectionState.Open) ora_Conn.Close();
ora_Conn.Dispose();
}
ora_Conn = null;
#endregion
};
public TransactionHelper()
{
try
{
if (ora_Conn == null)
{
initAction.Invoke();
}
}
catch (Exception ex)
{
StringBuilder lo_StringBuilder = new StringBuilder(ex.Message.ToString());
ECCHelper.ClassHelper.WriteLog(lo_StringBuilder);
disAction.Invoke();
}
//if (ora_Conn.State == ConnectionState.Open) ora_Conn.Close();
//ora_Conn.Dispose();
}
public void executeNoneQueryCommand(string sqlCommand)
{
try
{
ora_Command.CommandText = sqlCommand;
ora_Command.ExecuteNonQuery();
}
catch (Exception ex)
{
StringBuilder lo_StringBuilder = new StringBuilder(ex.Message.ToString());
ECCHelper.ClassHelper.WriteLog(lo_StringBuilder);
disAction.Invoke();
throw ex;
}
}
/// <summary>
/// 初始調用 OracleCommnad
/// </summary>
public OracleCommand InitCommand()
{
return ora_Command;
}
/// <summary>
/// 銷毀
/// </summary>
/// <returns></returns>
public bool CommitTransaction()
{
try
{
if (ora_Transaction != null)
{
ora_Transaction.Commit(); return true;
}
else { ora_Transaction.Rollback(); return false; }
}
catch (Exception ex)
{
if (ora_Transaction != null) ora_Transaction.Rollback();
StringBuilder lo_StringBuilder = new StringBuilder(ex.Message.ToString());
ECCHelper.ClassHelper.WriteLog(lo_StringBuilder);
return false;
}
finally
{
disAction.Invoke();
}
}
}
TransactionHelper的更多相关文章
- GC Ergonomics间接引发的锁等待超时问题排查分析
1. 问题背景 上周线上某模块出现锁等待超时,如下图所示: 我虽然不是该模块负责人,但出于好奇,也一起帮忙排查定位问题. 这里的业务背景就是在执行到某个地方时,需要去表中插入一批数据,这批数据需要根据 ...
- format ZKFC失败
at org.apache.hadoop.ha.ActiveStandbyElector$WatcherWithClientRef.waitForZKConnectionEvent(ActiveSta ...
- Known BREAKING CHANGES from NH3.3.3.GA to 4.0.0
Build 4.0.0.Alpha1 ============================= ** Known BREAKING CHANGES from NH3.3.3.GA to 4.0. ...
- NHibernate利用Mindscape.NHibernateModelDesigner实现数据库与实体之间的转换及操作
环境:   Visual Studio 2010 一.Mindscape.NhibernateModelDesigner安装   在打开 ...
随机推荐
- 【python实现卷积神经网络】池化层实现
代码来源:https://github.com/eriklindernoren/ML-From-Scratch 卷积神经网络中卷积层Conv2D(带stride.padding)的具体实现:https ...
- spring中BeanPostProcessor之三:InitDestroyAnnotationBeanPostProcessor(01)
在<spring中BeanPostProcessor之二:CommonAnnotationBeanPostProcessor(01)>一文中,分析到在调用CommonAnnotationB ...
- 设计模式系列之迭代器模式(Iterator Pattern)——遍历聚合对象中的元素
模式概述 模式定义 模式结构图 模式伪代码 模式改进 模式应用 模式在JDK中的应用 模式在开源项目中的应用 模式总结 说明:设计模式系列文章是读刘伟所著<设计模式的艺术之道(软件开发人员内功修 ...
- PHP代码审计(初级篇)
一.常见的PHP框架 1.zendframwork: (ZF)是Zend公司推出的一套PHP开发框架 功能非常的强大,是一个重量级的框架,ZF 用 100%面向对象编码实现. ZF 的组件结构独一无二 ...
- 发现一款手绘可视化神器!Python绘图还在用Matplotlib?out了 !
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取htt ...
- [Abp vNext 入坑分享] - 2.简化项目结构
一.简要说明 本篇文章根据我自己的需要对项目结果进行简化,让项目结构更符合我自己的要求,同时让项目跑起来.仅供参考 二.具体步骤 2.1卸载掉对我来说目前使用不上的项目,identityserver, ...
- JAVA的synchronized写法
使用关键字synchronized的写法比较多,常用的有如下几种,代码如下: public class MyService { synchronized public static void test ...
- C# WCF的通信模式
wcf 通信模式一般分为三种; 1,请求/响应模式 2,单工模式 3,双工模式 一,请求/响应模式 请求/响应通信是指客户端向服务端发送消息后,服务端会向客户端发送响应.这也意味着在接收到服务的响应以 ...
- 随笔之——浮动(float)的影响及其清除、、clear与overflow-hidden清除float的不同!!!
一.浮动(float)对内联元素的影响. 1.我们都知道,内联元素(例如:span/img/input...)在正常情况下不可以对其设置宽高的,它的大小之只和它内部内容的多少有关. 我们怎样才可以对其 ...
- 安装和使用redis
我现在只是在window上使用redis在其他平台上暂时没有操作过,如果你有其他好的意见欢迎提出来! 安装redis具体可查看:http://www.runoob.com/redis/redis-in ...