locked
Working with Subset of the entire data using MSF RRS feed

  • Question

  • I am syncing my database appointments with Outlook appointments using Microsoft Sync Framework (MSF). At a time I am working on a subset of the entire database, meaning I am syncing all appointments created between today and 14 days from today.

    When I call _metadata.DeleteDetector.MarkAllItemsUnreported();, it marks all the item "Unreported", including items that are not in my subset (data before today and data after 14 days)

    At the end of the method I do following to delete any unreported items, which actually delete items beyond my subset data (before today and after 14 days)
    oreach (ItemMetadata item in _metadata.DeleteDetector.FindUnreportedItems())

    {

    item.MarkAsDeleted(newVersion);

    SaveItemMetadata(item);

    }

    Below is the code that describe the problem.



    private
    void UpdateMetadataStoreWithLocalChanges()

    {

     

    SyncVersion newVersion = new SyncVersion(0, _metadata.GetNextTickCount());

    _metadata.DeleteDetector.MarkAllItemsUnreported();

     

    foreach (T itemData in this.itemDataList)

    {

     

    ItemMetadata item = null;

     

    ulong changeDetectionValue = GetChangeDetectionValue(itemData);

     

    string itemId = GetItemDataId(itemData);

     

     

    //Look up an item's metadata by its ID...

    item = _metadata.FindItemMetadataById(

    new SyncId(itemId));

     

    if(null == item)

    {

     

    // Now see if item exists with external id

    item = _metadata.FindItemMetadataByUniqueIndexedField(EXTERNAL_ID, itemId);

    }

     

    if (null == item)

    {

     

    //New item, must have been created since that last time the metadata was updated.

     

    //Create the item metadata required for sync (giving it a SyncID and a version, defined to be a DWORD and a ULONGLONG

     

    //For creates, simply provide the relative replica ID (0) and the tick count for the provider (ever increasing)

    item = _metadata.CreateItemMetadata(

    new SyncId(itemId), newVersion);

    item.SetCustomField(EXTERNAL_ID, itemId);

    item.ChangeVersion = newVersion;

    SaveItemMetadata(item, changeDetectionValue);

    }

     

    else

    {

     

    // There may be a case where item was marked as deleted previously,

     

    // because it was not part of the itemDataList in previous sync

     

    // Now if item marked as deleted, but in this sync we found that it still exists

     

    // Make them live.

     

    if (item.IsDeleted)

    {

    item.ResurrectDeletedItem();

    SaveItemMetadata(item);

    }

     

     

    if (IsChanged(item, changeDetectionValue)) // the item has changed since the last sync operation.

    {

     

    //Changed Item, this item has changed since the last time the metadata was updated.

     

    //Assign a new version by simply stating "who" modified this item (0 = local/me) and "when" (tick count for the store)

    item.ChangeVersion = newVersion;

    SaveItemMetadata(item, changeDetectionValue);

    }

     

    else

    {

     

    //Unchanged item, nothing has changes so just mark it as live so that the metadata knows it has not been deleted.

    _metadata.DeleteDetector.ReportLiveItemById(item.GlobalId);

    }

    }

    }

     

    //Now go back through the items that are no longer in the store and mark them as deleted in the metadata.

     

    //This sets the item as a tombstone.

     

    foreach (ItemMetadata item in _metadata.DeleteDetector.FindUnreportedItems())

    {

    item.MarkAsDeleted(newVersion);

    SaveItemMetadata(item);

    }

    }

    • Moved by Max Wang_1983 Wednesday, April 20, 2011 11:10 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, October 19, 2009 4:29 PM

Answers

  • Are you using Row filters or Custom filters? The online samples should show you how to use filters for your scenario. You shouldn't be manipulating metadata to achieve this.
    Saturday, November 21, 2009 12:21 AM
    Moderator

All replies

  • BTW

    I am doing following in my code as you can see

    if (item.IsDeleted)

    {

    item.ResurrectDeletedItem();

    SaveItemMetadata(item);

    }

    To circumvent the problem, but thats not I want since it deletes data and recreate it in somebody's outlook calendar.

    Monday, October 19, 2009 4:34 PM
  • Are you using Row filters or Custom filters? The online samples should show you how to use filters for your scenario. You shouldn't be manipulating metadata to achieve this.
    Saturday, November 21, 2009 12:21 AM
    Moderator