public int Update() { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; string commandText = "update line_info set max_voltage=?,min_voltage=?,max_power=?,min_power=?,max_current=?,min_current=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand)); int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Device = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Device" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static long DeleteLogByRecords(int records) { long result = 0L; string commandText = "select min(log.id) from (select top " + records + " id from logrecords order by id desc ) as log"; string arg = "delete from logrecords where id < "; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { commandText = "select min(logg.id) from (select id from logrecords order by id desc LIMIT " + records + " OFFSET 0 ) as logg"; } dbCommand.CommandText = commandText; object obj = dbCommand.ExecuteScalar(); if (obj != null && obj != DBNull.Value) { int num = 0; try { num = Convert.ToInt32(obj); } catch { } dbCommand.CommandText = arg + num; result = (long)dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public static bool SetEventInfo(DataTable eventlist) { bool result = false; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); foreach (DataRow dataRow in eventlist.Rows) { dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = string.Concat(new object[] { "update event_info set logflag = ", Convert.ToInt16(dataRow["logflag"]), ", mailflag = ", Convert.ToInt16(dataRow["mailflag"]), " where eventid = '", Convert.ToString(dataRow["eventid"]), "' " }); dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); DBCacheStatus.Event = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Event" }); return(true); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public static int UpdateGroupStatus(int i_selectflag, string str_groups) { int result = -1; DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; string commandText = string.Concat(new object[] { "update data_group set isselect = ", i_selectflag, " where id in (", str_groups, " )" }); dbCommand.CommandText = commandText; result = dbCommand.ExecuteNonQuery(); DBCacheStatus.Group = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Group" }); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public static long DeleteLogByDay(int iDays) { long result = 0L; DateTime dateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AddDays((double)(-(double)(iDays - 1))); new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0); string commandText = "delete from logrecords where ticks < #" + DateTime.Now.AddHours((double)(-24 * iDays)).ToString("yyyy-MM-dd HH:mm:ss") + "#"; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = commandText; if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } result = (long)dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public static int CreateZoneInfo(string str_name, string str_racklist, int i_sx, int i_sy, int i_ex, int i_ey, string str_color) { DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "insert into zone_info ( zone_nm,racks,sx,sy,ex,ey,color,reserve ) values(?zone_nm,?racks,?sx,?sy,?ex,?ey,?color,?reserve)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Clear(); dbCommand.Parameters.Add(DBTools.GetParameter("?zone_nm", str_name, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?racks", str_racklist, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?sx", i_sx, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?sy", i_sy, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ex", i_ex, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ey", i_ey, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?color", str_color, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?reserve", Convert.ToInt32("0"), dbCommand)); } else { string commandText = "insert into zone_info ( zone_nm,racks,sx,sy,ex,ey,color,reserve ) values(?,?,?,?,?,?,?,?)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Clear(); dbCommand.Parameters.Add(DBTools.GetParameter("@zone_nm", str_name, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@racks", str_racklist, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@sx", i_sx, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@sy", i_sy, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ex", i_ex, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ey", i_ey, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@color", str_color, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@reserve", Convert.ToInt32("0"), dbCommand)); } int num = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.ZONE = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_ZONE" }); int result = num; return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); if (ex.Message.IndexOf(" duplicate values ") > 0) { int result = -2; return(result); } } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static int CloseAllConnection() { if (DBUrl.RUNMODE == 2) { DBConn[] array = DBConnPool.dynaConns; for (int i = 0; i < array.Length; i++) { DBConn dBConn = array[i]; if (dBConn.con != null) { try { dBConn.close(); dBConn.con.Close(); dBConn.con = null; } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("Close DBConnection exception : " + ex.Message + "\n" + ex.StackTrace); } } } DBConn[] array2 = DBConnPool.dbConns; for (int j = 0; j < array2.Length; j++) { DBConn dBConn2 = array2[j]; if (dBConn2.con != null) { try { dBConn2.close(); dBConn2.con.Close(); dBConn2.con = null; } catch (Exception ex2) { DebugCenter.GetInstance().appendToFile("Close DBConnection exception : " + ex2.Message + "\n" + ex2.StackTrace); } } } return(1); } if (DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL")) { return(1); } DBConn[] array3 = DBConnPool.dynaConns; for (int k = 0; k < array3.Length; k++) { DBConn dBConn3 = array3[k]; if (dBConn3.con != null) { try { dBConn3.close(); dBConn3.con.Close(); dBConn3.con = null; } catch (Exception ex3) { DebugCenter.GetInstance().appendToFile("Close DBConnection exception : " + ex3.Message + "\n" + ex3.StackTrace); } } } return(1); }
public int Update() { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "update port_info set port_nm=?port_nm,port_confirmation=?port_confirmation,port_ondelay_time=?port_ondelay_time,port_offdelay_time=?port_offdelay_time,max_voltage=?max_voltage,min_voltage=?min_voltage,max_power_diss=?max_power_diss,min_power_diss=?min_power_diss,max_power=?max_power,min_power=?min_power,max_current=?max_current,min_current=?min_current,shutdown_method=?shutdown_method ,mac=?mac where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?port_nm", this.port_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?port_confirmation", this.port_confirmation, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?port_ondelay_time", this.port_ondelay_time, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?port_offdelay_time", this.port_offdelay_time, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_power_diss", this.max_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_power_diss", this.min_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_current", this.min_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?shutdown_method", this.shutdown_method, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?mac", this.port_mac, dbCommand)); } else { string commandText = "update port_info set port_nm=?,port_confirmation=?,port_ondelay_time=?,port_offdelay_time=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?,shutdown_method=? ,mac=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@port_nm", this.port_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@port_confirmation", this.port_confirmation, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@port_ondelay_time", this.port_ondelay_time, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@port_offdelay_time", this.port_offdelay_time, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@shutdown_method", this.shutdown_method, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@mac", this.port_mac, dbCommand)); } int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Device = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Device" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { dbCommand.Dispose(); if (dBConn != null) { dBConn.close(); } } return(-1); }
public int UpdateSetting() { DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "update smtpsetting set EnableSMTP=?EnableSMTP , ServerAddress=?ServerAddress , PortId=?PortId , EmailFrom=?EmailFrom , EmailTo=?EmailTo , SendEvent=?SendEvent , EnableAuth=?EnableAuth, Account=?Account, UserPwd=?UserPwd "; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?EnableSMTP", this.smtp_enable, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ServerAddress", this.smtp_server, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?PortId", this.smtp_port, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?EmailFrom", this.smtp_from, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?EmailTo", this.smtp_to, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?SendEvent", this.smtp_event, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?EnableAuth", this.smtp_auth, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?Account", this.smtp_account, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?UserPwd", this.smtp_pwd, dbCommand)); } else { string commandText = "update smtpsetting set EnableSMTP=? , ServerAddress=? , PortId=? , EmailFrom=? , EmailTo=? , SendEvent=? , EnableAuth=?, Account=?, UserPwd=? "; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@EnableSMTP", this.smtp_enable, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ServerAddress", this.smtp_server, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@PortId", this.smtp_port, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@EmailFrom", this.smtp_from, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@EmailTo", this.smtp_to, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@SendEvent", this.smtp_event, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@EnableAuth", this.smtp_auth, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@Account", this.smtp_account, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@UserPwd", this.smtp_pwd, dbCommand)); } int num = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Smtp = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Smtp" }); int result = num; return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); if (ex.Message.IndexOf(" duplicate values ") > 0) { int result = -2; return(result); } } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public int update() { int num = -1; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); string commandText = "update sys_para set para_value = '" + this.maintenance + "' where para_name = 'LIMITTYPE' and para_type = 'int' "; string commandText2 = "update sys_para set para_value = '" + this.days + "' where para_name = 'DAYLIMIT' and para_type = 'int' "; string commandText3 = "update sys_para set para_value = '" + this.recordNum + "' where para_name = 'RECORDSLIMIT' and para_type = 'int' "; string commandText4 = "update sys_para set para_value = '" + this.pageSize + "' where para_name = 'PAGESIZE' and para_type = 'int' "; string commandText5 = "update sys_para set para_value = '" + this.saveRange + "' where para_name = 'SAVERANGE' and para_type = 'int' "; dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = commandText; num = dbCommand.ExecuteNonQuery(); if (num < 1) { int result = num; return(result); } dbCommand.CommandText = commandText2; num = dbCommand.ExecuteNonQuery(); if (num < 1) { int result = num; return(result); } dbCommand.CommandText = commandText3; num = dbCommand.ExecuteNonQuery(); if (num < 1) { int result = num; return(result); } dbCommand.CommandText = commandText4; num = dbCommand.ExecuteNonQuery(); if (num < 1) { int result = num; return(result); } dbCommand.CommandText = commandText5; num = dbCommand.ExecuteNonQuery(); dbCommand.Dispose(); DBCacheStatus.SystemParameter = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_SystemParameter" }); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(num); }
public int Update() { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "update bank_info set port_nums=?port_nums,bank_nm=?bank_nm,voltage=?voltage,max_voltage=?max_voltage,min_voltage=?min_voltage,max_power_diss=?max_power_diss,min_power_diss=?min_power_diss,max_power=?max_power,min_power=?min_power,max_current=?max_current,min_current=?min_current where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?port_nums", this.portlists, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?bank_nm", this.bank_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?voltage", this.voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_power_diss", this.max_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_power_diss", this.min_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_current", this.min_current, dbCommand)); } else { if (this.bank_nm != null && this.bank_nm.Equals("\r\n")) { string commandText = "update bank_info set port_nums=?,voltage=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@port_nums", this.portlists, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@voltage", this.voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand)); } else { string commandText = "update bank_info set port_nums=?,bank_nm=?,voltage=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@port_nums", this.portlists, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@bank_nm", this.bank_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@voltage", this.voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power_diss", this.max_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power_diss", this.min_power_diss, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand)); } } int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Device = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Device" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static int DeleteGroupByID(long l_id) { DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; string commandText = "delete from group_detail where group_id = " + l_id; dbCommand.CommandText = commandText; int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); dbCommand.CommandText = "delete from groupcontroltask where groupid = " + l_id; result = dbCommand.ExecuteNonQuery(); dbCommand.CommandText = "delete from taskschedule where groupid = " + l_id; result = dbCommand.ExecuteNonQuery(); dbCommand.CommandText = "delete from data_group where id = " + l_id; result = dbCommand.ExecuteNonQuery(); dbCommand.CommandText = "delete from ugp where gid =" + l_id; dbCommand.ExecuteNonQuery(); DBCacheStatus.Group = true; DBCacheStatus.GroupTask = true; DBCacheStatus.User = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Group" }); DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_GroupTask" }); DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_User" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
private static string getExpiryfromlog() { DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getLogConnection(); if (dBConn != null && dBConn.con != null) { string result; if (DBUtil.DetermineTableExist(dBConn.con, "sys_info")) { dbCommand = dBConn.con.CreateCommand(); dbCommand.CommandText = "select * from sys_info "; object obj = dbCommand.ExecuteScalar(); if (obj != null && obj != DBNull.Value) { string text = Convert.ToString(obj); if (text.Length == 0) { result = "VALUENULL"; return(result); } try { text = AESEncryptionUtility.Decrypt(text, "evaluate_date-time"); result = text; return(result); } catch { result = "FATAL"; return(result); } } result = "NOVALUE"; return(result); } result = "NOTABLE"; return(result); } } catch (Exception) { string result = ""; return(result); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { try { dBConn.close(); } catch { } } } return(""); }
public int UpdateZone() { DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "update zone_info set zone_nm=?zone_nm , racks=?racks , sx=?sx ,sy=?sy, ex=?ex ,ey=?ey, color=?color , reserve=?reserve where id= " + this.z_id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?zone_nm", this.z_name, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?racks", this.z_racklist, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?sx", this.z_s_x, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?sy", this.z_s_y, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ex", this.z_e_x, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ey", this.z_e_y, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?color", this.z_color, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?reserve", this.z_reserve, dbCommand)); } else { string commandText = "update zone_info set zone_nm=? , racks=? , sx=? ,sy=?, ex=? ,ey=?, color=? , reserve=? where id= " + this.z_id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@zone_nm", this.z_name, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@racks", this.z_racklist, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@sx", this.z_s_x, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@sy", this.z_s_y, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ex", this.z_e_x, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ey", this.z_e_y, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@color", this.z_color, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@reserve", this.z_reserve, dbCommand)); } int num = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.ZONE = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_ZONE" }); int result = num; return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); if (ex.Message.IndexOf(" duplicate values ") > 0) { int result = -2; return(result); } } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static int GetRowCount(int i_range_type, DateTime dt_start, DateTime dt_end) { DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); long arg_0F_0 = dt_start.Ticks; long arg_17_0 = dt_end.Ticks; try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; switch (i_range_type) { case 0: dbCommand.CommandText = "select count(id) from logrecords"; break; case 1: dbCommand.CommandText = string.Concat(new string[] { "select count(id) from logrecords where ticks >= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# and ticks <= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# " }); break; case 2: dbCommand.CommandText = string.Concat(new string[] { "select count(id) from logrecords where ticks <= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# or ticks >= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# " }); break; } if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } object obj = dbCommand.ExecuteScalar(); dbCommand.Dispose(); int result; if (obj == null || obj is DBNull || Convert.ToInt32(obj) < 1) { result = -1; return(result); } result = Convert.ToInt32(obj); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static DataTable GetPrePage(int i_key, int i_range_type, DateTime dt_start, DateTime dt_end, int i_pagenum, int i_pagesize, int i_total) { DateTime now = DateTime.Now; DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn("insert_time"); dataColumn.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); DataColumn dataColumn2 = new DataColumn("eventid"); dataColumn2.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn2); DataColumn dataColumn3 = new DataColumn("parametervalue"); dataColumn3.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn3); DataColumn dataColumn4 = new DataColumn("id"); dataColumn4.DataType = Type.GetType("System.Int32"); dataTable.Columns.Add(dataColumn4); DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); long arg_BF_0 = dt_start.Ticks; long arg_C7_0 = dt_end.Ticks; string text = ""; switch (i_range_type) { case 0: text = string.Concat(new object[] { " 2=2 id > ", i_key, " and ticks <= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# " }); break; case 1: text = string.Concat(new object[] { " 2=2 id > ", i_key, " and ticks >= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# and ticks <= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# " }); break; case 2: text = string.Concat(new object[] { " 2=2 id > ", i_key, " and (ticks <= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# or ticks >= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# )" }); break; } try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; long num = 0L; long num2 = 0L; DataTable dataTable2 = new DataTable(); string commandText; if (i_pagenum * i_pagesize > i_total) { int num3 = i_pagenum * i_pagesize - i_total; commandText = string.Concat(new object[] { "select top ", i_pagesize - num3, " id from (select top ", i_pagesize - num3, " id from logrecords where ", text, " order by id asc) order by id desc" }); } else { commandText = string.Concat(new object[] { "select id from ( select top ", i_pagesize, " id from logrecords where ", text, " order by id asc ) order by id desc" }); } dbCommand.CommandText = commandText; if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader = dbCommand.ExecuteReader(); if (dbDataReader.HasRows) { dataTable2 = DBConn.ConvertOleDbReaderToDataTable(dbDataReader); } dbDataReader.Close(); DataRow[] array = dataTable2.Select("", "id DESC"); if (array.Length > 0) { num2 = Convert.ToInt64(array[0]["id"]); num = Convert.ToInt64(array[array.Length - 1]["id"]); } dbCommand.CommandText = string.Concat(new object[] { "select * from logrecords where id >= ", num, " and id <= ", num2, " order by id desc" }); if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader2 = dbCommand.ExecuteReader(); while (dbDataReader2.Read()) { string value = Convert.ToDateTime(dbDataReader2.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss"); string @string = dbDataReader2.GetString(2); string string2 = dbDataReader2.GetString(3); int num4 = Convert.ToInt32(dbDataReader2.GetValue(0)); DataRow dataRow = dataTable.NewRow(); dataRow["insert_time"] = value; dataRow["eventid"] = @string; dataRow["parametervalue"] = string2; dataRow["id"] = num4; dataTable.Rows.Add(dataRow); } dbDataReader2.Close(); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } Console.WriteLine("million sencods is : " + (DateTime.Now - now).TotalMilliseconds.ToString()); return(dataTable); }
public static DataTable GetSearchResult(int i_range_type, DateTime dt_start, DateTime dt_end, int i_pagenum, int i_pagesize, int i_total) { DateTime now = DateTime.Now; DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn("insert_time"); dataColumn.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); DataColumn dataColumn2 = new DataColumn("eventid"); dataColumn2.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn2); DataColumn dataColumn3 = new DataColumn("parametervalue"); dataColumn3.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn3); DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); long arg_95_0 = dt_start.Ticks; long arg_9D_0 = dt_end.Ticks; string text = ""; switch (i_range_type) { case 0: text = " 2=2 "; break; case 1: text = string.Concat(new string[] { " 2=2 and ticks >= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# and ticks <= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# " }); break; case 2: text = string.Concat(new string[] { " 2=2 and (ticks <= #", dt_start.ToString("yyyy-MM-dd HH:mm:ss"), "# or ticks >= #", dt_end.ToString("yyyy-MM-dd HH:mm:ss"), "# )" }); break; } try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (i_pagenum == 0 && i_pagesize == 0) { dbCommand.CommandText = "select ticks,eventid,logpara from logrecords where " + text + " order by id desc"; if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader = dbCommand.ExecuteReader(); while (dbDataReader.Read()) { string value = Convert.ToDateTime(dbDataReader.GetValue(0)).ToString("yyyy-MM-dd HH:mm:ss"); string @string = dbDataReader.GetString(1); string string2 = dbDataReader.GetString(2); DataRow dataRow = dataTable.NewRow(); dataRow["insert_time"] = value; dataRow["eventid"] = @string; dataRow["parametervalue"] = string2; dataTable.Rows.Add(dataRow); } dbDataReader.Close(); } else { if (LogInfo.m_type == i_range_type && DateTime.Compare(LogInfo.mdt_start, dt_start) == 0 && DateTime.Compare(LogInfo.mdt_end, dt_end) == 0) { long num; long num2; if (i_pagenum * i_pagesize > i_total) { num = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]); num2 = Convert.ToInt64(LogInfo.ht_cache[i_total]); } else { num = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]); num2 = Convert.ToInt64(LogInfo.ht_cache[i_pagenum * i_pagesize]); } dbCommand.CommandText = string.Concat(new object[] { "select * from logrecords where id >= ", num2, " and id <= ", num, " order by id desc" }); if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader2 = dbCommand.ExecuteReader(); while (dbDataReader2.Read()) { string value2 = Convert.ToDateTime(dbDataReader2.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss"); string string3 = dbDataReader2.GetString(2); string string4 = dbDataReader2.GetString(3); DataRow dataRow2 = dataTable.NewRow(); dataRow2["insert_time"] = value2; dataRow2["eventid"] = string3; dataRow2["parametervalue"] = string4; dataTable.Rows.Add(dataRow2); } dbDataReader2.Close(); } else { LogInfo.m_type = i_range_type; LogInfo.mdt_start = dt_start; LogInfo.mdt_end = dt_end; LogInfo.ht_cache = new Hashtable(); dbCommand.CommandText = "select id from logrecords where " + text + " order by id desc"; if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader3 = dbCommand.ExecuteReader(); int num3 = 1; while (dbDataReader3.Read()) { LogInfo.ht_cache.Add(num3, dbDataReader3.GetValue(0)); num3++; } dbDataReader3.Close(); new DataTable(); long num5; long num6; if (i_pagenum * i_pagesize > i_total) { int num4 = i_pagenum * i_pagesize - i_total; string.Concat(new object[] { "select top ", i_pagesize - num4, " id from (select top ", i_pagesize - num4, " id from logrecords where ", text, " order by id asc) order by id desc" }); num5 = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]); num6 = Convert.ToInt64(LogInfo.ht_cache[i_total]); } else { num5 = Convert.ToInt64(LogInfo.ht_cache[(i_pagenum - 1) * i_pagesize + 1]); num6 = Convert.ToInt64(LogInfo.ht_cache[i_pagenum * i_pagesize]); if (i_pagenum * i_pagesize > i_total / 2) { string.Concat(new object[] { "select top ", i_pagesize, " id from (select top ", i_total - i_pagenum * i_pagesize + i_pagesize, " id from logrecords where ", text, " order by id asc) order by id desc" }); } else { string.Concat(new object[] { "select id from (select top ", i_pagesize, " id from (select top ", i_pagenum * i_pagesize, " id from logrecords where ", text, " order by id desc) order by id asc) order by id desc" }); } } dbCommand.CommandText = string.Concat(new object[] { "select * from logrecords where id >= ", num6, " and id <= ", num5, " order by id desc" }); if (DBUrl.SERVERMODE) { dbCommand.CommandText = dbCommand.CommandText.Replace("#", "'"); } DbDataReader dbDataReader4 = dbCommand.ExecuteReader(); while (dbDataReader4.Read()) { string value3 = Convert.ToDateTime(dbDataReader4.GetValue(1)).ToString("yyyy-MM-dd HH:mm:ss"); string string5 = dbDataReader4.GetString(2); string string6 = dbDataReader4.GetString(3); DataRow dataRow3 = dataTable.NewRow(); dataRow3["insert_time"] = value3; dataRow3["eventid"] = string5; dataRow3["parametervalue"] = string6; dataTable.Rows.Add(dataRow3); } dbDataReader4.Close(); } } dbCommand.Dispose(); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } Console.WriteLine("million sencods is : " + (DateTime.Now - now).TotalMilliseconds.ToString()); return(dataTable); }
public static int DeleteByName(string str_zonename) { DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { string commandText = "select * from zone_info z inner join group_detail g on z.id = g.dest_id where z.zone_nm = '" + str_zonename + "' and g.grouptype = 'zone'"; dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = commandText; DbDataAdapter dataAdapter = DBConn.GetDataAdapter(dBConn.con); dataAdapter.SelectCommand = dbCommand; DataTable dataTable = new DataTable(); dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0) { string commandText2 = string.Concat(new object[] { "delete from group_detail where grouptype = 'zone' and group_id = ", dataTable.Rows[0]["group_id"], " and dest_id =", dataTable.Rows[0]["dest_id"] }); dbCommand.CommandText = commandText2; dbCommand.ExecuteNonQuery(); } string commandText3 = "delete from zone_info where zone_nm = '" + str_zonename + "'"; dbCommand.CommandText = commandText3; int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.ZONE = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_ZONE" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public int Update() { DBConn dBConn = null; OleDbCommand oleDbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { OleDbTransaction transaction = (OleDbTransaction)dBConn.con.BeginTransaction(); oleDbCommand = (OleDbCommand)dBConn.con.CreateCommand(); oleDbCommand.CommandType = CommandType.Text; oleDbCommand.Transaction = transaction; oleDbCommand.Parameters.Clear(); oleDbCommand.CommandText = "delete from group_detail where group_id = ? "; oleDbCommand.Parameters.Add("?", OleDbType.Integer); oleDbCommand.Prepare(); oleDbCommand.Parameters[0].Value = this.id; int result; try { oleDbCommand.ExecuteNonQuery(); } catch { oleDbCommand.Transaction.Rollback(); result = -1; return(result); } oleDbCommand.Parameters.Clear(); oleDbCommand.CommandText = string.Concat(new object[] { "insert into group_detail (group_id,grouptype,dest_id) values (", this.id, ",'", this.group_type, "',?)" }); oleDbCommand.Parameters.Add("?", OleDbType.Integer); oleDbCommand.Prepare(); string[] array = this.members.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string value = array2[i]; oleDbCommand.Parameters[0].Value = Convert.ToInt64(value); int num = oleDbCommand.ExecuteNonQuery(); if (num < 0) { oleDbCommand.Transaction.Rollback(); result = num; return(result); } } oleDbCommand.Parameters.Clear(); oleDbCommand.CommandText = "update data_group set groupname= ?, grouptype = ?, linecolor = ?, isselect = ?, thermalflag = ?, billflag = ? where id = " + this.id; oleDbCommand.Parameters.Add("?", OleDbType.VarChar); oleDbCommand.Parameters.Add("?", OleDbType.VarChar); oleDbCommand.Parameters.Add("?", OleDbType.VarChar); oleDbCommand.Parameters.Add("?", OleDbType.Integer); oleDbCommand.Parameters.Add("?", OleDbType.Integer); oleDbCommand.Parameters.Add("?", OleDbType.Integer); oleDbCommand.Parameters[0].Value = this.group_name; oleDbCommand.Parameters[1].Value = this.group_type; oleDbCommand.Parameters[2].Value = this.color; oleDbCommand.Parameters[3].Value = Convert.ToInt32(this.isselected); oleDbCommand.Parameters[4].Value = Convert.ToInt64(this.thermalflag); oleDbCommand.Parameters[5].Value = Convert.ToInt64(this.billflag); try { oleDbCommand.ExecuteNonQuery(); } catch { oleDbCommand.Transaction.Rollback(); result = -1; return(result); } oleDbCommand.Parameters.Clear(); oleDbCommand.Transaction.Commit(); DBCacheStatus.Group = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Group" }); result = 1; return(result); } } catch (Exception ex) { oleDbCommand.Transaction.Rollback(); DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); if (ex.Message.IndexOf(" duplicate values ") > 0) { int result = -2; return(result); } } finally { oleDbCommand.Dispose(); if (dBConn != null) { dBConn.close(); } } return(-1); }
private static int setExpiry4log(string strV, int iType) { DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getLogConnection(); if (dBConn != null && dBConn.con != null) { dbCommand = dBConn.con.CreateCommand(); switch (iType) { case 0: try { dbCommand.CommandText = "create table sys_info (sysid varchar(255) )"; dbCommand.ExecuteNonQuery(); dbCommand.CommandText = "insert into sys_info (sysid ) values ('" + strV + "' )"; dbCommand.ExecuteNonQuery(); int result = 1; return(result); } catch { int result = -1; return(result); } break; case 1: break; case 2: goto IL_A8; case 3: goto IL_CE; default: goto IL_F4; } try { dbCommand.CommandText = "insert into sys_info (sysid ) values ('" + strV + "' )"; dbCommand.ExecuteNonQuery(); int result = 1; return(result); } catch { int result = -1; return(result); } try { IL_A8: dbCommand.CommandText = "update sys_info set sysid = '" + strV + "'"; dbCommand.ExecuteNonQuery(); int result = 1; return(result); } catch { int result = -1; return(result); } try { IL_CE: dbCommand.CommandText = "update sys_info set sysid = '" + strV + "'"; dbCommand.ExecuteNonQuery(); int result = 1; return(result); } catch { int result = -1; return(result); } } IL_F4 :; } catch { int result = -1; return(result); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { try { dBConn.close(); } catch { } } } return(-1); }
public int Update() { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { string commandText = "update device_sensor_info set sensor_nm=?sensor_nm,max_humidity=?max_humidity,min_humidity=?min_humidity,max_temperature=?max_temperature,min_temperature=?min_temperature,max_press=?max_press,min_press=?min_press,sensor_type=?sensor_type,location_type=?location_type where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?sensor_nm", this.sensor_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_humidity", this.max_humidity, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_humidity", this.min_humidity, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_temperature", this.max_temperature, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_temperature", this.min_temperature, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?max_press", this.max_press, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?min_press", this.min_press, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?sensor_type", this.sensor_type, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?location_type", this.sensor_locationtype, dbCommand)); } else { string commandText = "update device_sensor_info set sensor_nm=?,max_humidity=?,min_humidity=?,max_temperature=?,min_temperature=?,max_press=?,min_press=?,sensor_type=?,location_type=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@sensor_nm", this.sensor_nm, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_humidity", this.max_humidity, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_humidity", this.min_humidity, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_temperature", this.max_temperature, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_temperature", this.min_temperature, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_press", this.max_press, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_press", this.min_press, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@sensor_type", this.sensor_type, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@location_type", this.sensor_locationtype, dbCommand)); } int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Device = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Device" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }