using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.Tools; using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl { class DeviceServiceImpl : DeviceService { public long add(string devName, string devCode, string devTypeId, string devModel, string custometDev, string customerName, string channel,string statusId) { long deviceId = -1; //DetectionItemService detectionItemService = new DetectionItemServiceImpl(); try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "INSERT INTO r_device (DEV_NAME,DEV_CODE,DEV_TYPEID,DEV_MODEL,REG_TIME,CUSTOMER_NAME,CUSTOMER_DEV,STATUSID,CHANNEL,ACTIVE)" + "values(@DEV_NAME,@DEV_CODE,@DEV_TYPEID,@DEV_MODEL,@REG_TIME,@CUSTOMER_NAME,@CUSTOMER_DEV,@STATUSID,@CHANNEL,@ACTIVE)"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; cmd.Parameters.Add("@DEV_CODE", MySqlDbType.String, 30).Value = devCode; cmd.Parameters.Add("@DEV_TYPEID", MySqlDbType.String, 30).Value = devTypeId; cmd.Parameters.Add("@DEV_MODEL", MySqlDbType.String, 30).Value = devModel; cmd.Parameters.Add("@REG_TIME", MySqlDbType.Date, 0).Value = DateTime.Now; cmd.Parameters.Add("@CUSTOMER_NAME", MySqlDbType.String, 30).Value = customerName; cmd.Parameters.Add("@CUSTOMER_DEV", MySqlDbType.String, 30).Value = custometDev; cmd.Parameters.Add("@STATUSID", MySqlDbType.String, 20).Value = statusId; cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = channel; cmd.Parameters.Add("@ACTIVE", MySqlDbType.Int64, 0).Value = 0; cmd.ExecuteNonQuery(); sQry = "SELECT max(ID) from r_device"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = cmd.ExecuteReader()) { if (aReader.Read()) deviceId = Convert.ToInt64(aReader.GetString(0)); } cmd.Dispose(); } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : " + ex.Message); deviceId = -1; } return deviceId; } public int update(long id, string devName, string devCode, string devTypeId, string devModel, string custometDev, string customerName, string channel, string statusId) { int iRetval = -1; try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; cmd.Parameters.Add("@DEV_CODE", MySqlDbType.String, 30).Value = devCode; cmd.Parameters.Add("@DEV_TYPEID", MySqlDbType.String, 30).Value = devTypeId; cmd.Parameters.Add("@DEV_MODEL", MySqlDbType.String, 30).Value = devModel; cmd.Parameters.Add("@CUSTOMER_NAME", MySqlDbType.String, 30).Value = customerName; cmd.Parameters.Add("@CUSTOMER_DEV", MySqlDbType.String, 30).Value = custometDev; cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = channel; if (!statusId.Equals("")) cmd.Parameters.Add("@STATUSID", MySqlDbType.String, 20).Value = statusId; cmd.ExecuteNonQuery(); cmd.Dispose(); iRetval = 0; } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : " + ex.Message); } return iRetval; } public int delete(long id) { int iRetval = -1; try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); cmd.Dispose(); iRetval = 0; } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : " + ex.Message); } return iRetval; } public List<DeviceDto> search(string devName, string devCode, string devModel, string suctomerDev, string customerName, string statusId) { List<DeviceDto> deviceDtoList = new List<DeviceDto>(); DictService dictService = new DictServiceImpl(); try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return null; } } string sQry = "SELECT * FROM r_device where active = " + 0; if (devName != "" && devName != null) sQry += " and DEV_NAME like '%" + devName + "%'"; if (devCode != "" && devCode != null) sQry += " and DEV_CODE like '%" + devCode + "%'"; if (devModel != "" && devModel != null) sQry += " and DEV_MODEL like '%" + devModel + "%'"; if (suctomerDev != "" && suctomerDev != null) sQry += " and CUSTOMER_DEV like '%" + suctomerDev + "%'"; if (customerName != "" && customerName != null) sQry += " and CUSTOMER_NAME like '%" + customerName + "%'"; if (statusId != "" && statusId != null) { if(statusId.Equals("4")) sQry += " and STATUSID != 2 "; else sQry += " and STATUSID = " + statusId; } MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) { DeviceDto deviceDto = new DeviceDto(); if (!aReader.IsDBNull(0)) deviceDto.Id = Convert.ToInt64(aReader.GetString(0)); if (!aReader.IsDBNull(1)) deviceDto.DevName = aReader.GetString(1); if (!aReader.IsDBNull(2)) deviceDto.DevCode = aReader.GetString(2); if (!aReader.IsDBNull(3)) { deviceDto.DevTypeId = aReader.GetString(3); } if (!aReader.IsDBNull(4)) deviceDto.DevModel = aReader.GetString(4); if (!aReader.IsDBNull(6)) deviceDto.CustomerName = aReader.GetString(6); if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); deviceDtoList.Add(deviceDto); } aCommand.Dispose(); } if (deviceDtoList.Count > 0) { foreach (DeviceDto deviceDto in deviceDtoList) { deviceDto.DevTypeName = dictService.getNameByCode("devType", deviceDto.DevTypeId); deviceDto.StatusName = dictService.getNameByCode("devStatus", deviceDto.StatusId); } } } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice: " + ex.Message); deviceDtoList = null; } return deviceDtoList; } public List<DeviceDto> getAllCounter() { List<DeviceDto> deviceDtoList = new List<DeviceDto>(); DictService dictService = new DictServiceImpl(); try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return null; } } string sQry = "SELECT * FROM r_device where active = " + 0 + " and DEV_TYPEID='2'"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) { DeviceDto deviceDto = new DeviceDto(); if (!aReader.IsDBNull(0)) deviceDto.Id = Convert.ToInt64(aReader.GetString(0)); if (!aReader.IsDBNull(1)) deviceDto.DevName = aReader.GetString(1); if (!aReader.IsDBNull(2)) deviceDto.DevCode = aReader.GetString(2); if (!aReader.IsDBNull(3)) { deviceDto.DevTypeId = aReader.GetString(3); } if (!aReader.IsDBNull(4)) deviceDto.DevModel = aReader.GetString(4); if (!aReader.IsDBNull(5)) deviceDto.CustomerName = aReader.GetString(6); if (!aReader.IsDBNull(6)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(7)) { deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); deviceDtoList.Add(deviceDto); } aCommand.Dispose(); } if (deviceDtoList.Count > 0) { foreach (DeviceDto deviceDto in deviceDtoList) { deviceDto.DevTypeName = dictService.getNameByCode("devType", deviceDto.DevTypeId); deviceDto.StatusName = dictService.getNameByCode("devStatus", deviceDto.StatusId); } } } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice: " + ex.Message); deviceDtoList = null; } return deviceDtoList; } public List<DeviceDto> searchPage(string devName, string devCode, string devModel, string customDev, string customerName, string statusId, int page, int limit) { List<DeviceDto> deviceDtoList = new List<DeviceDto>(); DictService dictService = new DictServiceImpl(); try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return null; } } string sQry = "SELECT * FROM r_device where active = " + 0; if (devName != "" && devName != null) sQry += " and DEV_NAME like '%" + devName + "%'"; if (devCode != "" && devCode != null) sQry += " and DEV_CODE like '%" + devCode + "%'"; if (devModel != "" && devModel != null) sQry += " and DEV_MODEL like '%" + devModel + "%'"; if (customDev != "" && customDev != null) sQry += " and CUSTOMER_DEV like '%" + customDev + "%'"; if (customerName != "" && customerName != null) sQry += " and CUSTOMER_NAME like '%" + customerName + "%'"; if (statusId != "" && statusId != null) { if(statusId.Equals("4")) sQry += " and STATUSID != 2"; else sQry += " and STATUSID = " + statusId; } sQry += " order by ID desc limit " + (page - 1) * limit+ " , "+ limit; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) { DeviceDto deviceDto = new DeviceDto(); if (!aReader.IsDBNull(0)) deviceDto.Id = Convert.ToInt64(aReader.GetString(0)); // id if (!aReader.IsDBNull(1)) deviceDto.DevName = aReader.GetString(1); // devName if (!aReader.IsDBNull(2)) deviceDto.DevCode = aReader.GetString(2); // devCode if (!aReader.IsDBNull(3)) { deviceDto.DevTypeId = aReader.GetString(3); // devType } if (!aReader.IsDBNull(4)) deviceDto.DevModel = aReader.GetString(4); // devModel if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime deviceDto.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceDto.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); // customDev if (!aReader.IsDBNull(8)) { deviceDto.StatusId = aReader.GetString(8); // devStatus } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); deviceDtoList.Add(deviceDto); } aCommand.Dispose(); } if (deviceDtoList.Count > 0) { foreach (DeviceDto deviceDto in deviceDtoList) { deviceDto.DevTypeName = dictService.getNameByCode("devType", deviceDto.DevTypeId); deviceDto.StatusName = dictService.getNameByCode("devStatus", deviceDto.StatusId); } } } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice: " + ex.Message); deviceDtoList = null; } finally { } return deviceDtoList; } public int getTotalCount(string devName, string devCode, string devModel, string customDev, string customerName, string statusId) { int totalCount = 0; try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "SELECT count(id) FROM r_device where active = " + 0; if (devName != "" && devName != null) sQry += " and DEV_NAME like '%" + devName + "%'"; if (devCode != "" && devCode != null) sQry += " and DEV_CODE like '%" + devCode + "%'"; if (devModel != "" && devModel != null) sQry += " and DEV_MODEL like '%" + devModel + "%'"; if (customDev != "" && customDev != null) sQry += " and CUSTOMER_DEV like '%" + customDev + "%'"; if (customerName != "" && customerName != null) sQry += " and CUSTOMER_NAME like '%" + customerName + "%'"; if (statusId != "" && statusId != null) { if (statusId.Equals("4")) sQry += " and STATUSID != 2"; else sQry += " and STATUSID = " + statusId; } MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) { totalCount = aReader.GetInt32(0); } aCommand.Dispose(); } } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getTotalCount: " + ex.Message); totalCount = 0; } finally { } return totalCount; } public List<DeviceView> getDeviceByChannel() { List<DeviceView> deviceViewList = new List<DeviceView>(); DictService dictService = new DictServiceImpl(); try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); int iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return null; } } string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); DataTable dt = new DataTable(); adap.Fill(dt); aCommand.Dispose(); adap.Dispose(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DeviceView deviceView = new DeviceView(); if (row[0] != DBNull.Value) deviceView.Id = Convert.ToInt64(row[0]); if (row[1] != DBNull.Value) deviceView.DevName = row[1].ToString(); if (row[2] != DBNull.Value) deviceView.DevCode = row[2].ToString(); if (row[3] != DBNull.Value) deviceView.DevTypeId = row[3].ToString(); if (row[4] != DBNull.Value) deviceView.DevModel = row[4].ToString(); if (row[5] != DBNull.Value) deviceView.RegTime = row[5].ToString(); if (row[6] != DBNull.Value) deviceView.CustomerName = row[6].ToString(); if (row[7] != DBNull.Value) deviceView.CustomerDev = row[7].ToString(); if (row[8] != DBNull.Value) deviceView.Channel = row[8].ToString(); if (row[9] != DBNull.Value) deviceView.Active = Convert.ToInt32(row[9]); if (row[10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(row[10]).ToString("yyyy - MM - dd HH: mm:ss"); if (row[11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(row[11]).ToString("yyyy - MM - dd HH: mm:ss"); if (row[12] != DBNull.Value) deviceView.StatusId = row[12].ToString(); if (row[13] != DBNull.Value) deviceView.Stability = row[13].ToString(); if (row[14] != DBNull.Value) deviceView.Accuracy = row[14].ToString(); if (row[15] != DBNull.Value) deviceView.BootFeature = row[15].ToString(); if (row[16] != DBNull.Value) deviceView.AgeRate = row[16].ToString(); if (row[17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(row[17]); deviceViewList.Add(deviceView); } } //using (MySqlDataReader aReader = aCommand.ExecuteReader()) //{ // while (aReader.Read()) // { // DeviceView deviceView = new DeviceView(); // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode // if (!aReader.IsDBNull(3)) // { // deviceView.DevTypeId = aReader.GetString(3); // devType // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); // } // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel // if (!aReader.IsDBNull(5)) // { // DateTime reg = aReader.GetDateTime(5); // regTime // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); // } // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); // if (!aReader.IsDBNull(10)) // { // DateTime reg = aReader.GetDateTime(10); // regTime // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); // } // if (!aReader.IsDBNull(11)) // { // DateTime reg = aReader.GetDateTime(11); // regTime // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); // } // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); // deviceViewList.Add(deviceView); // aCommand.Dispose(); // } //} if (deviceViewList.Count > 0) { foreach (DeviceView deviceView in deviceViewList) { deviceView.DevTypeName = dictService.getNameByCode("devType", deviceView.DevTypeId); } } } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getDeviceByChannel: " + ex.Message + " ; "+ ex.ToString()); deviceViewList = null; } finally { } return deviceViewList; } public int updateStatus(long id, string status, string channel) { int iRetval = -1; try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "UPDATE r_device SET STATUSID=@STATUS, CHANNEL=@CHANNEL WHERE ID = " + id; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STATUS", MySqlDbType.String, 30).Value = status; cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 30).Value = channel; cmd.ExecuteNonQuery(); cmd.Dispose(); iRetval = 0; } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : " + ex.Message); } return iRetval; } public int clearChannel() { int iRetval = -1; try { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); return iRetval; } } string sQry = "UPDATE r_device SET CHANNEL=''"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); cmd.Dispose(); iRetval = 0; } catch (MySqlException ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); } return iRetval; } } }