Поделиться через


Метод RecordRecoverableErrorForItem

Показывает, что во время сохранения данных для этого элемента в хранилище элементов произошла устранимая ошибка.

Пространство имен:  Microsoft.Synchronization
Сборка:  Microsoft.Synchronization (в Microsoft.Synchronization.dll)

Синтаксис

'Декларация
Public Sub RecordRecoverableErrorForItem ( _
    errorData As RecoverableErrorData _
)
'Применение
Dim instance As SaveChangeWithChangeUnitsContext
Dim errorData As RecoverableErrorData

instance.RecordRecoverableErrorForItem(errorData)
public void RecordRecoverableErrorForItem(
    RecoverableErrorData errorData
)
public:
void RecordRecoverableErrorForItem(
    RecoverableErrorData^ errorData
)
member RecordRecoverableErrorForItem : 
        errorData:RecoverableErrorData -> unit 
public function RecordRecoverableErrorForItem(
    errorData : RecoverableErrorData
)

Параметры

Исключения

Исключение Условие
ArgumentNullException

Параметр errorData имеет значение null Nothing nullptr unit пустая ссылка (Nothing в Visual Basic) .

Замечания

Когда вызывается этот метод, объект ItemOverride добавляется в набор известных знаний, а изменение элемента не будет повторно перечисляться на протяжении сеанса синхронизации.

Примеры

В следующем примере показано, как сообщить о возникновении устранимых ошибок, возникших при попытке поставщика назначения применить изменения к реплике назначения.

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);
}

См. также

Справочник

SaveChangeWithChangeUnitsContext Класс

Элементы SaveChangeWithChangeUnitsContext

Пространство имен Microsoft.Synchronization