public static void ClassSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService <ILoggingService, Hybrid.Logging.Logger>(); Store = SmartStore.GetGlobalSmartStore(); SetupData(); }
public static void ClassSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService<ILoggingService, Hybrid.Logging.Logger>(); Store = SmartStore.GetGlobalSmartStore(); SetupData(); }
public static async Task TestSetup(TestContext context) { var settings = new EncryptionSettings(new HmacSHA256KeyGenerator()); Encryptor.init(settings); var options = new LoginOptions(TestCredentials.LoginUrl, TestCredentials.ClientId, TestCallbackUrl, "mobile", TestScopes); var response = new AuthResponse { RefreshToken = TestCredentials.RefreshToken, AccessToken = TestAuthToken, InstanceUrl = TestCredentials.InstanceUrl, IdentityUrl = TestCredentials.IdentityUrl, Scopes = TestScopes, }; Account account = await AccountManager.CreateNewAccount(options, response); account.UserId = TestCredentials.UserId; account.UserName = TestCredentials.Username; await OAuth2.RefreshAuthToken(account); _smartStore = SmartStore.GetGlobalSmartStore(); _smartStore.ResetDatabase(); _syncManager = SyncManager.GetInstance(); _restClient = new RestClient(account.InstanceUrl, account.AccessToken, async () => { account = AccountManager.GetAccount(); AuthResponse authResponse = await OAuth2.RefreshAuthTokenRequest(account.GetLoginOptions(), account.RefreshToken); account.AccessToken = authResponse.AccessToken; return account.AccessToken; } ); CreateAccountsSoup(); _idToNames = await CreateTestAccountsOnServer(CountTestAccounts); }
public static SmartStore GetGlobalSmartStore() { var store = new SmartStore(null); // generate a "global" smartstore store.CreateMetaTables(); return(store); }
public static SmartStore GetSmartStore(Account account) { var store = new SmartStore(account); store.CreateMetaTables(); return(store); }
public static void TestSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService <ILoggingService, Hybrid.Logging.Logger>(); Store = SmartStore.GetGlobalSmartStore(); Store.ResetDatabase(); Store.RegisterSoup(TEST_SOUP, new[] { new IndexSpec("key", SmartStoreType.SmartString) }); }
public static void TestSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService<ILoggingService, Hybrid.Logging.Logger>(); Store = SmartStore.GetGlobalSmartStore(); Store.ResetDatabase(); Store.RegisterSoup(TEST_SOUP, new[] {new IndexSpec("key", SmartStoreType.SmartString)}); }
/// <summary> /// Create syncs soup if needed. /// </summary> /// <param name="store"></param> public static void SetupSyncsSoupIfNeeded(SmartStore.Store.SmartStore store) { if (store.HasSoup(Constants.SyncsSoup)) { return; } IndexSpec[] indexSpecs = {new IndexSpec(Constants.SyncType, SmartStoreType.SmartString)}; store.RegisterSoup(Constants.SyncsSoup, indexSpecs); }
public ContactSyncViewModel() { Account account = AccountManager.GetAccount(); if (account == null) return; _store = SmartStore.GetSmartStore(account); _syncManager = SyncManager.GetInstance(account); Contacts = new SortedObservableCollection<ContactObject>(); FilteredContacts = new SortedObservableCollection<ContactObject>(); IndexReference = new ObservableCollection<string>(); }
private string GetSoupTableNameFromDb(string soupName) { using ( ISQLiteStatement stmt = Query(SmartStore.SoupNamesTable, new[] { SmartStore.IdCol }, String.Empty, String.Empty, SmartStore.SoupNamePredicate, soupName)) { if (stmt.DataCount == 0) { return(null); } return(SmartStore.GetSoupTableName(stmt.GetInteger(SmartStore.IdCol))); } }
public void TestDeleteDb() { Assert.AreEqual("select TABLE_1_0, TABLE_1_1 from TABLE_1 order by TABLE_1_1", Store.ConvertSmartSql( "select {employees:firstName}, {employees:lastName} from {employees} order by {employees:lastName}")); SmartStore.DeleteAllDatabases(true); try { Store.HasSoup(DEPARTMENTS_SOUP); Assert.Fail("Table exists"); } catch (SQLiteException) { // we're good, table doesn't exist } finally { SetupData(); } }
public static async Task TestSetup(TestContext context) { var settings = new EncryptionSettings(new HmacSHA256KeyGenerator()); Encryptor.init(settings); var options = new LoginOptions(TestCredentials.LoginUrl, TestCredentials.ClientId, TestCallbackUrl, "mobile", TestScopes); var response = new AuthResponse { RefreshToken = TestCredentials.RefreshToken, AccessToken = TestAuthToken, InstanceUrl = TestCredentials.InstanceUrl, IdentityUrl = TestCredentials.IdentityUrl, Scopes = TestScopes, }; Account account = await AccountManager.CreateNewAccount(options, response); account.UserId = TestCredentials.UserId; account.UserName = TestCredentials.Username; await OAuth2.RefreshAuthToken(account); _smartStore = SmartStore.GetGlobalSmartStore(); _smartStore.ResetDatabase(); _syncManager = SyncManager.GetInstance(); _restClient = new RestClient(account.InstanceUrl, account.AccessToken, async() => { account = AccountManager.GetAccount(); AuthResponse authResponse = await OAuth2.RefreshAuthTokenRequest(account.GetLoginOptions(), account.RefreshToken); account.AccessToken = authResponse.AccessToken; return(account.AccessToken); } ); CreateAccountsSoup(); _idToNames = await CreateTestAccountsOnServer(CountTestAccounts); }
public static async Task TestSetup(TestContext context) { SFApplicationHelper.RegisterServices(); SDKServiceLocator.RegisterService <ILoggingService, Hybrid.Logging.Logger>(); var settings = new EncryptionSettings(new HmacSHA256KeyGenerator(HashAlgorithmNames.Sha256)); Encryptor.init(settings); var options = new LoginOptions(TestCredentials.LoginUrl, TestCredentials.ClientId, TestCallbackUrl, "mobile", TestScopes); var response = new AuthResponse { RefreshToken = TestCredentials.RefreshToken, AccessToken = TestAuthToken, InstanceUrl = TestCredentials.InstanceUrl, IdentityUrl = TestCredentials.IdentityUrl, Scopes = TestScopes, }; Account account = await AccountManager.CreateNewAccount(options, response); account.UserId = TestCredentials.UserId; account.UserName = TestCredentials.Username; await OAuth2.RefreshAuthTokenAsync(account); _smartStore = SmartStore.GetSmartStore(); _smartStore.ResetDatabase(); _syncManager = SyncManager.GetInstance(); _restClient = new RestClient(account.InstanceUrl, account.AccessToken, async(cancellationToken) => { account = AccountManager.GetAccount(); account = await OAuth2.RefreshAuthTokenAsync(account); return(account.AccessToken); } ); CreateAccountsSoup(); _idToNames = await CreateTestAccountsOnServer(CountTestAccounts); }
public async static Task TestSetup(TestContext context) { Store = SmartStore.GetGlobalSmartStore(); SetupData(); }
public static SmartStore GetGlobalSmartStore() { var store = new SmartStore(null); // generate a "global" smartstore return(store); }
public static SmartStore GetSmartStore(Account account) { var store = new SmartStore(account); return(store); }
public static SmartStore GetSmartStore() { var store = new SmartStore(); return(store); }
/// <summary> /// Save SyncState to db /// </summary> /// <param name="store"></param> public void Save(SmartStore.Store.SmartStore store) { try { store.Update(Constants.SyncsSoup, AsJson(), Id, false); } catch (SQLiteException sqe) { var se = new SmartStoreException("SqliteError occurred ", sqe); throw se; } }
/// <summary> /// Create sync state in database for a sync down and return corresponding SyncState /// </summary> /// <param name="store"></param> /// <param name="target"></param> /// <param name="options"></param> /// <param name="soupName"></param> /// <returns></returns> public static SyncState CreateSyncDown(SmartStore.Store.SmartStore store, SyncDownTarget target, string soupName, SyncOptions options = null) { var sync = new JObject { {Constants.SyncType, SyncTypes.SyncDown.ToString()}, {Constants.SyncTarget, target.AsJson()}, {Constants.SyncSoupName, soupName}, {Constants.SyncStatus, SyncStatusTypes.New.ToString()}, {Constants.SyncProgress, 0}, {Constants.SyncTotalSize, -1}, {Constants.SyncMaxTimeStamp, -1}, }; if (options != null) { sync[Constants.SyncOptions] = options.AsJson(); } JObject upserted = store.Upsert(Constants.SyncsSoup, sync); if (upserted != null) { return FromJson(upserted); } sync[Constants.SyncStatus] = SyncStatusTypes.Failed.ToString(); return FromJson(sync); }
public static void TestSetup(TestContext context) { Store = SmartStore.GetGlobalSmartStore(); Store.ResetDatabase(); Store.RegisterSoup(TEST_SOUP, new[] { new IndexSpec("key", SmartStoreType.SmartString) }); }
public static SmartStore GetSmartStore(Account account) { var store = new SmartStore(account); store.CreateMetaTables(); return store; }
public static SmartStore GetSmartStore(Account account) { var store = new SmartStore(account); return store; }
/// <summary> /// Build SyncState from store sync given by id /// </summary> /// <param name="store"></param> /// <param name="id"></param> /// <returns></returns> public static SyncState ById(SmartStore.Store.SmartStore store, long id) { JArray syncs = store.Retrieve(Constants.SyncsSoup, id); if (syncs == null || syncs.Count == 0) { return null; } return FromJson(syncs[0] as JObject); }
public static SmartStore GetGlobalSmartStore() { var store = new SmartStore(null); // generate a "global" smartstore return store; }
public static void TestSetup(TestContext context) { Store = SmartStore.GetGlobalSmartStore(); Store.ResetDatabase(); Store.RegisterSoup(TEST_SOUP, new[] {new IndexSpec("key", SmartStoreType.SmartString)}); }
public static SmartStore GetGlobalSmartStore() { var store = new SmartStore(null); // generate a "global" smartstore store.CreateMetaTables(); return store; }
public static SmartStore GetSmartStore() { var store = new SmartStore(); return store; }
public SmartStoreExtension() { _store = SmartStore.GetSmartStore(); CreateAccountsSoup(); CreateOpportunitiesSoup(); }