vb.net - Creating a Google Calendar event in VB -


i'm trying create google calendar event in visual basic using google api v3.

i've managed authenticate , events calendar i'm not sure how save events , documentation isn't helpful.

here's current code:

imports system.collections.generic imports system.io   imports system.threading  imports google.apis.calendar.v3 imports google.apis.calendar.v3.data imports google.apis.calendar.v3.eventsresource imports google.apis.services imports google.apis.auth.oauth2 imports google.apis.util.store imports google.apis.requests   public class clsgoogle       '' calendar scopes initialized on main method.     dim scopes ilist(of string) = new list(of string)()      '' calendar service.     dim service calendarservice      public calevents list(of [event]) = new list(of [event])     'list of events in calendar      sub new()       'classes constructor, authenticate google servers everytime object created         authenticate()     end sub      private function authenticate()     'function gets authenticates google servers          ' add calendar specific scope scopes list.         scopes.add(calendarservice.scope.calendar)           dim credential usercredential         using stream new filestream("client_secrets.json", filemode.open, fileaccess.read)             credential = googlewebauthorizationbroker.authorizeasync(                     googleclientsecrets.load(stream).secrets, scopes, "user", cancellationtoken.none,                     new filedatastore("calendar.vb.sample")).result         end using          ' create calendar service using initializer instance         dim initializer new baseclientservice.initializer()         initializer.httpclientinitializer = credential         initializer.applicationname = "vb.net calendar sample"         service = new calendarservice(initializer)         return 0             end function         sub getcalendar(mindate date, optional maxdate date = nothing)          dim list ilist(of calendarlistentry) = service.calendarlist.list().execute().items()     'list of google calendars user has         dim eventrequest listrequest = service.events.list(list("0").id)     'specifies google calendar perform query          eventrequest.timemin = mindate      'specifies minimum date in query          if not maxdate = nothing             eventrequest.timemax = maxdate      'specifies maximum date in query         end if         each calendarevent data.event in eventrequest.execute.items  'for each event in google calendar add calevents             calevents.add(calendarevent)         next     end sub       sub updatecalendar()         dim calendarevent new data.event         dim startdatetime new data.eventdatetime         dim date         = "19/11/2014 12:00"         startdatetime.datetime =         dim b date         b = a.addhours(2)         dim enddatetime new data.eventdatetime         enddatetime.datetime = b         calendarevent.start = startdatetime         calendarevent.end = enddatetime         calendarevent.id = system.guid.newguid.tostring         calendarevent.description = "test"           dim request new insertrequest(service, calendarevent, service.events.list(list("0").id))         request.createrequest()         request.execute()      end sub  end class 

1) new event

service.events.insert(calendarevent, service.events.list(list("0").id).execute() 

2) delete event (id event id)

' search id event

dim id string = getevent_id(oggetto, data, ora) service.events.delete(service.events.list(list("0").id, id).execute() 

3) update event (id event id)

' search id event

dim id string = getevent_id(oggetto, data, ora) service.events.update(calendarevent, service.events.list(list("0").id, id).execute() 

`------------------------------------------------------------------------------------------

public function getevent_id(testo string, data string, ora string)          dim eventrequest listrequest = service.events.list(service.events.list(list("0").id))         '         eventrequest.q = testo         '         each calendarevent data.event in eventrequest.execute.items               dim stringa string = data.tostring & " " & ora.tostring             if calendarevent.start.datetime.tostring <> nothing                 if calendarevent.start.datetime.tostring.substring(0, stringa.length) = data.tostring & " " & ora.tostring                     ' ok                     return calendarevent.id                 end if             end if         next         return 0 end function 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -