i'm trying query exchenge app appointments have set reminder current time.
i've created simple method returns 1 appointment start in nearest future:
public appointment getmyappointments() { try { calendarfolder cfolder = calendarfolder.bind(service, wellknownfoldername.calendar); calendarview calendarview = new calendarview(datetime.now, datetime.now.addhours(1));every appointment in 1 hour calendarview.propertyset = new propertyset(basepropertyset.firstclassproperties, itemschema.subject, itemschema.categories); finditemsresults<appointment> findresults = cfolder.findappointments(calendarview); list<item> items = new list<item>(); if (findresults.items.count > 0) // prevent exception { items.addrange(findresults.cast<item>()); } else { return null; } service.loadpropertiesforitems(items, new propertyset(basepropertyset.firstclassproperties, itemschema.subject, itemschema.categories, itemschema.body)); return findresults.items[0]; } catch (exception e) { return null; } }
this returns me top 1 appointment start in nearest future , active in current hour:
if plan appointment starts ad 14:00 , ends @ 14:30 method return appointment if start @ 13:01, return appointment if start in @ 14:22.
i change method return meeting have set reminder before current time , didn't start:
so if plan appointment @ 15:00 , set reminder 15 minutes , call method @ 14:45 i'll appointment.
my idea appointments in lets 8 hours, iterate on them , check if have isreminderset
, check if start
-reminderminutesbeforestart
smaller current time.
edit - temporary solution
public owaappointment getmyappointments(int minutes) { try { calendarfolder cfolder = calendarfolder.bind(service, wellknownfoldername.calendar); calendarview calendarview = new calendarview(datetime.now, datetime.now.addhours(10)); calendarview.propertyset = new propertyset(basepropertyset.firstclassproperties, itemschema.subject, itemschema.categories); finditemsresults<appointment> findresults = cfolder.findappointments(calendarview); list<item> items = new list<item>(); if (findresults.items.count > 0) { items.addrange(findresults.cast<item>()); } else { return null; } service.loadpropertiesforitems(items, new propertyset(basepropertyset.firstclassproperties, itemschema.subject, itemschema.categories, itemschema.body, itemschema.reminderdueby, itemschema.reminderminutesbeforestart)); var appointment = findresults.items .where(item => item.start >= datetime.now) .firstordefault(item => item.start.addminutes(-1*minutes) < datetime.now); return appointment // return appointment or null } catch (exception e) { return null; } }
but maybe can done ews easier?
yes, can done easier. getreminders operation ews (not ews managed api) introduced in exchange 2013. information can found here: getreminders operation. retrieve current reminders, set remindertype , endtime current time.
<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:header> <t:requestserverversion version="exchange2013" /> </soap:header> <soap:body> <m:getreminders> <m:endtime>2014-05-06t21:00:00z</m:endtime> <m:remindertype>all</m:remindertype> </m:getreminders> </soap:body> </soap:envelope>
Comments
Post a Comment