मैंने एक ऐसी सेवा लिखी जो एक एसक्यूएल तालिका में ईडब्ल्यूएस कैलेंडर नियुक्तियों को सिंक करता है।
यदि डेटाबेस में कोई पंक्ति है और ईडब्ल्यूएस में नहीं है तो परिवर्तनों को सम्मिलित करने/अपडेट करने के बाद हटाने के लिए मैं इसे हटा दूंगा, क्योंकि इसका मतलब है कि इसे एक्सचेंज में हटा दिया गया था। मैं डेटाबेस और विनिमय में नियुक्ति को ट्रैक करने के लिए 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
उत्तर के लिए धन्यवाद, मैं वास्तव में वहाँ खो गया था :-D – markus
एक अन्य विकल्प क्या विनिमय है पर नियुक्ति के डेटा से अपने आप की तुलना करने और पंक्तियों को EWS में मौजूद नहीं है हटाना है। हालांकि उस के लिए प्रदर्शन भयानक है। – Brent