对一个上规模的管理系统,由于参与管理的人非常多,操作者的权限分配和操作日志记录都是十分重要的。
权限分配要根据各个系统的事务逻辑而定,我这里谈一下如果构建一个良好的操作日志记录的方案。
我这里以操作一张财务流水表countlist为例:
1、在countlist中新增加一个字段op_flow,类型为text,可为空;
2、记录日志,每对这张countlist表进行操作,并且操作成功时,调用如下代码:
conn.open constr
set rs_t = conn.execute (" select isnull(op_flow,'') as op_flow from countlist where id="&id)
str = rs_t("op_flow")
rs_t.close
strAct="××操作"
str =now() & ":" &session("user_name")& ":" &strAct& "|" &str '// 格式为 时间:操作人:操作,|为分隔符
sql = " update countlist set op_flow='"&str&"' where id="&id
conn.execute(sql)
conn.close
3、显示日志,在显示日志的页面使用如下代码:
if not isnull(op_flow) then
ii=0
for each str in split(op_flow,"|")
if str<> "" then response.write str&"<br>"
ii=ii+1
if ii=6 then exit for '// 显示最新的六条操作
next
end if