我即将编写一个ews应用程序来连接与另一个日历程序的交换。发生了什么,我怎么知道,哪些约会在交换中被删除?有办法告诉吗?我在API和文档中找不到它。
提前致谢。
答案 0 :(得分:6)
根据用户删除约会(或任何项目)的方式,可以执行不同的操作:
您有多种方法可以获取有关已删除项目的信息:
答案 1 :(得分:0)
我编写了一个将EWS日历约会同步到Sql表的服务。
如果在插入/更新更改后删除,如果数据库中有行而不是EWS中的行,我将删除它,因为这意味着它已在Exchange中删除。我使用GUID跟踪数据库和交换中的约会。 Exchange web services: why is ItemId not constant? [continued]
只有几十个约会,性能很不错,我会在更大的数据集上尝试。
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