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