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 
|