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 修正帮的更多相关文章

  1. 为什么要做A.prototype.constructor=A这样的修正?

    问题 虽然看过这篇博文JavaScript prototype之后对原型理解不再那么模糊了,但是依然还有很多理解不甚透彻的地方.比如,今天看到一个原型式继承的例子,又有些困惑,于是找了些帖子看看,有了 ...

  2. 【Alpha】“北航社团帮”小程序v1.0发布声明

    我们的"北航社团帮"小程序发布啦!!! Alpha版本功能 功能列表和详情图 模块 功能 登录 授权登录,游客模式,无需填写信息 活动展示 首页轮播热度最高的四个活动,查看活动详情 ...

  3. 【Alpha】“北航社团帮”小程序v1.0项目展示

    目录 1.团队介绍 2.回答一些工程问题 整个项目的目标和预期功能 整个项目的预期典型用户 整个项目的预期用户数量 alpha满足的用户需求 alpha用户量一览 团队分工及经验教训 团队项目管理 时 ...

  4. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  5. 由Dapper QueryMultiple 返回数据的问题得出==》Dapper QueryMultiple并不会帮我们识别多个返回值的顺序

    异常汇总:http://www.cnblogs.com/dunitian/p/4523006.html#dapper 今天帮群友整理Dapper基础教程的时候手脚快了点,然后遇到了一个小问题,Dapp ...

  6. 周末聊聊IT人员的人脉观:关于帮妹子找兼职有感

    背景: 前几天,有个认识了好几年的网友,现在是大学生,在厦门读大一,说和她同学要一起到广州找兼职,看我有没有介绍. 像我这么积极热心善良的人,就说帮她找找看,结果问了几次,没消息,只好诚实的回复人家, ...

  7. 帮我做个APP,给你20万,做不做?

    一.为什么要写这篇文章 前段时间,有个辞职 创业的同事(做法务的)  问我 开发一个 新闻类的APP要多少钱,产品.UI.接口.后台管理页  他们啥都没有,想全部外包. 我 并没有在外包公司做过,也没 ...

  8. [修正] Firemonkey 中英文混排折行问题(移动平台)

    问题:FMX 在移动平台的文字显示并非由该平台的原生 API 来显示,而是由 FMX.TextLayout.GPU 来处理,也许是官方没留意到中文字符的问题,造成在中英文混排折行时,有些问题. 适用: ...

  9. [修正] Firemonkey Android 显示 Emoji (颜文字)

    问题:在 Android 平台下,显示 Emoji 文字,无法显示彩色(皆为黑色),例如 Edit 控件,即使将 Edit.ControlType = Platform 设为平台原生控件,还是没用(真 ...

随机推荐

  1. 【Leetcode 167】Two Sum II - Input array is sorted

    问题描述:给出一个升序排列好的整数数组,找出2个数,它们的和等于目标数.返回这两个数的下标(从1开始),其中第1个下标比第2个下标小. Input: numbers={2, 7, 11, 15}, t ...

  2. Apache Ignite简介以及Ignite和Coherence、Gemfire、Redis等的比较

    一.Ignite简介 Apache Ignite 内存数组组织框架是一个高性能.集成和分布式的内存计算和事务平台,用于大规模的数据集处理,比传统的基于磁盘或闪存的技术具有更高的性能,同时他还为应用和不 ...

  3. solr 的使用及安装【转】

    注本文以solr3.3为例 Solr 简介 Solr 是一个开源的企业级搜索服务器,底层使用易于扩展和修改的Java 来实现.       Solr 主要特性有:强大的全文检索功能,高亮显示检索结果, ...

  4. java6枚举类型

    java.lang.Enum > 使用enum定义. 类如: public class EnumDemo { enum Edge { TOP, BOTTOM, LEFT, RIGHT//定义了一 ...

  5. APP推送通知相关实现

      关于推送通知,iOS推送主要是通过服务端来实现的,相关过程可以参考下面两篇文章:   http://cshbbrain.iteye.com/blog/1859810   http://zxs198 ...

  6. 非常漂亮js动态球型云标签特效代码

    <%@ page contentType="text/html;charset=UTF-8" language="java" import="j ...

  7. 透过一个实例理解C++语言的explicit关键字

    我们先看一段代码:    建立people.cpp 文件,然后输入下列内容:class People{    public:      int age;     explicit People (in ...

  8. HDU1869 六度分离

    /* 六度分离 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  9. Git学习之常用的命令

    配置git git config --global user.name "你的github用户名" git config --global user.email "你的G ...

  10. Spring中引质增强的安全

    在引质增强中使用ThreadLocal变量,是因为控制状态使代理类变成了非线程安全的实例,为了解决单线程安全的问题,通过ThreadLocal让每个线程单独使用一个状态.