7

我即将写一个ews应用程序来连接交换与另一个日历程序。发生在我身上的是什么,我怎么知道,哪些约会在交换中被删除?有没有办法告诉?我无法在API和文档中找到它。交换Web服务管理,得到删除约会

在此先感谢。

回答

6

取决于用户如何删除约会(或项目),不同的事情完成:

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

你有多种方式来获取有关删除的项目信息:

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

感谢您的回答,我是真的失去了存在:-D – markus

+0

另一种选择是比较你有什么交流了预约数据,并删除不存在EWS行。尽管如此,性能仍然很糟糕。 – Brent

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