Método SaveChangeWithChangeUnitsContext.RecordRecoverableErrorForItem
Indica que um erro recuperável ocorreu quando os dados desse item foram salvos no repositório de itens.
Namespace: Microsoft.Synchronization
Assembly: Microsoft.Synchronization (em microsoft.synchronization.dll)
Sintaxe
'Declaração
Public Sub RecordRecoverableErrorForItem ( _
errorData As RecoverableErrorData _
)
'Uso
Dim instance As SaveChangeWithChangeUnitsContext
Dim errorData As RecoverableErrorData
instance.RecordRecoverableErrorForItem(errorData)
public void RecordRecoverableErrorForItem (
RecoverableErrorData errorData
)
public:
void RecordRecoverableErrorForItem (
RecoverableErrorData^ errorData
)
public void RecordRecoverableErrorForItem (
RecoverableErrorData errorData
)
public function RecordRecoverableErrorForItem (
errorData : RecoverableErrorData
)
Parâmetros
- errorData
Informações adicionais sobre o erro.
Comentários
Quando esse método é chamado, um objeto ItemOverride é adicionado ao conhecimento adquirido e a alteração do item não será enumerada novamente durante a sessão de sincronização.
Exemplo
O exemplo a seguir mostra como relatar erros recuperáveis que ocorrem quando o provedor de destino tentar aplicar alterações à réplica de destino.
Public Sub SaveItemChange(ByVal saveChangeAction__1 As SaveChangeAction, ByVal change As ItemChange, ByVal context As SaveChangeContext) Implements INotifyingChangeApplierTarget.SaveItemChange
Select Case saveChangeAction__1
' Update the item store and metadata store when an item is created or updated.
Case SaveChangeAction.Create, SaveChangeAction.UpdateVersionAndData
If True Then
Try
_itemStore.UpdateContactFromSync(change, DirectCast(context.ChangeData, String))
Catch ex As Exception
Dim errData As New RecoverableErrorData(ex)
context.RecordRecoverableErrorForItem(errData)
End Try
Exit Select
End If
' Update only the version of this item in the metadata store.
Case SaveChangeAction.UpdateVersionOnly
If True Then
Try
_itemStore.UpdateContactVersion(change.ItemId, change.ChangeVersion)
Catch ex As Exception
Dim errData As New RecoverableErrorData(ex)
context.RecordRecoverableErrorForItem(errData)
End Try
Exit Select
End If
' Delete the item from the item store and store a tombstone for it in the metadata store.
Case SaveChangeAction.DeleteAndStoreTombstone
If True Then
Try
_itemStore.DeleteContactFromSync(change.ItemId, change.ChangeVersion)
Catch ex As Exception
Dim errData As New RecoverableErrorData(ex)
context.RecordRecoverableErrorForItem(errData)
End Try
Exit Select
End If
' Neither merging of data nor removing tombstones is supported.
Case SaveChangeAction.UpdateVersionAndMergeData, SaveChangeAction.DeleteAndRemoveTombstone
If True Then
Throw New NotImplementedException()
End If
Case Else
If True Then
Throw New ArgumentOutOfRangeException()
End If
End Select
' Save the knowledge in the metadata store as each change is applied. Saving knowledge as each change is applied is
' not required. It is more robust than saving the knowledge only after each change batch, because if synchronization is interrupted
' before the end of a change batch, the knowledge will still reflect all of the changes applied. However, it is less efficient because
' knowledge must be stored more frequently.
Dim knowledge As SyncKnowledge = Nothing
Dim forgottenKnowledge As ForgottenKnowledge = Nothing
context.GetUpdatedDestinationKnowledge(knowledge, forgottenKnowledge)
_itemStore.ContactReplicaMetadata.SetKnowledge(knowledge)
End Sub
public void SaveItemChange(SaveChangeAction saveChangeAction, ItemChange change, SaveChangeContext context)
{
switch (saveChangeAction)
{
// Update the item store and metadata store when an item is created or updated.
case SaveChangeAction.Create:
case SaveChangeAction.UpdateVersionAndData:
{
try
{
_itemStore.UpdateContactFromSync(change, (string)context.ChangeData);
}
catch (Exception ex)
{
RecoverableErrorData errData = new RecoverableErrorData(ex);
context.RecordRecoverableErrorForItem(errData);
}
break;
}
// Update only the version of this item in the metadata store.
case SaveChangeAction.UpdateVersionOnly:
{
try
{
_itemStore.UpdateContactVersion(change.ItemId, change.ChangeVersion);
}
catch (Exception ex)
{
RecoverableErrorData errData = new RecoverableErrorData(ex);
context.RecordRecoverableErrorForItem(errData);
}
break;
}
// Delete the item from the item store and store a tombstone for it in the metadata store.
case SaveChangeAction.DeleteAndStoreTombstone:
{
try
{
_itemStore.DeleteContactFromSync(change.ItemId, change.ChangeVersion);
}
catch (Exception ex)
{
RecoverableErrorData errData = new RecoverableErrorData(ex);
context.RecordRecoverableErrorForItem(errData);
}
break;
}
// Neither merging of data nor removing tombstones is supported.
case SaveChangeAction.UpdateVersionAndMergeData:
case SaveChangeAction.DeleteAndRemoveTombstone:
{
throw new NotImplementedException();
}
default:
{
throw new ArgumentOutOfRangeException();
}
}
// Save the knowledge in the metadata store as each change is applied. Saving knowledge as each change is applied is
// not required. It is more robust than saving the knowledge only after each change batch, because if synchronization is interrupted
// before the end of a change batch, the knowledge will still reflect all of the changes applied. However, it is less efficient because
// knowledge must be stored more frequently.
SyncKnowledge knowledge;
ForgottenKnowledge forgottenKnowledge;
context.GetUpdatedDestinationKnowledge(out knowledge, out forgottenKnowledge);
_itemStore.ContactReplicaMetadata.SetKnowledge(knowledge);
}
Consulte também
Referência
Classe SaveChangeWithChangeUnitsContext
Membros SaveChangeWithChangeUnitsContext
Namespace Microsoft.Synchronization