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 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 InsertBillReport(string str_title, string str_writer, DateTime dt_time, string str_path) { int result = -1; DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); if (DBUrl.SERVERMODE) { string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?Title,?Writer,?ReportTime,?ReportPath)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?Title", str_title, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?Writer", str_writer, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ReportPath", str_path, dbCommand)); } else { string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?,?,?,?)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@Title", str_title, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@Writer", str_writer, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ReportPath", str_path, dbCommand)); } result = dbCommand.ExecuteNonQuery(); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { if (dbCommand != null) { dbCommand.Dispose(); } if (dBConn.con != 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 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 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 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 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 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); }
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); }
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 Save() { DbCommand dbCommand = null; DBConn dBConn = null; try { int result; if (this.gid == null || this.gid.Length < 1 || this.gid.Equals("0")) { result = -1; return(result); } if (this.bid == null || this.bid.Length < 1 || this.bid.Equals("0")) { result = -1; return(result); } "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBUrl.DEFAULT_HOST_PATH + ";Jet OLEDB:Database Password="******"update gatewaytable set eleflag=", current.ElectricityUsage, ",capacity=", current.Capacity, " where slevel=2 and gid='", this.gid, "' and bid='", this.bid, "' and sid='", current.SubmeterID, "' " }); dbCommand.ExecuteNonQuery(); } dbCommand.CommandText = string.Concat(new string[] { "update gatewaytable set disname = '", this.bname, "',location='", this.location, "' where slevel = 1 and gid = '", this.gid, "' and bid='", this.bid, "' " }); int num = dbCommand.ExecuteNonQuery(); dbCommand.Transaction.Commit(); dbCommand.Dispose(); dBConn.Close(); result = num; return(result); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); if (dbCommand != null) { try { dbCommand.Transaction.Rollback(); dbCommand.Dispose(); } catch (Exception) { } } if (dBConn.con != null) { try { dBConn.Close(); } catch (Exception) { } } } 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 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 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); }