问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

OracleBulkCopy找不到类型或命名空间

发布网友 发布时间:2022-04-07 21:01

我来回答

2个回答

懂视网 时间:2022-04-08 01:22

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Contract.IService;
using DevExpress.Data.PLinq.Helpers;
using Framework;
using Holworth.RiskInterface;
using HraWeb.Common;
using Oracle.DataAccess.Client;
using Utility;
using WebApp.Common;
using Contract.Domain;
using System.Collections;
using OracleConnection = System.Data.OracleClient.OracleConnection;

namespace HraWeb
{
public static class DataTableExtensions
{
public static DataTable ToDataTable<T>(this IList<T> list)
{

//创建属性的集合
List<PropertyInfo> pList = new List<PropertyInfo>();
//获得反射的入口

Type type = typeof(T);
DataTable dt = new DataTable();
//把所有的public属性加入到集合 并添加DataTable的列
Array.ForEach<PropertyInfo>(type.GetProperties(), p => { pList.Add(p); dt.Columns.Add(p.Name, p.PropertyType); });
foreach (var item in list)
{
//创建一个DataRow实例
DataRow row = dt.NewRow();
//给row 赋值
pList.ForEach(p => row[p.Name] = p.GetValue(item, null));
//加入到DataTable
dt.Rows.Add(row);
}
return dt;
}

}
public partial class BasLimitToConfigureManage : JQEntityManage<Contract.Domain.BasLimitConfig>
{
IRiskLimitControlService _riskLimitControlViewService;
IRiskLimitControlService RiskLimitControlViewService
{
get
{
if (_riskLimitControlViewService == null)
{
_riskLimitControlViewService = (IRiskLimitControlService)ctx["RiskLimitControlService"];
}
return _riskLimitControlViewService;
}
}

protected override void Page_Load(object sender, EventArgs e)
{
switch (Request["_method"])
{
case "setBatchDelRows":
setBatchDelRows();
break;
case "BasLimitControlRun":
BasLimitControlRun();
break;

}

//给基类服务接口复制,可不付
//base.svc = Psvc;
if (!IsPostBack)
{

}

base.Page_Load(sender, e);
}
#region 批量插入数据
/// <summary>
/// 批量插入数据
/// </summary>
/// <param name="dt">要插入的数据</param>
/// <param name="targetTable">数据库中的表</param>
public void BulkToDB(DataTable dt, string targetTable)
{

QueryInfo info=new QueryInfo();
info.CustomSQL = "select HIBERNATE_SEQUENCE.NEXTVAL from dual";
DataTable table= Dao.ExcuteDataSet(info).Tables[0];
Int64 increId = Convert.ToInt64(table.Rows[0][0].ToString());
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 | OracleBulkCopyOptions.Default);
bulkCopy.BatchSize = 100000;
bulkCopy.BulkCopyTimeout = 260;
bulkCopy.DestinationTableName = targetTable; //服务器上目标表的名称
bulkCopy.BatchSize = dt.Rows.Count; //每一批次中的行数
try
{
conn.Open();
if (dt != null && dt.Rows.Count != 0)

bulkCopy.WriteToServer(dt); //将提供的数据源中的所有行复制到目标表中
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
if (bulkCopy != null)
bulkCopy.Close();
}
}

#endregion
private void BasLimitControlRun()
{
//IList list = Dao.FindList(new QueryInfo("RskBook"));
//IList<RskBook> funlist=new List<RskBook>();
//foreach (RskBook rskBook in list)
//{
// funlist.Add(rskBook);
//}
QueryInfo info=new QueryInfo();
info.QueryObject = "select * from ccdd";
DataTable dt = Dao.ExcuteDataSet(info).Tables[0];
// dt.Columns.Remove("risk_book_id");
BulkToDB(dt,"ccdd" );
Int64 BasLimitControlId = 0;
if (!string.IsNullOrEmpty(Request["BasLimitControlId"]))
{
Int64.TryParse(Request["BasLimitControlId"], out BasLimitControlId);
}
RiskLimitControlViewService.ProcessRiskLimitControl(BasLimitControlId);
}

private void setBatchDelRows()
{
string CheckRowIds = Request["rowidList"];
List<string> idsList = CheckRowIds.Split(‘,‘).ToList();
List<int> intIds=new List<int>();
idsList.ForEach(a => { intIds.Add(int.Parse(a));});
if (!string.IsNullOrEmpty(CheckRowIds))
{
List<string> checkList = CheckRowIds.Split(‘,‘).ToList();
info=new QueryInfo();
info.CustomSQL = "delete from BasLimitConfig t where t.id in (:ids)";
info.Parameters.Add("ids",intIds.ToArray());
Dao.ExecuteUpdate(info);

}


}


/// <summary>
/// 设置查询条件或者语句
/// </summary>
/// <returns></returns>
protected override Framework.QueryInfo SetInfo()
{
InitSearchCache();
info = base.SetInfo();
if (!string.IsNullOrEmpty(Request["BaslimitproStruPId"]))
{

string LimitDim2Id = Request["BaslimitproStruPId"];
List<string> LimitDim2IdList = GetAllProChildIds(LimitDim2Id);
LimitDim2IdList.Add(LimitDim2Id);
string[] LimitDim2Ids = LimitDim2IdList.ToArray();

info.AddParam("LimitDim2Ids", LimitDim2Ids, " and LimitDim2Id in (:LimitDim2Ids)");

}
return info;
}

private void InitSearchCache()
{
SpringCache.Remove("GetBasLimitProStrucs");
List<BasLimitProStruc> list1 = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;

if (list1 == null || list1.Count <= 0)
{
IList list2 = Dao.FindList(new QueryInfo("BasLimitProStruc"));

List<BasLimitProStruc> list3 = new List<BasLimitProStruc>();
foreach (var b in list2)
{

list3.Add(b as BasLimitProStruc);
}

SpringCache.Insert("GetBasLimitProStrucs", list3);


}
SpringCache.Remove("GetBasLimitConfigs");
List<BasLimitConfig> list11 = SpringCache.Get("GetBasLimitConfigs") as List<BasLimitConfig>;

if (list11 == null || list11.Count <= 0)
{
IList list12 = Dao.FindList(new QueryInfo("BasLimitConfig"));

List<BasLimitConfig> list3 = new List<BasLimitConfig>();
foreach (var b in list12)
{

list3.Add(b as BasLimitConfig);
}

SpringCache.Insert("GetBasLimitConfigs", list3);


}
SpringCache.Remove("BasLimitBusiStrucs");
List<BasLimitBusiStruc> childList = SpringCache.Get("BasLimitBusiStrucs") as List<BasLimitBusiStruc>;
if (childList == null || childList.Count <= 0)
{
IList list12 = Dao.FindList(new QueryInfo("BasLimitBusiStruc"));

List<BasLimitBusiStruc> list3 = new List<BasLimitBusiStruc>();
foreach (var b in list12)
{

list3.Add(b as BasLimitBusiStruc);
}

SpringCache.Insert("BasLimitBusiStrucs", list3);


}
}

private List<string> GetAllProChildIds(string parentID)
{
List<string> ids = new List<string>();

List<BasLimitProStruc> list1 = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;

List<BasLimitProStruc> prosFuncList = new List<BasLimitProStruc>();
prosFuncList = list1;
prosFuncList = (from s in prosFuncList where s.ParentId.ToString() == parentID select s).ToList();

//QueryInfo info = new QueryInfo("BasLimitProStruc b");
//info.AddParam("ParentId", parentID, " and (b.ParentId=:ParentId )");

//prosList = Dao.FindList(info);
foreach (BasLimitProStruc b1 in prosFuncList)
{
//BasLimitProStruc b1 = b as BasLimitProStruc;
ids.Add(b1.Id);
if (ParentHasChild(b1.Id))
{

ids.AddRange(GetAllProChildIds(b1.Id));
}

}

 

 


return ids;

 


}
private Spring.Caching.ICache cache;
private Spring.Caching.ICache SpringCache
{
get
{
if (cache == null)
cache = (Spring.Caching.ICache)ctx.GetObject("AspNetCache");
return cache;
}
set
{
cache = value;
}
}
private bool ParentHasChild(string id)
{

List<BasLimitProStruc> list1 = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;
list1 = (from s in list1 where s.ParentId.ToString() == id select s).ToList();
if (list1.Count > 0)
return true;
return false;

}

/// <summary>
/// 初始化页面控件
/// </summary>
protected override void InitPage()
{
base.InitPage();

// BindDrop(drp_Unit, "SPSW", true);
}
public static List<int?> list1 = new List<int?>();
public static List<int?> list2 = new List<int?>();
public static List<int?> list3 = new List<int?>();
public static List<int?> list4 = new List<int?>();
public override void ChangeList(QueryInfo infoList)
{

 


List<PorductUpperLimit> dic = new List<PorductUpperLimit>();

List<BasLimitConfig> funcBasLimitConfigList = new List<BasLimitConfig>();
list1.Clear();
list2.Clear();
foreach (var b in infoList.List)
{
BasLimitConfig b1 = b as BasLimitConfig;
list1.Add(b1.LimitDim1Id);
list2.Add(b1.LimitDim2Id);
funcBasLimitConfigList.Add(b as BasLimitConfig);

}


// 1.算出每个交易员对应货币的实际额度
foreach (BasLimitConfig b in funcBasLimitConfigList)
{
if (IsTrader(b.LimitDim1Id) && IsMoney(Convert.ToString(b.LimitDim2Id)))
{

dic.Add(new PorductUpperLimit() { TraderId = b.LimitDim1Id, TraderName = b.LimitDim1Value, ProductId = b.LimitDim2Id, ProductName = b.LimitDim2Value, UpperLimitValue = b.UpperLimitValue });
b.ActualIsAmount = b.UpperLimitValue;
// b.PartIsAmount = b.UpperLimitValue;
}
else
{

b.ActualIsAmount = NextnodeAmount(b);
// b.PartIsAmount = NextnodePartAmount(b);

}
//if (b.ActualIsAmount <= 0 && b.PartIsAmount > 0)
//{
// b.ActualIsAmount = b.PartIsAmount;
//}

}

 


}

private decimal? NextnodePartAmount(BasLimitConfig b)
{
decimal? d = 0;
string childServiceId = "";
string childProductId = "";
int? id1 = b.LimitDim1Id;
int? id2 = b.LimitDim2Id;
try
{

string strId1s = GetchildServiceId(id1);
if (strId1s.Contains(‘,‘))
strId1s = strId1s.Substring(0, strId1s.Length - 1);
string strId2s = GetchildProductId(id2);
if (strId2s.Contains(‘,‘))
strId2s = strId2s.Substring(0, strId2s.Length - 1);

List<string> strid1Arr = strId1s.Split(‘,‘).ToList();
List<string> strid2Arr = strId2s.Split(‘,‘).ToList();

for (int i = 0; i < strid1Arr.Count; i++)
{
for (int j = 0; j < strid2Arr.Count; j++)
{
List<BasLimitConfig> BasLimitConfigs = SpringCache.Get("GetBasLimitConfigs") as List<BasLimitConfig>;
string i1 = strid1Arr[i];
string i2 = strid2Arr[j];
//if (list1.Contains(int.Parse(i1)) && list2.Contains(int.Parse(i2)))
{
BasLimitConfigs = (from s in BasLimitConfigs
where s.LimitDim1Id.ToString() == i1.ToString() && s.LimitDim2Id.ToString() == i2.ToString()
select s).ToList();
if (BasLimitConfigs != null && BasLimitConfigs.Count > 0)
{
BasLimitConfig b1 = BasLimitConfigs[0];
//QueryInfo info = new QueryInfo("BasLimitConfig");
//info.AddParam("LimitDim1Id", i1, " and LimitDim1Id=:LimitDim1Id");
//info.AddParam("LimitDim2Id", i2, " and LimitDim2Id=:LimitDim2Id");
//BasLimitConfig b1 = Dao.FindOne(info) as BasLimitConfig;
if (b1 != null)
{
d += b1.UpperLimitValue;

}
}


}

}

}
}
catch (Exception ex)
{

JSUtil.log(ex.ToString());
}

return d;
}

 


private decimal? NextnodeAmount(BasLimitConfig b)
{
decimal? d = 0;
int? id1 = b.LimitDim1Id;
int? id2 = b.LimitDim2Id;

try
{

string strId1s = GetAllTraderId(id1);
if (strId1s.Contains(‘,‘))
strId1s = strId1s.Substring(0, strId1s.Length - 1);
string strId2s = GetAllProductId(id2);
if (strId2s.Contains(‘,‘))
strId2s = strId2s.Substring(0, strId2s.Length - 1);

List<string> strid1Arr = strId1s.Split(‘,‘).ToList();
List<string> strid2Arr = strId2s.Split(‘,‘).ToList();

for (int i = 0; i < strid1Arr.Count; i++)
{
for (int j = 0; j < strid2Arr.Count; j++)
{
List<BasLimitConfig> BasLimitConfigs = SpringCache.Get("GetBasLimitConfigs") as List<BasLimitConfig>;
string i1 = strid1Arr[i];
string i2 = strid2Arr[j];
//if (list1.Contains(int.Parse(i1)) && list2.Contains(int.Parse(i2)))
{
BasLimitConfigs = (from s in BasLimitConfigs
where s.LimitDim1Id.ToString() == i1.ToString() && s.LimitDim2Id.ToString() == i2.ToString()
select s).ToList();
if (BasLimitConfigs != null && BasLimitConfigs.Count > 0)
{
BasLimitConfig b1 = BasLimitConfigs[0];

if (b1 != null)
{
d += b1.UpperLimitValue;

}
}


}

}

}
}
catch (Exception ex)
{

JSUtil.log(ex);
}

 

return d;

 


}
//why
private string GetchildProductId(int? id2)
{
string PNameList = string.Empty;
List<BasLimitProStruc> childList = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;
childList = (from s in childList where s.ParentId.ToString() == id2.ToString() select s).ToList();
for (int i = 0; i < childList.Count; i++)
{
PNameList += (int.Parse(childList[i].Id)) + ",";
}

return PNameList;
}

private string GetchildServiceId(int? id2)
{
string PNameList = string.Empty;
List<BasLimitBusiStruc> childList = SpringCache.Get("BasLimitBusiStrucs") as List<BasLimitBusiStruc>;
childList = (from s in childList where s.ParentId.ToString() == id2.ToString() select s).ToList();
for (int i = 0; i < childList.Count; i++)
{
PNameList += (int.Parse(childList[i].Id)) + ",";
}
return PNameList;
}
private string GetAllProductId(int? id2)
{
string PNameList = string.Empty;
if (IsMoney(id2.ToString()))
{
list4.Add(id2);
return id2.ToString();
}
List<BasLimitProStruc> childList2 = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;
childList2 = (from s in childList2 where s.ParentId.ToString() == id2.ToString() select s).ToList();

//QueryInfo info = new QueryInfo("BasLimitProStruc");
//info.AddParam("ParentId", id2, " and ParentId=:ParentId");

//IList childList = Dao.FindByQueryInfo(info).List;


for (int i = 0; i < childList2.Count; i++)
{
//BasLimitProStruc basLimitPro = childList[i] as BasLimitProStruc;
PNameList += GetAllProductId(int.Parse(childList2[i].Id)) + ",";
}


return PNameList;
}

private string GetAllTraderId(int? id1)
{
string PNameList = string.Empty;
if (IsTrader(id1))
{

list3.Add(id1);

return id1.ToString();
}
//
List<BasLimitBusiStruc> childList = SpringCache.Get("BasLimitBusiStrucs") as List<BasLimitBusiStruc>;
childList = (from s in childList where s.ParentId.ToString() == id1.ToString() select s).ToList();

//
//QueryInfo info = new QueryInfo("BasLimitBusiStruc");
//info.AddParam("ParentId", id1, " and ParentId=:ParentId");
//IList childList = Dao.FindByQueryInfo(info).List;
if (childList != null && childList.Count > 0)
{
for (int i = 0; i < childList.Count; i++)
{
//BasLimitBusiStruc child = childList[i] as BasLimitBusiStruc;

PNameList += GetAllTraderId(int.Parse(childList[i].Id)) + ",";
}
}

 

 


return PNameList;

 

}


private bool IsMoney(string limitDim2Id)
{

List<BasLimitProStruc> list = SpringCache.Get("GetBasLimitProStrucs") as List<BasLimitProStruc>;
list = (from s in list where s.Id.ToString() == limitDim2Id.ToString() && s.IsMoney == 1 select s).ToList();

//QueryInfo MoneyInfo = new QueryInfo("BasLimitProStruc");

//MoneyInfo.Where.Add("where", " and Id=:limitDim2Id and ProLevel=4");
//MoneyInfo.Parameters.Add("limitDim2Id", limitDim2Id);
//IList list = Dao.FindByQueryInfo(MoneyInfo).List;

if (list.Count > 0)
{
return true;
}
return false;
}

private bool IsTrader(decimal? limitDim1Id)
{
List<BasLimitBusiStruc> list = SpringCache.Get("BasLimitBusiStrucs") as List<BasLimitBusiStruc>;
list = (from s in list where s.Id == limitDim1Id.ToString() && s.IsTrader == 1 select s).ToList();

//QueryInfo TraderInfo = new QueryInfo("BasLimitBusiStruc");

//TraderInfo.Where.Add("where", " and Id=:limitDim1Id and IsTrader=1");
//TraderInfo.Parameters.Add("limitDim1Id", limitDim1Id);
//IList list = Dao.FindByQueryInfo(TraderInfo).List;

if (list.Count > 0)
{
return true;
}
return false;
}


}

internal class PorductUpperLimit
{
public int? TraderId { get; set; }
public string TraderName { get; set; }
public int? ProductId { get; set; }
public string ProductName { get; set; }
public decimal? UpperLimitValue { get; set; }

}
}

 

OracleBulkCopy

标签:

热心网友 时间:2022-04-07 22:30

需要使用Oracle自己的ODP.net才可以使用!
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
单位高温防护欠缺致员工中暑如何对待 狗狗为什么爱看视频 360浏览器怎么设置倍速播放 ...先讲女主的灵魂飘荡了一段时间,然后重生,请问是那本? 拯救者散热器怎么开 电脑如何一键还原系统电脑一键还原怎么操作 神舟笔记本电脑怎么重新设置神舟战神bios恢复出厂设置 神舟电脑恢复出厂设置神舟战神怎么恢复原厂系统 水泥楼梯如何铺木楼梯 家里面楼梯是水泥的不想铺地毯或者地砖还能铺什么 成语“安若浮生”是什么意思? 浮生若梦类似的成语 类似浮生如梦的成语 一颗心上面写浮生两字是什么成语 谜面: 方得浮生一日闲 (打成语一) 疯狂猜成语之书生的全部答案之浮生 天天猜成语两个字浮生 一个黑色的心里写着浮生打一成语 黑色底上面有浮生两字打一成语 什么浮生的成语 黑底写着白字浮生打成语 浮字和生字猜一成语 浮生是什么成语 怎样用 Excel 做雅思成绩计算器? Wps简历保存到本地没有电话和邮箱 自喷漆瓶子里有颗珠子是干啥子用的? 红米k30怎么开启超级夜景 罐装自喷漆2K素色漆怎么做到不固化? 方大炭素是什么性质的企业?方大炭素为什么业绩好就是不涨?方大炭素属于哪个集团? 八大员老证要过期了怎么继续教育 教师中二评中一需要什么? 中二教师几年能晋升中一 教师中二转中一所需条件 教师中二晋升中一绿色通到啥条件? 安静的女孩发型颜色冷棕色好看还是冷茶色好看 保定市教师评职称,中二评中一需要什么材料? 教师中二晋级中一所需的资格证及证书都哪些河南 教师评中教一级需要那些材料 文静女孩适合头发冷茶色还是冷棕色吗 2015年河南中二晋升中一小学教师资格证可以吗 文静的女孩头发染冷茶色好看还是冷棕色好看 热水器烧水温度上不去怎么办 初中教师中二进中一,教数学,最高学历本科(汉语言文学专业),要破格吗、还是正常?破格到底是咋回事? 小学教师小一职称评定 南充教师职称中二转小一 南京中小学教师升职称,是不是从:二级~小职称~一级 ?分别需要哪些条件呢? 唯品会如何使用唯品币 那位亲告诉我唯品会的唯品币如何使用 在唯品会购买唯品卡可以获得唯品币吗? 唯品会退货赚钱是怎么回事