做一个WEB保存冲突机制

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 jinlianshuang 的 blog

1.webqueryopen中检查加锁标记,没加锁,则加锁,已加锁,提示。
2。onunload中,执行代理,解锁


3.试着在webqueryopen 中输出,但不能使用print

   print "content-type:text/plain"
   print "content-type:text/html"
   print
   print "<html>"
   print "<body >"
   print "<br><br><br>"
   print "<div align = center>"+"<a href='javascript:history.go(-1)'>返回</a></div><div>"
   print "<div align = center style='font-size :11pt'>  对不起,你所打开的文档已由"+ doc.lockusername(0) + "于" + doc.lockdate(0) +"打开编辑"
   print "<br><br>  请稍后再操作。"
   print "<br><br>"
   print "</body></html>"

4。在onload中可以执行,但作户可以看到打开的文档
if (doc.isdocbeingedited.value == 1 ){

 if (doc.lockusername.value != ""){
  alert("文档由" + doc.lockusername.value + "锁定;时间:"+doc.lockdate.value)
  history.go(-1)
 }
}

5.在webqueryopen 中可以通过

因为之后notes会生成那个form的html代码。所以这个地方不能用print
但可以用ndocument.replaceitemvalue("$$htmlhead","your javascript code here")

提示,用history.go(-1)返回前页:

 if doc.isdocbeingedited(0) =1 then
  
  if doc.lockusername(0) <> "" then
   somevar = evaluate("@name([abbreviate];lockusername)",doc)
   somevar1 = evaluate("@text(lockdate)",doc)
   conflict_tip = "<script> alert('提示:文档由" + somevar(0) + "打开编辑;时间:" + somevar1(0) + ",为避免保存冲突,请稍后再操作!'); history.go(-1)</script>"
   set item = doc.replaceitemvalue("$$htmlhead",conflict_tip)
   
   
  else
   
   doc.lockusername = doc.curusername(0)
   doc.lockdate = now
   call doc.save(true,true)
  end if
  
  
 end if


解决了在webqueryopen中打开判断并提示,阻止编辑的问题。


1.相同的用户就不再提示。代理作为web用户运行,锁定时由web用户保存,下次保存时不会直接冲突,@userroles不管是不是作为web运行,都能取到当前web用户的角色。

2。解锁:

onunload 时调用代理解除。

var doc = window.document.forms[0]

var url = doc.dbreferer.value + "/unlockdoc?openagent&unid="+doc.unid.value
var features = "top=1000,left=1000"
if ( doc.isdocbeingedited.value == 1 ){
 window.open(url,"",features)
}

top=1000,left=1000 为了不在屏幕上显示窗口
代理:unlockdoc
 set session = new notessession
 set db = session.currentdatabase
 set doc = session.documentcontext 
 dim notedoc as notesdocument
 dim unid as string
 
 
 unid=strright(doc.query_string(0),"unid=")
 
 messagebox("in inlockdoc!!")
 
 messagebox(unid)
 
 set notedoc = db.getdocumentbyunid( unid )
 notedoc.lockusername = ""
 notedoc.lockdate = ""
 call notedoc.save(true,true)
 '自动关闭窗口
 print "<script language=javascript>"
 print "window.close()"
 print "</script>"

var doc = window.document.forms[0]

var url = doc.dbreferer.value + "/unlockdoc?openagent&unid="+doc.unid.value
var features = "top=1000,left=1000"
if ( doc.isdocbeingedited.value == 1 ){
 window.open(url,"",features)
}

3.使用自锁方法对原文档影响太大,改用锁库方式。
 webqueryopen 不是新文档并且是编辑时,打开锁库,查找当前文档有没有加锁,有锁则提示,没锁则加锁。
 onunload 编辑时调用代理unlock 根据unid查锁库,有则删除

主表单只需要域:isdocbeingedited dbdir

本文关键:做一个WEB保存冲突机制
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top