Exchange Web 服务管理,获取已删除的约会

发布于 2024-12-04 19:45:18 字数 99 浏览 2 评论 0原文

我即将编写一个 ews 应用程序来连接交换与另一个日历程序。我发生了什么事,我如何知道哪些约会在交换中被删除?有办法告诉吗?我在 API 和文档中找不到它。

提前致谢。

I am about to write a ews-application to connect exchange with another calendar programm. What occured to me, how do I get to know, which appointments get deleted on exchange? Is there a way to tell? I couldn't find it in the API and documentation.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

向地狱狂奔 2024-12-11 19:45:18

根据用户删除约会(或任何项目)的方式,会执行不同的操作:

  • 软删除:项目移至邮箱的回收站。
  • 硬删除:该项目被立即删除。

您可以通过多种方式获取有关已删除项目的信息:

  • 使用 FindItems 调用查询文件夹并在 ItemView 的 Traversal 属性中选择 ItemTraversal.Associated。注意:这需要 Exchange 2010。
  • 一次使用 SyncFolderItems 并将同步 cookie 存储在某处。稍后,使用之前存储的 cookie 再次执行 SyncFolderItems。 Exchange 现在将为您提供文件夹发生的更改的详细列表。
  • 查询回收站中的约会。它们很可能来自用户的默认日历。

Depending on how a user deletes an appointment (or any item), different things are done:

  • Soft-Delete: The item is moved to the recycle bin of the mailbox.
  • Hard-Delete: The item is instantly removed.

You have multiple ways to get information about deleted items:

  • Query the folder using a FindItems call and select ItemTraversal.Associated in the Traversal property of the ItemView. Note: This requires Exchange 2010.
  • Use the SyncFolderItems at one time and store the synchronization cookie somewhere. Later, execute the SyncFolderItems again using the previously stored cookie. Exchange will now give you a detailed list of changes which happened to the folder.
  • Query the Recycle bin for appointments. They will most likely have come from the default calendar of the user.
本王不退位尔等都是臣 2024-12-11 19:45:18

我编写了一项将 EWS 日历约会同步到 Sql 表的服务。

对于插入/更新更改后的删除,如果数据库中有一行而不是在 EWS 中,我将删除它,因为这意味着它已在 Exchange 中删除。我使用 GUID 来跟踪数据库和交换中的约会。 Exchange Web 服务:为什么 ItemId 不恒定? [续]

只需几十个约会,性能就不错,我将在更大的数据集上尝试它。

Dim appointmentGuid As New List(Of String)
For Each appointment In appointments 'appointments is IEnumerable(Of Appointment) from EWS
Dim guid As String = GetGuidForAppointment(appointment)
If String.IsNullOrEmpty(guid) Then
    SetGuidForAppointment(appointment)
    guid = GetGuidForAppointment(appointment)
End If
appointmentGuid.Add(guid)

 'Upsert rows
 ...
Next

'Delete orphaned rows 
Using sqlConnection As New SqlConnection(ConnectionString)
Dim deleteScript As New StringBuilder()
Using sqlCmd As New SqlCommand("SELECT ID FROM Appointments", sqlConnection)
    Using sqlDataReader As SqlDataReader = sqlCmd.ExecuteReader()
        sqlConnection.Open()
        While sqlDataReader.Read()
            Dim guid As String = sqlDataReader.GetString(0)
            If Not appointmentGuid.Contains(guid) Then
                deleteScript.AppendFormat("DELETE FROM Appointments WHERE ID = '{0}'; ", guid)
            End If
        End While
    End Using
End Using
If deleteScript.Length > 0 Then
    Using sqlCmd As New SqlCommand(deleteScript.ToString(), sqlConnection)
        sqlCmd.ExecuteNonQuery()
    End Using
End If
End Using

I wrote a service that syncs EWS Calendar Appointments to a Sql Table.

For deletion after Inserting/Updating changes if there is a row in the database and not in EWS I will delete it, as this means it was deleted in Exchange. I use GUIDs to track the appointment in database and exchange. Exchange web services: why is ItemId not constant? [continued]

Performance is decent with just couple dozen appointments, I will try it on much larger dataset.

Dim appointmentGuid As New List(Of String)
For Each appointment In appointments 'appointments is IEnumerable(Of Appointment) from EWS
Dim guid As String = GetGuidForAppointment(appointment)
If String.IsNullOrEmpty(guid) Then
    SetGuidForAppointment(appointment)
    guid = GetGuidForAppointment(appointment)
End If
appointmentGuid.Add(guid)

 'Upsert rows
 ...
Next

'Delete orphaned rows 
Using sqlConnection As New SqlConnection(ConnectionString)
Dim deleteScript As New StringBuilder()
Using sqlCmd As New SqlCommand("SELECT ID FROM Appointments", sqlConnection)
    Using sqlDataReader As SqlDataReader = sqlCmd.ExecuteReader()
        sqlConnection.Open()
        While sqlDataReader.Read()
            Dim guid As String = sqlDataReader.GetString(0)
            If Not appointmentGuid.Contains(guid) Then
                deleteScript.AppendFormat("DELETE FROM Appointments WHERE ID = '{0}'; ", guid)
            End If
        End While
    End Using
End Using
If deleteScript.Length > 0 Then
    Using sqlCmd As New SqlCommand(deleteScript.ToString(), sqlConnection)
        sqlCmd.ExecuteNonQuery()
    End Using
End If
End Using
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文