/// <summary> /// 更新设备状态为忙碌 /// </summary> /// <param name="iStatus">0空闲,1忙碌</param> /// <returns></returns> public static EnumSubmitResult UpdateDeviceStatus(int iStatus) { EnumSubmitResult enmResult = EnumSubmitResult.Failed; string strIP = GetLocalIP(); if (strIP != "") { JAAJ_DeviceInfo odiDeviceInfo = GetDeviceInfoByIP(strIP); if (odiDeviceInfo != null) { string strSqlString = "Update JAAJ_Devices SET iDeviceStatus=" + iStatus + " WHERE iDeviceID=" + odiDeviceInfo.iDeviceID + " "; SqlDatabase odbDataBase = new SqlDatabase(connectionString); DbCommand odbCommand = odbDataBase.GetSqlStringCommand(strSqlString); try { int iResult = odbDataBase.ExecuteNonQuery(odbCommand); if (iResult > 0) { enmResult = EnumSubmitResult.Success; } else { enmResult = EnumSubmitResult.Failed; } } catch (Exception oeException) { throw new Exception(oeException.Message, oeException); } } } return(enmResult); }
/// <summary> /// 更新设备状态为空闲、插入已考试科目ID与子项ID、删除当前子项考试过程记录 /// </summary> /// <returns>EnumSubmitResult</returns> public static EnumSubmitResult UpdateDeviceStatusCallListDeleteExamProcess(int iExamineeID) { EnumSubmitResult enmResult = EnumSubmitResult.Failed; string strIP = GetLocalIP(); if (strIP != "") { JAAJ_DeviceInfo odiDeviceInfo = GetDeviceInfoByIP(strIP); JAAJ_ExamProceInfo oepiExamProceInfo = GetExamProceInfoByExamineeID(iExamineeID); if (oepiExamProceInfo != null) { JAAJ_SubjectItemInfo osiiSubjectItemInfo = GetSubjectItemInfoByID(oepiExamProceInfo.iSubjectItemID); if (odiDeviceInfo != null && osiiSubjectItemInfo != null) { string strStoreProcedure = "JAAJ_UpdateDeviceStatusCallListDeleteExamProcess"; SqlDatabase odbDataBase = new SqlDatabase(connectionString); DbCommand odbCommand = odbDataBase.GetStoredProcCommand(strStoreProcedure); odbDataBase.AddInParameter(odbCommand, "@iExamineeID", System.Data.DbType.Int32, iExamineeID); odbDataBase.AddInParameter(odbCommand, "@iSubjectID", System.Data.DbType.Int32, osiiSubjectItemInfo.iSubjectID); odbDataBase.AddInParameter(odbCommand, "@iSubjectItemID", System.Data.DbType.Int32, osiiSubjectItemInfo.iSubjectItemID); odbDataBase.AddInParameter(odbCommand, "@iDeviceID", System.Data.DbType.Int32, odiDeviceInfo.iDeviceID); odbDataBase.AddOutParameter(odbCommand, "@result", System.Data.DbType.Int32, 8); using (IDbConnection connection = odbDataBase.CreateConnection()) { connection.Open(); try { odbDataBase.ExecuteNonQuery(odbCommand); int i = int.Parse(odbCommand.Parameters["@result"].Value.ToString()); enmResult = (EnumSubmitResult)i; } catch (Exception oeException) { //throw new Exception(oeException.Message, oeException); } connection.Close(); } odbCommand.Dispose(); } } } return(enmResult); }
/// <summary> /// 获取设备信息实体 /// </summary> /// <param name="strIP">设备IP</param> /// <returns>设备信息实体,JAAJ_DeviceInfo</returns> public static JAAJ_DeviceInfo GetDeviceInfoByIP(string strIP) { string strSqlString = "SELECT * FROM JAAJ_Devices WHERE nvcIP='" + strIP + "' "; SqlDatabase odbDataBase = new SqlDatabase(connectionString); DbCommand odbCommand = odbDataBase.GetSqlStringCommand(strSqlString); JAAJ_DeviceInfo oInfo = null; try { using (IDataReader reader = odbDataBase.ExecuteReader(odbCommand)) { if (reader.Read()) { oInfo = new JAAJ_DeviceInfo(); ModelHelper.LoadInfoData(oInfo, reader); } } } catch (Exception oeException) { throw new Exception(oeException.Message, oeException); } return(oInfo); }