Output.DB.SensusOracle.Database : Writing results more robust, preventing program crash.
This commit is contained in:
@@ -626,14 +626,23 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
|
||||
public Retv WriteResultsToDB(OracleConnection conn, Results.Entities.Batch batch, bool safeMode)
|
||||
{
|
||||
OracleTransaction transaction = null;
|
||||
OracleTransaction transaction;
|
||||
|
||||
try
|
||||
{
|
||||
conn.Open(); /// Open the Oracle database
|
||||
|
||||
transaction = conn.BeginTransaction();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.ErrorFormat("Results of batch {0} not written to ORACLE DB (phase 1): {1}",
|
||||
batch.BatchNr, exc.Message);
|
||||
conn.Close();
|
||||
return Retv.Error;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SaveBatchData(conn, batch);
|
||||
foreach (var wMtr in batch.WaterMeters)
|
||||
{
|
||||
@@ -641,20 +650,17 @@ namespace TBF.BenchControl.Output.DB.SensusOracle
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
conn.Close();
|
||||
log.ErrorFormat("Results of batch {0} correctly written to ORACLE DB", batch.BatchNr);
|
||||
return Retv.OK;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (transaction != null) transaction.Rollback();
|
||||
|
||||
log.ErrorFormat("Results of batch {0} not written to ORACLE database: {1}",
|
||||
batch.BatchNr, exc.Message);
|
||||
|
||||
transaction.Rollback();
|
||||
conn.Close();
|
||||
log.ErrorFormat("Results of batch {0} not written to ORACLE DB: {1}", batch.BatchNr, exc.Message);
|
||||
return Retv.Error;
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
return Retv.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user