Advertisement
imjyb1008

json_events

May 24th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Initialize
  2.     On Error Goto ErrorHandler
  3.    
  4.     Dim session As New NotesSession
  5.     Dim db As NotesDatabase
  6.     Dim view As NotesView
  7.     Dim vEntries As NotesViewEntryCollection
  8.     Dim vEntry As NotesViewEntry
  9.    
  10.     Dim startDate As String
  11.     Dim endDate As String
  12.     Dim title As String
  13.     Dim unid As String
  14.     Dim color As String
  15.    
  16.     Dim jsonHeader As String
  17.     Dim jsonData As String
  18.    
  19.     jsonHeader = "Content-type: application/json"
  20.     jsonData = ""
  21.    
  22.     Set db = session.CurrentDatabase
  23.     Set view=db.GetView("events1")
  24.     Set vEntries=view.Getallentriesbykey("A",True)
  25.    
  26.     If vEntries.Count >= 1 Then
  27.        
  28.         Set vEntry = vEntries.GetFirstEntry
  29.        
  30.         While Not(vEntry Is Nothing)
  31.            
  32.             startDate= |"| + vEntry.Columnvalues(0) + |"|
  33.             endDate =|"| + vEntry.Columnvalues(1)+ |"|
  34.             title = |"| +vEntry.Columnvalues(2)+ |"|
  35.             unid = vEntry.Columnvalues(3)
  36.             color = |"| + vEntry.Columnvalues(4) + |"|
  37.            
  38.             If Not vEntry Is Nothing Then      
  39.                 'fullcalendar有個機制: 如果endDate=""會自動為startDate  ,  color=""會自動為default  所以不用特地用程式再另外判斷
  40.                 jsonData = jsonData +_
  41.                 |{| +_
  42.                 |"allday": false,| +_
  43.                 |"title":| + title + |,|+_
  44.                 |"start":| + startDate + |,|+_
  45.                 |"end":| + endDate + |,| +_
  46.                 |"color":| + color +_
  47.                 |},|
  48.             End If
  49.  
  50.             Set vEntry = vEntries.Getnextentry(vEntry)
  51.         Wend
  52.        
  53.         jsonData = "[" + Left(jsonData,Len(jsonData)-1) + "]"
  54.        
  55.     End If
  56.    
  57.     Print jsonHeader + Chr(10) + jsonData
  58.    
  59.     Exit Sub   
  60. ErrorHandler:
  61.     Msgbox "Error"
  62. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement