标签:
1.先查看概念 可以看highplayer博客
http://blog.csdn.net/highplayer/article/details/6613817
2.
protected void staticStressTest(object sender, EventArgs e)
{
#region MyRegion
if (string.IsNullOrEmpty(txt_ComputeDate_.Value))
{
Page.ClientScript.RegisterClientScriptBlock(JSUtil.CurrentPage.GetType(), Util.NewGuid(), @"<script>$.messager.alert(‘操作提示‘, ‘查询日期不能为空!‘);</script>");
return;
}
DataTable dt = new DataTable();
DateTime computeDate = DateTime.Parse(txt_ComputeDate_.Value);
double[] termList =
{
0.01, 0.02, 0.03, 0.05, 0.1, 0.2, 0.3, 0.5, 1, 2, 5, 0, -0.01, -0.02, -0.03,
-0.05, -0.1, -0.2, -0.3, -0.5, -1, -2, -5
};
string[] nameList =
{
"Add_One_Percent", "Add_Two_Percent", "Add_Three_Percent", "Add_Five_Percent",
"Add_Ten_Percent", "Add_Twenty_Percent", "Add_Thirty_Percent", "Add_Fifty_Percent",
"Add_One_Hundred_Percent", "Add_Two_Hundred_Percent",
"Add_Five_Hundred_Percent", "Unchanged_Value", "Minus_One_Percent", "Minus_Two_Percent",
"Minus_Three_Percent", "Minus_Five_Percent", "Minus_Ten_Percent", "Minus_Twenty_Percent",
"Minus_Thirty_Percent", "Minus_Fifty_Percent", "Minus_One_Hundred_Percent",
"Minus_Two_Hundred_Percent",
"Minus_Five_Hundred_Percent"
};
for (int i = 0; i < termList.Length; i++)
{
ShockInputData shockInputData = new ShockInputData();
shockInputData.ShockValueTypeID = (int)LookupItems.VALUE_TYPE_PERCENTAGE;
shockInputData.ShockValue = termList[i];
shockInputData.ShockModeID = (int)LookupItems.SHOCK_MODE_ADD;
shockInputData.ShockScope = "ALL";
shockInputData.ShockFlag = Constants.SHOCK_YES;
shockInputData.ShockType = "MarketPrice";
Psvc.GenerateStressedTranCashflowByDatesWithShock(computeDate, computeDate, computeDate,
computeDate, shockInputData, "STRESS_TEST_STATIC");
payoffComputationService.ComputeTransactionPayoffByDate(computeDate, "STRESS_TEST_STATIC");
string sql =
"select t.portfolio_id as ITEM_ID,t.transaction_id ,t.transaction_sub_id,t.as_of_date as COMPUTE_DATE,po.portfolio_name,round(sum(t.mark_to_market_value),2) " +
nameList[i] +
" from tran_payoff t " +
"inner join bas_portfolio po on po.portfolio_id=t.portfolio_id" +
" where t.result_use_type = ‘STRESS_TEST_STATIC‘ and as_of_date=:ComputeDate" +
" group by t.portfolio_id,t.as_of_date,t.transaction_id,t.transaction_sub_id,po.portfolio_name";
QueryInfo dsInfo = new QueryInfo();
dsInfo.CustomSQL = sql;
dsInfo.AddParam("ComputeDate",computeDate);
DataSet tempSet = Dao.ExcuteDataSet(dsInfo);
tempSet.Tables[0].PrimaryKey = new[]
{
tempSet.Tables[0].Columns[0],
tempSet.Tables[0].Columns[1],
tempSet.Tables[0].Columns[2],
tempSet.Tables[0].Columns[3]
};
if (i == 0)
{
dt = tempSet.Tables[0];
}
else
{
dt.Merge(tempSet.Tables[0]);
}
}
var resultList = dt.ToList<RskStaticStressTest>();
QueryInfo deleteInfo = new QueryInfo();
deleteInfo.CustomSQL = "delete from RskStaticStressTest where ComputeDate=:ComputeDate";
deleteInfo.Parameters.Add("ComputeDate", computeDate);
Dao.ExecuteUpdate(deleteInfo);
Dao.SaveOrUpdateAll(resultList);
ASPxGridView1.DataSource = dt;Session["rsk_staticstress_dev"] = dt;
ASPxGridView1.DataBind();
#endregion
//Page.ClientScript.RegisterClientScriptBlock(JSUtil.CurrentPage.GetType(), Util.NewGuid(), @"<script>DataGrid.WaitMessage(‘正在加载数据,请稍后。。’);</script>");
//Thread.Sleep(5000);
//Page.ClientScript.RegisterClientScriptBlock(JSUtil.CurrentPage.GetType(), Util.NewGuid(), @"<script> DataGrid.RemoveWaitMessage();</script>");
Page.ClientScript.RegisterClientScriptBlock(JSUtil.CurrentPage.GetType(), Util.NewGuid(), @"<script>$.messager.alert(‘操作提示‘, ‘计算成功!‘);</script>");
}
DataTable 设置primarykey 后进行 Merge操作
标签:
原文地址:http://www.cnblogs.com/kexb/p/4881762.html