locked
Needd urgent help to show conflict changes between client & server on client side RRS feed

  • Question

  • I want to show the details of conflict changes between client & server on client side i.e @mobile device.

    I used following code to raise the event at client side,but unable to get the conflict details at client.(I want to show it through messagebox)

     

    I add below event in the class which is implementing SqlCeClientSyncProvider.

     

    this.ConflictResolver.ClientUpdateServerUpdateAction  = ResolveAction.FireEvent;



     

    this.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(SampleClientSyncProvider_ApplyChangeFailed);

     

     

    Same thing I have done @server.It is working fine by raising the following event.i write req information in log file.

     

    this.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(SampleServerSyncProvider_ApplyChangeFailed);

    • Moved by Hengzhe Li Friday, April 22, 2011 2:27 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, July 8, 2009 4:55 AM

Answers

  • Let us try this - instead of doing a bi-directional sync in your sync app, let us make 2 SyncAgent.Synchronization() call.  The first is to using DownloadOnly as the sync direction and the second sync is to use UploadOnly as the sync direction.

    In this case, all conflits will show on the ChangeApplyFailed event on the client provider.

    Thanks. 
    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 24, 2009 5:57 PM
    Answerer

All replies

  • I want to show the details of conflict changes between client & server on client side i.e @mobile device.

    I used following code to raise the event at client side,but unable to get the conflict details at client.(I want to show it through messagebox)

     

    I add below event in the class which is implementing SqlCeClientSyncProvider.

     

    this.ConflictResolver.ClientUpdateServerUpdateAction  = ResolveAction.FireEvent;

     

    this.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(SampleClientSyncProvider_ApplyChangeFailed);

     

     

    Same thing I have done @server.It is working fine by raising the following event.i write req information in log file.

     

    this.ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(SampleServerSyncProvider_ApplyChangeFailed);

     

    I get the client side ApplyChangeFailed  event only in case of ClientInsertServerInsertAction .

    can anybody give solution for the above issue.

    • Merged by warrentang Monday, July 13, 2009 7:32 AM duplicate
    Friday, July 10, 2009 9:01 AM
  • Hello - What is your business scenario and what sync direction do you have in your sync application?  What I suspect is that the conflicts were resolved during upload phase.
    1. If client win then server data were updated during the upload phase.
    2. If server win then the upload phase does nothing and the server change is coming down to the client afterwards during download phase.

    If the above 2 are true and you really want to show/resolve the same confilcts(changes) on the client side, then try to do a dummy update (it seems you have modified the data on the client side such as UPDATE tableA set columnB=columnB where id = 100) on the client before the change is coming down to the client from the server.  There are 2 key points here -
    1. You need to record which rows have seen conflicts during the upload phase.
    2. You need to do the dummy update of those conflicted rows on the client store before the client applies the server's change (the ApplyingChanges event on the client provider you can try).

    Thanks.
    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, July 21, 2009 2:32 PM
    Answerer
  • hi,

    thanks for reply.

    i used the bidirectional sync.

    i just want the
    ApplyChangeFailed event should get raised at client side for the conflict changes.

    it get fired only for clientinsertserverinsert for a row of same primary key and not for other conflict.

    At the server side the same event gets fired for all Conflict changes.....so why not on client side?
    is Sync service by microsoft missing something?

    hope u understood the scenario.

    hoping ur reply.

    Wednesday, July 22, 2009 11:38 AM
  • Hello

    The reason you see PK collision is due to data itself.
    During bi-directional, once uploading is completed, the client thinks it has all its changes sent to the server and the client is done.  The client provider internally bumps its sent anchor to a new value, say 100 so all previous changes say 90 to 99 are covered by it.  If we do a client win, then client data should be enforced on the server table.  If this is a server win, then the server provider doesn't need to deal with the conflits because the those conflicting data will be downloaded to the client in the next downloading phase.  Once these rows are downloaded, the client provider will check to see if any changes is bigger than 100.  If not then there is no conflicts.

    So all you have observed is by-design.  We did not miss anything.

    But if you have to see those conflicts on the downloading phase, your app needs to modify the conflitcting row(s) on the client store after the uploading phase is completed so that those rows will have a update count > 100.  And the client provider can detect the conflicts.

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, July 22, 2009 5:27 PM
    Answerer
  • Hi,

    Thanks for ur reply...

    I think u didn't understood the scenario properly ......

    Following are the scenario for data conflict in Sync service- we want to deal with it.......

     

    1)A ClientInsertServerInsert conflict occurs when the client and server both insert a row with the same primary key. This type of conflict is also known as a primary key collision.

    2)A ClientUpdateServerUpdate conflict occurs when the client and server change the same row. This is the most common type of conflict.

    3)A ClientUpdateServerDelete conflict occurs when the client updates a row and the server deletes the same row.

    4)A ClientDeleteServerUpdate conflict occurs when the client deletes a row and the server updates the same row.

    5) An ErrorsOccurred conflict occurs when an error prevents a row from being applied, in this case all data for that particular synchronization session gets rolled back.

     

    If a row cannot be applied during synchronization, it is typically because either an error or a data conflict occurred. In both cases, the DbServerSyncProvider ApplyChangeFailed event or SqlCeClientSyncProvider ApplyChangeFailed event is raised, depending on whether the error or conflict occurred during the upload or download phase of synchronization.

     

    The ApplyChangeFailed event gets fired on server for each conflict mention above but not on the client(mobile device).Only for the  ClientInsertServerInsert conflict the ApplyChangeFailed event gets fired on client side.

     

    So the simple question is how to get details of conflict using sync service on client side ......?

    Also when there is
    ErrorsOccurred conflict occurs ,all data gets rolled back. E.g. If synchronization sync 100 record & 101th record has some invalid data, all records get rolled back. we want to give message to the client for invalid data& other record should get committed in database.

     



    I would like to know how to handle the above situation.

     

    Thursday, July 23, 2009 5:10 AM
  • Let us try this - instead of doing a bi-directional sync in your sync app, let us make 2 SyncAgent.Synchronization() call.  The first is to using DownloadOnly as the sync direction and the second sync is to use UploadOnly as the sync direction.

    In this case, all conflits will show on the ChangeApplyFailed event on the client provider.

    Thanks. 
    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 24, 2009 5:57 PM
    Answerer
  • hi ,

    thanks for your reply.

    I hope ur taking about ApplyChangeFailed event not the ChangeApplyFailed because i didn't get any such event on the client provider.
    Plese correct me if i am wrong. 


    I  tried the Download first and then upload synchrionization call.

    But the event ApplyChangeFailed events get fired only when there is  ClientInsertServerInsertAction action and not for other action like

    ClientUpdateServerUpdateAction .

    could u please give suggestion  on the same.

    Monday, July 27, 2009 5:48 AM