locked
How to decode SentAnchor and ReceivedAnchors in anchor table RRS feed

  • Question

  • Hi,

    Two questions:

    1. Anybody aware of how to decode the varbinary values of Sent and Recived anchors stored in anchor table?

    2. when exactly are conflict stored procedures (xxxUpdateConflict and xxxDeleteConflict) are called during bidirectional synchronization?
    • Moved by Max Wang_1983 Thursday, April 21, 2011 11:35 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Saturday, August 22, 2009 12:23 PM

Answers

  • 1.
    This is the code for getting SentAnchor:

    reader.GetBytes(0, 0L, buffer, 0, 8); //read SentAnchor from db to buffer byte[60]
    long num2 = BitConverter.ToInt64(buffer, 0); //convert to long
    
     
    ReceivedAnchor is returned by SelectNewAnchorCommand from server, and serailzed in following way:

    object _rawNewAnchor = newAnchor;
    using (MemoryStream serializationStream2 = new MemoryStream())
    {
      new BinaryFormatter().Serialize(serializationStream2, _rawNewAnchor);
      SyncAnchor newAnchor = (new SyncAnchor());
      newAnchor.Anchor = serializationStream.ToArray();
    //...
    }

    newAnchor.Anchor is the value of __sysSyncArticles.ReceivedAnchor.

    2. The conflict stored procedures (xxxUpdateConflict and xxxDeleteConflict) are called when ApplyChanges() is called, and conflict is detected. The sps are used to populate DbServerSyncProvider  -> ApplyChangeFiled -> ApplyChangeFailedEventArgs -> SysConflict.ServerChanges/ClientChanges.
    Sunday, August 30, 2009 11:46 PM
  • Please check the values in buffer [2048].

    In following code, the value of receivedAnchor & num2 both are 6110.
                byte[] buffer = new byte[2048];
                buffer[0] = 0xDE;
                buffer[1] = 0x17;
                UInt64 receivedAnchor = BitConverter.ToUInt64(buffer, 0);
                long num2 = BitConverter.ToInt64(buffer, 0); //convert to long

    • Marked as answer by DevUser1 Sunday, September 6, 2009 7:34 AM
    Friday, September 4, 2009 12:57 AM

All replies

  • 1.
    This is the code for getting SentAnchor:

    reader.GetBytes(0, 0L, buffer, 0, 8); //read SentAnchor from db to buffer byte[60]
    long num2 = BitConverter.ToInt64(buffer, 0); //convert to long
    
     
    ReceivedAnchor is returned by SelectNewAnchorCommand from server, and serailzed in following way:

    object _rawNewAnchor = newAnchor;
    using (MemoryStream serializationStream2 = new MemoryStream())
    {
      new BinaryFormatter().Serialize(serializationStream2, _rawNewAnchor);
      SyncAnchor newAnchor = (new SyncAnchor());
      newAnchor.Anchor = serializationStream.ToArray();
    //...
    }

    newAnchor.Anchor is the value of __sysSyncArticles.ReceivedAnchor.

    2. The conflict stored procedures (xxxUpdateConflict and xxxDeleteConflict) are called when ApplyChanges() is called, and conflict is detected. The sps are used to populate DbServerSyncProvider  -> ApplyChangeFiled -> ApplyChangeFailedEventArgs -> SysConflict.ServerChanges/ClientChanges.
    Sunday, August 30, 2009 11:46 PM
  • hi Bob,

    I am reading the hexadecimal value and storing it after casting it to the BigInt like select cast(0x00000000000017DE as BigInt) which gives 6110 in one of the sproc which is more readable.

    However with the code snippet you have provided I am getting a negative value in num2 after conversion,which is a big number as compared to the casted bigint

    rdr.GetBytes(0, 0, buffer, 0, 2048);//read SentAnchor from db to buffer byte[2048]
    UInt64 receivedAnchor = BitConverter.ToUInt64(buffer, 0);

    Basically my requirement is to maintain  a anchor_audit table which will have BigInt equivalent of binary.

    Let me know your thought on this ?

    Tuesday, September 1, 2009 8:07 AM
  • Please check the values in buffer [2048].

    In following code, the value of receivedAnchor & num2 both are 6110.
                byte[] buffer = new byte[2048];
                buffer[0] = 0xDE;
                buffer[1] = 0x17;
                UInt64 receivedAnchor = BitConverter.ToUInt64(buffer, 0);
                long num2 = BitConverter.ToInt64(buffer, 0); //convert to long

    • Marked as answer by DevUser1 Sunday, September 6, 2009 7:34 AM
    Friday, September 4, 2009 12:57 AM