Oraclebulkcopy correction Help

Source: Internet
Author: User
Tags oracleconnection reflection

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 ();
Get the English name of the table
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\ attachment 1." Data mart "transaction Data Summary-1 (modified)-copy";
Dtmulu = Excelutil.getexcelsheetcontent (fileName, "directory" + "$");
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 ("property sheet") > 0))
{

#region Reflection Gets the assembly where the validation page resides

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 ()))//Record End
{

Break
}
if (Agreementcode = = "1")//Verify yourself Call
{
A.agreementcode = Agreementcode;
}
Else
{
Etrorsb.append (String. Format ("{0} row {1} column value: {2} conversion failed", I,1,agreementcode));
Continue

}
After successful verification
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", "Test");
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 = "Test succeeded! "
};
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 *; 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 gets the current value of the sequence

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); /Use data from other sources to load the Oracle table in a valid batch
Oraclebulkcopy bulkcopy = new Oraclebulkcopy (connorclestring,
Oraclebulkcopyoptions.useinternaltransaction);
Bulkcopy.bulkcopytimeout = 260 * 1000;
Bulkcopy.destinationtablename = targettable;//The name of the target table on the server
Bulkcopy.batchsize = 50000;//number of rows in each batch
try
{ br> Conn. Open ();
if (dt! = null && dt. Rows.Count! = 0)

Bulkcopy.writetoserver (DT); Copy all rows from the supplied data source to the target table
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 ("Test Big Data Success");


}
}
}

Oraclebulkcopy correction Help

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.