locked
Outlook Sync with own Database RRS feed

  • Question

  • Hello,

     

    I want to try to sync my Outlook with a Database of Contacts. I using VS2008 with SP1.

     

    Now I downloaded the Outlook Contacts Sample but that didn´t work. I cann´t compile the sample, some errors are "IsLastBatch is read only" and "ItemChange have no Contructor with 5 Arguments" (I tranlated from my german version of VS2008).

     

    Can someone send me a newer version of the MsfSample or decribe what are the changes?

     

    Thank you very much

    Michael Kolowicz

    • Moved by Max Wang_1983 Thursday, April 21, 2011 6:02 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Thursday, November 13, 2008 6:51 AM

Answers

  • Hi again:

     

    These are the changes you need to make:

     

    When you create an ItemChange you have to specify the changeKind in the constructor. 

     

    For example in GenericSyncProvider.cs Line 534

     

    Original Code:

    Code Snippet

    // If the metadata is for a tombstone, the change is a delete.

    if (!mappedKnowledge.Contains(replicaId, item.ItemId, item.ChangeVersion))

    {

    ItemChange itemChange = new ItemChange(IdFormats, replicaId,

          item.ItemId, item.CreationVersion, item.ChangeVersion);

     

    if (item.IsTombstone)

                itemChange.ChangeKind = ChangeKind.Deleted;

     

          // Change isn't known to the remote store, so add it to the batch.

          changeBatch.Add(itemChange);

    }

     

     

    Modified Code:

    Code Snippet

    // If the metadata is for a tombstone, the change is a delete.

    if (!mappedKnowledge.Contains(replicaId, item.ItemId, item.ChangeVersion))

    {

    ChangeKind changeKind = ChangeKind.Update;

          if (item.IsTombstone)

          {

                changeKind = ChangeKind.Deleted;

          }

     

          // Add extra parameter (changeKind)

    ItemChange itemChange = new ItemChange(IdFormats, replicaId,

          item.ItemId, changeKind, item.CreationVersion,

    item.ChangeVersion);

                       

    // Change isn't known to the remote store, so add it to the batch.

    changeBatch.Add(itemChange);

    }

     

     

    The field IsLastBatch is now read-only.  To set the last batch in a change batch you need to change the code from:

    Code Snippet

    if((changes.Count < batchSize) || (changes.Count == 0))

    {

        changeBatch.IsLastBatch = true;

    }

     

    To:

    Code Snippet

    if((changes.Count < batchSize) || (changes.Count == 0))

    {

        changeBatch.SetLastBatch();

    }

     

     

    Let me know if this helped

     

    Maria del Mar Alvarez Rohena - MSFT

    Monday, November 17, 2008 11:23 PM
  • For Line 870 (and also 972) change the code to:

    Code Snippet

     

    change = new ItemChange(IdFormats, replicaId, ic.ItemId, ChangeKind.UnknownItem, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);

     

    // Remove This Line: change.ChangeKind = ChangeKind.UnknownItem;

     

     

    For Line 1129 (and also 1154 and 1217), change code to:

    Code Snippet

    saveChangeContext.RecordRecoverableErrorForItem(

    new RecoverableErrorData(new Exception("Couldn't save the changes because the contact was locked or has changed: " + item.Uri)));

    skippedItems.Add(item.Uri);

     

     

    Maria del Mar Alvarez Rohena - MSFT
    Saturday, November 22, 2008 1:32 AM

All replies

  • What version of Microsoft Sync Framework SDK are you using?  The Outlook Contacts Sample was created with Microsoft Sync Framework SDK v1 CTP2. 

     

    In newer versions of the SDK those APIs have changed.  To use the sample with your version of Sync Framework SDK you have to make minor changes to the sample code to make it compile.  Let me know why version of the SDK you installed to futher help you.

     

    Maria del Mar Alvarez Rohena - MSFT

    Saturday, November 15, 2008 1:08 AM
  • Thank you for your reply.

     

    I using the MSF SDK 1.0 that would be installed with Visual Studio 2008 SP 1. The Version is 1.0.1215.0. I hope that help you to assist me.

     

    Michael Kolowicz

    Saturday, November 15, 2008 8:04 PM
  • Hi again:

     

    These are the changes you need to make:

     

    When you create an ItemChange you have to specify the changeKind in the constructor. 

     

    For example in GenericSyncProvider.cs Line 534

     

    Original Code:

    Code Snippet

    // If the metadata is for a tombstone, the change is a delete.

    if (!mappedKnowledge.Contains(replicaId, item.ItemId, item.ChangeVersion))

    {

    ItemChange itemChange = new ItemChange(IdFormats, replicaId,

          item.ItemId, item.CreationVersion, item.ChangeVersion);

     

    if (item.IsTombstone)

                itemChange.ChangeKind = ChangeKind.Deleted;

     

          // Change isn't known to the remote store, so add it to the batch.

          changeBatch.Add(itemChange);

    }

     

     

    Modified Code:

    Code Snippet

    // If the metadata is for a tombstone, the change is a delete.

    if (!mappedKnowledge.Contains(replicaId, item.ItemId, item.ChangeVersion))

    {

    ChangeKind changeKind = ChangeKind.Update;

          if (item.IsTombstone)

          {

                changeKind = ChangeKind.Deleted;

          }

     

          // Add extra parameter (changeKind)

    ItemChange itemChange = new ItemChange(IdFormats, replicaId,

          item.ItemId, changeKind, item.CreationVersion,

    item.ChangeVersion);

                       

    // Change isn't known to the remote store, so add it to the batch.

    changeBatch.Add(itemChange);

    }

     

     

    The field IsLastBatch is now read-only.  To set the last batch in a change batch you need to change the code from:

    Code Snippet

    if((changes.Count < batchSize) || (changes.Count == 0))

    {

        changeBatch.IsLastBatch = true;

    }

     

    To:

    Code Snippet

    if((changes.Count < batchSize) || (changes.Count == 0))

    {

        changeBatch.SetLastBatch();

    }

     

     

    Let me know if this helped

     

    Maria del Mar Alvarez Rohena - MSFT

    Monday, November 17, 2008 11:23 PM
  • Hello,

     

    thank you very much. i have change the code and I still have problems - Sorry!!!

     

    Here are the lines in the GenericsyncProvider.cs

     

    Line 870 (and also 972):

    Code Snippet

    // Remote item has no local counterpart

    // This item is unknown to us

    change = new ItemChange(IdFormats, replicaId, ic.ItemId, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);

    // Mark the change as unknown

    change.ChangeKind = ChangeKind.UnknownItem;

     

     

    How correct this part?

     

    Line 1129 (and also 1154 and 1217)

    Code Snippet

    saveChangeContext.RecordRecoverableErrorForItem(

    new Exception("Couldn't save the changes because the contact was locked or has changed: " + item.Uri));

    skippedItems.Add(item.Uri);

     

     

    The error says "The best overloaded method match for "saveChangeContext.RecordRecoverableErrorForItem"

    has some invalid arguments

     

    Tuesday, November 18, 2008 7:48 AM
  • Hi again

     

    I am going to take a look at this and get back at you tomorrow

     

    Maria del Mar Alvarez - MSFT

     

    Friday, November 21, 2008 1:59 AM
  • For Line 870 (and also 972) change the code to:

    Code Snippet

     

    change = new ItemChange(IdFormats, replicaId, ic.ItemId, ChangeKind.UnknownItem, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);

     

    // Remove This Line: change.ChangeKind = ChangeKind.UnknownItem;

     

     

    For Line 1129 (and also 1154 and 1217), change code to:

    Code Snippet

    saveChangeContext.RecordRecoverableErrorForItem(

    new RecoverableErrorData(new Exception("Couldn't save the changes because the contact was locked or has changed: " + item.Uri)));

    skippedItems.Add(item.Uri);

     

     

    Maria del Mar Alvarez Rohena - MSFT
    Saturday, November 22, 2008 1:32 AM
  • Thank you very much !!!!!

     

    Now it works.  I can start to make the changes to my own application and try to understand the sync process.

     

    Greetings

    Michael

    Saturday, November 22, 2008 7:20 AM