/// <summary> /// 소스에 대한 연결 문자열을 구하여 연결 커넥션 객체 리턴 /// </summary> /// <param name="isource_id"></param> /// <returns></returns> public object GetConnectionPerSourceID(int isource_id) { Biz_Bsc_Interface_Datasource objBSC = new Biz_Bsc_Interface_Datasource(isource_id); string strCon = ""; if (objBSC.ISource_Type.ToUpper() == "SYSTEM.DATA.SQLCLIENT") { strCon = "Data Source={0};Initial Catalog={1};User ID={2};Password={3}"; strCon = String.Format(strCon, objBSC.ICs_Data_Source, objBSC.ICs_Initial_Catalog, objBSC.ICs_User_Id, objBSC.ICs_Password); SqlConnection objCon = new SqlConnection(strCon); return(objCon); } else if (objBSC.ISource_Type.ToUpper() == "SYSTEM.DATA.ORACLECLIENT") { strCon = "Data Source={0};Persist Security Info=True;User ID={1};Password={2}; Unicode=True"; strCon = String.Format(strCon, objBSC.ICs_Data_Source, objBSC.ICs_User_Id, objBSC.ICs_Password); OracleConnection objCon = new OracleConnection(strCon); return(objCon); } else if (objBSC.ISource_Type.ToUpper() == "SYSTEM.DATA.OLEDB") { strCon = "Provider={0};Data Source={1};User Id={2};Password={3};"; strCon = String.Format(strCon, objBSC.ICs_Provider, objBSC.ICs_Data_Source, objBSC.ICs_User_Id, objBSC.ICs_Password); OleDbConnection objCon = new OleDbConnection(strCon); return(objCon); } return(null); }
public DataTable GetOrginalInterfaceData(object dicode, object diname, int itxr_user, string iYmd) { Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource(); DataSet rDs = new DataSet(); DataSet dsDicode = base.GetAllList(dicode.ToString(), "", "PULL", itxr_user); string sRtnMsg = ""; bool bisSucc = false; int iAffRow = 0; if (dsDicode.Tables.Count > 0) { Object objCon = objDS.GetConnection(int.Parse(dsDicode.Tables[0].Rows[0]["SOURCE_ID"].ToString()), out bisSucc, out sRtnMsg); string sQry = dsDicode.Tables[0].Rows[0]["QUERY"].ToString(); sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + iYmd + "'"); sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + iYmd + "'"); if (bisSucc) { if (objCon.GetType() == typeof(SqlConnection)) { SqlConnection conn = (SqlConnection)objCon; SqlCommand cmmd = new SqlCommand(sQry, conn); SqlDataAdapter dadt = new SqlDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OracleConnection)) { OracleConnection conn = (OracleConnection)objCon; OracleCommand cmmd = new OracleCommand(sQry, conn); OracleDataAdapter dadt = new OracleDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OleDbConnection)) { OleDbConnection conn = (OleDbConnection)objCon; OleDbCommand cmmd = new OleDbCommand(sQry, conn); OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } } } return(rDs.Tables[0]); }
public int ExecRowDataInterface(string iYmd, int itxr_user) { Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource(); DataSet rDs = null; DataSet dsDicode = base.GetAllList("", "", "PULL", itxr_user); string sRtnMsg = ""; bool bisSucc = false; int iAffRow = 0; int iGetRow = 0; if (dsDicode.Tables.Count > 0) { int iRow = dsDicode.Tables[0].Rows.Count; for (int i = 0; i < iRow; i++) { base.ISource_Id = int.Parse(dsDicode.Tables[0].Rows[i]["SOURCE_ID"].ToString()); Object objCon = objDS.GetConnection(base.ISource_Id, out bisSucc, out sRtnMsg); base.IDicode = dsDicode.Tables[0].Rows[i]["DICODE"].ToString(); string sQry = dsDicode.Tables[0].Rows[i]["QUERY"].ToString(); sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + iYmd + "'"); sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + iYmd + "'"); rDs = new DataSet(); if (bisSucc) { if (objCon.GetType() == typeof(SqlConnection)) { SqlConnection conn = (SqlConnection)objCon; SqlCommand cmmd = new SqlCommand(sQry, conn); SqlDataAdapter dadt = new SqlDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OracleConnection)) { OracleConnection conn = (OracleConnection)objCon; OracleCommand cmmd = new OracleCommand(sQry, conn); OracleDataAdapter dadt = new OracleDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OleDbConnection)) { OleDbConnection conn = (OleDbConnection)objCon; OleDbCommand cmmd = new OleDbCommand(sQry, conn); OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } } else { return(0); } sQry = this.GetRowDataQuery(base.IDicode, iYmd, rDs, itxr_user); //iGetRow += base.DbAgentObj.ExecuteNonQuery(sQry); string[] arrQuery = sQry.Split(';'); IDbConnection dbcon = DbAgentHelper.CreateDbConnection(); dbcon.Open(); IDbTransaction trx = dbcon.BeginTransaction(); try { for (int k = 0; k < arrQuery.Length; k++) { if (arrQuery[k].Length > 0) { iGetRow += DbAgentObj.ExecuteNonQuery(arrQuery[k]); } } trx.Commit(); } catch (Exception ex) { trx.Rollback(); iGetRow = 0; } finally { dbcon.Close(); } } } return(iGetRow); }
public DataTable GetDataResult(string idicode, string sPreYMD, string sCurYMD, int itxr_user) { Biz_Bsc_Interface_Dicode objBSC = new Biz_Bsc_Interface_Dicode(idicode, itxr_user); string sQry = objBSC.IQuery; int isource_id = objBSC.ISource_Id; bool bisSucc = false; string sRtnMsg = ""; int iAffRow = 0; sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + sCurYMD + "'"); sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + sPreYMD + "'"); DataSet rDs = new DataSet(); Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource(); Object objCon = objDS.GetConnection(isource_id, out bisSucc, out sRtnMsg); if (bisSucc && sQry.Trim().Length > 0) { if (objCon.GetType() == typeof(SqlConnection)) { SqlConnection conn = (SqlConnection)objCon; SqlCommand cmmd = new SqlCommand(sQry, conn); SqlDataAdapter dadt = new SqlDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OracleConnection)) { OracleConnection conn = (OracleConnection)objCon; OracleCommand cmmd = new OracleCommand(sQry, conn); OracleDataAdapter dadt = new OracleDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } else if (objCon.GetType() == typeof(OleDbConnection)) { OleDbConnection conn = (OleDbConnection)objCon; OleDbCommand cmmd = new OleDbCommand(sQry, conn); OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd); iAffRow = dadt.Fill(rDs); if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } if (rDs.Tables.Count > 0) { return(rDs.Tables[0]); } else { return(null); } } else { return(null); } }