public static int InsertRackEffect(string str_sql, DateTime dt_inserttime) { if (DBUrl.SERVERMODE) { WorkQueue <string> .getInstance_rackeffect().WorkSequential = true; WorkQueue <string> .getInstance_rackeffect().EnqueueItem(str_sql); return(1); } if (DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL")) { WorkQueue <string> .getInstance_rackeffect().WorkSequential = true; WorkQueue <string> .getInstance_rackeffect().EnqueueItem(str_sql); return(1); } DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getThermalConnection(); if (dBConn != null && dBConn.con != null) { dbCommand = dBConn.con.CreateCommand(); } dbCommand.CommandText = str_sql.Replace("'", "#"); dbCommand.ExecuteNonQuery(); dbCommand.Dispose(); dBConn.Close(); return(1); } catch (Exception ex) { try { dbCommand.Dispose(); } catch { } try { dBConn.Close(); } catch { } DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Generate RackEffect Error : " + ex.Message + "\n" + ex.StackTrace); } return(-1); }
public static void DeleteOverallRemainLastSomeHours(int hours, DateTime currentTime) { DateTime dateTime = currentTime.AddHours((double)(-(double)hours)); Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); string text = "delete from rack_effect where insert_time < #" + dateTime.ToString("yyyy-MM-dd HH:mm:ss") + "#"; if (DBUrl.SERVERMODE || DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL")) { WorkQueue <string> .getInstance_rackeffect().WorkSequential = true; WorkQueue <string> .getInstance_rackeffect().EnqueueItem(text); return; } DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getThermalConnection(); if (dBConn != null && dBConn.con != null) { dbCommand = dBConn.con.CreateCommand(); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = text; dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); dBConn.Close(); } catch (Exception ex) { try { dbCommand.Dispose(); } catch { } try { dBConn.Close(); } catch { } DebugCenter.GetInstance().appendToFile("Delete Rack effect: " + ex.Message + "\n" + ex.StackTrace); } }