Advertisement
imjyb1008

data_json

May 24th, 2014
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Initialize
  2.    
  3.     Dim session As New NotesSession
  4.     Dim db As NotesDatabase
  5.     Dim doc As NotesDocument                 ' agent context
  6.     Dim View As NotesView                         ' search view
  7.     Dim vEntries As NotesViewEntryCollection
  8.     Dim vEntry As NotesViewEntry
  9.     Dim strCol1 As String
  10.     Dim strCol2 As String
  11.     Dim strCol3 As String
  12.     Dim strCol4 As String
  13.     Dim json As String
  14.    
  15.     Set db = session.currentdatabase
  16.     Set doc = session.DocumentContext
  17.    
  18.     On Error Goto ErrorHandler
  19.       ' use to force agent output to not include header info
  20.     Print "Content-type: application/json"
  21.    
  22.     Set view=db.GetView("events1")
  23.     Set vEntries=view.Getallentriesbykey("A",True)
  24.     If vEntries.Count = 0 Then ' NO DOCS FOUND ERROR
  25.              ' json =  {toplevel:[{"Status":"No Documents Found"}]}
  26.         Print json
  27.         Goto TheEnd
  28.     End If
  29.    
  30.     json = "["
  31.     Set vEntry = vEntries.GetFirstEntry
  32.     Dim i As Integer
  33.     While Not(vEntry Is Nothing)
  34.        
  35.        
  36.         strCol1= vEntry.Columnvalues(0)
  37.         strCol2 = vEntry.Columnvalues(1)
  38.         strCol3 = vEntry.Columnvalues(2)
  39.         strCol4 = vEntry.Columnvalues(3)
  40.        
  41.         Set vEntry = vEntries.Getnextentry(vEntry)
  42.         If vEntry Is Nothing Then
  43.                      ' json = json + {"title":}+ strcol + "{}}]}
  44.         Else 'need the , at the end if not the last entry
  45.            
  46.     '       json = json +"{""allday"":false,""title"":""+ strcol3+ "','start':"'+ strcol1+ "','end':'"+ strcol2+ "','id':'"+strCol4+"' },"
  47.             If strcol2="" Then
  48.                
  49.                 json = json +"{""allday"":false,""title"":"""       + strcol3+ """,""start"":"""+ strcol1+ """ },"
  50.             Else
  51.                
  52.                 json = json +"{""allday"":false,""title"":"""       + strcol3+ """,""start"":"""+ strcol1+ """,""end"":"""+ strcol2+ """ },"
  53.             End If
  54.            
  55.             i=i+1
  56.         End If
  57.     Wend
  58.    
  59.     json = Left(json,Len(json)-1) +  "]"
  60.     'Messagebox json
  61.     Print json
  62.     Goto TheEnd
  63.     Exit Sub
  64. ErrorHandler:
  65.    '   json =  {toplevel:[{"ERROR":Error$ & "    Line#: "   &  Erl &    Object: & Lsi_info(2)}]}
  66.     Print json
  67.     Resume TheEnd
  68.    
  69. TheEnd:
  70.    
  71.    
  72. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement