本文整理汇总了C#中IGroup.GetSyncActionService方法的典型用法代码示例。如果您正苦于以下问题:C# IGroup.GetSyncActionService方法的具体用法?C# IGroup.GetSyncActionService怎么用?C# IGroup.GetSyncActionService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGroup
的用法示例。
在下文中一共展示了IGroup.GetSyncActionService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveConflicts
public void ResolveConflicts(IGroup group)
{
var conflictService = group.GetSyncConflictService();
var syncActionService = group.GetSyncActionService();
var historyService = group.GetService<IMultiFileSystemHistoryService>();
var changeGraphBuilder = new ChangeGraphBuilder(m_FileReferenceComparer);
var syncStateUpdater = new SyncActionUpdateBuilder();
foreach (var conflict in conflictService.Items)
{
IFileReference resolved;
if (TryResolveConflict(changeGraphBuilder, historyService, conflict, out resolved))
{
// remove the conflict
syncStateUpdater.RemoveConflict(conflict);
// add sync actions
throw new NotImplementedException();
}
}
syncStateUpdater.Apply(syncActionService, conflictService);
}
示例2: Synchronize
public void Synchronize(IGroup group)
{
var syncFolders = group.GetConfigurationService().Items.ToArray();
// there need to be at least 2 sync folders, otherwise, syncing makes no sense
if (syncFolders.Length < 2)
{
return;
}
var historyService = group.GetService<IMultiFileSystemHistoryService>();
historyService.CreateSnapshot();
// we cannot sync if there isn't at least one snapshot
if(!historyService.Snapshots.Any())
{
return;
}
// we cannot sync if there is not at least one snapshot per history
if (historyService.LatestSnapshot.HistoryNames.Any(name => historyService.LatestSnapshot.GetSnapshot(name) == null))
{
return;
}
// get required services
var syncPointService = group.GetSyncPointService();
var conflictService = group.GetSyncConflictService();
var syncActionService = group.GetSyncActionService();
var filter = syncFolders.ToMultiFileSystemChangeFilter(m_FilterFactory);
var latestSyncPoint = syncPointService.LatestSyncPoint;
var diff = GetDiff(historyService, latestSyncPoint, filter);
var wasReset = ResetSyncStateIfNecessary(group, diff);
if (wasReset)
{
diff = GetDiff(historyService, latestSyncPoint, filter);
latestSyncPoint = syncPointService.LatestSyncPoint;
}
// for all folders, get the changes since the last sync
var newSyncPoint = new MutableSyncPoint()
{
Id = GetNextSyncPointId(syncPointService.LatestSyncPoint),
MultiFileSystemSnapshotId = diff.ToSnapshot.Id,
FilterConfigurations = syncFolders.ToDictionary(f => f.Name, f => f.Filter)
};
var syncStateUpdater = new SyncActionUpdateBuilder();
var changeGraphBuilder = new ChangeGraphBuilder(m_FileReferenceComparer);
foreach (var graph in changeGraphBuilder.GetChangeGraphs(diff))
{
var path = graph.ValueNodes.First(node => node.Value != null).Value.Path;
// skip if there is a conflict for the current file
if (conflictService.ItemExists(path))
{
continue;
}
// check if all pending sync actions can be applied to the change graph
var unapplicaleSyncActions = GetUnapplicableSyncActions(graph, syncActionService[path].Where(IsPendingSyncAction));
// pending sync actions could not be applied => skip file
if (unapplicaleSyncActions.Any())
{
// cancel unapplicable actions
syncStateUpdater.UpdateSyncActions(unapplicaleSyncActions.Select(a => a.WithState(SyncActionState.Cancelled)));
// add a conflict for the file (the snapshot id of the conflict can be determined from the oldest unapplicable sync action)
var oldestSyncPointId = unapplicaleSyncActions.Min(a => a.SyncPointId);
var snapshotId = oldestSyncPointId > 1
? syncPointService[oldestSyncPointId - 1].MultiFileSystemSnapshotId
: null;
syncStateUpdater.AddConflict(new ConflictInfo(unapplicaleSyncActions.First().Path, snapshotId));
continue;
}
//in the change graph, detect conflicts
// if there is only one sink, no conflicts exist
var acylicGraph = graph.ToAcyclicGraph();
var sinks = acylicGraph.GetSinks().ToArray();
if (!sinks.Any())
{
// not possible (in this case the graph would be empty, which cannot happen)
throw new InvalidOperationException();
}
if (sinks.Length == 1)
{
// no conflict => generate sync actions, to replace the outdated file versions or add the file to a target
//.........这里部分代码省略.........
示例3: ResetSyncStateIfNecessary
bool ResetSyncStateIfNecessary(IGroup group, IMultiFileSystemDiff diff)
{
var syncPointService = group.GetSyncPointService();
var syncActionService = group.GetSyncActionService();
var conflictService = group.GetSyncConflictService();
var syncFolders = group.GetConfigurationService().Items.ToArray();
var latestSyncPoint = syncPointService.LatestSyncPoint;
if (ContainsNewFolders(diff) || WasFilterModified(syncFolders, latestSyncPoint))
{
// insert "Reset" sync point
var resetSyncPoint = new MutableSyncPoint()
{
Id = GetNextSyncPointId(latestSyncPoint),
MultiFileSystemSnapshotId = null,
FilterConfigurations = syncFolders.ToDictionary(f => f.Name, f => f.Filter)
};
syncPointService.AddItem(resetSyncPoint);
// cancel all pending sync actions
var cancelledSyncActions = syncActionService.PendingItems
.Select(a => a.WithState(SyncActionState.Cancelled));
syncActionService.UpdateItems(cancelledSyncActions);
// remove all conflicts
conflictService.RemoveItems(conflictService.Items.ToArray());
return true;
}
return false;
}