Пример #1
0
 public void InsertAccount(JObject account)
 {
     if (account != null)
     {
         _store.Upsert(AccountsSoup, account);
     }
 }
Пример #2
0
        public JObject SaveToSoup(DTO.UserSettingsDto settings)
        {
            var sync = JObject.FromObject(settings);

            SetupSyncsSoupIfNotExistsNeeded();
            return(_store.Upsert(SoupName, sync, "UserId"));
        }
Пример #3
0
        private JObject SaveStateToSoup(SyncState state, string transactionItemType, string docVersionId)
        {
            if (state == null || state.Status != SyncState.SyncStatusTypes.Done)
            {
                throw new SyncException("Only SyncStatusTypes.Done can be saved to soup.");
            }

            var syncItem = new SuccessfulSync()
            {
                SyncId = state.Id.ToString(),
                TransactionItemType = transactionItemType,
                DocVersionId        = docVersionId
            };

            var sync = JObject.FromObject(syncItem);

            return(_store.Upsert(SoupName, sync, "TransactionItemType"));
        }
Пример #4
0
 public void SaveToSoup(List <Model.Models.CategoryContent> newCategoryContents)
 {
     if (newCategoryContents == null)
     {
         return;
     }
     foreach (var newCategoryContent in newCategoryContents)
     {
         _store.Upsert(SoupName, JObject.Parse(CustomPrefixJsonConvert.SerializeObject(newCategoryContent)));
     }
 }
 public async void DeleteObject(ContactObject contact)
 {
     if (contact == null)
     {
         return;
     }
     try
     {
         var item = _store.Retrieve(ContactSoup,
                                    _store.LookupSoupEntryId(ContactSoup, Constants.Id, contact.ObjectId))[0].ToObject <JObject>();
         item[SyncManager.Local]          = true;
         item[SyncManager.LocallyDeleted] = true;
         _store.Upsert(ContactSoup, item);
         contact.Deleted = true;
         await UpdateContact(contact);
     }
     catch (Exception)
     {
         Debug.WriteLine("Exception occurred while trying to delete");
     }
 }
        public async void SaveNote(NoteObject note, bool isCreated)
        {
            if (note == null)
            {
                return;
            }
            try
            {
                QuerySpec querySpec = QuerySpec.BuildExactQuerySpec(NotesSoup, Constants.Id, note.ObjectId, 1);
                JArray    returned  = _store.Query(querySpec, 0);
                JObject   item      = returned.Count > 0 ? returned[0].ToObject <JObject>() : new JObject();

                item[NoteObject.TitleField]      = note.Title;
                item[NoteObject.ContentField]    = Convert.ToBase64String(Encoding.UTF8.GetBytes(note.Content));
                item[SyncManager.Local]          = true;
                item[SyncManager.LocallyUpdated] = !isCreated;
                item[SyncManager.LocallyCreated] = isCreated;
                item[SyncManager.LocallyDeleted] = false;
                if (isCreated && item[Constants.Attributes.ToLower()] == null)
                {
                    item[Constants.Id] = "local_" + SmartStore.CurrentTimeMillis;
                    note.ObjectId      = item[Constants.Id].Value <string>();
                    var attributes = new JObject();
                    attributes[Constants.Type.ToLower()] = Constants.Contact;
                    item[Constants.Attributes.ToLower()] = attributes;
                    _store.Create(NotesSoup, item);
                }
                else
                {
                    _store.Upsert(NotesSoup, item);
                }
                note.UpdatedOrCreated = true;
                await UpdateNote(note);
            }
            catch (Exception)
            {
                Debug.WriteLine("Exception occurred while trying to save");
            }
        }
Пример #7
0
        public JObject SaveStateToSoup(Account account)
        {
            if (string.IsNullOrWhiteSpace(account?.UserName) || string.IsNullOrWhiteSpace(account.LoginUrl))
            {
                throw new SyncException("Only Account with username and loginUrl can be saved to soup.");
            }

            SetupSyncsSoupIfNotExistsNeeded();
            var loginItem = new LoginAccount()
            {
                UserName = account.UserName,
                LoginUrl = account.LoginUrl
            };

            var sync = JObject.FromObject(loginItem);

            return(_store.Upsert(SoupName, sync, "UserName"));
        }
Пример #8
0
        private void SaveReview(SmartStore store, ContentReview contentReview)
        {
            var record = JObject.FromObject(contentReview,
                                            JsonSerializer.Create(CustomJsonSerializerSettings.Instance.Settings));

            record[SyncManager.Local] = true;

            var info = contentReview.GetType().GetTypeInfo().GetCustomAttributes()
                       .SingleOrDefault(t => t is JsonObjectAttribute) as JsonObjectAttribute;

            if (info != null)
            {
                record[Constants.SobjectType] = string.Format(info.Title,
                                                              SfdcConfig.CustomerPrefix);
            }
            record[SyncManager.LocallyCreated] = true;
            record[SyncManager.LocallyUpdated] = false;
            record[SyncManager.LocallyUpdated] = false;
            record[Constants.Id] = Guid.NewGuid();
            store.Upsert(SoupName, record, Constants.Id, false);
        }