locked
FullEnumerationSimpleSyncProvider and Updates RRS feed

  • Question

  • Does the FullEnumerationSimpleSyncProvider do any short of checking to see if an item needs to be updated?  Currently my providers are always doing an update of every single records and I am not sure if that is suppose to be what is happening or if I am doing something wrong. I keep my unique id and the datetime stamp in my metadata store and was hoping I could utilize the datetime stamp to do some basic evaluation of if the update was necessary.
    Friday, March 5, 2010 9:17 PM

Answers

  • Hi, dosborn.

    Change detection is a phase in which the "delta" (changes) are detected. It is performed by the Sync engine, so you don't need to worry about it.

    What you need to do is report the metadata you have for a specific item, the engine will figure out if this item has changed (and needs to be synced) or not.

    You don't need to "indicate" which custom field should be used for change detection - once a custom field IS defined, it is considered by the engine when detecting changes.

    Your EnumerateItems method looks OK, but can you please tell us what does the SyncRepository.GetAllSyncHeaders() method do? From the symptoms you described it looks like you "tell" the engine that all your items have been updated.

    One thing you could do is have only 1 item (to avoid confusion) and sync under the debugger. Compare the values you report for NAME, TIMESTAMP and TABLENAME with the values in the MetadataStore and see whether they match.

    Also, may I ask what are you sync-ing? Is it a database (I've noticed a field called TableName. Is it something which changes over time ?).

     

    Adrian.

    Monday, March 22, 2010 9:17 PM
  • Thanks, i was able to get the issue resolved.  It appears as though my timestamp field was getting updated and hence MS Sync was working properly.
    Tuesday, March 23, 2010 4:19 PM

All replies

  • Hi dosborn,

    FullEnumerationSimpleSyncProvider uses metadata to track what changes have been made to an item. This means if there is any local changes made, you need to

    reflect that change by reporting a changed metadata within EnumerateItems call.

    For example, this can be a datetime stamp (i.e. last modified time) change.

    Hope this helps,

    Patrick

    Friday, March 5, 2010 10:01 PM
  • What's the syntax for this?
    Saturday, March 6, 2010 2:23 AM
  • During change detection phase, the user provider needs to report the user item metadata information to the Full Enumeration Provider which will compare them to the existing information in the metadata store to decide which the user items were changed so to enumerate them later on during sync.  In general these information on the metadata store is for internal usage.

    By the way, do you see any issue beside curious about the "Update" of each metadata item record in the metadata store?

    Thanks.

    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Sunday, March 7, 2010 4:43 PM
    Answerer
  • But how do I indicate that it use the datetime field that I store in the metadata store for the purpose of change detection?  What are you calling the change detection phase? Do I need to implement an interface that allows me to handle change detection??

    I don't want to be updating everything in the database every sync because it takes forever.  The initial sync takes 45 minutes to an hour and so does the update if it updates each item.  Its only 3,000 records and I wouldn't think it should take that long to handle the sync.  I need to get things sped up and I am hoping I can do it without switching to an Anchor Enumeration Provider. Though I may need to anyways.  I just don't want to build a big infrastructure to handle deletes for the anchor method. MS Sync seems really functional, but the documentation is really lacking and there doesn't seem to be very much of a community around it except for people posting questions trying to figure out how to implement things.
    Monday, March 8, 2010 1:46 AM
  • Here's my EnumerateItems Method. Does it need to be doing something differently to handle change detecting or do I handle change detection in another method? syncHeader.Timestamp is a datetime field which should be used to know if a field was updated.

    public override void EnumerateItems(FullEnumerationContext context)
            {
                List<ItemFieldDictionary> items = new List<ItemFieldDictionary>();
    
                IList<SyncHeader> syncHeaders = _syncRepository.GetAllSyncHeaders();
    
                foreach (SyncHeader syncHeader in syncHeaders)
                {
                    ItemFieldDictionary dict = new ItemFieldDictionary();
                    dict.Add(new ItemField(ItemFields.CUSTOM_FIELD_NAME, typeof(Guid), syncHeader.UUID));
                    dict.Add(new ItemField(ItemFields.CUSTOM_FIELD_TIMESTAMP, typeof(string), syncHeader.Timestamp.ToString()));
                    dict.Add(new ItemField(ItemFields.CUSTOM_FIELD_TABLENAME, typeof(string), syncHeader.TableName));
    
                    items.Add(dict);
                }
    
    
                context.ReportItems(items);
            }
    Monday, March 8, 2010 3:01 PM
  • Do I need to be defining my ItemMetadataSchema somehow to indicate that it should use CUSTOM_FELD_TIMESTAMP for change detection?


            public override ItemMetadataSchema MetadataSchema
            {
                get
                {
                    CustomFieldDefinition[] customFields = new CustomFieldDefinition[3];
                    customFields[0] = new CustomFieldDefinition(ItemFields.CUSTOM_FIELD_NAME, typeof(Guid));
                    customFields[1] = new CustomFieldDefinition(ItemFields.CUSTOM_FIELD_TIMESTAMP, typeof(string), 45);
                    customFields[2] = new CustomFieldDefinition(ItemFields.CUSTOM_FIELD_TABLENAME, typeof(string), 150);
    
                    IdentityRule[] identityRule = new IdentityRule[1];
                    identityRule[0] = new IdentityRule(new uint[] { ItemFields.CUSTOM_FIELD_NAME });
    
    
                    return new ItemMetadataSchema(customFields, identityRule);
                }
            }

    Monday, March 8, 2010 3:20 PM
  • Hi, dosborn.

    Change detection is a phase in which the "delta" (changes) are detected. It is performed by the Sync engine, so you don't need to worry about it.

    What you need to do is report the metadata you have for a specific item, the engine will figure out if this item has changed (and needs to be synced) or not.

    You don't need to "indicate" which custom field should be used for change detection - once a custom field IS defined, it is considered by the engine when detecting changes.

    Your EnumerateItems method looks OK, but can you please tell us what does the SyncRepository.GetAllSyncHeaders() method do? From the symptoms you described it looks like you "tell" the engine that all your items have been updated.

    One thing you could do is have only 1 item (to avoid confusion) and sync under the debugger. Compare the values you report for NAME, TIMESTAMP and TABLENAME with the values in the MetadataStore and see whether they match.

    Also, may I ask what are you sync-ing? Is it a database (I've noticed a field called TableName. Is it something which changes over time ?).

     

    Adrian.

    Monday, March 22, 2010 9:17 PM
  • Thanks, i was able to get the issue resolved.  It appears as though my timestamp field was getting updated and hence MS Sync was working properly.
    Tuesday, March 23, 2010 4:19 PM