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("测试大数据成功");

}
}
}

时间: 2024-11-02 12:02:15

OracleBulkCopy 修正帮的相关文章

程序员同事问shell脚本刷流量,不讨巧帮他填了一个巨坑

程序员同事闲来无事问我可以用shell脚本写个刷微博访问量的没.于是脑海里想起了病毒营销或者fork×××这些词.依稀操刀稀松吧啦的写了起来.并测试了下,脚本内容是下面这样的:脚本跑起来的样子当然仅仅是为了展示shell脚本威力.当然还是希望大家靠实际的阅读量.拿微信公众号来说,刷量增粉的很多.同样笔者手里也有些软件.但一次都没有使用过.以来防止被中马,二来做人如果都急功近利.光追求虚妄的东西而没有实质内容.没有实际转化率和留存,本质上就是自欺欺人.不闲扯我们继续看 思路来源:Linux世界里著

PHP开发学习门户帮您内推简历

如果您正在寻找一份与开发相关的工作,我可以帮您免费推荐一些相应的工作 将您的简历发送到:[email protected] 职位类型: Android工程师 PHP开发工程师 C++开发工程师 后台开发架构师 WEB前端工程师 美术设计师 Java高级工程师 -- 招聘公司: 百度 阿里巴巴 腾讯 新浪 完美世界 智明星通 乐元素 -- 自身要求: 个人文化修养高,有一定的学历 专业知识扎实,编程动手能力强 有团队合作意识,工作积极负责 具体的职位还会有其他一些特定要求,不再一一列举 欢迎正在求

【心灵鸡汤】大神,我有个问题,帮我看看

提前先申明今天的话题不是为了责备或者责怪,如果你非要这么理解我也没有办法 今天的话题就由下面这张图引出来,以下是一个找人帮忙解决问题的描述 最近这段时间经常遇到类似这样的寻求帮助的. 我说一下我看到这样的寻求帮助的对话之后内心的变化过程 认真读每一句话 从描述找遇到的问题 内心狂躁 心中一万个草泥马在奔腾 一般任何人只要找我问问题,我都会尽量尽我所能去解决,如果真真解决不了,当然也只能抱歉,因为我个人能力不够,仍然需要学习 那么为什么我内心会狂躁 因为我看了半天没读懂你到底要问什么,你的困难在哪

万创帮平台从工作到生活,一帮到底

在雷锋日当天,很多人自发开展学习"雷锋精神"的活动,对于雷锋的感人事迹,宝宝们应该不陌生,雷锋乐于助人,扶贫济困,谦虚待人,见义勇为,这些良好美德永远都不会过时,永远都值得我们学习. 生活中,我们常常需要帮助别人,也常常需要别人帮助自己,乐于助人是中华民族的传统美德,如果每个人都保有一颗热心肠,相信"人性冷漠"这样的词语也不会出现在我们的脑海中. 城市生活中,左领右舍互不相识,亲戚朋友远在他乡.当你回到家突然发现灯泡不亮了,或者是马桶堵水了,又或者是洗衣机出故障了,

《亿人帮》与《新米公益》竞品分析报告(简要版)

<亿人帮>与<新米公益>竞品分析报告(简要版) --白斌 [email protected] iOS. APP版本皆为最新版 2016.12.12 竞品选择:<新米公益> 理由:都是互联网+公益,项目模式相同,两款APP均在2015年第二季度上线,SWOT四方面两者几乎是同样的起点.下面从产品的五个层次对二者进行分析并提出建议 一.战略层: 1.产品比较 产品名称 志愿者参与方式 slogan <新米公益> 走路.早起.答题 不止更好的自己 <亿人帮&

MySQL日志审计 帮你揪出内个干坏事儿的小子

MySQL日志审计 帮你揪出内个干坏事的小子 简介 Part1:写在最前 MySQL本身并不像MariaDB和Percona一样提供审计功能,但如果我们想对数据库进行审计,去看是谁把我的数据库数据给删了,该怎么办呢?我们主要利用init-connect参数,让每个登录的用户都记录到我们的数据库中,并抓取其connection_id(),再根据binlog就能够找出谁干了那些破事儿. MariaDB如何审计,可移步: http://suifu.blog.51cto.com/9167728/1857

正则 模式修正符

模式修正符 说明 i 表示在和模式进行匹配进不区分大小写 m 将模式视为多行,使用^和$表示任何一行都可以以正则表达式开始或结束 s 如果没有使用这个模式修正符号,元字符中的"."默认不能表示换行符号,将字符串视为单行 x 表示模式中的空白忽略不计 e 正则表达式必须使用在preg_replace替换字符串的函数中时才可以使用(讲这个函数时再说) A 以模式字符串开头,相当于元字符^ Z 以模式字符串结尾,相当于元字符$ U 正则表达式的特点:就是比较"贪婪",使用

[修正] Firemonkey Android Edit 可输入 Emoji (颜文字)

问题:在 Android 平台下,TEdit 输入 Emoji 文字,无法显示彩色(皆为黑色),即使将 Edit.ControlType = Platform 设为平台原生控件,还是没用(真机测试 Style 与 Platform 是一样的,而 iOS 平台则不同). 修正方法: 请将源码 FMX.TextLayout.GPU.pas 复制到自己的工程目录里,再进行修改. procedure TTextLayoutNG.DoDrawLayout(const ACanvas: TCanvas);

记一次帮群友简单提权

00x1 故事是这样发生的 直接上菜刀. 找个地儿随便上传个exp.稀里哗啦随便点目录.觉得还是权限蛮大的.上传个cmd再说. 这就尴尬了. 然后又多找几个地儿的试了试.终于OK. 虚拟机,EXP轻松秒之.不过呢,低调. GETPASS 后来那个哥们儿跟我说 安全狗?为啥我的pr都不杀?难道我的免杀???开啥国际玩笑.懊恼的我已经是system权限.那么直接就这样搞了. 记住PID.等下日了他. 第一次那么吊的日狗. 可是怎么登录都是 在群里@了帅哥果断有人帮我.然后Frie大大说.转发3389