c# - EWS Save Guid per Calendar Appointment -
i need save guid per every appointment. i've tried utilize policytag
, archivetag
,but got ,
"the property policytag valid exchange exchange2013 or later versions.",
exception.
does have similar exchange 2010? understand there appointment.id
contains self-generated id. prefer not utilize it. give thanks you.
a way deal problem create extended property, , set guid appointment, , wont alter unless made re-create appointment (after property)
private static readonly propertydefinitionbase appointementidpropertydefinition = new extendedpropertydefinition(defaultextendedpropertyset.publicstrings, "appointmentid", mapipropertytype.string); public static propertyset propertyset = new propertyset(basepropertyset.firstclassproperties, appointementidpropertydefinition); //setting property appointment public static void setguidforappointement(appointment appointment) { seek { appointment.setextendedproperty((extendedpropertydefinition)appointementidpropertydefinition, guid.newguid().tostring()); appointment.update(conflictresolutionmode.alwaysoverwrite, sendinvitationsorcancellationsmode.sendtonone); } grab (exception ex) { // logging exception } } //getting property appointment public static string getguidforappointement(appointment appointment) { var result = ""; seek { appointment.load(propertyset); foreach (var extendedproperty in appointment.extendedproperties) { if (extendedproperty.propertydefinition.name == "appointmentid") { result = extendedproperty.value.tostring(); } } } grab (exception ex) { // logging exception } homecoming result; }
this solution works in case of single appointments , in case of using on premises exchange. problem here in case of meetings in online web access (owa), such office 365, properties of appointments copied original appointment organizer, among these properties extended properties appoinmentid among them. hence avoid trouble, create appointment id of attendee similar 1 original in organizer, , add together email address service owner (the service produced notification). without solution , appointment in internal scheme have similar appointmentid original booking , considered one, or might have different 2 appointments same id.
private static void setguidformeetingappiontment(appointment appointment) { var log = ""; seek { if (!appointment.ismeeting) return; if (appointment.service.impersonateduserid == null) return; /* * tricky case if appointment created @ attendee no guid. * in case application should original appointment organizer's side, , guid, paste in new booking * attendee side, , add together attendee emailaddress. */ if (getguidformeetingappointement(appointment).length <= 36) { // if attendee, original appointment organizer's service if (appointment.service.impersonateduserid.id != appointment.organizer.address) { log += "1/5 getting original event of meeting\n"; if (exchangeliteservice.services.containskey(appointment.organizer.address)) { // finditemsresults<appointment> originalappointments; var originalappointments = exchangeliteservice.services[appointment.organizer.address].findappointments(wellknownfoldername.calendar, new calendarview(appointment.start, appointment.end, 1)); if (originalappointments == null) return; //there must original appointment. if (!originalappointments.any()) return; //there must original appointment. var originalappointment = originalappointments.first(); // there should 1 appointment @ specifict time , date. log += "2/5 getting guid original event of meeting\n"; var originalappointmentid = getguidformeetingappointement(originalappointment); if (string.isnullorempty(originalappointmentid)) return; // original appointment must have guid already. var orignalappointmentidguid = originalappointmentid.substring(0, 36); log += "3/5 attaching email address guid extracted\n"; var newappointmentid = orignalappointmentidguid + "_" + appointment.service.impersonateduserid.id; log += "4/5 setting new guid meeting appointment\n"; appointment.setextendedproperty((extendedpropertydefinition)appointementidpropertydefinition, newappointmentid); log += "5/5 updateing meeting appointment\n"; appointment.update(conflictresolutionmode.alwaysoverwrite, sendinvitationsorcancellationsmode.sendtonone); } else //then user invited organizer outside system. { // delete if there similar exchangeliteservice.oncalldeletebookingfrominternal(appointment.service.impersonateduserid.id, appointment.start, appointment.end); //assign new var appointmentidguid = guid.newguid().tostring(); var newappointmentid = appointmentidguid + "_" + appointment.service.impersonateduserid.id; appointment.setextendedproperty((extendedpropertydefinition)appointementidpropertydefinition, newappointmentid); appointment.update(conflictresolutionmode.alwaysoverwrite, sendinvitationsorcancellationsmode.sendtonone); } //get guid part of (without address of organizer) } else // if organizer { log += "if new meeting appointment , notification organizer\n"; var appointmentidguid = guid.newguid().tostring(); var newappointmentid = appointmentidguid + "_" + appointment.service.impersonateduserid.id; appointment.setextendedproperty((extendedpropertydefinition)appointementidpropertydefinition, newappointmentid); appointment.update(conflictresolutionmode.alwaysoverwrite, sendinvitationsorcancellationsmode.sendtonone); } } else { log += "if updated meeting appointment , has guid already\n"; var appointmentid = getguidformeetingappointement(appointment); var appointmentidguid = appointmentid.substring(0, 36); var newappointmentid = appointmentidguid + "_" + appointment.service.impersonateduserid.id; appointment.setextendedproperty((extendedpropertydefinition)appointementidpropertydefinition, newappointmentid); appointment.update(conflictresolutionmode.alwaysoverwrite, sendinvitationsorcancellationsmode.sendtonone); } } grab (exception ex) { //logging exception } }
c# guid ews exchange-server-2010
No comments:
Post a Comment