如何知道已删除哪些重复发生的事件?

时间:2016-09-12 21:19:57

标签: office365 office365api office365-restapi

我的应用已订阅称为ConferenceRoom的office365日历。因此,当事件被创建/修改/删除时,office365服务器将向我的应用程序发送通知,告知这三个事件发生了。

在日历中,我为每个星期一(通过浏览器)创建定期活动站立会议。在此之后,我的应用会收到ChangeType: Created的通知,这是该通知事件的重复部分:

Recurrence:
 { Pattern:
    { Type: 'Weekly',
      Interval: 1,
      Month: 0,
      DayOfMonth: 0,
      DaysOfWeek: [Object],
      FirstDayOfWeek: 'Sunday',
      Index: 'First' },
   Range:
    { Type: 'NoEnd',
      StartDate: '2016-09-12',
      EndDate: '0001-01-01',
      RecurrenceTimeZone: 'FLE Standard Time',
      NumberOfOccurrences: 0 } },

该事件的整个数据(id来自通知):

{ '@odata.context': 'https://outlook.office.com/api/v2.0/$metadata#Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46%40ea38f869-d755-40c7-9c95-e6277325b7ae\')/Events/$entity',
  '@odata.id': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Events(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAFZAABi3Yqq_sjMSYdHHux_aUXFAAAMNRbUAAA=\')',
  '@odata.etag': 'W/"Yt2KqvrIzEmHRx7sfmlFxQAADDdF3g=="',
  Id: 'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAFZAABi3Yqq_sjMSYdHHux_aUXFAAAMNRbUAAA=',
  CreatedDateTime: '2016-09-13T03:55:43.5305953-02:00',
  LastModifiedDateTime: '2016-09-13T03:55:43.5476101-02:00',
  ChangeKey: 'Yt2KqvrIzEmHRx7sfmlFxQAADDdF3g==',
  Categories: [],
  OriginalStartTimeZone: 'FLE Standard Time',
  OriginalEndTimeZone: 'FLE Standard Time',
  ResponseStatus: { Response: 'Organizer', Time: '0001-01-01T00:00:00Z' },
  iCalUId: '040000008200E00074C5B7101A82E00800000000F9B6FC76830DD2010000000000000000100000005D7D5B0B8D1EA84E86C8AEE4014697CA',
  ReminderMinutesBeforeStart: 15,
  IsReminderOn: true,
  HasAttachments: false,
  Subject: 'standup meeting',
  Body:
   { ContentType: 'HTML',
     Content: '<html>\r\n<head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta content="text/html; charset=us-ascii">\r\n<style type="text/css" style="display:none">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir="ltr">\r\n<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">\r\n<p><br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n' },
  BodyPreview: '',
  Importance: 'Normal',
  Sensitivity: 'Normal',
  Start:
   { DateTime: '2016-09-12T03:00:00.0000000',
     TimeZone: 'Etc/GMT+2' },
  End:
   { DateTime: '2016-09-12T03:30:00.0000000',
     TimeZone: 'Etc/GMT+2' },
  Location: { DisplayName: '', Address: {}, Coordinates: {} },
  IsAllDay: false,
  IsCancelled: false,
  IsOrganizer: true,
  Recurrence:
   { Pattern:
      { Type: 'Weekly',
        Interval: 1,
        Month: 0,
        DayOfMonth: 0,
        DaysOfWeek: [ 'Monday' ],
        FirstDayOfWeek: 'Sunday',
        Index: 'First' },
     Range:
      { Type: 'NoEnd',
        StartDate: '2016-09-12',
        EndDate: '0001-01-01',
        RecurrenceTimeZone: 'FLE Standard Time',
        NumberOfOccurrences: 0 } },
  ResponseRequested: false,
  SeriesMasterId: null,
  ShowAs: 'Busy',
  Type: 'SeriesMaster',
  Attendees: [],
  Organizer:
   { EmailAddress:
      { Name: 'John Smith',
        Address: 'john.smith@sample.onmicrosoft.com' } },
  WebLink: 'https://outlook.office365.com/owa/?ItemID=AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT%2FM8JoV8TI5B1BhmG2N%2BBwBi3Yqq%2BsjMSYdHHux%2BaUXFAAAAAAFZAABi3Yqq%2BsjMSYdHHux%2BaUXFAAAMNRbUAAA%3D&exvsurl=1&viewModel=ICalendarItemDetailsViewModelFactory',
  'Calendar@odata.associationLink': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Calendars(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAEGAABi3Yqq_sjMSYdHHux_aUXFAAAAAA0jAAA=\')/$ref',
  'Calendar@odata.navigationLink': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Calendars(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAEGAABi3Yqq_sjMSYdHHux_aUXFAAAAAA0jAAA=\')' }

这很好。当我在日历中删除该事件的一次出现时出现问题。我的应用会收到ChangeType: Updated的通知,该通知的正文与创建活动时的内容非常相似。没有关于该活动被取消的日期的信息。

eventId来自ChangeType: Updated通知时的事件数据:

{ '@odata.context': 'https://outlook.office.com/api/v2.0/$metadata#Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46%40ea38f869-d755-40c7-9c95-e6277325b7ae\')/Events/$entity',
  '@odata.id': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Events(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAFZAABi3Yqq_sjMSYdHHux_aUXFAAAMNRbUAAA=\')',
  '@odata.etag': 'W/"Yt2KqvrIzEmHRx7sfmlFxQAADDdF3w=="',
  Id: 'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAFZAABi3Yqq_sjMSYdHHux_aUXFAAAMNRbUAAA=',
  CreatedDateTime: '2016-09-13T03:55:43.5305953-02:00',
  LastModifiedDateTime: '2016-09-13T03:57:48.2229052-02:00',
  ChangeKey: 'Yt2KqvrIzEmHRx7sfmlFxQAADDdF3w==',
  Categories: [],
  OriginalStartTimeZone: 'FLE Standard Time',
  OriginalEndTimeZone: 'FLE Standard Time',
  ResponseStatus: { Response: 'Organizer', Time: '0001-01-01T00:00:00Z' },
  iCalUId: '040000008200E00074C5B7101A82E00800000000F9B6FC76830DD2010000000000000000100000005D7D5B0B8D1EA84E86C8AEE4014697CA',
  ReminderMinutesBeforeStart: 15,
  IsReminderOn: true,
  HasAttachments: false,
  Subject: 'standup meeting',
  Body:
   { ContentType: 'HTML',
     Content: '<html>\r\n<head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta content="text/html; charset=us-ascii">\r\n<style type="text/css" style="display:none">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir="ltr">\r\n<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">\r\n<p><br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n' },
  BodyPreview: '',
  Importance: 'Normal',
  Sensitivity: 'Normal',
  Start:
   { DateTime: '2016-09-12T03:00:00.0000000',
     TimeZone: 'Etc/GMT+2' },
  End:
   { DateTime: '2016-09-12T03:30:00.0000000',
     TimeZone: 'Etc/GMT+2' },
  Location: { DisplayName: '', Address: {}, Coordinates: {} },
  IsAllDay: false,
  IsCancelled: false,
  IsOrganizer: true,
  Recurrence:
   { Pattern:
      { Type: 'Weekly',
        Interval: 1,
        Month: 0,
        DayOfMonth: 0,
        DaysOfWeek: [ 'Monday' ],
        FirstDayOfWeek: 'Sunday',
        Index: 'First' },
     Range:
      { Type: 'NoEnd',
        StartDate: '2016-09-12',
        EndDate: '0001-01-01',
        RecurrenceTimeZone: 'FLE Standard Time',
        NumberOfOccurrences: 0 } },
  ResponseRequested: false,
  SeriesMasterId: null,
  ShowAs: 'Busy',
  Type: 'SeriesMaster',
  Attendees: [],
  Organizer:
   { EmailAddress:
      { Name: 'John Smith',
        Address: 'john.smith@sample.onmicrosoft.com' } },
  WebLink: 'https://outlook.office365.com/owa/?ItemID=AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT%2FM8JoV8TI5B1BhmG2N%2BBwBi3Yqq%2BsjMSYdHHux%2BaUXFAAAAAAFZAABi3Yqq%2BsjMSYdHHux%2BaUXFAAAMNRbUAAA%3D&exvsurl=1&viewModel=ICalendarItemDetailsViewModelFactory',
  'Calendar@odata.associationLink': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Calendars(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAEGAABi3Yqq_sjMSYdHHux_aUXFAAAAAA0jAAA=\')/$ref',
  'Calendar@odata.navigationLink': 'https://outlook.office.com/api/v2.0/Users(\'2ce6a929-0b04-40fb-9c73-d812370e0d46@ea38f869-d755-40c7-9c95-e6277325b7ae\')/Calendars(\'AAMkADg5YzZmNTViLWM3NjEtNGI4Mi04Yjg4LTkyOWQ4NjFjM2QzOABGAAAAAAATT-M8JoV8TI5B1BhmG2N_BwBi3Yqq_sjMSYdHHux_aUXFAAAAAAEGAABi3Yqq_sjMSYdHHux_aUXFAAAAAA0jAAA=\')' }

这是图像,以清除我在日历中的确切做法:enter image description here

您能告诉我如何知道哪个事件被删除了吗?

这似乎是死路一条,所以任何帮助都会受到赞赏。

仅供参考:周期性事件只有一个eventId并删除一次重复出现的事件并不会发送ChangeType: DELETED的通知

1 个答案:

答案 0 :(得分:1)

不幸的是,API目前不会让您知道哪个事件已被删除。当您删除单个事件时,它会触发SeriesMaster上的更新。当此更新进入时,您将必须计算何时应该发生所有会议,然后获取所有发生的事件。迭代事件后,您可以推断出已从先前计算中删除的事件。由于您的会议将永远每周重复一次,因此您需要限制您请求发生的时间范围。

如果使用Python,我强烈推荐使用方便的rrule类附带的dateutil包:https://dateutil.readthedocs.io/en/stable/rrule.html