Ejemplo n.º 1
0
        public void MakeSetTimeCmdParam(string asCmdCode, ref string asCmdParam)
        {
            if (asCmdCode != "SET_TIME")
            {
                return;
            }

            asCmdParam = "{\"time\":\"" + FKWebTools.GetFKTimeString14(DateTime.Now) + "\"}";
        }
Ejemplo n.º 2
0
        public void PrintDebugMsg(string astrFunction, string astrMsg)
        {
            if (!m_bShowDebugMsg)
            {
                return;
            }

            logger.Info(astrFunction + " -- " + astrMsg);
            FKWebTools.PrintDebug(astrFunction, astrMsg);
        }
Ejemplo n.º 3
0
        public void MakeSetTimeCmdParamBin(string asCmdCode, out byte[] abytCmdParam)
        {
            abytCmdParam = new byte[0];

            if (asCmdCode != "SET_TIME")
            {
                return;
            }

            string sCmdParam = "{\"time\":\"" + FKWebTools.GetFKTimeString14(DateTime.Now) + "\"}";

            CreateBSCommBufferFromString(sCmdParam, out abytCmdParam);
        }
Ejemplo n.º 4
0
        public void Test()
        {
            const string csFuncName = "Test";

            string strJson;

            PrintDebugMsg(csFuncName, "0 - Start");

            try
            {
                SqlConnection conn = new SqlConnection(msDbConn);
                conn.Open();
                conn.Close();
            }
            catch (Exception e)
            {
                PrintDebugMsg(csFuncName, "1 - " + e.ToString());
                return;
            }

            strJson = "{abc:12345,fgh:quit,k1k:7896}";
            if (FKWebTools.GetFieldValueInJSONString(strJson, "fgh") != "quit")
            {
                PrintDebugMsg(csFuncName, "Error - Json parser");
                return;
            }
            if (FKWebTools.GetFieldValueInJSONString(strJson, "k1k") != "7896")
            {
                PrintDebugMsg(csFuncName, "Error - Json parser");
                return;
            }

            if (FKWebTools.ConvertFKTimeToNormalTimeString("20121213140123") != "2012-12-13 14:01:23")
            {
                PrintDebugMsg(csFuncName, "Error - FK time string convert");
                return;
            }

            if (FKWebTools.GetFKTimeString14(Convert.ToDateTime("2013-2-3 19:7:29")) != "20130203190729")
            {
                PrintDebugMsg(csFuncName, "Error - time to FKTime14 convert");
                return;
            }

            PrintDebugMsg(csFuncName, "OK - End");
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        // 기대가 조작자지령을 접수하고 올려보내는 결과를 받을때 호출되는 함수이다.
        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;
            }
        }
Ejemplo n.º 7
0
        // 기대의 접속상태표를 갱신한다.
        public void UpdateFKDeviceStatus(
            SqlConnection asqlConn,
            string asDevId,
            string asDevName,
            string asDevTime,
            string asDevInfo)
        {
            const string csFuncName = "UpdateFKDeviceStatus";

            PrintDebugMsg(csFuncName, "0 - DevTime:" + asDevTime + ", DevId:" + asDevId + ", DevName:" + asDevName);

            if (asqlConn.State != ConnectionState.Open)
            {
                return;
            }

            try
            {
                PrintDebugMsg(csFuncName, "1");

                SqlCommand sqlCmd = new SqlCommand("usp_update_device_conn_status", asqlConn);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.Add("@dev_id", SqlDbType.VarChar).Value            = asDevId;
                sqlCmd.Parameters.Add("@dev_name", SqlDbType.VarChar).Value          = asDevName;
                sqlCmd.Parameters.Add("@tm_last_update", SqlDbType.DateTime).Value   = DateTime.Now;
                sqlCmd.Parameters.Add("@fktm_last_update", SqlDbType.DateTime).Value = FKWebTools.ConvertFKTimeToNormalTimeString(asDevTime);
                sqlCmd.Parameters.Add("@dev_info", SqlDbType.VarChar).Value          = asDevInfo;

                sqlCmd.ExecuteNonQuery();

                PrintDebugMsg(csFuncName, "2");
            }
            catch (Exception e)
            {
                PrintDebugMsg(csFuncName, "Except - 1 - " + e.ToString());
            }
        }
Ejemplo n.º 8
0
        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}");
            }
        }
Ejemplo n.º 9
0
        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}");
            }
        }