ConstraintConflictResolutionAction 枚举

表示用于解决特定约束冲突的操作。

命名空间: Microsoft.Synchronization
程序集: Microsoft.Synchronization(在 microsoft.synchronization.dll 中)

语法

声明
Public Enumeration ConstraintConflictResolutionAction
用法
Dim instance As ConstraintConflictResolutionAction
public enum ConstraintConflictResolutionAction
public enum class ConstraintConflictResolutionAction
public enum ConstraintConflictResolutionAction
public enum ConstraintConflictResolutionAction

成员

  成员名称 说明
DestinationWins 对目标副本的变更始终入选。变更应用方将源变更传递给 SaveItemChange 方法,并指定 DeleteAndStoreTombstone 的保存操作。目标提供程序将为源变更创建逻辑删除。当目标作为源在后续的同步过程中操作时,目标会枚举一个表示源项删除的变更,这样就会从同步社区中删除它。 
Merge 源项中的数据与目标项合并。变更应用方将源副本的变更数据传递给 SaveItemChange 方法,并指定 ChangeIdUpdateVersionAndMergeData 的保存操作。有关详细信息,请参阅检测和解决约束冲突中的“合并冲突项”一节。 
RenameDestination 对目标副本上的冲突项进行重命名,以使其不再与从源提供程序发送的变更发生冲突,并将源变更应用到目标副本。变更应用方将变更传递给 SaveItemChange 方法,并指定 RenameDestinationAndUpdateVersionData 的保存操作。 
RenameSource 对从源提供程序发送的变更进行重命名,以使其不再与目标副本上的冲突项发生冲突,并且将源变更应用到目标副本。变更应用方将变更传递给 SaveItemChange 方法,并指定 RenameSourceAndUpdateVersionAndData 的保存操作。 
SaveConflict 记录冲突,不应用变更。变更应用方将冲突数据传递给 SaveConstraintConflict 方法,该方法可将冲突保存在冲突日志中。有关记录冲突的详细信息,请参阅记录和管理冲突。 
SkipChange 忽略冲突,而不应用变更。变更应用方不将冲突数据传递到目标提供程序。 
SourceWins 对源副本的变更始终入选。变更应用方将变更传递给 SaveItemChange 方法,并指定 DeleteConflictingAndSaveSourceItem 的保存操作。将源变更应用到目标副本并从目标副本中删除冲突的目标项。 

备注

ConstraintConflictResolutionAction 的成员指定变更应用方用来解决约束冲突的操作。约束冲突指违反有关项或变更单位的约束(如文件夹的关系或文件系统中同名数据的位置)的冲突。指定抵触冲突解决策略后,当发生抵触约束冲突时,变更应用方会指定约束冲突解决操作。否则,同步应用程序会在收到发生约束冲突的通知后,指定约束冲突解决操作。

有关约束冲突的详细信息,请参见检测和解决约束冲突

示例

下面的示例实现 ItemConstraint 事件的处理程序。该处理程序向用户显示冲突项,并基于用户的响应设置约束冲突解决操作。

Private Sub HandleItemConstraint(ByVal sender As [Object], ByVal args As ItemConstraintEventArgs)
    If ConstraintConflictReason.Collision = args.ConstraintConflictReason Then
        ' Display the two items that are in conflict and solicit a resolution from the user.
        Dim srcContact As New Contact(DirectCast(args.SourceChangeData, String()))
        Dim destContact As New Contact(DirectCast(args.DestinationChangeData, String()))
        Dim msg As String = ("Source change is " & srcContact.ToString() & vbLf & "Destination change is ") & destContact.ToString() & vbLf & "Click Yes to rename the source change and apply it." & vbLf & "Click No to rename the destination item and apply the source change." & vbLf & "Click Cancel to delete the destination item and apply the source change."
        Dim ccDlg As New ConstraintConflictDlg(msg)
        ccDlg.ShowDialog()

        ' Set the resolution action based on the user's response.
        args.SetResolutionAction(ccDlg.Resolution)
    Else
        args.SetResolutionAction(ConstraintConflictResolutionAction.SaveConflict)
    End If
End Sub
void HandleItemConstraint(Object sender, ItemConstraintEventArgs args)
{
    if (ConstraintConflictReason.Collision == args.ConstraintConflictReason)
    {
        // Display the two items that are in conflict and solicit a resolution from the user.
        Contact srcContact = new Contact((string[])args.SourceChangeData);
        Contact destContact = new Contact((string[])args.DestinationChangeData);
        string msg = "Source change is " + srcContact.ToString() +
                   "\nDestination change is " + destContact.ToString() +
                   "\nClick Yes to rename the source change and apply it." +
                   "\nClick No to rename the destination item and apply the source change." +
                   "\nClick Cancel to delete the destination item and apply the source change.";
        ConstraintConflictDlg ccDlg = new ConstraintConflictDlg(msg);
        ccDlg.ShowDialog();

        // Set the resolution action based on the user's response.
        args.SetResolutionAction(ccDlg.Resolution);
    }
    else 
    {
        args.SetResolutionAction(ConstraintConflictResolutionAction.SaveConflict);
    }
}

请参阅

参考

Microsoft.Synchronization 命名空间