Answered by:
FileSyncProviderManagedSample and ManagedNTFSSample in MSF

Question
-
I installed MSF and tried to modify the samples in MSF.
First, I tried to handle the conflict in ManagedNTFSSample and then modified the code as below.
public void Synchronize(KnowledgeSyncProvider destinationProvider, KnowledgeSyncProvider sourceProvider, uint
batchSize, string scopeName)
{
// Set the batch size on each provider((MyStore)destinationProvider).RequestedBatchSize = batchSize;
((MyStore)sourceProvider).RequestedBatchSize = batchSize;destinationProvider.Configuration.ConflictResolutionPolicy =
ConflictResolutionPolicy.ApplicationDefined;
sourceProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;
SyncCallbacks scb = sourceProvider.DestinationCallbacks;
scb.ItemConflicting += new EventHandler<ItemConflictingEventArgs>(OnItemConflicting);// Create the sync session
SyncOrchestrator syncAgent = new SyncOrchestrator();syncAgent.LocalProvider = destinationProvider;
syncAgent.RemoteProvider = sourceProvider;
syncAgent.Direction = SyncDirectionOrder.DownloadAndUpload;
syncAgent.Synchronize();
}public void OnItemConflicting(object sender, ItemConflictingEventArgs args)
{
args.SetResolutionAction(ConflictResolutionAction.DestinationWins);
}It works, then I try to add the same code to FileSyncProviderManagedSample.
sourceProvider = new FileSyncProvider(sourceReplicaId, sourceReplicaRootPath, filter, options);
destinationProvider = new FileSyncProvider(destinationReplicaId, destinationReplicaRootPath, filter, options);destinationProvider.AppliedChange += new EventHandler<AppliedChangeEventArgs>(OnAppliedChange);
destinationProvider.SkippedChange += new EventHandler<SkippedChangeEventArgs>(OnSkippedChange);sourceProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;
destinationProvider.Configuration.ConflictResolutionPolicy =ConflictResolutionPolicy.ApplicationDefined;
SyncCallbacks scb = sourceProvider.DestinationCallbacks;
scb.ItemConflicting += new EventHandler<ItemConflictingEventArgs>(OnItemConflicting);
SyncOrchestrator agent = new SyncOrchestrator();
agent.LocalProvider = sourceProvider;
agent.RemoteProvider = destinationProvider;
agent.Direction = SyncDirectionOrder.Upload; // Sync source to destination
agent.Synchronize();But it cannot receive ItemConflicting event when there is conflict.
Does anyone know how to handle conflict in FileSyncProviderManagedSample or how to implement preview mode in ManagedNTFSSample ?
Thanks.
- Moved by Max Wang_1983 Thursday, April 21, 2011 6:10 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
Thursday, August 28, 2008 9:26 AM
Answers
-
Hi -
The FileSyncProviderManagedSample demonstrates the FileSyncProvider that we ship with the framework. This has a conflict resolution policy of LastWriteTimeWins ALWAYS. So you will not see the conflicts and your application cannot handle them.
The ManagedNTFSSample demonstrates how to write a sample sync provider - it just so happens that the sample sync's files on two sides. The sample also does not support hierarchies ( in case you were interested in that). To implement something like Preview in this sample - you have to allow a sync to proceed normally and look at all changes that you see on the :
aveItemChange ( and similar methods on INotifyingChangeApplierTargets) WITHOUT applying these changes.
Hope this helps.
Thanks
Deepa
- Proposed as answer by L Zhou [MSFT]Editor Friday, March 20, 2009 10:32 AM
- Marked as answer by Liam Cavanagh - MSFTMicrosoft employee Thursday, April 9, 2009 4:01 PM
Wednesday, September 3, 2008 10:04 PMAnswerer
All replies
-
Hi -
The FileSyncProviderManagedSample demonstrates the FileSyncProvider that we ship with the framework. This has a conflict resolution policy of LastWriteTimeWins ALWAYS. So you will not see the conflicts and your application cannot handle them.
The ManagedNTFSSample demonstrates how to write a sample sync provider - it just so happens that the sample sync's files on two sides. The sample also does not support hierarchies ( in case you were interested in that). To implement something like Preview in this sample - you have to allow a sync to proceed normally and look at all changes that you see on the :
aveItemChange ( and similar methods on INotifyingChangeApplierTargets) WITHOUT applying these changes.
Hope this helps.
Thanks
Deepa
- Proposed as answer by L Zhou [MSFT]Editor Friday, March 20, 2009 10:32 AM
- Marked as answer by Liam Cavanagh - MSFTMicrosoft employee Thursday, April 9, 2009 4:01 PM
Wednesday, September 3, 2008 10:04 PMAnswerer -
Thanks for your reply.
Do you know that will FileSyncProvider support custom conflict handle in next MSF release?
Could you give me some advices about how to modify the ManagedNTFSSample to support hierarchies?
Thanks.
Friday, October 3, 2008 8:27 AM