public void SyncDownContacts()
 {
     RegisterSoup();
     if (syncId == -1)
     {
         string soqlQuery =
             SOQLBuilder.GetInstanceWithFields(ContactObject.ContactFields)
             .From(Constants.Contact)
             .Limit(Limit)
             .Build();
         SyncOptions    options = SyncOptions.OptionsForSyncDown(SyncState.MergeModeOptions.LeaveIfChanged);
         SyncDownTarget target  = new SoqlSyncDownTarget(soqlQuery);
         try
         {
             SyncState sync = _syncManager.SyncDown(target, ContactSoup, HandleSyncUpdate);
             syncId = sync.Id;
         }
         catch (SmartStoreException)
         {
             // log here
         }
     }
     else
     {
         _syncManager.ReSync(syncId, HandleSyncUpdate);
     }
 }
Beispiel #2
0
        public async Task <String> FetchLastModifiedDate(SyncManager syncManager, String objectType, String objectId)
        {
            String query = SOQLBuilder.GetInstanceWithFields(Constants.LastModifiedDate)
                           .From(objectType)
                           .Where(Constants.Id + " = '" + objectId + "'")
                           .Build();

            var lastModResponse = await syncManager.SendRestRequest(RestRequest.GetRequestForQuery(syncManager.ApiVersion, query));

            if (lastModResponse.Success)
            {
                return
                    (lastModResponse.AsJObject.ExtractValue <JArray>(Constants.Records)[0].Value <JObject>()
                     .ExtractValue <string>(Constants.LastModifiedDate));
            }
            return(null);
        }
        public void SyncDownNotes()
        {
            RegisterSoup();
            string soqlQuery =
                SOQLBuilder.GetInstanceWithFields(NoteObject.NoteFields)
                .From(NoteObject.NoteSObjectType)
                .Limit(Limit)
                .Build();
            SyncOptions    options = SyncOptions.OptionsForSyncDown(SyncState.MergeModeOptions.LeaveIfChanged);
            SyncDownTarget target  = new SoqlSyncDownTarget(soqlQuery);

            try
            {
                SyncState sync = _syncManager.SyncDown(target, NotesSoup, HandleSyncUpdate, options);
                syncId = sync.Id;
            }
            catch (SmartStoreException)
            {
                // log here
            }
        }
        public async override Task <JArray> StartFetch(SyncManager syncManager, long maxTimeStamp)
        {
            var request  = RestRequest.GetRequestForMetadata(syncManager.ApiVersion, ObjectType);
            var response = await syncManager.SendRestRequest(request);

            var recentItems = SyncManager.Pluck <string>(response.AsJObject.ExtractValue <JArray>(Constants.RecentItems),
                                                         Constants.Id);
            // Building SOQL query to get requested at
            String soql = SOQLBuilder.GetInstanceWithFields(FieldList.ToArray()).From(ObjectType).Where("Id IN ('" + String.Join("', '", recentItems) + "')").Build();

            // Get recent items attributes from server
            request  = RestRequest.GetRequestForQuery(syncManager.ApiVersion, soql);
            response = await syncManager.SendRestRequest(request);

            var responseJson = response.AsJObject;
            var records      = responseJson.ExtractValue <JArray>(Constants.Records);

            // Recording total size
            TotalSize = records.Count;

            return(records);
        }