diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/info/bootFeature.designer.cs b/RbFreqStandMeasure/info/bootFeature.designer.cs index 68d915f..7e46577 100644 --- a/RbFreqStandMeasure/info/bootFeature.designer.cs +++ b/RbFreqStandMeasure/info/bootFeature.designer.cs @@ -65,7 +65,7 @@ this.label_bootFeature.Location = new System.Drawing.Point(101, 9); this.label_bootFeature.Margin = new System.Windows.Forms.Padding(0); this.label_bootFeature.Name = "label_bootFeature"; - this.label_bootFeature.Size = new System.Drawing.Size(107, 27); + this.label_bootFeature.Size = new System.Drawing.Size(250, 27); this.label_bootFeature.TabIndex = 103; this.label_bootFeature.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/info/bootFeature.designer.cs b/RbFreqStandMeasure/info/bootFeature.designer.cs index 68d915f..7e46577 100644 --- a/RbFreqStandMeasure/info/bootFeature.designer.cs +++ b/RbFreqStandMeasure/info/bootFeature.designer.cs @@ -65,7 +65,7 @@ this.label_bootFeature.Location = new System.Drawing.Point(101, 9); this.label_bootFeature.Margin = new System.Windows.Forms.Padding(0); this.label_bootFeature.Name = "label_bootFeature"; - this.label_bootFeature.Size = new System.Drawing.Size(107, 27); + this.label_bootFeature.Size = new System.Drawing.Size(250, 27); this.label_bootFeature.TabIndex = 103; this.label_bootFeature.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index 91ee328..e9dc1c9 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -39,7 +39,7 @@ this.label_count.BackColor = System.Drawing.Color.Transparent; this.label_count.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_count.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_count.Location = new System.Drawing.Point(196, 110); + this.label_count.Location = new System.Drawing.Point(161, 110); this.label_count.Margin = new System.Windows.Forms.Padding(0); this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); @@ -52,10 +52,10 @@ this.label_stability.BackColor = System.Drawing.Color.Transparent; this.label_stability.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_stability.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_stability.Location = new System.Drawing.Point(195, 59); + this.label_stability.Location = new System.Drawing.Point(160, 59); this.label_stability.Margin = new System.Windows.Forms.Padding(0); this.label_stability.Name = "label_stability"; - this.label_stability.Size = new System.Drawing.Size(152, 27); + this.label_stability.Size = new System.Drawing.Size(210, 27); this.label_stability.TabIndex = 81; this.label_stability.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -63,7 +63,7 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(109, 110); + this.label2.Location = new System.Drawing.Point(74, 110); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(87, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(112, 57); + this.label9.Location = new System.Drawing.Point(77, 57); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(83, 27); diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/info/bootFeature.designer.cs b/RbFreqStandMeasure/info/bootFeature.designer.cs index 68d915f..7e46577 100644 --- a/RbFreqStandMeasure/info/bootFeature.designer.cs +++ b/RbFreqStandMeasure/info/bootFeature.designer.cs @@ -65,7 +65,7 @@ this.label_bootFeature.Location = new System.Drawing.Point(101, 9); this.label_bootFeature.Margin = new System.Windows.Forms.Padding(0); this.label_bootFeature.Name = "label_bootFeature"; - this.label_bootFeature.Size = new System.Drawing.Size(107, 27); + this.label_bootFeature.Size = new System.Drawing.Size(250, 27); this.label_bootFeature.TabIndex = 103; this.label_bootFeature.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index 91ee328..e9dc1c9 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -39,7 +39,7 @@ this.label_count.BackColor = System.Drawing.Color.Transparent; this.label_count.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_count.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_count.Location = new System.Drawing.Point(196, 110); + this.label_count.Location = new System.Drawing.Point(161, 110); this.label_count.Margin = new System.Windows.Forms.Padding(0); this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); @@ -52,10 +52,10 @@ this.label_stability.BackColor = System.Drawing.Color.Transparent; this.label_stability.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_stability.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_stability.Location = new System.Drawing.Point(195, 59); + this.label_stability.Location = new System.Drawing.Point(160, 59); this.label_stability.Margin = new System.Windows.Forms.Padding(0); this.label_stability.Name = "label_stability"; - this.label_stability.Size = new System.Drawing.Size(152, 27); + this.label_stability.Size = new System.Drawing.Size(210, 27); this.label_stability.TabIndex = 81; this.label_stability.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -63,7 +63,7 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(109, 110); + this.label2.Location = new System.Drawing.Point(74, 110); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(87, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(112, 57); + this.label9.Location = new System.Drawing.Point(77, 57); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(83, 27); diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 796a9b3..483fc5a 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -70,25 +70,20 @@ public void draw(List bdList, List gpList) { try - { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::bd:" + bdList.Count); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::gp:" + gpList.Count); - + { if (bdList.Count > 0 || gpList.Count>0) { - if (this.InvokeRequired) + + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - //coo = new Coordinate(); - //panelSite.Controls.Add(coo); - //coo.Show(); - drawFunc(bdList); - drawFunc(gpList); - } - )); - + panelSite.Controls.Clear(); + coo = new Coordinate(); + panelSite.Controls.Add(coo); + coo.Show(); + drawFunc(bdList); + drawFunc(gpList); } + )); } } @@ -103,44 +98,49 @@ { try { - if (this.InvokeRequired) + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - if (gvsList.Count > 0) + if (gvsList.Count > 0) + { + Graphics gp = coo.CreateGraphics(); + gp.SmoothingMode = SmoothingMode.HighQuality; + + int gpCount = 0; + int bdCount = 0; + foreach (string gsv in gvsList) { - - Graphics gp = coo.CreateGraphics(); - gp.SmoothingMode = SmoothingMode.HighQuality; - - foreach (string gsv in gvsList) - { - string[] arr = gsv.Split(','); - int length = arr.Length; - for (int i = 4; i < arr.Length; i = i + 3) + string[] arr = gsv.Split(','); + int length = arr.Length; + for (int i = 4; i < arr.Length; i = i + 3) + { + if ((i + 3) < arr.Length) { - if ((i + 3) < arr.Length) - { - int Elevation = Convert.ToInt32(arr[i + 1]); - int azimuth = Convert.ToInt32(arr[i + 2]); - double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); - double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; - double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; + int Elevation = Convert.ToInt32(arr[i + 1]); + int azimuth = Convert.ToInt32(arr[i + 2]); + double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); + double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; + double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; - int x = (int)Math.Floor(600 / 2 + xCor); - int y = (int)Math.Floor(610 / 2 - yCor); - string type = "CHN"; - if (gsv.Contains("GPGSV")) type = "USA"; - gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); - } + int x = (int)Math.Floor(600 / 2 + xCor); + int y = (int)Math.Floor(610 / 2 - yCor); + string type = "CHN"; + if (gsv.Contains("GPGSV")) { type = "USA"; gpCount++; } + else { bdCount++; } + gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); + + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gvsList.count="+ gvsList.Count+",画了一个" +type + "x="+x+"y="+y); + } } - gp.Dispose(); + if(gpCount>0)label_usaTotal.Text = gpCount + ""; + if (bdCount > 0) label_chnTotal.Text = bdCount + ""; } + gp.Dispose(); } - )); - } + )); + + } catch (Exception e) { diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/info/bootFeature.designer.cs b/RbFreqStandMeasure/info/bootFeature.designer.cs index 68d915f..7e46577 100644 --- a/RbFreqStandMeasure/info/bootFeature.designer.cs +++ b/RbFreqStandMeasure/info/bootFeature.designer.cs @@ -65,7 +65,7 @@ this.label_bootFeature.Location = new System.Drawing.Point(101, 9); this.label_bootFeature.Margin = new System.Windows.Forms.Padding(0); this.label_bootFeature.Name = "label_bootFeature"; - this.label_bootFeature.Size = new System.Drawing.Size(107, 27); + this.label_bootFeature.Size = new System.Drawing.Size(250, 27); this.label_bootFeature.TabIndex = 103; this.label_bootFeature.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index 91ee328..e9dc1c9 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -39,7 +39,7 @@ this.label_count.BackColor = System.Drawing.Color.Transparent; this.label_count.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_count.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_count.Location = new System.Drawing.Point(196, 110); + this.label_count.Location = new System.Drawing.Point(161, 110); this.label_count.Margin = new System.Windows.Forms.Padding(0); this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); @@ -52,10 +52,10 @@ this.label_stability.BackColor = System.Drawing.Color.Transparent; this.label_stability.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_stability.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_stability.Location = new System.Drawing.Point(195, 59); + this.label_stability.Location = new System.Drawing.Point(160, 59); this.label_stability.Margin = new System.Windows.Forms.Padding(0); this.label_stability.Name = "label_stability"; - this.label_stability.Size = new System.Drawing.Size(152, 27); + this.label_stability.Size = new System.Drawing.Size(210, 27); this.label_stability.TabIndex = 81; this.label_stability.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -63,7 +63,7 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(109, 110); + this.label2.Location = new System.Drawing.Point(74, 110); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(87, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(112, 57); + this.label9.Location = new System.Drawing.Point(77, 57); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(83, 27); diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 796a9b3..483fc5a 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -70,25 +70,20 @@ public void draw(List bdList, List gpList) { try - { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::bd:" + bdList.Count); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::gp:" + gpList.Count); - + { if (bdList.Count > 0 || gpList.Count>0) { - if (this.InvokeRequired) + + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - //coo = new Coordinate(); - //panelSite.Controls.Add(coo); - //coo.Show(); - drawFunc(bdList); - drawFunc(gpList); - } - )); - + panelSite.Controls.Clear(); + coo = new Coordinate(); + panelSite.Controls.Add(coo); + coo.Show(); + drawFunc(bdList); + drawFunc(gpList); } + )); } } @@ -103,44 +98,49 @@ { try { - if (this.InvokeRequired) + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - if (gvsList.Count > 0) + if (gvsList.Count > 0) + { + Graphics gp = coo.CreateGraphics(); + gp.SmoothingMode = SmoothingMode.HighQuality; + + int gpCount = 0; + int bdCount = 0; + foreach (string gsv in gvsList) { - - Graphics gp = coo.CreateGraphics(); - gp.SmoothingMode = SmoothingMode.HighQuality; - - foreach (string gsv in gvsList) - { - string[] arr = gsv.Split(','); - int length = arr.Length; - for (int i = 4; i < arr.Length; i = i + 3) + string[] arr = gsv.Split(','); + int length = arr.Length; + for (int i = 4; i < arr.Length; i = i + 3) + { + if ((i + 3) < arr.Length) { - if ((i + 3) < arr.Length) - { - int Elevation = Convert.ToInt32(arr[i + 1]); - int azimuth = Convert.ToInt32(arr[i + 2]); - double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); - double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; - double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; + int Elevation = Convert.ToInt32(arr[i + 1]); + int azimuth = Convert.ToInt32(arr[i + 2]); + double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); + double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; + double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; - int x = (int)Math.Floor(600 / 2 + xCor); - int y = (int)Math.Floor(610 / 2 - yCor); - string type = "CHN"; - if (gsv.Contains("GPGSV")) type = "USA"; - gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); - } + int x = (int)Math.Floor(600 / 2 + xCor); + int y = (int)Math.Floor(610 / 2 - yCor); + string type = "CHN"; + if (gsv.Contains("GPGSV")) { type = "USA"; gpCount++; } + else { bdCount++; } + gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); + + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gvsList.count="+ gvsList.Count+",画了一个" +type + "x="+x+"y="+y); + } } - gp.Dispose(); + if(gpCount>0)label_usaTotal.Text = gpCount + ""; + if (bdCount > 0) label_chnTotal.Text = bdCount + ""; } + gp.Dispose(); } - )); - } + )); + + } catch (Exception e) { diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 45e6e14..d699915 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -25,7 +25,7 @@ public List detections; private bool isUpdate = false; - public long detectionId = -1; + public long detectionItemId = -1; private System.Threading.Timer timerAccuracy; delegate void TimerDelegate(string text); @@ -67,7 +67,7 @@ #region 稳定度 - public void detecStability(long deviceId, string startTime, string interval, SerialPort port, bool isStartNow, bool isUpdates) + public void detecStability(long deviceId, string startTime, string interval, SerialPort port,bool isNow, bool isUpdates) { resultStability1 = new List(); resultStability10 = new List(); @@ -80,7 +80,7 @@ portStability = port; devIdStability = deviceId; int delay = 0; - if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) + if (Convert.ToDateTime(startTime) > DateTime.Now) { TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; @@ -98,87 +98,77 @@ } private void exeStability1(Object State) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度1s"); try - { - while (true) + { + lock (obj) { - lock (obj) - { - lock(resultStability1) - { - if (!isUsing) + lock(resultStability1) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度1s"); - - string result = ""; - - string fre = getFrequencyData(portStability); - if (fre.Equals("")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "从" + portStability.PortName + "获取稳定度1s数据失败,!"); - } resultStability1.Add(fre); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度1s fre=" + fre); - if (!isUpdate) + if (!isUpdate) detectionService.add(devIdStability, fre, "1-1"); + } + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度1s fre=" + fre); + if (!isUpdate) + { + if (resultStability1.Count == 101) { - detectionService.add(devIdStability, fre, "1-1"); - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); + timerStability1.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始计算稳定度结果"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始计算稳定度结果"); - result = FreMath.Stable(resultStability1) + ""; - resultStability1.Clear(); + result = FreMath.Stable(resultStability1) + ""; + resultStability1.Clear(); - // 更新检测结果 - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", result, "", "", ""); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionId); + // 更新检测结果 + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } - } } - else - { - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); - - string result1 = FreMath.Stable(resultStability1) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", result1, "", "", ""); - - updateView(resultStability1); - stability.label_result.Text = result1; - - resultStability1.Clear(); - } - } - - break; } - } - } + else + { + if (resultStability1.Count == 101) + { + timerStability1.Dispose(); + + string result1 = FreMath.Stable(resultStability1) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + + updateView(resultStability1); + stability.label_result.Text = result1; + + resultStability1.Clear(); + } + } + } } + } catch (Exception ex) { @@ -190,240 +180,204 @@ } private void exeStability10(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) + resultStability10.Add(fre); + if (!isUpdate) detectionService.add(devIdStability, fre, "1-10"); + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre); + if (!isUpdate) + { + if (resultStability10.Count == 101) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度10s"); + timerStability10.Dispose(); + result = FreMath.Stable(resultStability10) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result); - string result = ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result, "", ""); - string fre = getFrequencyData(portStability); - if (fre.Equals("")) + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) { - //MessageBox.Show("从" + portStability.PortName + "获取数据失败!"); - return; - } - resultStability10.Add(fre); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre); - if (!isUpdate) - { - detectionService.add(devIdStability, fre, "1-10"); - - if (resultStability10.Count == 101) + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) { - timerStability10.Dispose(); - result = FreMath.Stable(resultStability10) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", result, "", ""); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); - } - - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); } - } - else - { - if (resultStability10.Count == 101) + + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { - timerStability10.Dispose(); - - - string result1 = FreMath.Stable(resultStability10) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", result1, "", ""); - - updateView(resultStability10); - stability.label_result.Text = result1; + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } - break; } } + else + { + if (resultStability10.Count == 101) + { + timerStability10.Dispose(); + + + string result1 = FreMath.Stable(resultStability10) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result1, "", ""); + + updateView(resultStability10); + stability.label_result.Text = result1; + } + } } - - } private void exeStability20(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) - { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); - - string result = ""; - - string fre = getFrequencyData(portStability); - if (fre.Equals("")) - { - return; - } - resultStability20.Add(fre); - - if (isUpdate) - { - detectionService.add(devIdStability, fre, "1-20"); - - if (resultStability20.Count == 101) - { - timerStability20.Dispose(); - - result = FreMath.Stable(resultStability20) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", result, ""); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); - - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(detectionId, "3", ""); - portStability.Close(); - } - - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - - resultStability20.Clear(); - } - - } - else - { - if (resultStability20.Count == 101) - { - timerStability20.Dispose(); - - - string result1 = FreMath.Stable(resultStability20) + ""; - detectionItemService.updateDetecStatus(devIdStability, "", "", "", "", "", "", "", result1, ""); - - updateView(resultStability20); - stability.label_result.Text = result1; - resultStability20.Clear(); - - } - } - isUsing = false; - break; - } + resultStability20.Add(fre); + if (isUpdate) detectionService.add(devIdStability, fre, "1-20"); } - } + + if (isUpdate) + { + if (resultStability20.Count == 101) + { + timerStability20.Dispose(); + + result = FreMath.Stable(resultStability20) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result); + + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", result, ""); + + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(detectionItemId, "3", ""); + portStability.Close(); + } + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + + resultStability20.Clear(); + } + + } + else + { + if (resultStability20.Count == 101) + { + timerStability20.Dispose(); + + + string result1 = FreMath.Stable(resultStability20) + ""; + detectionItemService.updateDetecStatus(devIdStability, "", "", "", "", "", "", "", result1, ""); + + updateView(resultStability20); + stability.label_result.Text = result1; + resultStability20.Clear(); + + } + } + } } private void exeStability100(Object State) { - while (true) - { - lock (obj) + + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); + + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) + resultStability100.Add(fre); + if (!isUpdate) detectionService.add(devIdStability, fre, "1-100"); + } + + + if (!isUpdate) + { + if (resultStability100.Count == 101) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); + timerStability100.Dispose(); - string result = ""; + result = FreMath.Stable(resultStability100) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result); - string fre = getFrequencyData(portStability); - if (fre.Equals("")) + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result); + + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) { - return; - } - resultStability100.Add(fre); - - if (!isUpdate) - { - detectionService.add(devIdStability, fre, "1-100"); - - if (resultStability100.Count == 101) + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) { - - timerStability100.Dispose(); - - result = FreMath.Stable(resultStability100) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", "", result); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - resultStability100.Clear(); } - } - else - { - if (resultStability100.Count == 101) + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { - timerStability100.Dispose(); - - string result1 = FreMath.Stable(resultStability100) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", "", result1); - - updateView(resultStability100); - stability.label_result.Text = result1; - resultStability100.Clear(); + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } - break; + resultStability100.Clear(); } } - } + else + { + if (resultStability100.Count == 101) + { + timerStability100.Dispose(); + + string result1 = FreMath.Stable(resultStability100) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result1); + updateView(resultStability100); + stability.label_result.Text = result1; + resultStability100.Clear(); + } + } + } } #endregion @@ -438,6 +392,8 @@ if (isUpdates) { isUpdate = true; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度"); + } int delay = 0; if (Convert.ToDateTime(endTime)>=DateTime.Now) @@ -450,62 +406,59 @@ private void exeAccuracy(Object State) { try - { - while (true) + { + lock (obj) { - lock (obj) - { - if (!isUsing) + if(isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); + string result = ""; + double sum = 0.0; + List resultList = new List(); + + for (int i = 0; i < 50; i++) { - string result = ""; - double sum = 0.0; - List resultList = new List(); - - for (int i = 0; i < 50; i++) - { - string fre = getFrequencyData(portAccuracy); - resultList.Add(fre); - if (fre.Equals("")) continue; - if (!isUpdate) - { - detectionService.add(devIdAccuracy, fre, "2"); - } - if (resultList.Count == 3) - { - sum = sum + Convert.ToDouble(fre); - break; - } - - Thread.Sleep(500); - } - - result = sum / 3 + ""; - timerAccuracy.Dispose(); - - - while (true) - { - if (detectionId != -1) - { - detectionItemService.updateDetecStatus(detectionId, "", result, "", "", "", "", "", "", ""); - break; - } - } + string fre = getFrequencyData(portAccuracy); + resultList.Add(fre); + if (fre.Equals("")) continue; if (!isUpdate) { - deviceService.updateStatus(devIdAccuracy, "3", ""); - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + detectionService.add(devIdAccuracy, fre, "2"); } - else + if (resultList.Count == 3) { - accuracy.label_result.Text = result; - updateView(resultList); + sum = sum + Convert.ToDouble(fre); + break; } - portAccuracy.Close(); - break; + + Thread.Sleep(500); } - } + + result = sum / 3 + ""; + timerAccuracy.Dispose(); + + while (true) + { + if (detectionItemId != -1) + { + detectionItemService.updateDetecStatus(detectionItemId, "", result, "", "", "", "", "", "", ""); + break; + } + } + if (!isUpdate) + { + deviceService.updateStatus(devIdAccuracy, "3", ""); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + else + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新label_result:" + result); + + accuracy.label_result.Text = result; + updateView(resultList); + } + portAccuracy.Close(); + } + } catch (Exception ex) { @@ -525,7 +478,7 @@ portBootFeature = port; devIdBootFeature = deviceId; int delay = 0; - if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) + if (!isStartNow && Convert.ToDateTime(startTime) >= DateTime.Now) { TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; @@ -533,66 +486,55 @@ timerBootFeature = new System.Threading.Timer(exeBootFeature, null, delay + 100, 60*60*1000); } private void exeBootFeature(Object State) - { - while (true) + { + lock (obj) { - lock (obj) + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); + + string result = ""; + double sum = 0.0; + int count = 0; + for (int i = 0; i < 50; i++) { - if (!isUsing) + string fre = getFrequencyData(portBootFeature); + if (!fre.Equals("")) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); - - isUsing = true; - string result = ""; - double sum = 0.0; - for (int i = 0; i < 3; i++) - { - string fre = getFrequencyData(portBootFeature); - if (fre.Equals("")) - { - //MessageBox.Show("从" + portBootFeature.PortName + "获取数据失败!"); - isUsing = false; - return; - } - detectionService.add(devIdStability, fre, "3"); - sum = sum + Convert.ToDouble(fre); - } - resultBootFeature.Add(sum / 3 + ""); - - if (resultBootFeature.Count == 8) - { - string max = "0.0"; - string min = "0.0"; - foreach (string fre in resultBootFeature) - { - if (Convert.ToDouble(fre) > Convert.ToDouble(max)) max = fre; - if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; - } - result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; - - detectionItemService.updateDetecStatus(detectionId, "", "", result, "", "", "", "", "", ""); - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdBootFeature, "3", ""); - portBootFeature.Close(); - } - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - timerBootFeature.Dispose(); - resultBootFeature.Clear(); - } - - isUsing = false; - - break; - } + count++; + sum = sum + Convert.ToDouble(fre); + if (count == 3) break; + } } - } + detectionService.add(devIdBootFeature, sum / 3 + "", "3"); + resultBootFeature.Add(sum / 3 + ""); + if (resultBootFeature.Count == 8) + { + timerBootFeature.Dispose(); + string max = "0.0"; + string min = "0.0"; + foreach (string fre in resultBootFeature) + { + if (Convert.ToDouble(fre) > Convert.ToDouble(max)) max = fre; + if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; + } + result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; + + detectionItemService.updateDetecStatus(detectionItemId, "", "", result, "", "", "", "", "", ""); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdBootFeature, "3", ""); + portBootFeature.Close(); + } + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + + resultBootFeature.Clear(); + } + } } #endregion @@ -612,63 +554,54 @@ TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; } - timerAgeRate = new System.Threading.Timer(exeAgeRate, null, delay + 100, 12 * 60 * 60 * 1000); + timerAgeRate = new System.Threading.Timer(exeAgeRate, null, delay + 100, 12* 60* 60 * 1000); } private void exeAgeRate(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测日老化率"); + + string result = ""; + double sum = 0.0; + int count = 0; + for (int i = 0; i < 50; i++) { - if (!isUsing) + string fre = getFrequencyData(portAgeRate); + if (!fre.Equals("")) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测日老化率"); - - string result = ""; - double sum = 0.0; - for (int i = 0; i < 3; i++) - { - string fre = getFrequencyData(portAgeRate); - if (fre.Equals("")) - { - //MessageBox.Show("从" + portAgeRate.PortName + "获取数据失败!"); - isUsing = false; - return; - } - detectionService.add(devIdStability, fre, "4"); - sum = sum + Convert.ToDouble(fre); - } - resultAgeRate.Add(sum / 3 + ""); - - if (resultAgeRate.Count == 15) - { - double r = 0.0; - double k = FreMath.DriftRate(resultAgeRate, out r); - result = k + "," + r; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", result, "", "", "", "", ""); - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdAgeRate, "3", ""); - portAgeRate.Close(); - } - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - timerAgeRate.Dispose(); - resultAgeRate.Clear(); - } - isUsing = false; - - break; + count++; + sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } - } + detectionService.add(devIdAgeRate, sum / 3+"", "4"); + resultAgeRate.Add(sum / 3 + ""); + + if (resultAgeRate.Count == 15) + { + timerAgeRate.Dispose(); + double r = 0.0; + double k = FreMath.DriftRate(resultAgeRate, out r); + result = k + "," + r.ToString().Substring(0,5); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); + + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", result, "", "", "", "", ""); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdAgeRate, "3", ""); + portAgeRate.Close(); + } + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + + resultAgeRate.Clear(); + } + } } #endregion @@ -678,96 +611,109 @@ // 获取检测数据 public string getFrequencyData(SerialPort port) { + string received = ""; try { - isUsing = true; - if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); - else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); - string received = ""; - if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) + while (true) { - int count = 0; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值1"); - - while (count < 5000) + if (!isUsing) { - int readLen = port.BytesToRead; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen =" + readLen); + isUsing = true; + if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); + else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); - if (readLen > 0) + if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) { - byte[] buffer = new byte[readLen]; - port.Read(buffer, 0, readLen);// 接收数据到buffer里面 - string data = Encoding.ASCII.GetString(buffer); - string[] dataArray = data.Split(' '); - if (data.StartsWith("$") && dataArray.Length == 2 && data.LastIndexOf('$') == 0) + int count = 0; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值1"); + + while (count < 5000) { - if (received.Contains("-")) + int readLen = port.BytesToRead; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen =" + readLen); + + if (readLen > 0) { - received =( Convert.ToDouble(dataArray[0].Replace("$", "")) - Convert.ToDouble("0."+data.Split(' ')[1].Replace(".", "").Replace("-","").TrimEnd('0')))+ ""; - } - else received = dataArray[0].Replace("$", "") + "." + data.Split(' ')[1].Replace(".", "").TrimEnd('0'); - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "before received = " + received); - - received = ((Convert.ToDouble(received) - 10000000) / 10000000) +""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "received = "+ received); - - break; - } - } - count++; - } - } - else - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值2"); - - int count = 0; - - while (count < 5000) - { - int readLen = port.BytesToRead; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen=" + readLen); - - if (readLen > 0) - { - byte[] buffer = new byte[readLen]; - port.Read(buffer, 0, readLen);// 接收数据到buffer里面 - string data = Encoding.ASCII.GetString(buffer); - string[] dataArray = data.Split(' '); - if (dataArray.Length >= 3) - { - foreach (string sss in dataArray) - { - if (sss.Contains("E")) + byte[] buffer = new byte[readLen]; + port.Read(buffer, 0, readLen);// 接收数据到buffer里面 + string data = Encoding.ASCII.GetString(buffer); + string[] dataArray = data.Split(' '); + if (data.StartsWith("$") && dataArray.Length == 2 && data.LastIndexOf('$') == 0) { - received = sss; - //received = float.Parse(received)+""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取测量值2:" + received + ":" + data); + if (received.Contains("-")) + { + received = (Convert.ToDouble(dataArray[0].Replace("$", "")) - Convert.ToDouble("0." + data.Split(' ')[1].Replace(".", "").Replace("-", "").TrimEnd('0'))) + ""; + } + else received = dataArray[0].Replace("$", "") + "." + data.Split(' ')[1].Replace(".", "").TrimEnd('0'); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "before received = " + received); + + received = ((Convert.ToDouble(received) - 10000000) / 10000000) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "received = " + received); + break; } } - if (!received.Equals("")) break; + count++; } } - count++; + else + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值2"); + + int count = 0; + + while (count < 5000) + { + int readLen = port.BytesToRead; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen=" + readLen); + + if (readLen > 0) + { + byte[] buffer = new byte[readLen]; + port.Read(buffer, 0, readLen);// 接收数据到buffer里面 + string data = Encoding.ASCII.GetString(buffer); + string[] dataArray = data.Split(' '); + if (dataArray.Length >= 3) + { + foreach (string sss in dataArray) + { + if (sss.Contains("E")) + { + received = sss; + //received = float.Parse(received)+""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取测量值2:" + received + ":" + data); + break; + } + } + if (!received.Equals("")) break; + } + } + count++; + } + } + + + if (received.Equals("")) + { + string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!" + DateTime.Now.ToLongTimeString()); + } + break; } } - isUsing = false; - - if (received.Equals("")) - { - string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel","通道"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name+"获取数据失败!"+ DateTime.Now.ToLongTimeString()); - } - return received; + } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "错误:" + ex.Message); return ""; } + finally + { + isUsing = false; + } + return received; } diff --git a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs index 4de721d..00440fc 100644 --- a/RbFreqStandMeasure/R_DataBase/Model/Detection.cs +++ b/RbFreqStandMeasure/R_DataBase/Model/Detection.cs @@ -21,6 +21,7 @@ string frequency; string detectionItem; + public long Id { get @@ -74,5 +75,6 @@ } public string DetectionItem { get => detectionItem; set => detectionItem = value; } + } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs index 43b713d..6077a86 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/CounterDataService.cs @@ -11,7 +11,7 @@ long add(long deviceId, string outValue, string value, string sensitivity, string logTime, string detecType); List getHistory(long deviceId, string outValue, string type); int update(long deviceId, string outValue, string value, string sensitivity, DateTime logTime, string detecType); - int delete(long deviceId, string outValue, string value, string sensitivity, string logTime); + int delete(long deviceId, string outValue, string logTime); int updateById(long id, string outValue, string value, string sensitivity, DateTime logTime, string detecType); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs index a2e25aa..0fd7b24 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterCheckParamServiceImpl.cs @@ -21,8 +21,13 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开,进行重连!"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_check_params (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -67,7 +72,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET (SO_OUT_DELAY,SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE,SO_ELE_ALARM," + @@ -111,7 +121,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterCheckParams : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_check_params"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs index 209d57b..94ad90e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDataServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } //先查询是否有历史数据 string sQry = "select ID from r_counter_data where DEVICE_ID=" + deviceId + " and OUT_VALUE = " + outValue; @@ -90,7 +95,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID=@DEVICE_ID AND OUT_VALUE=@OUT_VALUE"; @@ -154,7 +164,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "update r_counter_data set OUT_VALUE=@OUT_VALUE, VALUE=@VALUE, SENSITIVITY=@SENSITIVITY, LOG_TIME@LOG_TIME, DETEC_TYPE=@DETEC_TYPE " + @@ -188,7 +203,7 @@ } - public int delete(long deviceId, string outValue, string value, string sensitivity, string logTime) + public int delete(long deviceId, string outValue,string logTime) { int iRetval = -1; try @@ -196,18 +211,21 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } - string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID,OUT_VALUE=@OUT_VALUE,VALUE=@VALUE,SENSITIVITY=@SENSITIVITY,LOG_TIME=@LOG_TIME"; + string sQry = "delete from r_counter_data where DEVICE_ID=@DEVICE_ID and OUT_VALUE=@OUT_VALUE and LOG_TIME=@LOG_TIME"; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEVICE_ID", MySqlDbType.Int64, 20).Value = deviceId; cmd.Parameters.Add("@OUT_VALUE", MySqlDbType.String, 255).Value = outValue; - cmd.Parameters.Add("@VALUE", MySqlDbType.String, 0).Value = value; - cmd.Parameters.Add("@SENSITIVITY", MySqlDbType.String, 0).Value = sensitivity; - cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 0).Value = logTime; + cmd.Parameters.Add("@LOG_TIME", MySqlDbType.String, 20).Value = logTime; cmd.ExecuteNonQuery(); @@ -232,7 +250,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_data where DEVICE_ID = " + deviceId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs index 8be1990..f807b5c 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterDetecInitServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_counter_detec_init order by ID"; @@ -63,7 +68,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterData : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "select ID from r_counter_detec_init where FREQUENCY=" + frequency +" AND CYCLE="+cycle; MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -109,7 +119,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_detec_init SET FREQUENCY=@FREQUENCY, CYCLE=@CYCLE " + @@ -141,7 +156,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "delete from r_counter_detec_init WHERE ID = " + id; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs index e49af7a..6a29597 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/CounterParamServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_counter_param (DEVICE_ID,BAUD_RATE,GENERATOR_IP,SIGNAL_SOURCE_IP)" + @@ -53,6 +58,16 @@ try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addCounterParam : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } string sql = "SELECT * FROM r_counter_param where DEVICE_ID = " + deviceId; MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 81b6393..5d2608a 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -20,7 +20,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection_item (DEVICE_ID,START_TIME,END_TIME,STABILITY,ACCURACY,BOOT_FEATURE,AGE_RATE,STABILITY_INTERVAL,CHANNEL,STABILITY_1,STABILITY_10,STABILITY_20,STABILITY_100)" + @@ -78,7 +83,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection_item SET START_TIME=@START_TIME,END_TIME=@END_TIME,STABILITY=@STABILITY,ACCURACY=@ACCURACY,BOOT_FEATURE=@BOOT_FEATURE,AGE_RATE=@AGE_RATE,STABILITY_INTERVAL=@INTERVAL,COUNTER_DETEC=@COUNTER_DETEC WHERE DEVICE_ID = " + deviceId; @@ -115,7 +125,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; @@ -176,7 +191,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET STATUSID="+"1"+", CHANNEL=@CHANNEL where ID=" + deviceId; @@ -187,11 +207,11 @@ if (isDeleteData) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + "AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + "AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } @@ -215,7 +235,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where DEVICE_ID = " + deviceId; @@ -266,7 +291,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetectionItem : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection_item where ID = " + detectionId; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs index e0ce857..66e9d26 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionServiceImpl.cs @@ -22,7 +22,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDetection : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "INSERT INTO r_detection (DEVICE_ID,LOG_TIME,FREQUENCY,DETECTION_ITEM)" + @@ -57,7 +62,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateFrequency : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_detection SET FREQUENCY=@FREQUENCY WHERE ID = " + detectionId; @@ -86,7 +96,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDetection : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_detection where DEVICE_ID = " + deviceId +" and DETECTION_ITEM='" + detectionType + "' and (LOG_TIME BETWEEN '" + startTime + "' and '"+ endTime + "') order by LOG_TIME"; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 0179b93..917870b 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -24,7 +24,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "addDeviced : 数据库链接断开"); - return deviceId; + 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)" + @@ -71,7 +76,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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 "; @@ -112,7 +122,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "deleteDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_device SET ACTIVE = 1 WHERE ID = " + id; @@ -144,7 +159,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } } string sQry = "SELECT * FROM r_device where active = " + 0; @@ -218,7 +238,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "searchDevice : 数据库链接断开"); - return null; + 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'"; @@ -273,11 +298,19 @@ { List deviceDtoList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; - + try { - conn = DbConnectService.getConnection(); + 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; @@ -344,11 +377,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return deviceDtoList; @@ -358,12 +387,20 @@ string customDev, string customerName, string statusId) { int totalCount = 0; - MySqlConnection conn = null; try { - conn = DbConnectService.getConnection(); - + 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) @@ -401,11 +438,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } + } return totalCount; @@ -415,11 +448,20 @@ { List deviceViewList = new List(); DictService dictService = new DictServiceImpl(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + 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 "; @@ -478,11 +520,6 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); //用完即关闭连接 - } } return deviceViewList; } @@ -496,7 +533,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + 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; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index 1b85062..9d7782f 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -12,15 +12,23 @@ { public String getNameByCode(string codeType,string code) { - String name = ""; - MySqlConnection conn = null; + String name = ""; try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return ""; + } + } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - - conn = DbConnectService.getConnection(); - MySqlCommand cmd = new MySqlCommand(sql, conn); + + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); @@ -47,11 +55,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return name; } @@ -59,13 +63,22 @@ public List getTypeListByCodeType(string codeType) { List nameList = new List(); - MySqlConnection conn = null; + try { - conn = DbConnectService.getConnection(); + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return nameList; + } + } string sQry = "SELECT * FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "')"; - MySqlCommand aCommand = new MySqlCommand(sQry, conn); + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); using (MySqlDataReader aReader = aCommand.ExecuteReader()) { @@ -80,8 +93,7 @@ } aCommand.Dispose(); - conn.Close(); - conn.Dispose(); // 用完即关闭连接 + } } catch(MySqlException ex) @@ -91,11 +103,7 @@ } finally { - if (null != conn) - { - conn.Close(); - conn.Dispose(); // 用完即关闭连接 - } + } return nameList; @@ -107,6 +115,17 @@ CounterParam counterParam = new CounterParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterParam; + } + } + string sQry = "SELECT * FROM r_counter_param"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -142,7 +161,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_param SET GENERATOR_IP='"+ ip +"'"; @@ -167,6 +191,16 @@ CounterCheckParam counterCheckParam = new CounterCheckParam(); try { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return counterCheckParam; + } + } string sQry = "SELECT * FROM r_counter_check_params"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -208,7 +242,12 @@ if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDeviced : 数据库链接断开"); - return iRetval; + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } } string sQry = "UPDATE r_counter_check_params SET SO_OUT_DELAY=@SO_OUT_DELAY,SO_ELE_FREQUENCY=@SO_ELE_FREQUENCY,SO_ELE_ADD_VALUE=@SO_ELE_ADD_VALUE,SO_ELE_ALARM=@SO_ELE_ALARM,FRE_THRESHOLD1=@FRE_THRESHOLD1,FRE_THRESHOLD2=@FRE_THRESHOLD2,FRE_ELE_ADD_VALUE=@FRE_ELE_ADD_VALUE,CYC_THRESHOLD1=@CYC_THRESHOLD1,CYC_THRESHOLD2=@CYC_THRESHOLD2,CYC_ELE_ADD_VALUE=@CYC_ELE_ADD_VALUE"; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs index 0d37157..1eb7da3 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIBServiceImpl.cs @@ -89,7 +89,7 @@ try { _portOperatorBaseGpib.WriteLine(content); - + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 693541b..4c72443 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -42,19 +42,18 @@ { try { - if (freqRequest == 0) - { - tcpService.write("INIT"); + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - freqRequest++; - } - tcpService.write("MEAS:FREQ?"); + //freqRequest++; + + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); return tcpService.read(); } - catch(Exception ex) + catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getFreq:" + ex.Message); return null; @@ -66,16 +65,13 @@ { try { - if (periodRequest == 0) - { - tcpService.write("INIT"); + + //tcpService.write("INIT"); - tcpService.write("*WAI"); + //tcpService.write("*WAI"); - periodRequest++; - } - tcpService.write("MEAS:PERIOD?"); + tcpService.write("READ?"); return tcpService.read(); } diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs index b18389a..647ce40 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/SensitivityServiceImpl.cs @@ -50,7 +50,7 @@ currentValue_E = GPIB_TCPIP_OPERATIO.getFreq(tcpService);//Hz else if (type == "period") currentValue_E = GPIB_TCPIP_OPERATIO.getPeriod(tcpService);//s - + if (currentValue_E == "") continue; currentValue = UnitConvertHelper.convertDt(currentValue_E); //检测数据是否在容差范围内 bool errorCheckResult = satisfyCheck(counterCheckParam, sensitivityContentParam, currentValue, type); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index b347641..4f0bb8a 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -92,6 +92,7 @@ { _portOperatorBaseTcp.WriteLine(content); + result = 0; } catch (Exception ex) diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 6c4071b..6e59072 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f3b87bb..8bf08b3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -315,8 +315,8 @@ private void comboBox_counters_SelectedIndexChanged(object sender, EventArgs e) { - text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; + deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); detected = false; @@ -351,25 +351,7 @@ colValue.Text = "测量周期"; } - table_counterDetecInit.Rows.Clear(); - List queryList = counterDetecInitService.getAll(); - if (null != queryList && queryList.Count > 0) - { - int index = 1; - foreach (CounterDetecInit counterDetecInit in queryList) - { - if (textBox_detecModel.Text.Equals("周期测量")) - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Cycle, "", "", "", counterDetecInit.Id); - } - else - { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - } - //dataGridView_CounterResult.Rows.Add(index, devType, devCode, devPort, counterDetecInit.Frequency, "", "", "", counterDetecInit.Id); - index++; - } - } + LoadCounterDetecInitList(); } private void dataGridView_CounterResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) @@ -402,9 +384,9 @@ string value = dataGridView_CounterResult.CurrentRow.Cells[5].Value.ToString(); string sensitivity = dataGridView_CounterResult.CurrentRow.Cells[6].Value.ToString(); string logTime = dataGridView_CounterResult.CurrentRow.Cells[7].Value.ToString(); - if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(value) && !String.IsNullOrEmpty(sensitivity)) + if (!String.IsNullOrEmpty(outValue)&& !String.IsNullOrEmpty(sensitivity)) { - counterDataService.delete(deviceId, outValue, value, sensitivity, logTime); + counterDataService.delete(deviceId, outValue, logTime); } //deviceService.delete(Convert.ToInt32(dataGridView_DevList.Rows[dataGridView_DevList.CurrentRow.Index].Cells[8].Value)); MessageBox.Show("删除成功", "提示"); @@ -641,7 +623,7 @@ CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); gPIBService.open(gPIBService.getId()[0]); - tcpService.open("TCPIP0::"+text_counterIp.Text+"::inst0::INST"); + tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); //tcpService.open(text_counterIp.Text); int index = 0; diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 74bfd5a..03f9d90 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -251,7 +251,7 @@ } } long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; this.HideMaskAction(); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs index f79f8b1..05081ac 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.Designer.cs @@ -66,13 +66,13 @@ this.label15 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label6 = new System.Windows.Forms.Label(); - this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.checkBox_100s = new System.Windows.Forms.CheckBox(); this.checkBox20s = new System.Windows.Forms.CheckBox(); this.checkBox10s = new System.Windows.Forms.CheckBox(); this.checkBox1s = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.btnCancelSetDev = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.btnSave = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -88,7 +88,7 @@ this.panel1.Controls.Add(this.label11); this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(639, 32); + this.panel1.Size = new System.Drawing.Size(662, 32); this.panel1.TabIndex = 11; this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); // @@ -100,7 +100,7 @@ this.btnExitDev.FlatAppearance.BorderSize = 0; this.btnExitDev.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnExitDev.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btnExitDev.Location = new System.Drawing.Point(603, 5); + this.btnExitDev.Location = new System.Drawing.Point(634, 5); this.btnExitDev.Margin = new System.Windows.Forms.Padding(0); this.btnExitDev.Name = "btnExitDev"; this.btnExitDev.Size = new System.Drawing.Size(20, 20); @@ -148,7 +148,7 @@ this.groupBox1.Controls.Add(this.text_channelNo); this.groupBox1.Location = new System.Drawing.Point(10, 32); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(619, 134); + this.groupBox1.Size = new System.Drawing.Size(640, 134); this.groupBox1.TabIndex = 18; this.groupBox1.TabStop = false; // @@ -160,11 +160,11 @@ this.btn_downChannelList.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_downChannelList.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btn_downChannelList.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.btn_downChannelList.Location = new System.Drawing.Point(542, 96); + this.btn_downChannelList.Location = new System.Drawing.Point(558, 96); this.btn_downChannelList.Margin = new System.Windows.Forms.Padding(0); this.btn_downChannelList.Name = "btn_downChannelList"; this.btn_downChannelList.Padding = new System.Windows.Forms.Padding(1, 2, 0, 0); - this.btn_downChannelList.Size = new System.Drawing.Size(17, 23); + this.btn_downChannelList.Size = new System.Drawing.Size(20, 22); this.btn_downChannelList.TabIndex = 22; this.btn_downChannelList.Text = "﹀"; this.btn_downChannelList.UseVisualStyleBackColor = false; @@ -197,7 +197,7 @@ this.text_customerName.Name = "text_customerName"; this.text_customerName.PreventEnterBeep = true; this.text_customerName.ReadOnly = true; - this.text_customerName.Size = new System.Drawing.Size(150, 27); + this.text_customerName.Size = new System.Drawing.Size(170, 27); this.text_customerName.TabIndex = 32; // // label2 @@ -227,7 +227,7 @@ this.text_customerDev.Name = "text_customerDev"; this.text_customerDev.PreventEnterBeep = true; this.text_customerDev.ReadOnly = true; - this.text_customerDev.Size = new System.Drawing.Size(150, 27); + this.text_customerDev.Size = new System.Drawing.Size(169, 27); this.text_customerDev.TabIndex = 29; // // text_devType @@ -246,7 +246,7 @@ this.text_devType.Name = "text_devType"; this.text_devType.PreventEnterBeep = true; this.text_devType.ReadOnly = true; - this.text_devType.Size = new System.Drawing.Size(150, 27); + this.text_devType.Size = new System.Drawing.Size(170, 27); this.text_devType.TabIndex = 30; // // label1 @@ -287,7 +287,7 @@ this.text_devCode.Name = "text_devCode"; this.text_devCode.PreventEnterBeep = true; this.text_devCode.ReadOnly = true; - this.text_devCode.Size = new System.Drawing.Size(150, 27); + this.text_devCode.Size = new System.Drawing.Size(169, 27); this.text_devCode.TabIndex = 25; // // text_devName @@ -306,7 +306,7 @@ this.text_devName.Name = "text_devName"; this.text_devName.PreventEnterBeep = true; this.text_devName.ReadOnly = true; - this.text_devName.Size = new System.Drawing.Size(150, 27); + this.text_devName.Size = new System.Drawing.Size(170, 27); this.text_devName.TabIndex = 26; this.text_devName.WatermarkColor = System.Drawing.SystemColors.ButtonShadow; // @@ -347,7 +347,7 @@ this.text_channelNo.Name = "text_channelNo"; this.text_channelNo.PreventEnterBeep = true; this.text_channelNo.ReadOnly = true; - this.text_channelNo.Size = new System.Drawing.Size(150, 27); + this.text_channelNo.Size = new System.Drawing.Size(169, 27); this.text_channelNo.TabIndex = 34; // // comboBox_channelNo @@ -406,7 +406,7 @@ this.groupBox2.Location = new System.Drawing.Point(10, 169); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(619, 129); + this.groupBox2.Size = new System.Drawing.Size(640, 129); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // @@ -436,7 +436,7 @@ this.timePicker_endTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_endTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_endTime.IsPopupCalendarOpen = false; - this.timePicker_endTime.Location = new System.Drawing.Point(414, 75); + this.timePicker_endTime.Location = new System.Drawing.Point(418, 75); // // // @@ -468,7 +468,7 @@ this.timePicker_endTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_endTime.Name = "timePicker_endTime"; this.timePicker_endTime.ShowUpDown = true; - this.timePicker_endTime.Size = new System.Drawing.Size(199, 23); + this.timePicker_endTime.Size = new System.Drawing.Size(204, 23); this.timePicker_endTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_endTime.TabIndex = 20; this.timePicker_endTime.ValueChanged += new System.EventHandler(this.timePicker_endTime_ValueChanged); @@ -486,7 +486,7 @@ this.timePicker_startTime.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.timePicker_startTime.Format = DevComponents.Editors.eDateTimePickerFormat.Custom; this.timePicker_startTime.IsPopupCalendarOpen = false; - this.timePicker_startTime.Location = new System.Drawing.Point(122, 76); + this.timePicker_startTime.Location = new System.Drawing.Point(116, 76); this.timePicker_startTime.MinDate = new System.DateTime(2021, 4, 12, 0, 0, 0, 0); // // @@ -521,7 +521,7 @@ this.timePicker_startTime.MonthCalendar.TodayButtonVisible = true; this.timePicker_startTime.Name = "timePicker_startTime"; this.timePicker_startTime.ShowUpDown = true; - this.timePicker_startTime.Size = new System.Drawing.Size(193, 23); + this.timePicker_startTime.Size = new System.Drawing.Size(204, 23); this.timePicker_startTime.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.timePicker_startTime.TabIndex = 21; this.timePicker_startTime.TimeSelectorTimeFormat = DevComponents.Editors.DateTimeAdv.eTimeSelectorFormat.Time24H; @@ -579,7 +579,7 @@ // label3 // this.label3.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label3.Location = new System.Drawing.Point(310, 73); + this.label3.Location = new System.Drawing.Point(315, 73); this.label3.Margin = new System.Windows.Forms.Padding(0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(100, 27); @@ -632,10 +632,54 @@ this.groupBox3.Enabled = false; this.groupBox3.Location = new System.Drawing.Point(10, 299); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(619, 56); + this.groupBox3.Size = new System.Drawing.Size(640, 56); this.groupBox3.TabIndex = 37; this.groupBox3.TabStop = false; // + // checkBox_100s + // + this.checkBox_100s.AutoSize = true; + this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox_100s.Location = new System.Drawing.Point(476, 22); + this.checkBox_100s.Name = "checkBox_100s"; + this.checkBox_100s.Size = new System.Drawing.Size(58, 24); + this.checkBox_100s.TabIndex = 357; + this.checkBox_100s.Text = "100s"; + this.checkBox_100s.UseVisualStyleBackColor = true; + // + // checkBox20s + // + this.checkBox20s.AutoSize = true; + this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox20s.Location = new System.Drawing.Point(366, 22); + this.checkBox20s.Name = "checkBox20s"; + this.checkBox20s.Size = new System.Drawing.Size(50, 24); + this.checkBox20s.TabIndex = 356; + this.checkBox20s.Text = "20s"; + this.checkBox20s.UseVisualStyleBackColor = true; + // + // checkBox10s + // + this.checkBox10s.AutoSize = true; + this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox10s.Location = new System.Drawing.Point(242, 23); + this.checkBox10s.Name = "checkBox10s"; + this.checkBox10s.Size = new System.Drawing.Size(50, 24); + this.checkBox10s.TabIndex = 355; + this.checkBox10s.Text = "10s"; + this.checkBox10s.UseVisualStyleBackColor = true; + // + // checkBox1s + // + this.checkBox1s.AutoSize = true; + this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.checkBox1s.Location = new System.Drawing.Point(124, 22); + this.checkBox1s.Name = "checkBox1s"; + this.checkBox1s.Size = new System.Drawing.Size(42, 24); + this.checkBox1s.TabIndex = 354; + this.checkBox1s.Text = "1s"; + this.checkBox1s.UseVisualStyleBackColor = true; + // // label6 // this.label6.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); @@ -694,56 +738,12 @@ this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // - // checkBox_100s - // - this.checkBox_100s.AutoSize = true; - this.checkBox_100s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox_100s.Location = new System.Drawing.Point(477, 22); - this.checkBox_100s.Name = "checkBox_100s"; - this.checkBox_100s.Size = new System.Drawing.Size(58, 24); - this.checkBox_100s.TabIndex = 357; - this.checkBox_100s.Text = "100s"; - this.checkBox_100s.UseVisualStyleBackColor = true; - // - // checkBox20s - // - this.checkBox20s.AutoSize = true; - this.checkBox20s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox20s.Location = new System.Drawing.Point(358, 22); - this.checkBox20s.Name = "checkBox20s"; - this.checkBox20s.Size = new System.Drawing.Size(50, 24); - this.checkBox20s.TabIndex = 356; - this.checkBox20s.Text = "20s"; - this.checkBox20s.UseVisualStyleBackColor = true; - // - // checkBox10s - // - this.checkBox10s.AutoSize = true; - this.checkBox10s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox10s.Location = new System.Drawing.Point(242, 23); - this.checkBox10s.Name = "checkBox10s"; - this.checkBox10s.Size = new System.Drawing.Size(50, 24); - this.checkBox10s.TabIndex = 355; - this.checkBox10s.Text = "10s"; - this.checkBox10s.UseVisualStyleBackColor = true; - // - // checkBox1s - // - this.checkBox1s.AutoSize = true; - this.checkBox1s.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.checkBox1s.Location = new System.Drawing.Point(124, 22); - this.checkBox1s.Name = "checkBox1s"; - this.checkBox1s.Size = new System.Drawing.Size(42, 24); - this.checkBox1s.TabIndex = 354; - this.checkBox1s.Text = "1s"; - this.checkBox1s.UseVisualStyleBackColor = true; - // // SetDevTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(638, 430); + this.ClientSize = new System.Drawing.Size(662, 430); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 6f77dc8..da45f50 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -151,7 +151,7 @@ if (checkBox_100s.Checked) interval = interval + "100"; stability = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { stability = "-1"; if (checkBox1s.Checked) stability1 = "-1"; @@ -172,7 +172,7 @@ if (checkBox_accuracy.Checked) { accuracy = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { accuracy = "-1"; detectionHelper.detecAccuracy(deviceId, port, endTime, true, false); @@ -185,7 +185,7 @@ if (checkBox_bootFeature.Checked) { bootFeature = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { bootFeature = "-1"; detectionHelper.detecBootFeature(deviceId, startTime, port, true); @@ -199,7 +199,7 @@ if (checkBox_ageRate.Checked) { ageRate = "-2"; - if (checkBox_now.Checked || timePicker_startTime.Value == DateTime.Now) + if (checkBox_now.Checked || timePicker_startTime.Value <= DateTime.Now) { ageRate = "-1"; detectionHelper.detecAgeRate(deviceId, startTime, port, true); @@ -210,9 +210,10 @@ } } - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - + long detectionItemId = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionItemId = detectionItemId; this.HideMaskAction(); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); HomeCtrlForm.homeCtrlForm.LoadDevToBeTested(); } diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 8ed1f64..8af1705 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -168,8 +168,7 @@ DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) - { - + { port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; @@ -258,6 +257,7 @@ //开始检测 + //稳定度 if (checkBox_stability.Checked) { if (checkBox1s.Checked) interval = "1,"; @@ -284,9 +284,8 @@ if (checkBox_100s.Checked) stability100 = "-2"; detectionHelper.detecStability(deviceId, startTime, interval, port, false, false); } - - } + // 准确度 if (checkBox_accuracy.Checked) { accuracy = "-2"; @@ -300,6 +299,7 @@ detectionHelper.detecAccuracy(deviceId, port, endTime, false, false); } } + //开机特性 if (checkBox_bootFeature.Checked) { bootFeature = "-2"; @@ -314,6 +314,7 @@ } } + //日老化率 if (checkBox_ageRate.Checked) { ageRate = "-2"; @@ -332,7 +333,7 @@ //开始检测 long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); - detectionHelper.detectionId = detectionId0; + detectionHelper.detectionItemId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 7636e03..f52da1a 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -51,7 +51,7 @@ public static DataGridView dataGridView; public static Label label_redetecting; - + long deviceId = -1; string startTime = ""; string endTime = ""; @@ -225,7 +225,7 @@ tableTimes.Columns.Add("stability10", Type.GetType("System.String")); tableTimes.Columns.Add("stability20", Type.GetType("System.String")); tableTimes.Columns.Add("stability100", Type.GetType("System.String")); - + tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12 // 获取当前页的数据 List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) @@ -234,7 +234,7 @@ int index = 1; foreach (DetectionItem detection in queryList) { - tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100); + tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id); index++; } @@ -256,6 +256,7 @@ dataGridView_times.Columns[9].Visible = false; dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; + dataGridView_times.Columns[12].Visible = false; dataGridView_times.Columns[0].ReadOnly = true; dataGridView_times.Columns[1].ReadOnly = true; @@ -400,6 +401,7 @@ label_redetecting = this.label_reDetecting; ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data); + dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value); dlg.deviceId = deviceId; dlg.label_devCode.Text = label_devCode.Text; dlg.label_devModel.Text = label_devModel.Text; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index b426aee..0225309 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -35,6 +35,7 @@ DetectionItemService detectionItemService = new DetectionItemServiceImpl(); public string detectType = ""; public long deviceId=-1; + public long detectionItemId = -1; public Action HideMaskAction { @@ -135,7 +136,7 @@ DeviceService devService = new DeviceServiceImpl(); - + detectionHelper.detectionItemId = detectionItemId; //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 15067c5..e33e95d 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -42,7 +42,7 @@ this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; - this.label_accuracy.Size = new System.Drawing.Size(162, 27); + this.label_accuracy.Size = new System.Drawing.Size(212, 27); this.label_accuracy.TabIndex = 100; this.label_accuracy.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/ageRate.designer.cs b/RbFreqStandMeasure/info/ageRate.designer.cs index e310441..806892d 100644 --- a/RbFreqStandMeasure/info/ageRate.designer.cs +++ b/RbFreqStandMeasure/info/ageRate.designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.label_r = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -40,21 +40,21 @@ // // chart1 // - chartArea2.AxisX.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisX.MajorGrid.Enabled = false; - chartArea2.AxisY.LabelAutoFitMaxFontSize = 9; - chartArea2.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; - chartArea2.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea2); - this.chart1.Location = new System.Drawing.Point(0, 42); + chartArea6.AxisX.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisX.MajorGrid.Enabled = false; + chartArea6.AxisY.LabelAutoFitMaxFontSize = 9; + chartArea6.AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver; + chartArea6.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea6); + this.chart1.Location = new System.Drawing.Point(0, 33); this.chart1.Name = "chart1"; - series2.ChartArea = "ChartArea1"; - series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; - series2.IsVisibleInLegend = false; - series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; - series2.Name = "Series1"; - this.chart1.Series.Add(series2); - this.chart1.Size = new System.Drawing.Size(405, 201); + series6.ChartArea = "ChartArea1"; + series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline; + series6.IsVisibleInLegend = false; + series6.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; + series6.Name = "Series1"; + this.chart1.Series.Add(series6); + this.chart1.Size = new System.Drawing.Size(405, 210); this.chart1.TabIndex = 117; this.chart1.Text = "chart1"; // @@ -63,10 +63,10 @@ this.label_r.BackColor = System.Drawing.Color.Transparent; this.label_r.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_r.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_r.Location = new System.Drawing.Point(318, 12); + this.label_r.Location = new System.Drawing.Point(355, 6); this.label_r.Margin = new System.Windows.Forms.Padding(0); this.label_r.Name = "label_r"; - this.label_r.Size = new System.Drawing.Size(83, 27); + this.label_r.Size = new System.Drawing.Size(50, 27); this.label_r.TabIndex = 116; this.label_r.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -74,10 +74,10 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(213, 12); + this.label4.Location = new System.Drawing.Point(257, 3); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(105, 27); + this.label4.Size = new System.Drawing.Size(101, 27); this.label4.TabIndex = 115; this.label4.Text = "相关系数(%):"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -87,10 +87,10 @@ this.label_k.BackColor = System.Drawing.Color.Transparent; this.label_k.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_k.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_k.Location = new System.Drawing.Point(100, 12); + this.label_k.Location = new System.Drawing.Point(76, 4); this.label_k.Margin = new System.Windows.Forms.Padding(0); this.label_k.Name = "label_k"; - this.label_k.Size = new System.Drawing.Size(101, 27); + this.label_k.Size = new System.Drawing.Size(176, 27); this.label_k.TabIndex = 114; this.label_k.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -98,10 +98,10 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(13, 12); + this.label2.Location = new System.Drawing.Point(2, 3); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(87, 27); + this.label2.Size = new System.Drawing.Size(82, 27); this.label2.TabIndex = 112; this.label2.Text = "测量结果:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -110,10 +110,10 @@ // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.chart1); - this.Controls.Add(this.label_r); - this.Controls.Add(this.label4); this.Controls.Add(this.label_k); + this.Controls.Add(this.label_r); + this.Controls.Add(this.chart1); + this.Controls.Add(this.label4); this.Controls.Add(this.label2); this.Name = "ageRate"; this.Size = new System.Drawing.Size(405, 246); diff --git a/RbFreqStandMeasure/info/bootFeature.designer.cs b/RbFreqStandMeasure/info/bootFeature.designer.cs index 68d915f..7e46577 100644 --- a/RbFreqStandMeasure/info/bootFeature.designer.cs +++ b/RbFreqStandMeasure/info/bootFeature.designer.cs @@ -65,7 +65,7 @@ this.label_bootFeature.Location = new System.Drawing.Point(101, 9); this.label_bootFeature.Margin = new System.Windows.Forms.Padding(0); this.label_bootFeature.Name = "label_bootFeature"; - this.label_bootFeature.Size = new System.Drawing.Size(107, 27); + this.label_bootFeature.Size = new System.Drawing.Size(250, 27); this.label_bootFeature.TabIndex = 103; this.label_bootFeature.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index 91ee328..e9dc1c9 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -39,7 +39,7 @@ this.label_count.BackColor = System.Drawing.Color.Transparent; this.label_count.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_count.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_count.Location = new System.Drawing.Point(196, 110); + this.label_count.Location = new System.Drawing.Point(161, 110); this.label_count.Margin = new System.Windows.Forms.Padding(0); this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); @@ -52,10 +52,10 @@ this.label_stability.BackColor = System.Drawing.Color.Transparent; this.label_stability.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_stability.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_stability.Location = new System.Drawing.Point(195, 59); + this.label_stability.Location = new System.Drawing.Point(160, 59); this.label_stability.Margin = new System.Windows.Forms.Padding(0); this.label_stability.Name = "label_stability"; - this.label_stability.Size = new System.Drawing.Size(152, 27); + this.label_stability.Size = new System.Drawing.Size(210, 27); this.label_stability.TabIndex = 81; this.label_stability.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // @@ -63,7 +63,7 @@ // this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(109, 110); + this.label2.Location = new System.Drawing.Point(74, 110); this.label2.Margin = new System.Windows.Forms.Padding(0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(87, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(112, 57); + this.label9.Location = new System.Drawing.Point(77, 57); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(83, 27); diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 796a9b3..483fc5a 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -70,25 +70,20 @@ public void draw(List bdList, List gpList) { try - { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::bd:" + bdList.Count); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "开始画啦 ::::::gp:" + gpList.Count); - + { if (bdList.Count > 0 || gpList.Count>0) { - if (this.InvokeRequired) + + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - //coo = new Coordinate(); - //panelSite.Controls.Add(coo); - //coo.Show(); - drawFunc(bdList); - drawFunc(gpList); - } - )); - + panelSite.Controls.Clear(); + coo = new Coordinate(); + panelSite.Controls.Add(coo); + coo.Show(); + drawFunc(bdList); + drawFunc(gpList); } + )); } } @@ -103,44 +98,49 @@ { try { - if (this.InvokeRequired) + Invoke(new MethodInvoker(delegate () { - Invoke(new MethodInvoker(delegate () - { - if (gvsList.Count > 0) + if (gvsList.Count > 0) + { + Graphics gp = coo.CreateGraphics(); + gp.SmoothingMode = SmoothingMode.HighQuality; + + int gpCount = 0; + int bdCount = 0; + foreach (string gsv in gvsList) { - - Graphics gp = coo.CreateGraphics(); - gp.SmoothingMode = SmoothingMode.HighQuality; - - foreach (string gsv in gvsList) - { - string[] arr = gsv.Split(','); - int length = arr.Length; - for (int i = 4; i < arr.Length; i = i + 3) + string[] arr = gsv.Split(','); + int length = arr.Length; + for (int i = 4; i < arr.Length; i = i + 3) + { + if ((i + 3) < arr.Length) { - if ((i + 3) < arr.Length) - { - int Elevation = Convert.ToInt32(arr[i + 1]); - int azimuth = Convert.ToInt32(arr[i + 2]); - double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); - double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; - double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; + int Elevation = Convert.ToInt32(arr[i + 1]); + int azimuth = Convert.ToInt32(arr[i + 2]); + double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); + double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; + double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; - int x = (int)Math.Floor(600 / 2 + xCor); - int y = (int)Math.Floor(610 / 2 - yCor); - string type = "CHN"; - if (gsv.Contains("GPGSV")) type = "USA"; - gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); - } + int x = (int)Math.Floor(600 / 2 + xCor); + int y = (int)Math.Floor(610 / 2 - yCor); + string type = "CHN"; + if (gsv.Contains("GPGSV")) { type = "USA"; gpCount++; } + else { bdCount++; } + gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); + + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gvsList.count="+ gvsList.Count+",画了一个" +type + "x="+x+"y="+y); + } } - gp.Dispose(); + if(gpCount>0)label_usaTotal.Text = gpCount + ""; + if (bdCount > 0) label_chnTotal.Text = bdCount + ""; } + gp.Dispose(); } - )); - } + )); + + } catch (Exception e) { diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 45e6e14..d699915 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -25,7 +25,7 @@ public List detections; private bool isUpdate = false; - public long detectionId = -1; + public long detectionItemId = -1; private System.Threading.Timer timerAccuracy; delegate void TimerDelegate(string text); @@ -67,7 +67,7 @@ #region 稳定度 - public void detecStability(long deviceId, string startTime, string interval, SerialPort port, bool isStartNow, bool isUpdates) + public void detecStability(long deviceId, string startTime, string interval, SerialPort port,bool isNow, bool isUpdates) { resultStability1 = new List(); resultStability10 = new List(); @@ -80,7 +80,7 @@ portStability = port; devIdStability = deviceId; int delay = 0; - if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) + if (Convert.ToDateTime(startTime) > DateTime.Now) { TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; @@ -98,87 +98,77 @@ } private void exeStability1(Object State) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度1s"); try - { - while (true) + { + lock (obj) { - lock (obj) - { - lock(resultStability1) - { - if (!isUsing) + lock(resultStability1) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度1s"); - - string result = ""; - - string fre = getFrequencyData(portStability); - if (fre.Equals("")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "从" + portStability.PortName + "获取稳定度1s数据失败,!"); - } resultStability1.Add(fre); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度1s fre=" + fre); - if (!isUpdate) + if (!isUpdate) detectionService.add(devIdStability, fre, "1-1"); + } + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度1s fre=" + fre); + if (!isUpdate) + { + if (resultStability1.Count == 101) { - detectionService.add(devIdStability, fre, "1-1"); - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); + timerStability1.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始计算稳定度结果"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始计算稳定度结果"); - result = FreMath.Stable(resultStability1) + ""; - resultStability1.Clear(); + result = FreMath.Stable(resultStability1) + ""; + resultStability1.Clear(); - // 更新检测结果 - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", result, "", "", ""); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionId); + // 更新检测结果 + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } - } } - else - { - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); - - string result1 = FreMath.Stable(resultStability1) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", result1, "", "", ""); - - updateView(resultStability1); - stability.label_result.Text = result1; - - resultStability1.Clear(); - } - } - - break; } - } - } + else + { + if (resultStability1.Count == 101) + { + timerStability1.Dispose(); + + string result1 = FreMath.Stable(resultStability1) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + + updateView(resultStability1); + stability.label_result.Text = result1; + + resultStability1.Clear(); + } + } + } } + } catch (Exception ex) { @@ -190,240 +180,204 @@ } private void exeStability10(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) + resultStability10.Add(fre); + if (!isUpdate) detectionService.add(devIdStability, fre, "1-10"); + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre); + if (!isUpdate) + { + if (resultStability10.Count == 101) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度10s"); + timerStability10.Dispose(); + result = FreMath.Stable(resultStability10) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result); - string result = ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result, "", ""); - string fre = getFrequencyData(portStability); - if (fre.Equals("")) + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) { - //MessageBox.Show("从" + portStability.PortName + "获取数据失败!"); - return; - } - resultStability10.Add(fre); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre); - if (!isUpdate) - { - detectionService.add(devIdStability, fre, "1-10"); - - if (resultStability10.Count == 101) + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) { - timerStability10.Dispose(); - result = FreMath.Stable(resultStability10) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", result, "", ""); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); - } - - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); } - } - else - { - if (resultStability10.Count == 101) + + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { - timerStability10.Dispose(); - - - string result1 = FreMath.Stable(resultStability10) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", result1, "", ""); - - updateView(resultStability10); - stability.label_result.Text = result1; + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } - break; } } + else + { + if (resultStability10.Count == 101) + { + timerStability10.Dispose(); + + + string result1 = FreMath.Stable(resultStability10) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result1, "", ""); + + updateView(resultStability10); + stability.label_result.Text = result1; + } + } } - - } private void exeStability20(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) - { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); - - string result = ""; - - string fre = getFrequencyData(portStability); - if (fre.Equals("")) - { - return; - } - resultStability20.Add(fre); - - if (isUpdate) - { - detectionService.add(devIdStability, fre, "1-20"); - - if (resultStability20.Count == 101) - { - timerStability20.Dispose(); - - result = FreMath.Stable(resultStability20) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", result, ""); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); - - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(detectionId, "3", ""); - portStability.Close(); - } - - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - - resultStability20.Clear(); - } - - } - else - { - if (resultStability20.Count == 101) - { - timerStability20.Dispose(); - - - string result1 = FreMath.Stable(resultStability20) + ""; - detectionItemService.updateDetecStatus(devIdStability, "", "", "", "", "", "", "", result1, ""); - - updateView(resultStability20); - stability.label_result.Text = result1; - resultStability20.Clear(); - - } - } - isUsing = false; - break; - } + resultStability20.Add(fre); + if (isUpdate) detectionService.add(devIdStability, fre, "1-20"); } - } + + if (isUpdate) + { + if (resultStability20.Count == 101) + { + timerStability20.Dispose(); + + result = FreMath.Stable(resultStability20) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result); + + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", result, ""); + + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(detectionItemId, "3", ""); + portStability.Close(); + } + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + + resultStability20.Clear(); + } + + } + else + { + if (resultStability20.Count == 101) + { + timerStability20.Dispose(); + + + string result1 = FreMath.Stable(resultStability20) + ""; + detectionItemService.updateDetecStatus(devIdStability, "", "", "", "", "", "", "", result1, ""); + + updateView(resultStability20); + stability.label_result.Text = result1; + resultStability20.Clear(); + + } + } + } } private void exeStability100(Object State) { - while (true) - { - lock (obj) + + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); + + string result = ""; + + string fre = getFrequencyData(portStability); + if (!fre.Equals("")) { - if (!isUsing) + resultStability100.Add(fre); + if (!isUpdate) detectionService.add(devIdStability, fre, "1-100"); + } + + + if (!isUpdate) + { + if (resultStability100.Count == 101) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); + timerStability100.Dispose(); - string result = ""; + result = FreMath.Stable(resultStability100) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result); - string fre = getFrequencyData(portStability); - if (fre.Equals("")) + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result); + + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) { - return; - } - resultStability100.Add(fre); - - if (!isUpdate) - { - detectionService.add(devIdStability, fre, "1-100"); - - if (resultStability100.Count == 101) + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) { - - timerStability100.Dispose(); - - result = FreMath.Stable(resultStability100) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", "", result); - - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionId, "0", "", "", "", "", "", "", "", ""); + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - } - detectionItem = detectionItemService.searchById(detectionId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - resultStability100.Clear(); } - } - else - { - if (resultStability100.Count == 101) + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { - timerStability100.Dispose(); - - string result1 = FreMath.Stable(resultStability100) + ""; - detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", "", result1); - - updateView(resultStability100); - stability.label_result.Text = result1; - resultStability100.Clear(); + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } - break; + resultStability100.Clear(); } } - } + else + { + if (resultStability100.Count == 101) + { + timerStability100.Dispose(); + + string result1 = FreMath.Stable(resultStability100) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result1); + updateView(resultStability100); + stability.label_result.Text = result1; + resultStability100.Clear(); + } + } + } } #endregion @@ -438,6 +392,8 @@ if (isUpdates) { isUpdate = true; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度"); + } int delay = 0; if (Convert.ToDateTime(endTime)>=DateTime.Now) @@ -450,62 +406,59 @@ private void exeAccuracy(Object State) { try - { - while (true) + { + lock (obj) { - lock (obj) - { - if (!isUsing) + if(isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); + string result = ""; + double sum = 0.0; + List resultList = new List(); + + for (int i = 0; i < 50; i++) { - string result = ""; - double sum = 0.0; - List resultList = new List(); - - for (int i = 0; i < 50; i++) - { - string fre = getFrequencyData(portAccuracy); - resultList.Add(fre); - if (fre.Equals("")) continue; - if (!isUpdate) - { - detectionService.add(devIdAccuracy, fre, "2"); - } - if (resultList.Count == 3) - { - sum = sum + Convert.ToDouble(fre); - break; - } - - Thread.Sleep(500); - } - - result = sum / 3 + ""; - timerAccuracy.Dispose(); - - - while (true) - { - if (detectionId != -1) - { - detectionItemService.updateDetecStatus(detectionId, "", result, "", "", "", "", "", "", ""); - break; - } - } + string fre = getFrequencyData(portAccuracy); + resultList.Add(fre); + if (fre.Equals("")) continue; if (!isUpdate) { - deviceService.updateStatus(devIdAccuracy, "3", ""); - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + detectionService.add(devIdAccuracy, fre, "2"); } - else + if (resultList.Count == 3) { - accuracy.label_result.Text = result; - updateView(resultList); + sum = sum + Convert.ToDouble(fre); + break; } - portAccuracy.Close(); - break; + + Thread.Sleep(500); } - } + + result = sum / 3 + ""; + timerAccuracy.Dispose(); + + while (true) + { + if (detectionItemId != -1) + { + detectionItemService.updateDetecStatus(detectionItemId, "", result, "", "", "", "", "", "", ""); + break; + } + } + if (!isUpdate) + { + deviceService.updateStatus(devIdAccuracy, "3", ""); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + else + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新label_result:" + result); + + accuracy.label_result.Text = result; + updateView(resultList); + } + portAccuracy.Close(); + } + } catch (Exception ex) { @@ -525,7 +478,7 @@ portBootFeature = port; devIdBootFeature = deviceId; int delay = 0; - if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) + if (!isStartNow && Convert.ToDateTime(startTime) >= DateTime.Now) { TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; @@ -533,66 +486,55 @@ timerBootFeature = new System.Threading.Timer(exeBootFeature, null, delay + 100, 60*60*1000); } private void exeBootFeature(Object State) - { - while (true) + { + lock (obj) { - lock (obj) + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); + + string result = ""; + double sum = 0.0; + int count = 0; + for (int i = 0; i < 50; i++) { - if (!isUsing) + string fre = getFrequencyData(portBootFeature); + if (!fre.Equals("")) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); - - isUsing = true; - string result = ""; - double sum = 0.0; - for (int i = 0; i < 3; i++) - { - string fre = getFrequencyData(portBootFeature); - if (fre.Equals("")) - { - //MessageBox.Show("从" + portBootFeature.PortName + "获取数据失败!"); - isUsing = false; - return; - } - detectionService.add(devIdStability, fre, "3"); - sum = sum + Convert.ToDouble(fre); - } - resultBootFeature.Add(sum / 3 + ""); - - if (resultBootFeature.Count == 8) - { - string max = "0.0"; - string min = "0.0"; - foreach (string fre in resultBootFeature) - { - if (Convert.ToDouble(fre) > Convert.ToDouble(max)) max = fre; - if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; - } - result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; - - detectionItemService.updateDetecStatus(detectionId, "", "", result, "", "", "", "", "", ""); - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdBootFeature, "3", ""); - portBootFeature.Close(); - } - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - timerBootFeature.Dispose(); - resultBootFeature.Clear(); - } - - isUsing = false; - - break; - } + count++; + sum = sum + Convert.ToDouble(fre); + if (count == 3) break; + } } - } + detectionService.add(devIdBootFeature, sum / 3 + "", "3"); + resultBootFeature.Add(sum / 3 + ""); + if (resultBootFeature.Count == 8) + { + timerBootFeature.Dispose(); + string max = "0.0"; + string min = "0.0"; + foreach (string fre in resultBootFeature) + { + if (Convert.ToDouble(fre) > Convert.ToDouble(max)) max = fre; + if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; + } + result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; + + detectionItemService.updateDetecStatus(detectionItemId, "", "", result, "", "", "", "", "", ""); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdBootFeature, "3", ""); + portBootFeature.Close(); + } + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + + resultBootFeature.Clear(); + } + } } #endregion @@ -612,63 +554,54 @@ TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = secondSpan.Milliseconds; } - timerAgeRate = new System.Threading.Timer(exeAgeRate, null, delay + 100, 12 * 60 * 60 * 1000); + timerAgeRate = new System.Threading.Timer(exeAgeRate, null, delay + 100, 12* 60* 60 * 1000); } private void exeAgeRate(Object State) - { - while (true) - { - lock (obj) + { + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测日老化率"); + + string result = ""; + double sum = 0.0; + int count = 0; + for (int i = 0; i < 50; i++) { - if (!isUsing) + string fre = getFrequencyData(portAgeRate); + if (!fre.Equals("")) { - isUsing = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测日老化率"); - - string result = ""; - double sum = 0.0; - for (int i = 0; i < 3; i++) - { - string fre = getFrequencyData(portAgeRate); - if (fre.Equals("")) - { - //MessageBox.Show("从" + portAgeRate.PortName + "获取数据失败!"); - isUsing = false; - return; - } - detectionService.add(devIdStability, fre, "4"); - sum = sum + Convert.ToDouble(fre); - } - resultAgeRate.Add(sum / 3 + ""); - - if (resultAgeRate.Count == 15) - { - double r = 0.0; - double k = FreMath.DriftRate(resultAgeRate, out r); - result = k + "," + r; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); - - detectionItemService.updateDetecStatus(detectionId, "", "", "", result, "", "", "", "", ""); - - DetectionItem detectionItem = detectionItemService.searchById(detectionId); - if (detectionItem != null) - { - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdAgeRate, "3", ""); - portAgeRate.Close(); - } - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - timerAgeRate.Dispose(); - resultAgeRate.Clear(); - } - isUsing = false; - - break; + count++; + sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } - } + detectionService.add(devIdAgeRate, sum / 3+"", "4"); + resultAgeRate.Add(sum / 3 + ""); + + if (resultAgeRate.Count == 15) + { + timerAgeRate.Dispose(); + double r = 0.0; + double k = FreMath.DriftRate(resultAgeRate, out r); + result = k + "," + r.ToString().Substring(0,5); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); + + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", result, "", "", "", "", ""); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdAgeRate, "3", ""); + portAgeRate.Close(); + } + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + + resultAgeRate.Clear(); + } + } } #endregion @@ -678,96 +611,109 @@ // 获取检测数据 public string getFrequencyData(SerialPort port) { + string received = ""; try { - isUsing = true; - if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); - else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); - string received = ""; - if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) + while (true) { - int count = 0; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值1"); - - while (count < 5000) + if (!isUsing) { - int readLen = port.BytesToRead; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen =" + readLen); + isUsing = true; + if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); + else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); - if (readLen > 0) + if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) { - byte[] buffer = new byte[readLen]; - port.Read(buffer, 0, readLen);// 接收数据到buffer里面 - string data = Encoding.ASCII.GetString(buffer); - string[] dataArray = data.Split(' '); - if (data.StartsWith("$") && dataArray.Length == 2 && data.LastIndexOf('$') == 0) + int count = 0; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值1"); + + while (count < 5000) { - if (received.Contains("-")) + int readLen = port.BytesToRead; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen =" + readLen); + + if (readLen > 0) { - received =( Convert.ToDouble(dataArray[0].Replace("$", "")) - Convert.ToDouble("0."+data.Split(' ')[1].Replace(".", "").Replace("-","").TrimEnd('0')))+ ""; - } - else received = dataArray[0].Replace("$", "") + "." + data.Split(' ')[1].Replace(".", "").TrimEnd('0'); - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "before received = " + received); - - received = ((Convert.ToDouble(received) - 10000000) / 10000000) +""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "received = "+ received); - - break; - } - } - count++; - } - } - else - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值2"); - - int count = 0; - - while (count < 5000) - { - int readLen = port.BytesToRead; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen=" + readLen); - - if (readLen > 0) - { - byte[] buffer = new byte[readLen]; - port.Read(buffer, 0, readLen);// 接收数据到buffer里面 - string data = Encoding.ASCII.GetString(buffer); - string[] dataArray = data.Split(' '); - if (dataArray.Length >= 3) - { - foreach (string sss in dataArray) - { - if (sss.Contains("E")) + byte[] buffer = new byte[readLen]; + port.Read(buffer, 0, readLen);// 接收数据到buffer里面 + string data = Encoding.ASCII.GetString(buffer); + string[] dataArray = data.Split(' '); + if (data.StartsWith("$") && dataArray.Length == 2 && data.LastIndexOf('$') == 0) { - received = sss; - //received = float.Parse(received)+""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取测量值2:" + received + ":" + data); + if (received.Contains("-")) + { + received = (Convert.ToDouble(dataArray[0].Replace("$", "")) - Convert.ToDouble("0." + data.Split(' ')[1].Replace(".", "").Replace("-", "").TrimEnd('0'))) + ""; + } + else received = dataArray[0].Replace("$", "") + "." + data.Split(' ')[1].Replace(".", "").TrimEnd('0'); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "before received = " + received); + + received = ((Convert.ToDouble(received) - 10000000) / 10000000) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "received = " + received); + break; } } - if (!received.Equals("")) break; + count++; } } - count++; + else + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始获取测量值2"); + + int count = 0; + + while (count < 5000) + { + int readLen = port.BytesToRead; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "readLen=" + readLen); + + if (readLen > 0) + { + byte[] buffer = new byte[readLen]; + port.Read(buffer, 0, readLen);// 接收数据到buffer里面 + string data = Encoding.ASCII.GetString(buffer); + string[] dataArray = data.Split(' '); + if (dataArray.Length >= 3) + { + foreach (string sss in dataArray) + { + if (sss.Contains("E")) + { + received = sss; + //received = float.Parse(received)+""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取测量值2:" + received + ":" + data); + break; + } + } + if (!received.Equals("")) break; + } + } + count++; + } + } + + + if (received.Equals("")) + { + string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!" + DateTime.Now.ToLongTimeString()); + } + break; } } - isUsing = false; - - if (received.Equals("")) - { - string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel","通道"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name+"获取数据失败!"+ DateTime.Now.ToLongTimeString()); - } - return received; + } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "错误:" + ex.Message); return ""; } + finally + { + isUsing = false; + } + return received; } diff --git a/RbFreqStandMeasure/tools/FreshStatus.cs b/RbFreqStandMeasure/tools/FreshStatus.cs index ae01c38..0b2f119 100644 --- a/RbFreqStandMeasure/tools/FreshStatus.cs +++ b/RbFreqStandMeasure/tools/FreshStatus.cs @@ -46,6 +46,7 @@ timerClock = new System.Threading.Timer(exeClock, null, 50, 60 * 1000); isStarted = true; } + private static void exeClock(Object State) { try @@ -190,6 +191,8 @@ } LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "清空清空清空 : " + dataArray.Length); int index = -1; + bool gpdrawed = false; + bool bddrawed = false; foreach (string sss in dataArray) { index++; @@ -287,15 +290,21 @@ { if (sss.Contains("GPGSV")) { - gpList.Add(sss); - totalGP = Convert.ToInt32(sss.Split(',')[3]); gpMessCount = Convert.ToInt32(sss.Split(',')[1]); + if (gpList.Count < gpMessCount) + { + gpList.Add(sss); + totalGP = Convert.ToInt32(sss.Split(',')[3]); + } } else { - bdList.Add(sss); - totalBD = Convert.ToInt32(sss.Split(',')[3]); bdMessCount = Convert.ToInt32(sss.Split(',')[1]); + if (bdList.Count < bdMessCount) + { + bdList.Add(sss); + totalBD = Convert.ToInt32(sss.Split(',')[3]); + } } LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpList.Count : " + gpList.Count); LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpMessCount : " + gpMessCount); @@ -303,21 +312,26 @@ LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "bdMessCount : " + bdMessCount); if ((gpList.Count>0 &&gpList.Count == gpMessCount) || (bdList.Count>0) && bdList.Count == bdMessCount) - { - try + { + if (gpList.Count == gpMessCount) gpdrawed = true; + if (bdList.Count == bdMessCount) bddrawed = true; + if (!gpdrawed || !bddrawed) { - lock (obj) + try { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新画:::: : "); + lock (obj) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新画:::: : "); - StatusCtrlForm.statusCtrlForm.draw(bdList, gpList); + StatusCtrlForm.statusCtrlForm.draw(bdList, gpList); + } + } - + catch (Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "draw gsv error:" + ex.Message); + } } - catch (Exception ex) - { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "draw gsv error:" + ex.Message); - } } }