OracleBulkCopy 修正帮
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Contract.Domain;
using DevExpress.Data;
using Framework;
using Holworth.Utility;
using HraWeb.Common;
using Holworth.RiskInterface;
using System.Net;
using System.IO;
using System.Text;
using Contract.IService;
using HraModel;
using Oracle.DataAccess.Client;
using OracleConnection = System.Data.OracleClient.OracleConnection;
namespace HraWeb
{
public partial class Test : BasePage
{
DataTable dtMulu = new DataTable();
//获取表的英文名
public string GetTableToEn(string tableName)
{
string ReturntableName = "";
for (int i = 0; i < dtMulu.Rows.Count; i++)
{
if (tableName == dtMulu.Rows[i][1].ToString().Trim())
{
ReturntableName = dtMulu.Rows[i][2].ToString();
break;
}
}
return ReturntableName;
}
public void GetExcelDirectory()
{
// System.Windows.Forms.OpenFileDialog fd = new OpenFileDialog();
string fileName;
//if (fd.ShowDialog() == DialogResult.OK)
{
//fileName = fd.FileName;
fileName = @"F:\project1\附件1.【数据集市】交易数据汇总-1(修改) - 副本";
dtMulu = ExcelUtil.GetExcelSheetContent(fileName, "目录" + "$");
string[] dtAllTable = ExcelUtil.GetExcelTableName(fileName);
HraWeb.ReportEg.To38Validate.Validate.FX_FORWARD_V fc = new HraWeb.ReportEg.To38Validate.Validate.FX_FORWARD_V();
foreach (string item in dtAllTable)
{
if (!(item.LastIndexOf("属性表") > 0))
{
#region 反射获取验证页面所在的程序集
Assembly asm = Assembly.GetAssembly(fc.GetType());
#endregion
DataTable dtAllList = ExcelUtil.GetExcelSheetContent(fileName, item + "$");
if (dtAllTable.Length > 0 && dtAllTable != null)
{
string tableEn = GetTableToEn(item);
Type t = asm.GetType(fc.GetType().Namespace+ "."+tableEn);
object o = Activator.CreateInstance(t);
MethodInfo getSqlMethodInfo = t.GetMethod("TestImport");
if (!string.IsNullOrEmpty(tableEn))
{
getSqlMethodInfo.Invoke(o, new object[] { fileName,tableEn });
}
}
}
}
}
}
public void TestImport()
{
string[] tableName= Holworth.Utility.ExcelUtil.GetExcelTableName(@"c:\1.xls");
System.Data.DataTable table = Holworth.Utility.ExcelUtil.GetExcelSheetContent(@"c:\1.xls",tableName[0]);
System.Text.StringBuilder etrorSb=new StringBuilder();
int i=0;
System.Collections.ArrayList list = new System.Collections.ArrayList();
foreach (System.Data.DataRow row in table.Rows)
{
Contract.Domain.BasAgreement a = new Contract.Domain.BasAgreement();
string AgreementCode=row[0].ToString();
if(string.IsNullOrEmpty(row[0].ToString()))//记录结束
{
break;
}
if (AgreementCode == "1")//验证自己调用
{
a.AgreementCode = AgreementCode;
}
else
{
etrorSb.Append(string.Format("第{0}行{1}列值为:{2}转换失败",i,1,AgreementCode));
continue;
}
//验证成功后
list.Add(a);
a.State.MarkNew();
i++;
}
if (list.Count > 0)
{
Dao.SaveOrUpdateAll(list);
}
if (!string.IsNullOrEmpty(etrorSb.ToString()))
{
Utility.JSUtil.log(etrorSb.ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
// GetExcelDirectory();
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request["_method"]))
{
try
{
switch (Request["_method"])
{
case "Test":
int riskBookId = 10002;
int attributeLookupId = 100;
int timeHorizon = 1;
int periodLength = 1;
int dateTimeSpan = 1;
int windowSize = 30;
int simulationNumber = 0;
int tickNumber = 30;
int resultNumber = 5;
int riskModelTypeID = 1302;
double decayFactor = 1.0;
int horizonNumber = 1;
double timeStepLength = 1;
DateTime computeDate=DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
ShockInputData shockInputData = new ShockInputData();
shockInputData.ShockFlag = Constants.SHOCK_NO;
shockInputData.ShockTypeID = Constants.DEFAULT_SHOCK_TYPE_ID;
shockInputData.ShockValueTypeID = Constants.DEFAULT_SHOCK_VALUE_TYPE_ID;
shockInputData.ShockModeID = Constants.DEFAULT_SHOCK_MODE_ID;
shockInputData.ShockValue = Constants.DEFAULT_SHOCK_VALUE;
CashflowGenerationService.GenerateTransactionCashflowByDatesWithShock(computeDate, computeDate, computeDate, computeDate, shockInputData, "DEAL_ENTRY");
//riskReturnComputationService.ProcessPriceReturn(CurrentUser.UserId, CurrentUser.UserName, computeDate, periodLength, windowSize, dateTimeSpan);
//riskVolatilityComputationService.ProcessPriceVolatility(CurrentUser.UserId, CurrentUser.UserName, computeDate, periodLength, windowSize, decayFactor);
//riskCorrelationComputationService.ProcessPriceCorrelation(CurrentUser.UserId, CurrentUser.UserName, computeDate, periodLength, windowSize, decayFactor);
//forwardPriceSimulationService.SimulateForwardPriceForMultiPeriod(computeDate, simulationNumber, horizonNumber, timeStepLength, windowSize, 602, 100);
wfService.SaveStartFlow(Utility.Util.NewGuid(), "Tesy","测试");
valueAtRiskCalculationService.SaveComputeValueAtRiskByUserId(computeDate, riskBookId, attributeLookupId, timeHorizon, windowSize, simulationNumber, tickNumber, resultNumber, riskModelTypeID, CurrentUser.UserId, CurrentUser.UserName);
//riskCorrelationDecompositionService.DecomposeRiskFactorCorrelationData(DateTime.Parse("2013/11/29"), 30);
// Holworth.Utility.Utility.DownLoadExchageRade("2014_10", @"c:\1.xls");
var obj = new
{
Message = "测试成功!"
};
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
break;
}
}
catch (Exception ex)
{
var obj = new
{
ErrorCode = 9999,
Message = ex.Message
};
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
Utility.JSUtil.log(ex);
}
finally
{
Response.End();
}
}
}
}
IRiskVolatilityComputationService _riskVolatilityComputationService = null;
IRiskVolatilityComputationService riskVolatilityComputationService
{
get
{
if (_riskVolatilityComputationService == null)
{
_riskVolatilityComputationService = ctx["RiskVolatilityComputationService"] as IRiskVolatilityComputationService;
}
return _riskVolatilityComputationService;
}
}
IWorkFlowEngineService _wfService = null;
IWorkFlowEngineService wfService
{
get
{
if (_wfService == null)
{
_wfService = ctx["WorkFlowEngineService"] as IWorkFlowEngineService;
}
return _wfService;
}
}
IValueAtRiskCalculationService _valueAtRiskCalculationService = null;
IValueAtRiskCalculationService valueAtRiskCalculationService
{
get
{
if (_valueAtRiskCalculationService == null)
{
_valueAtRiskCalculationService = ctx["ValueAtRiskCalculationService"] as IValueAtRiskCalculationService;
}
return _valueAtRiskCalculationService;
}
}
IRiskReturnComputationService _riskReturnComputationService = null;
IRiskReturnComputationService riskReturnComputationService
{
get
{
if (_riskReturnComputationService == null)
{
_riskReturnComputationService = ctx["RiskReturnComputationService"] as IRiskReturnComputationService;
}
return _riskReturnComputationService;
}
}
IRiskCorrelationComputationService _riskCorrelationComputationService = null;
IRiskCorrelationComputationService riskCorrelationComputationService
{
get
{
if (_riskCorrelationComputationService == null)
{
_riskCorrelationComputationService = ctx["RiskCorrelationComputationService"] as IRiskCorrelationComputationService;
}
return _riskCorrelationComputationService;
}
}
IRiskCorrelationDecompositionService _riskCorrelationDecompositionService = null;
IRiskCorrelationDecompositionService riskCorrelationDecompositionService
{
get
{
if (_riskCorrelationDecompositionService == null)
{
_riskCorrelationDecompositionService = ctx["RiskCorrelationDecompositionService"] as IRiskCorrelationDecompositionService;
}
return _riskCorrelationDecompositionService;
}
}
IForwardPriceSimulationService _forwardPriceSimulationService = null;
IForwardPriceSimulationService forwardPriceSimulationService
{
get
{
if (_forwardPriceSimulationService == null)
{
_forwardPriceSimulationService = ctx["ForwardPriceSimulationService"] as IForwardPriceSimulationService;
}
return _forwardPriceSimulationService;
}
}
ICashflowGenerationService _CashflowGenerationService;
ICashflowGenerationService CashflowGenerationService
{
get
{
if (_CashflowGenerationService == null)
{
_CashflowGenerationService = ctx["CashflowGenerationService"] as ICashflowGenerationService;
}
return _CashflowGenerationService;
}
}
protected void testLongData(object sender, EventArgs e)
{
QueryInfo info = new QueryInfo();
info.QueryObject = "select * from ccdd where risk_book_id=4513";
DataTable dt = Dao.ExcuteDataSet(info).Tables[0];
DataRow row = dt.Rows[0];
for (int i = 0; i < 10000 * 100; i++)
{
DataRow NewRow = dt.NewRow();
NewRow.ItemArray = row.ItemArray;
dt.Rows.Add(NewRow);
}
GC.Collect();
// dt.Columns.Remove("risk_book_id");
BulkToDB(dt, "ccdd");
}
public void BulkToDB(DataTable dt, string targetTable)
{
QueryInfo info = new QueryInfo();
DataTable table = null;
Int64 increId = 0;
lock (new object())
{
#region 获取序列的当前值
QueryInfo searchInfo = new QueryInfo();
searchInfo.CustomSQL = "select CCDD_SEQ.NEXTVAL from dual";
table = Dao.ExcuteDataSet(searchInfo).Tables[0];
increId = Convert.ToInt64(table.Rows[0][0].ToString());
#endregion
info.NamedQuery = "PRO_SEQUENCE";
info.Parameters.Add("v_simulation_number", dt.Rows.Count);
Dao.ExcuteDataSet(info);
foreach (DataRow t in dt.Rows)
{
t["risk_book_id"] = increId++;
}
}
string connOrcleString =
"Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.252)(PORT = 1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME =hra)));User Id=nethra;Password=nethra;";
//= "Data Source=192.168.2.252;Database=hra;Uid=nethra;Pwd=nethra;";
OracleConnection conn = new OracleConnection(connOrcleString);
// OracleBulkCopy bulkCopy = new OracleBulkCopy(connOrcleString, OracleBulkCopyOptions.UseInternalTransaction); //用其它源的数据有效批量加载Oracle表中
OracleBulkCopy bulkCopy = new OracleBulkCopy(connOrcleString,
OracleBulkCopyOptions.UseInternalTransaction);
bulkCopy.BulkCopyTimeout = 260 * 1000;
bulkCopy.DestinationTableName = targetTable; //服务器上目标表的名称
bulkCopy.BatchSize = 50000; //每一批次中的行数
try
{
conn.Open();
if (dt != null && dt.Rows.Count != 0)
bulkCopy.WriteToServer(dt); //将提供的数据源中的所有行复制到目标表中
QueryInfo searchInfo = new QueryInfo();
searchInfo.CustomSQL = "select CCDD_SEQ.NEXTVAL from dual";
table = Dao.ExcuteDataSet(searchInfo).Tables[0];
}
catch (Exception ex)
{
throw ex;
}
finally
{
info = new QueryInfo();
info.NamedQuery = "PRO_SEQUENCE";
info.Parameters.Add("v_simulation_number", -1);
Dao.ExcuteDataSet(info);
conn.Close();
if (bulkCopy != null)
bulkCopy.Close();
}
throw new Exception("测试大数据成功");
}
}
}
OracleBulkCopy 修正帮的更多相关文章
- 为什么要做A.prototype.constructor=A这样的修正?
问题 虽然看过这篇博文JavaScript prototype之后对原型理解不再那么模糊了,但是依然还有很多理解不甚透彻的地方.比如,今天看到一个原型式继承的例子,又有些困惑,于是找了些帖子看看,有了 ...
- 【Alpha】“北航社团帮”小程序v1.0发布声明
我们的"北航社团帮"小程序发布啦!!! Alpha版本功能 功能列表和详情图 模块 功能 登录 授权登录,游客模式,无需填写信息 活动展示 首页轮播热度最高的四个活动,查看活动详情 ...
- 【Alpha】“北航社团帮”小程序v1.0项目展示
目录 1.团队介绍 2.回答一些工程问题 整个项目的目标和预期功能 整个项目的预期典型用户 整个项目的预期用户数量 alpha满足的用户需求 alpha用户量一览 团队分工及经验教训 团队项目管理 时 ...
- 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目
最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...
- 由Dapper QueryMultiple 返回数据的问题得出==》Dapper QueryMultiple并不会帮我们识别多个返回值的顺序
异常汇总:http://www.cnblogs.com/dunitian/p/4523006.html#dapper 今天帮群友整理Dapper基础教程的时候手脚快了点,然后遇到了一个小问题,Dapp ...
- 周末聊聊IT人员的人脉观:关于帮妹子找兼职有感
背景: 前几天,有个认识了好几年的网友,现在是大学生,在厦门读大一,说和她同学要一起到广州找兼职,看我有没有介绍. 像我这么积极热心善良的人,就说帮她找找看,结果问了几次,没消息,只好诚实的回复人家, ...
- 帮我做个APP,给你20万,做不做?
一.为什么要写这篇文章 前段时间,有个辞职 创业的同事(做法务的) 问我 开发一个 新闻类的APP要多少钱,产品.UI.接口.后台管理页 他们啥都没有,想全部外包. 我 并没有在外包公司做过,也没 ...
- [修正] Firemonkey 中英文混排折行问题(移动平台)
问题:FMX 在移动平台的文字显示并非由该平台的原生 API 来显示,而是由 FMX.TextLayout.GPU 来处理,也许是官方没留意到中文字符的问题,造成在中英文混排折行时,有些问题. 适用: ...
- [修正] Firemonkey Android 显示 Emoji (颜文字)
问题:在 Android 平台下,显示 Emoji 文字,无法显示彩色(皆为黑色),例如 Edit 控件,即使将 Edit.ControlType = Platform 设为平台原生控件,还是没用(真 ...
随机推荐
- java web 程序---登陆验证注销/重定向session_login.jsp/
思路:第一个页面是:session_login.页面,一个form表单,一个脚本,输入的名称不为空,不,则重定向 到welcome.jsp页面.否则,显示登陆失败,请输入登陆名称: 第二个页面,是we ...
- windows python文件拷贝到linux上执行问题-换行符问题/r/n
之前在Windows下写好了一个Python脚本,运行没问题,今天在Linux下,脚本开头的注释行已经指明了解释器的路径,也用chmod给了执行权限,但就是不能直接运行脚本. 1 问题1: 报错:: ...
- Git操作行
基础层:-----------------#初始化一个版本仓库git init #复制远程版本库git clone url #添加远程版本库origingit remote add origin ur ...
- Java复习——反射和泛型的复习
反射 Class类 一个类被类加载器加载到内存之中,占有一片区域,这个空间里的内容就是类的字节码,不同的类的字节码是不一样的,这一个个空间页可以使用类来表示,这就是Class类. 根据这个概念可知:不 ...
- 【BZOJ】1008: [HNOI2008]越狱(组合数学)
题目 题目描述 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 输入输出格式 ...
- json data 解析demo
json data: demo: JsonObject jsonObject= JsonHandle.getAsJsonObject(city_dataInfo).get("data&quo ...
- IIS Worker Process 遇到了一个问题,需要关闭
服务器为2003系统,平时都用的好好的,但是最近经常跳出了!IIS Worker Process 遇到问题关闭! 第二个对话框还有个请单击此处的连接 以下文件将包含在这个错误报告中:C:\DOCUME ...
- Java int Integer
http://www.cnblogs.com/haimingwey/archive/2012/04/16/2451813.html http://developer.51cto.com/art/200 ...
- ceph journal更换位置
只在这里做简单的演示 ceotos7 环境 3个mon节点 3个osd节点 环境搭建我这里不再叙述 我们查看一下分区情况: [root@ceph_1 ~]# lsblkNAME MAJ: ...
- Python Tuples
1. basic Tuples is a sequence of immutable object. It's a sequence, just like List. However, it cann ...