public String InsertEi_OmeSQLServer(SqlEi_OmeObject sqlEi_Omes) { sql = ""; ProjectStringPool stringPool = new ProjectStringPool(); //List<OraEi_OmeObject> insertedEi_OmeObjects = new List<OraEi_OmeObject>(); sql = stringPool.getInsSQLServerEi_OmeSQL(); actionResult = "SUCCESS"; OpenConnection(); try { SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = sql; sqlCommand.Parameters.AddWithValue("@val01", sqlEi_Omes.Ei_ome01); sqlCommand.Parameters.AddWithValue("@val02", sqlEi_Omes.Ei_ome02); sqlCommand.Parameters.AddWithValue("@val03", sqlEi_Omes.Ei_ome04); sqlCommand.Parameters.AddWithValue("@val04", sqlEi_Omes.Ei_ome05); sqlCommand.Parameters.AddWithValue("@val05", sqlEi_Omes.Ei_ome06); sqlCommand.Parameters.AddWithValue("@val06", sqlEi_Omes.Ei_ome07); sqlCommand.Parameters.AddWithValue("@val07", sqlEi_Omes.Ei_ome08); sqlCommand.Parameters.AddWithValue("@val08", sqlEi_Omes.Ei_ome09); sqlCommand.Parameters.AddWithValue("@val09", sqlEi_Omes.Ei_ome10); sqlCommand.Parameters.AddWithValue("@val010", sqlEi_Omes.Ei_ome11); sqlCommand.Parameters.AddWithValue("@val011", sqlEi_Omes.Ei_ome12); sqlCommand.Parameters.AddWithValue("@val012", sqlEi_Omes.Ei_ome13); /* * sqlCommand.Parameters.AddWithValue("@val13", sqlEi_Omes.Ei_ome14); * sqlCommand.Parameters.AddWithValue("@val14", sqlEi_Omes.Ei_ome15); * sqlCommand.Parameters.AddWithValue("@val15", sqlEi_Omes.Ei_omevoid); * sqlCommand.Parameters.AddWithValue("@val16", sqlEi_Omes.Ei_omevoidu); * sqlCommand.Parameters.AddWithValue("@val17", sqlEi_Omes.Ei_omevoidd); * sqlCommand.Parameters.AddWithValue("@val18", sqlEi_Omes.Ei_omevoidm); * sqlCommand.Parameters.AddWithValue("@val19", sqlEi_Omes.Tc_omevoids); * sqlCommand.Parameters.AddWithValue("@val20", sqlEi_Omes.Ei_omecncl); * sqlCommand.Parameters.AddWithValue("@val21", sqlEi_Omes.Ei_omecnclu); * sqlCommand.Parameters.AddWithValue("@val22", sqlEi_Omes.Ei_omecncld); * sqlCommand.Parameters.AddWithValue("@val23", sqlEi_Omes.Ei_omecnclm); * sqlCommand.Parameters.AddWithValue("@val24", sqlEi_Omes.Tc_omecncls); */ sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { Console.Write("SQLServer Ins Ei_Ome Exception : " + ex.Message); actionResult = "FAIL"; } finally { CloseConnection(); } return(actionResult); }
static void Main(string[] args) { ProjectStringPool projectStringPool = new ProjectStringPool(); OracleDBConductor oracleDBConductor = new OracleDBConductor(); DataTable dataTable; SqlEi_OmeObject sqlEi_OmeObject; OraTc_OmeObject oraTc_OmeObject; List <SqlEi_OmeObject> goodSQLServerEi_OmeObjects; List <SqlEi_OmeObject> insertedEi_OmeObjects; List <OraTc_OmeObject> updatedTc_OmeObjects; string oraResult; int dataCount; string actionResult; //int deletedRows; try { string oraSQLString = projectStringPool.getSelectEi_OmeDataSQL(); dataTable = oracleDBConductor.GetDataTable(oraSQLString); oraResult = ""; goodSQLServerEi_OmeObjects = new List <SqlEi_OmeObject>(); if (dataTable.Rows.Count > 0) { foreach (DataRow row in dataTable.Rows) { sqlEi_OmeObject = new SqlEi_OmeObject(); oraTc_OmeObject = new OraTc_OmeObject(); oraResult = "Y"; try { sqlEi_OmeObject.Ei_ome01 = row[dataTable.Columns["ome01"]].ToString(); sqlEi_OmeObject.Ei_ome02 = (row[dataTable.Columns["ome02"]]) == DBNull.Value ? "" : Convert.ToDateTime(row[dataTable.Columns["ome02"]]).ToString("yyyy-MM-dd"); sqlEi_OmeObject.Ei_ome04 = row[dataTable.Columns["ome04"]].ToString(); sqlEi_OmeObject.Ei_ome05 = row[dataTable.Columns["ome042"]].ToString(); sqlEi_OmeObject.Ei_ome06 = row[dataTable.Columns["ome043"]].ToString(); sqlEi_OmeObject.Ei_ome07 = row[dataTable.Columns["ome044"]].ToString(); sqlEi_OmeObject.Ei_ome08 = row[dataTable.Columns["ome16"]].ToString(); sqlEi_OmeObject.Ei_ome09 = row[dataTable.Columns["ome21"]].ToString(); sqlEi_OmeObject.Ei_ome10 = (row[dataTable.Columns["ome211"]]) == DBNull.Value ? 0 : Convert.ToDecimal(row[dataTable.Columns["ome211"]]); sqlEi_OmeObject.Ei_ome11 = (row[dataTable.Columns["ome59"]]) == DBNull.Value ? 0 : Convert.ToDecimal(row[dataTable.Columns["ome59"]]); sqlEi_OmeObject.Ei_ome12 = (row[dataTable.Columns["ome59x"]]) == DBNull.Value ? 0 : Convert.ToDecimal(row[dataTable.Columns["ome59x"]]); sqlEi_OmeObject.Ei_ome13 = (row[dataTable.Columns["ome59t"]]) == DBNull.Value ? 0 : Convert.ToDecimal(row[dataTable.Columns["ome59t"]]); } catch (Exception ex) { oraResult = "N"; Console.WriteLine("Foreach Exception:" + ex.Message); PostalService postalService = new PostalService(); postalService.SendMail("*****@*****.**", "Intermediate Data Copier Alert", ex.Message); break; } finally { if (oraResult == "Y") { SQLServerDataSecuricor dataSecuricor = new SQLServerDataSecuricor(); dataCount = 0; dataCount = dataSecuricor.SelectEi_OmeRowCounts(sqlEi_OmeObject.Ei_ome01); if (dataCount == 0) { goodSQLServerEi_OmeObjects.Add(sqlEi_OmeObject); } } } //End of try-catch-finally //}//End of foreach } //End of if else actionResult = "FAILED"; insertedEi_OmeObjects = new List <SqlEi_OmeObject>(); updatedTc_OmeObjects = new List <OraTc_OmeObject>(); if (goodSQLServerEi_OmeObjects.Count > 0) { foreach (SqlEi_OmeObject ei_InsOme in goodSQLServerEi_OmeObjects) { SQLServerConductor sqlServerConductor = new SQLServerConductor(); actionResult = sqlServerConductor.InsertEi_OmeSQLServer(ei_InsOme); if (actionResult == "SUCCESS") { insertedEi_OmeObjects.Add(ei_InsOme); } } foreach (SqlEi_OmeObject ei_ome in goodSQLServerEi_OmeObjects) { oracleDBConductor.UpdateTc_OmeDB(ei_ome.Ei_ome01); } } } } catch (Exception ex) { Console.Write("Exception : " + ex.Message); return; } }