脚本:
macro_command main()
char name[16] = "0"
char password[20] = "0"
short privilege = 0 //权限设定
short command = 0 //控制命令,用于控制账号新增和登录
short destination = 0
short total_row = 0
short row_number=0
short recordID = 0
bool result_query = false
FILL(name[0], 0, 16)
//在配方数据库中查找账号和密码
GetData(password[0], "Barcode Scanner/Keyboard", BARCODE, 1, 20) //获取刷卡密码
RecipeQuery("SELECT * FROM UAC ", destination)
result_query = RecipeQuery("SELECT * FROM UAC WHERE UAC.password == %(password)", total_row) //查询配方UAC.password = 刷卡密码的有几条
if (result_query == true) then //如有查询到
command = 3
SetData(command, "Local HMI", LW, 8950, 1)
// RecipeQueryGetRecordID(recordID, total_row) //查到这条的行数是多少
for row_number=0 to total_row-1 step 1
RecipeQueryGetRecordID(recordID,row_number) //把row_number指定欲取得查询结果中的第几笔数据的数据列编号,并将资料列编号写入recordID
SetData(recordID, "Local HMI", RECIPE, "UAC.Selection")
next
DELAY(300)
RecipeGetData(name[0], "UAC.name", recordID)
RecipeGetData(privilege, "UAC.privilege", recordID)
//新增临时账户
SetData(name[0], "Local HMI", LW, 8954, 16)
SetData(password[0], "Local HMI", LW, 8962, 20)
SetData(privilege, "Local HMI", LW, 8953, 1) //临时账号权限
command = 5
SetData(command, "Local HMI", LW, 8952, 1) //临时账号时间为5分钟
command = 6 //6为“单位:分钟“;15为"单位:天数"
SetData(command, "Local HMI", LW, 8950, 1) //新增临时账号
DELAY(500)
//登录
SetData(name[0], "Local HMI", LW, 8954, 16)
SetData(password[0], "Local HMI", LW, 8962, 20)
command = 1
SetData(command, "Local HMI", LW, 8950, 1) //登录临时账号
end if
if (result_query == false) then
end if
end macro_command