Ejemplo n.º 1
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.º 2
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.º 3
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}");
            }
        }