互联网服务代理办公自动化

求助:定时归档代理出错

就是得到路径打开对应库的时候报错:

1.jpg





代码如下:

Sub Initialize
%REM
定时归档
创建时间:2013-3-20
%END REM

On Error Goto errormsg

Dim gurl As String

Dim getPath As String

getPath=Strleftback(goalcPath,"")

If getPath="" Then

getPath="linkeyarc.nsf"

Else

getPath=getPath+"linkeyarc.nsf"

End If



Dim session As New notessession

Dim wdb As NotesDatabase

Dim wview As NotesView

Dim wdelview As NotesView

Dim wdc As NotesDocumentCollection

Dim dc As NotesDocumentCollection

Dim lockview As NotesView

Dim lockdc As NotesDocumentCollection

Dim wdoc As NotesDocument

Dim movedoc As NotesDocument

Dim munid As String

Dim strq As String

Set wdb=session.currentdatabase

Set wview = wdb.GetView("viewguidanglist")


Msgbox "批量归档统计开始(wview.count)"

Msgbox wview.AllEntries.count

For p=0 To wview.AllEntries.count

Set wdoc = wview.GetFirstDocument

If Not wdoc Is Nothing Then

munid = wdoc.docUNID(0)

'文档存盘时首先解除本用户锁定的所有文档

Set lockview=wdb.getview("viewWorkflowLockDoc")

Set lockdc=lockview.getalldocumentsbykey(munid,True)

Call lockdc.removeall(True)

'解锁结束



Dim dbpath As String

If Instr(wdoc.path(0),"")>0 Then

dbpath=Strrightback(wdoc.path(0),"")

Else

dbpath=Strrightback(wdoc.path(0),"/")

End If



If dbpath<>"" Then

Dim gdb As NotesDatabase

Dim gview As NotesView

Dim gdoc As NotesDocument



Set gdb=opendb(dbpath)

Set gview=gdb.getview("All")

Set gdoc=gview.getdocumentbykey(wdoc.docUNID(0),True)

If Not gdoc Is Nothing Then

Call SaveMainDoc(gdoc)

'加强版,增加MainType和SubType为空时判断数据库类别再赋值start

If gdoc.MainType(0)="" Then

If dbpath="linkey_sw.nsf" Then

gdoc.MainType="收文文件"

Elseif dbpath="linkey_fw.nsf" Then

gdoc.MainType="发文文件"

End If

End If

If gdoc.SubType(0)="" Then

gdoc.SubType=Mid(gdoc.Created,1,4)

End If

'加强版,增加MainType和SubType为空时判断数据库类别再赋值end


Call GuidDanNew(gdoc,gdoc.Universalid,getPath,"3",gdoc.CanReaderUser,"归档",gdoc.MainType(0),gdoc.SubType(0))

gdoc.form="NewDoc"

gdoc.Stauts="2"

Call gdoc.save(True,True)

If gdoc.deldoc(0)<>"1" Then'删除副本

Call EditToDoDocURL()

Msgbox "("+dbpath+"):"+gdoc.Subject(0)

Call gdoc.remove(True)'删除主文档


Set wdelview=wdb.getview("delall")

Set wdc=wdelview.getalldocumentsbykey(wdoc.docUNID(0),True)

'删除所有跟踪文档

'Msgbox "所有跟踪文档统计(wdc.count)"

'Msgbox wdc.count

Call wdc.removeall(True)

End If



Dim SendTo As Variant

Dim NotesSubject,NotesBody

Dim arcdb As NotesDatabase

Dim arcdbpath As String

Dim arcview As NotesView

Dim arcdoc As NotesDocument

If Instr(getPath,"")>0 Then

arcdbpath=Strrightback(getPath,"")

Else

arcdbpath=Strrightback(getPath,"/")

End If

If arcdbpath<>"" Then

Set arcdb=opendb(arcdbpath)

Set arcview=arcdb.getview("viewdoclistbyunid")

Set arcdoc=arcview.getdocumentbykey(munid+"00",True)


SendTo=arcdoc.CanReaderUser

SendTo=Arrayappend(SendTo,arcdoc.CanPrintUser)

SendTo=Arrayappend(SendTo,arcdoc.CanCheckOutUser)

SendTo=Arrayappend(SendTo,arcdoc.CanReaderForm)

SendTo=myunique(SendTo)

NotesSubject=arcdoc.SendToSubject(0)

NotesBody=arcdoc.getitemvalue("SendToBody")(0)

NotesBody=Replace(NotesBody,"$$arcurl",""+arcdoc.Subject(0)+"")


If arcdoc.SendDoc(0)="1" Then'发送邮件

On Error Resume Next

Call SendMail(SendTo,NotesSubject,NotesBody,goalCUserName)


Elseif arcdoc.SendDoc(0)="2" Then'发送短消息

Call SendSms(goalCUserName,SendTo,NotesSubject,NotesBody,"1","0")

End If

End If

Else

'在实例库有文档,但在应用库找不到的文档,作迁移到历史实例库处理(先检查应用库的all视图,是否有问题,如果没问题再迁移)

'Msgbox dbpath+" no doc:"+munid +" " +wdoc.Created +" ,please check (all) view"

Set wdelview=wdb.getview("delall")

Set wdc=wdelview.getalldocumentsbykey(wdoc.docUNID(0),True)

Set movedoc=wdc.getfirstdocument

While Not movedoc Is Nothing

Call MoveHistory(movedoc)

Set movedoc=wdc.getnextdocument(movedoc)

Wend

'删除所有跟踪文档

'Msgbox dbpath+"删除所有跟踪文档统计(wdc.count)"

'Msgbox wdc.count

Call wdc.removeall(True)

End If

End If

Call wview.Refresh

End If

Next



Msgbox "批量归档结束!!!"

'Print ""




Exit Sub
errormsg:

Msgbox "wf_agentguidang init Error:" & Str(Erl) & "  " & Error
End Sub
参与4

3同行回答

starcraftstarcraft交互工程师IBM
数据库是否损坏 以及权限显示全部
数据库是否损坏 以及权限收起
互联网服务 · 2013-03-22
浏览676
windindreamwindindream技术经理孚邦
明显你的数据库没有打开嘛,你看看是不是没有权限还是路径不对呢显示全部
明显你的数据库没有打开嘛,你看看是不是没有权限还是路径不对呢收起
互联网服务 · 2013-03-22
浏览635
wxfwbg_noteswxfwbg_notesIT顾问华润水泥
错误具体是哪行code?opendb函数是什么内容?应该是这个函数打开DB的时候,没有获取到对象。显示全部
错误具体是哪行code?

opendb函数是什么内容?应该是这个函数打开DB的时候,没有获取到对象。收起
农业其它 · 2013-03-22
浏览697

提问者

gengyabin2011
软件开发工程师物美商业集团

相关问题

相关资料

问题状态

  • 发布时间:2013-03-22
  • 关注会员:1 人
  • 问题浏览:3512
  • 最近回答:2013-03-22
  • X社区推广