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安装   在打开 ...
随机推荐
- AJ学IOS(40)UI之核心动画_抖动效果_CAKeyframeAnimation
AJ分享,必须精品 效果: 效果一: 效果二: 代码: // // NYViewController.m // 图片抖动 // // Created by apple on 15-5-8. // Co ...
- 计时线程Runnable和Handler的结合
利用Runnable和Handler,来创建计时线程 private double recodeTime = 0;// 用于计时 private double econdTime = 0;// 用于计 ...
- B - Fadi and LCM CodeForces - 1285C 质因子
题目大意很简单,给你一个整数X,让你求a和b,使得max(a,b)尽可能的小,然后打印a,b 题解:想到了质因子分解,也考虑到了暴力,但是觉得暴力的话会TLE,所以打算用贪心做,然后就一直Wa.... ...
- Windows环境下搭建Cocos2d-x3.2环境并配置android交叉编译环境
一.软件 1)VS2012(C++11特性在VS2012以上可以使用):传送门: 2)Cocos2d-x官网源码:传送门:http://cocos2d-x.org/download 3)JDK:传送门 ...
- git多人协作操作流程
git协作工作流程 git checkout work 自己工作分支工作 git commit -a -m ''自己工作分支提交 git checkout master 切换到主分支 git pull ...
- 功能测试--聊天功能测试&微信聊天
微信聊天功能测试 发送对象 普通用户.公众号.群.其他特殊主体 衍生功能 转发.语音转文字.删除等 消息发送 单聊.群聊.语音.文字.图片.表情.链接.字符及长度 消息管理 发布通知.接受通知.发文件 ...
- .Net Core主机配置
Host:(主机)负责web应用程序的启用和生成期管理,配置服务器和请求处理管道. 主机配置日志,依赖注入关系,实际上是一个封装了应用资源的对象. 创建主机生成器-〉配置主机-〉创建主机-〉运行主机. ...
- tensorflow1.0 构建神经网络做图片分类
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_dat ...
- 点击表头取下标&js时间转时间戳
1.Date.parse(new Date("2017-7-31")); 2.$("th").eq(this.cellIndex); // 3.end($ar ...
- php最快捷的插入数据,3000万仅需5秒
<?phpheader('content-type:text/html;charset=utf-8');//采集数据$url="http://www.keepclub.com/club ...