1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Sub Initialize Dim session As New notessession Dim doc As notesDocument Dim db As NotesDatabase Set db = session.CurrentDatabase Set doc = session.documentContext Print "Content-type:text/html" ' Format a nice header telling the content type. Print "" Print |<SCRIPT Language="JavaScript">| Print |<!--| ' Check if user is registered. Set status. Call RefreshUser(db, doc) ' Check for messages. Call Check_Messages(db, doc) ' Check for messages regularly. ' Specify your polling time here in milliseconds. Print |timerID = setTimeout("document.location.reload()",1000);| Print |//-->| Print |</script>| End Sub |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Sub RefreshUser(db As NotesDataBase, doc As NotesDocument) Dim uDoc As NotesDocument Dim view As NotesView Set view = db.GetView("Users") ' Find the users status document. Set uDoc = view.GetDocumentByKey(doc.Remote_User(0), True) If Not uDoc Is Nothing Then ' Set the users status to logged in. uDoc.status = "Online" Else ' Create a status document for first timers. Set uDoc = db.CreateDocument uDoc.Form = "user" Dim userName As New NotesName(doc.Remote_User(0)) uDoc.userCN = userName.Common uDoc.user = userName.Canonical uDoc.status = "Online" End If Call uDoc.Save(True, True) End Sub |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Sub Check_Messages(db As NotesDatabase, doc As NotesDocument) Dim view As NotesView Set view = db.GetView("e-msg (not delivered)") ' Check for messages. Dim mDoc As NotesDocument Set mDoc = view.GetDocumentByKey(doc.Remote_User(0), True) If Not mDoc Is Nothing then ' User got messages! mDoc.delivered = "1" ' Flag as delivered. Call mDoc.Save(False, False) ' Bring up the pop-up. doc.thisDb = Evaluate(|@WebDbName|) thisDb = doc.thisDb(0) Print |iMsg = window.open('/| + thisDb + |/e-msg?openForm&to=| + mDoc.fromEncoded(0) + |&unid=| + mDoc.UniversalID + |', '','height=220,width=250,resizable=yes,left=500,top=60');| End If End Sub |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |