Chinaunix首页 | 论坛 | 博客
  • 博客访问: 432200
  • 博文数量: 73
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 1260
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-28 09:31
文章分类

全部博文(73)

文章存档

2011年(1)

2010年(18)

2009年(28)

2008年(26)

我的朋友

分类:

2010-07-22 13:12:13

   
    在博文《
部分文档设置Alarm不生效问题的解决之道》完成后不久,通过实验重现了该文中提及的故障现象,同时对解决方法的脚本做了补充。在这个脚本实现如下功能:
    1、对于重复日历项生成 Alarm Document 进行修正,对已经过往的从($Alarms)目录中清除掉,以期避免用户访问此目录时看到,认为是Alarm功能失效。
    2、在database关闭前,检索($Alarms)目录中第一个alarm的alarm time,与保存在CalendarSetting概要文档中的 LastAlarmDate 进行比较,若后者较大,将lastAlarmDate值设置为该值提前30分钟,并写回概要文档。避免了下一次访问邮箱数据库时该Alarm没有响应。



示例Lotus Script代码:


Sub Queryclose(Source As Notesuidatabase, Continue As Variant)
    
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim v As NotesView
    Dim profile As notesdocument
    Dim calprofile As notesdocument
    Dim ownername As notesname     
    Dim doc As NotesDocument
    Dim item As NotesItem
    Dim AlarmOffset As Integer
    Dim BaseDt As NotesDateTime
    Dim newAlarmValue() As Variant
    Dim i, j As Integer
    Dim fElder As Boolean
    
    Set db = s.CurrentDatabase
    Set calprofile = db.getprofiledocument("Calendarprofile")
    If calprofile Is Nothing Then Exit Sub
    Set item=calprofile.GetFirstItem("Owner")
    If item Is Nothing Then Exit Sub
    Set ownername = New NotesName(calprofile.GetItemValue("Owner")(0))
    If ownername.canonical = s.username Then
        Set profile = db.getprofiledocument("CalendarSettings", s.UserName )
        If profile Is Nothing Then Exit Sub
        
        If profile.HasItem("lastAlarmDate") Then
            Set BaseDT = new NotesDatetime(profile.GetFirstItem

("lastAlarmDate").values(0))
        Else
            Exit Sub
        End If
    End If
    
    
    Set v = db.GetView("($Alarms)")
    Set doc = v.GetFirstDocument
    
    While Not doc Is Nothing
        If Not doc.HasItem("$AlarmTime") And doc.HasItem("$AlarmOffset") Then
            Set item = doc.GetFirstItem("CalendarDateTime")
            If Not item Is Nothing Then
                AlarmOffset = new NotesDate(doc.getfirstitem

("$AlarmOffset").values(0))
                i = 0
                j = 0
                fElder = False
                Forall x In item.Values
                    Dim tmpDT As New NotesDateTime(Cstr(x))
                    Call tmpDT.AdjustMinute(AlarmOffset)
                    If tmpDT.TimeDifference(BaseDT) > 0 Then
                        Redim Preserve newAlarmValue(j)
                        newAlarmValue(j) = x
                        j = j +1
                    Else
                        i = i + 1
                    End If
                End Forall
                If i > 0 Then
                    Call doc.CopyItem(item, "CalendarDateTimeOld")
                    Call doc.ReplaceItemValue("CalendarDateTime",

newAlarmValue)
                    Call doc.save(True,True)
                End If                
            End If
            
        End If
        Set doc = v.GetNextDocument(doc)
    Wend
    Call v.Refresh
    
    Set doc = v.GetFirstDocument
    If doc.HasItem("$AlarmTime") And doc.HasItem("$AlarmOffset") Then
        Set tmpDT = doc.GetFirstItem("$AlarmTime").values(0)
        If tmpDT.TimeDifference(BaseDT) < 0 Then
            Call tmpDT.AdjustMinute(-30)
            profile.lastAlarmDate = tmpDT.localtime
            Call profile.Save(True, True)
        End If    
    End If
    
End Sub


阅读(404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~