static public string MakeCmd(SqlConnection msqlConn, string Cmd, string mDevId, byte[] mParam) { string sSql; SqlCommand sqlCmd; SqlParameter sqlParamCmdParam; string mTransID; mTransID = GetNewTransId(msqlConn); switch (Cmd) { case "GET_USER_ID_LIST": break; } sSql = "delete from tbl_fkcmd_trans_cmd_param where trans_id = '" + mTransID + "'"; ExecuteSimpleCmd(msqlConn, sSql); sSql = "delete from tbl_fkcmd_trans_cmd_result where trans_id = '" + mTransID + "'"; ExecuteSimpleCmd(msqlConn, sSql); if (mParam != null && mParam.Length > 0) { sSql = "insert into tbl_fkcmd_trans_cmd_param"; sSql += "(trans_id, device_id, cmd_param)"; sSql += "values(@trans_id, @device_id, @cmd_param)"; //txtStatus.Text = sSql; sqlCmd = new SqlCommand(sSql, msqlConn); sqlCmd.Parameters.Add("@trans_id", SqlDbType.VarChar); sqlCmd.Parameters["@trans_id"].Value = mTransID; sqlCmd.Parameters.Add("@device_id", SqlDbType.VarChar); sqlCmd.Parameters["@device_id"].Value = mDevId; sqlParamCmdParam = sqlCmd.Parameters.Add("@cmd_param", SqlDbType.VarBinary); sqlParamCmdParam.Direction = ParameterDirection.Input; sqlParamCmdParam.Size = mParam.Length; sqlParamCmdParam.Value = mParam; sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); } sSql = "insert into tbl_fkcmd_trans"; sSql += "(trans_id, device_id, cmd_code, status, update_time)"; sSql += "values(@trans_id, @device_id, @cmd_code, 'WAIT', @update_time)"; sqlCmd = new SqlCommand(sSql, msqlConn); sqlCmd.Parameters.Add("@trans_id", SqlDbType.VarChar); sqlCmd.Parameters["@trans_id"].Value = mTransID; sqlCmd.Parameters.Add("@device_id", SqlDbType.VarChar); sqlCmd.Parameters["@device_id"].Value = mDevId; sqlCmd.Parameters.Add("@cmd_code", SqlDbType.VarChar); sqlCmd.Parameters["@cmd_code"].Value = Cmd; sqlCmd.Parameters.Add("@update_time", SqlDbType.VarChar); sqlCmd.Parameters["@update_time"].Value = FKWebTools.TimeToString(DateTime.Now); sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); return(mTransID); }
public string InsertEnrollData(string astrDevId, string astrEnrollData) { string strEnrollId; string strBackupNumber; string strUserPrivilege; string strFpData; string strPassword; string strIdCard; int nBackupNumber; strEnrollId = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "enroll_id"); strBackupNumber = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "backup_number"); strUserPrivilege = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "user_privilege"); strFpData = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "fp_data"); strPassword = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "password"); strIdCard = FKWebTools.GetFieldValueInJSONString(astrEnrollData, "idcard"); try { if (!FKWebTools.IsValidEngDigitString(strEnrollId, 24)) { return("{result:ERROR_INVALID_PARAM_ENROLL_ID}"); } nBackupNumber = Convert.ToInt32(strBackupNumber); if (nBackupNumber < 0 || nBackupNumber > 12) { return("{result:ERROR_INVALID_PARAM_BACKUP_NUMBER}"); } } catch (Exception) { return("{result:ERROR_INVALID_PARAM}"); } try { string strSql; SqlConnection conn = new SqlConnection(msDbConn); conn.Open(); strSql = "INSERT INTO tbl_realtime_enroll_data"; strSql = strSql + "(update_time, device_id, enroll_id, backup_number, user_privilege, fp_data, password, idcard)"; strSql = strSql + "VALUES('" + FKWebTools.TimeToString(DateTime.Now) + "', "; strSql = strSql + "'" + astrDevId + "', "; strSql = strSql + "'" + strEnrollId + "', "; strSql = strSql + "'" + nBackupNumber + "', "; strSql = strSql + "'" + strUserPrivilege + "', "; strSql = strSql + "'" + strFpData + "', "; strSql = strSql + "'" + strPassword + "', "; strSql = strSql + "'" + strIdCard + "')"; SqlCommand cmd = new SqlCommand(strSql, conn); cmd.ExecuteNonQuery(); conn.Close(); return("{result:OK}"); } catch (Exception) { return("{result:ERROR_DB_ACCESS}"); } }
// 기대가 조작자지령을 접수하고 올려보내는 결과를 받을때 호출되는 함수이다. public void SetCmdResult( string asTransId, string asDevId, string asCmdCode, string asCmdResult, out string asResponseCode) { const string csFuncName = "SetCmdResult"; string sTransId = ""; string sSql; SqlConnection sqlConn = null; SqlTransaction sqlTrans = null; bool bIsTransStart = false; PrintDebugMsg(csFuncName, "0 - trans_id:" + asTransId + ", dev_id:" + asDevId); try { sqlConn = new SqlConnection(msDbConn); sqlConn.Open(); } catch (Exception) { PrintDebugMsg(csFuncName, "Error - Not connected db"); sqlConn.Close(); asResponseCode = "ERROR_DB_CONNECT"; return; } // "기대재기동"지령이 발행된것이 있으면 그것을 기대로 내려보낸다. if (CheckResetCmd(sqlConn, asDevId, out sTransId)) { PrintDebugMsg(csFuncName, "1 - " + sTransId); sqlConn.Close(); asResponseCode = "RESET_FK"; return; } try { sqlTrans = sqlConn.BeginTransaction(); bIsTransStart = true; sSql = "UPDATE tbl_fkcmd_trans SET cmd_result='" + asCmdResult + "', status='RESULT', update_time='" + FKWebTools.TimeToString(DateTime.Now) + "'"; sSql = sSql + " WHERE trans_id='" + asTransId + "' AND device_id='" + asDevId + "'"; sSql = sSql + " AND status='RUN'"; PrintDebugMsg(csFuncName, "2 - " + sSql); SqlCommand sqlCmd = new SqlCommand(sSql, sqlConn, sqlTrans); sqlCmd.ExecuteNonQuery(); sqlTrans.Commit(); bIsTransStart = false; sqlConn.Close(); PrintDebugMsg(csFuncName, "3"); asResponseCode = "OK"; return; } catch (Exception e) { PrintDebugMsg(csFuncName, "Except - 1 - " + e.ToString()); if (bIsTransStart) { sqlTrans.Rollback(); } bIsTransStart = false; sqlConn.Close(); asResponseCode = "ERROR_DB_ACCESS"; PrintDebugMsg(csFuncName, "Except - 2"); return; } }
public string InsertGLog(string astrDevId, string astrGLog) { string strEnrollId; string strVerifyMode; string strIoMode; string strIoTime; strEnrollId = FKWebTools.GetFieldValueInJSONString(astrGLog, "enroll_id"); strVerifyMode = FKWebTools.GetFieldValueInJSONString(astrGLog, "verify_mode"); strIoMode = FKWebTools.GetFieldValueInJSONString(astrGLog, "io_mode"); strIoTime = FKWebTools.GetFieldValueInJSONString(astrGLog, "io_time"); strIoTime = FKWebTools.ConvertFKTimeToNormalTimeString(strIoTime); try { if (!FKWebTools.IsValidEngDigitString(strEnrollId, 24)) { return("{result:ERROR_INVALID_PARAM_ENROLL_ID}"); } if (String.IsNullOrEmpty(strVerifyMode) || strVerifyMode.Length > 8) { return("{result:ERROR_INVALID_PARAM_VERIFY_MODE}"); } if (String.IsNullOrEmpty(strIoMode) || strIoMode.Length > 8) { return("{result:ERROR_INVALID_PARAM_IO_MODE}"); } if (!FKWebTools.IsValidTimeString(strIoTime)) { return("{result:ERROR_INVALID_PARAM_IO_TIME}"); } } catch (Exception) { return("{result:ERROR_INVALID_PARAM}"); } try { string strSql; SqlConnection conn = new SqlConnection(msDbConn); conn.Open(); strSql = "INSERT INTO tbl_realtime_glog"; strSql = strSql + "(update_time, device_id, enroll_id, verify_mode, io_mode, io_time)"; strSql = strSql + "VALUES('" + FKWebTools.TimeToString(DateTime.Now) + "', "; strSql = strSql + "'" + astrDevId + "', "; strSql = strSql + "'" + strEnrollId + "', "; strSql = strSql + "'" + strVerifyMode + "', "; strSql = strSql + "'" + strIoMode + "', "; strSql = strSql + "'" + strIoTime + "')"; SqlCommand cmd = new SqlCommand(strSql, conn); cmd.ExecuteNonQuery(); conn.Close(); return("{result:OK}"); } catch (Exception) { return("{result:ERROR_DB_ACCESS}"); } }