public async Task Init() { if (LocalDBExists) { return; } var store = new MobileServiceSQLiteStore("syncstore.db"); store.DefineTable <Order>(); store.DefineTable <Account>(); store.DefineTable <Category>(); store.DefineTable <Product>(); try { await _MobileServiceClient.SyncContext.InitializeAsync(store); } catch (Exception ex) { Debug.WriteLine(@"Failed to initialize sync context: {0}", ex.Message); Insights.Report(ex, Insights.Severity.Error); } _OrderTable = _MobileServiceClient.GetSyncTable <Order>(); _AccountTable = _MobileServiceClient.GetSyncTable <Account>(); _CategoryTable = _MobileServiceClient.GetSyncTable <Category>(); _ProductTable = _MobileServiceClient.GetSyncTable <Product>(); }
public async Task Init() { if (MobileService.SyncContext.IsInitialized) { return; } var path = "syncstore.db"; var store = new MobileServiceSQLiteStore(path); store.DefineTable <Order>(); store.DefineTable <Account>(); store.DefineTable <Contact>(); try { await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler()); } catch (Exception ex) { Debug.WriteLine(@"Sync Failed: {0}", ex.Message); } orderTable = MobileService.GetSyncTable <Order>(); accountTable = MobileService.GetSyncTable <Account>(); contactTable = MobileService.GetSyncTable <Contact>(); }
public async Task Init() { if (MobileService.SyncContext.IsInitialized) { return; } var store = new MobileServiceSQLiteStore("syncstore.db"); store.DefineTable <Order>(); store.DefineTable <Account>(); try { await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler()); } catch (Exception ex) { Debug.WriteLine(@"Sync Failed: {0}", ex.Message); Insights.Report(ex, Insights.Severity.Error); } _OrderTable = MobileService.GetSyncTable <Order>(); _AccountTable = MobileService.GetSyncTable <Account>(); }
public AzureClient() { _client = new MobileServiceClient(ServiceUri); var store = new MobileServiceSQLiteStore(DbPath); store.DefineTable <Login>(); store.DefineTable <PurchaseOrder>(); store.DefineTable <PurchaseOrderItem>(); _client.SyncContext.InitializeAsync(store); _loginTable = _client.GetSyncTable <Login>(); _purchaseOrderTable = _client.GetSyncTable <PurchaseOrder>(); _purchaseOrderItemTable = _client.GetSyncTable <PurchaseOrderItem>(); }
private ItemManager() { client = new MobileServiceClient(Constants.ServiceURL); LocalStore = new MobileServiceSQLiteStore(Constants.LocalDbName); applicationservice = new ApplicationService(); LocalStore.DefineTable <E_Shop_Xamarin.Models.Image>(); LocalStore.DefineTable <Item>(); LocalStore.DefineTable <Cart>(); client.SyncContext.InitializeAsync(LocalStore); imageTable = client.GetSyncTable <E_Shop_Xamarin.Models.Image>(); itemTable = client.GetSyncTable <Item>(); cartTable = client.GetSyncTable <Cart>(); }
public async Task PullAsync_Should_Be_Able_To_Pull_A_Data() { //Arrange var table = _instance.GetSyncTable <TodoItem>(); //Act var query = table.CreateQuery().Where(e => e.Name.Contains("Task")).OrderBy(e => e.Name); await table.PullAsync("pulltest", query); var data = table.ToList("pulltest"); //Assert Assert.IsTrue(data.Count > 0); Assert.IsInstanceOfType(table, typeof(IMobileServiceCrudTable <TodoItem>)); }
public async Task <List <T> > GetAll <T>() { InitializedCheck(); var table = _mobileServiceClient.GetSyncTable <T>(); return(await table.ToListAsync()); }
public async Task InitializeAsync() { this.MobileService = new MobileServiceClient(MobileUrl, new LoggingHandler()); // string filename = "local.db"; // string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // string libraryPath = Path.Combine(documentsPath, "..", "Library"); // var path = Path.Combine(libraryPath, filename); // var path = Path.Combine(documentsPath, filename); // if (!File.Exists(path)) // { // File.Create(path).Dispose(); // } //var store = new MobileServiceSQLiteStore(path); var store = new MobileServiceSQLiteStore("local.db"); store.DefineTable <Job>(); jobTable = MobileService.GetSyncTable <Job>(); await MobileService.SyncContext.InitializeAsync(store, StoreTrackingOptions.NotifyLocalAndServerOperations); // jobTable = MobileService.GetSyncTable<Job>(); }
public async Task ReadAsync_RoundTripsBytes() { const string tableName = "bytes_test_table"; ResetDatabase(tableName); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable(tableName, new JObject { { "id", String.Empty }, { "data", new byte[0] } }); var hijack = new TestHttpHandler(); IMobileServiceClient service = await CreateClient(hijack, store); IMobileServiceSyncTable table = service.GetSyncTable(tableName); byte[] theData = { 0, 128, 255 }; JObject inserted = await table.InsertAsync(new JObject { { "data", theData } }); Assert.Equal(theData, inserted["data"].Value <byte[]>()); JObject rehydrated = await table.LookupAsync(inserted["id"].Value <string>()); Assert.Equal(theData, rehydrated["data"].Value <byte[]>()); }
public async Task ReadAsync_RoundTripsBytes_Generic() { const string tableName = "BytesType"; ResetDatabase(tableName); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable <BytesType>(); var hijack = new TestHttpHandler(); IMobileServiceClient service = await CreateClient(hijack, store); IMobileServiceSyncTable <BytesType> table = service.GetSyncTable <BytesType>(); byte[] theData = { 0, 128, 255 }; BytesType inserted = new BytesType { Data = theData }; await table.InsertAsync(inserted); Assert.Equal(inserted.Data, theData); BytesType rehydrated = await table.LookupAsync(inserted.Id); Assert.Equal(rehydrated.Data, theData); }
public async Task InsertAsync_Throws_IfItemAlreadyExistsInLocalStore() { ResetDatabase(TestTable); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable(TestTable, new JObject() { { "id", String.Empty }, { "String", String.Empty } }); var hijack = new TestHttpHandler(); IMobileServiceClient service = await CreateClient(hijack, store); string pullResult = "[{\"id\":\"abc\",\"String\":\"Wow\"}]"; hijack.AddResponseContent(pullResult); hijack.AddResponseContent("[]"); IMobileServiceSyncTable table = service.GetSyncTable(TestTable); await table.PullAsync(null, null); var ex = await Assert.ThrowsAsync <MobileServiceLocalStoreException>(() => table.InsertAsync(new JObject() { { "id", "abc" } })); Assert.Equal("An insert operation on the item is already in the queue.", ex.Message); }
public async Task ReadAsync_RoundTripsDate() { string tableName = "itemWithDate"; ResetDatabase(tableName); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable(tableName, new JObject() { { "id", String.Empty }, { "date", DateTime.Now } }); var hijack = new TestHttpHandler(); IMobileServiceClient service = await CreateClient(hijack, store); IMobileServiceSyncTable table = service.GetSyncTable(tableName); DateTime theDate = new DateTime(2014, 3, 10, 0, 0, 0, DateTimeKind.Utc); JObject inserted = await table.InsertAsync(new JObject() { { "date", theDate } }); Assert.Equal(inserted["date"].Value <DateTime>(), theDate); JObject rehydrated = await table.LookupAsync(inserted["id"].Value <string>()); Assert.Equal(rehydrated["date"].Value <DateTime>(), theDate); }
public AzureClient() { _client = new MobileServiceClient(Helpers.Settings.AzureUrl); _table = _client.GetSyncTable <T>(); }
public async Task ReadAsync_RoundTripsDate_Generic() { string tableName = "NotSystemPropertyCreatedAtType"; ResetDatabase(tableName); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable <NotSystemPropertyCreatedAtType>(); var hijack = new TestHttpHandler(); IMobileServiceClient service = await CreateClient(hijack, store); IMobileServiceSyncTable <NotSystemPropertyCreatedAtType> table = service.GetSyncTable <NotSystemPropertyCreatedAtType>(); DateTime theDate = new DateTime(2014, 3, 10, 0, 0, 0, DateTimeKind.Utc); var inserted = new NotSystemPropertyCreatedAtType() { __CreatedAt = theDate }; await table.InsertAsync(inserted); Assert.Equal(inserted.__CreatedAt.ToUniversalTime(), theDate); NotSystemPropertyCreatedAtType rehydrated = await table.LookupAsync(inserted.Id); Assert.Equal(rehydrated.__CreatedAt.ToUniversalTime(), theDate); }
public async Task PullAsync_TriggersPush_WhenPushOtherTablesIsTrue_AndThereIsOperationTable() { ResetDatabase(TestTable); TestUtilities.DropTestTable(TestDbName, "relatedTable"); TestUtilities.DropTestTable(TestDbName, "StringIdType"); var hijack = new TestHttpHandler(); hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}"); hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hi\"}"); hijack.AddResponseContent("[{\"id\":\"abc\",\"String\":\"Hey\"},{\"id\":\"def\",\"String\":\"World\"}]"); // for pull hijack.AddResponseContent("[]"); // last page var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable("relatedTable", new JObject() { { "id", String.Empty } }); store.DefineTable <StringIdType>(); IMobileServiceClient client = await CreateClient(hijack, store); // insert item in pull table IMobileServiceSyncTable unrelatedTable = client.GetSyncTable("relatedTable"); await unrelatedTable.InsertAsync(new JObject() { { "id", "abc" } }); // then insert item in other table MobileServiceSyncTable <StringIdType> mainTable = client.GetSyncTable <StringIdType>() as MobileServiceSyncTable <StringIdType>; var item = new StringIdType() { Id = "abc", String = "what?" }; await mainTable.InsertAsync(item); await mainTable.PullAsync(null, null, null, true, CancellationToken.None); Assert.Equal(4, hijack.Requests.Count); // 2 for push and 2 for pull QueryEquals(hijack.Requests[0].RequestUri.AbsolutePath, "/tables/relatedTable"); QueryEquals(hijack.Requests[1].RequestUri.AbsolutePath, "/tables/StringIdType"); QueryEquals(hijack.Requests[1].RequestUri.AbsolutePath, "/tables/StringIdType"); QueryEquals(hijack.Requests[1].RequestUri.AbsolutePath, "/tables/StringIdType"); Assert.Equal(0L, client.SyncContext.PendingOperations); }
public async Task SystemPropertiesArePreserved_OnlyWhenReturnedFromServer() { ResetDatabase(TestTable); var hijack = new TestHttpHandler(); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable <ToDoWithSystemPropertiesType>(); IMobileServiceClient service = await CreateClient(hijack, store); IMobileServiceSyncTable <ToDoWithSystemPropertiesType> table = service.GetSyncTable <ToDoWithSystemPropertiesType>(); // first insert an item var updatedItem = new ToDoWithSystemPropertiesType() { Id = "b", String = "Hey", Version = "abc", CreatedAt = new DateTime(2013, 1, 1, 1, 1, 1, DateTimeKind.Utc), UpdatedAt = new DateTime(2013, 1, 1, 1, 1, 2, DateTimeKind.Utc) }; await table.UpdateAsync(updatedItem); var lookedupItem = await table.LookupAsync("b"); Assert.Equal("Hey", lookedupItem.String); Assert.Equal("abc", lookedupItem.Version); // we ignored the sys properties on the local object Assert.Equal(lookedupItem.CreatedAt, new DateTime(0, DateTimeKind.Utc)); Assert.Equal(lookedupItem.UpdatedAt, new DateTime(0, DateTimeKind.Utc)); Assert.Equal(1L, service.SyncContext.PendingOperations); // operation pending hijack.OnSendingRequest = async req => { string content = await req.Content.ReadAsStringAsync(); Assert.Equal(@"{""id"":""b"",""String"":""Hey""}", content); // the system properties are not sent to server return(req); }; string updateResult = "{\"id\":\"b\",\"String\":\"Wow\",\"version\":\"def\",\"createdAt\":\"2014-01-29T23:01:33.444Z\", \"updatedAt\":\"2014-01-30T23:01:33.444Z\"}"; hijack.Responses.Add(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(updateResult) }); // push await service.SyncContext.PushAsync(); Assert.Equal(0L, service.SyncContext.PendingOperations); // operation removed lookedupItem = await table.LookupAsync("b"); Assert.Equal("Wow", lookedupItem.String); Assert.Equal("def", lookedupItem.Version); // we preserved the system properties returned from server on update Assert.Equal(lookedupItem.CreatedAt.ToUniversalTime(), new DateTime(2014, 01, 29, 23, 1, 33, 444, DateTimeKind.Utc)); Assert.Equal(lookedupItem.UpdatedAt.ToUniversalTime(), new DateTime(2014, 01, 30, 23, 1, 33, 444, DateTimeKind.Utc)); }
private TodoItemManager() { this.client = new MobileServiceClient(Constants.ApplicationURL); var store = new MobileServiceSQLiteStore("localstore.db"); store.DefineTable<TodoItem>(); this.client.SyncContext.InitializeAsync(store); this.todoTable = client.GetSyncTable<TodoItem>(); }
//private IMobileServiceTable<TodoItem> todoTable = App.MobileService.GetTable<TodoItem>(); public MainPageViewModel() { _mobileService = new MobileServiceClient( "https://isvacceleratoreumar.azurewebsites.net", "https://default-web-eastus744386286bdd4ad5816e8100d15de451.azurewebsites.net", ""); _todoTable = _mobileService.GetSyncTable<TodoItem>(); }
public BaseAzureRest() { Client = new MobileServiceClient(ServiceUri); var store = new MobileServiceSQLiteStore(DbPath); store.DefineTable <TObject>(); Client.SyncContext.InitializeAsync(store); Table = Client.GetSyncTable <TObject>(); }
public AzureClient() { _remoteClient = new MobileServiceClient("http://midemo.azurewebsites.net/"); var store = new MobileServiceSQLiteStore(DB_PATH); store.DefineTable <ToDoItem>(); _remoteClient.SyncContext.InitializeAsync(store); _todoItemsTable = _remoteClient.GetSyncTable <ToDoItem>(); }
public CategoryDirectoryService() { Client = new MobileServiceClient(MyAppServiceURL); var store = new MobileServiceSQLiteStore(dbPath); store.DefineTable <Category>(); Client.SyncContext.InitializeAsync(store); Table = Client.GetSyncTable <Category>(); }
void InitializeOfflineStore() { var store = new MobileServiceSQLiteStore(AppConstants.DB_FILENAME); store.DefineTable <Ticket>(); _client.SyncContext.InitializeAsync(store); _ticketsTable = _client.GetSyncTable <Ticket>(); }
private ContactsManager() { client = new MobileServiceClient("https://appcontact.azurewebsites.net"); var store = new MobileServiceSQLiteStore("contact2.db"); store.DefineTable <Contact>(); this.client.SyncContext.InitializeAsync(store); contactTable = client.GetSyncTable <Contact>(); }
public AzureClient() { _client = new MobileServiceClient("http://midemoxamarintiempo.azurewebsites.net"); var store = new MobileServiceSQLiteStore(dbPath); store.DefineTable <Client>(); _client.SyncContext.InitializeAsync(store); _table = _client.GetSyncTable <Client>(); }
public AzureClient() { _client = new MobileServiceClient(serviceUri); var store = new MobileServiceSQLiteStore(dbPath); store.DefineTable <Contact>(); _client.SyncContext.InitializeAsync(store); _table = _client.GetSyncTable <Contact>(); }
private TodoItemManager() { this.client = new MobileServiceClient(Constants.ApplicationURL); var store = new MobileServiceSQLiteStore("localstore.db"); store.DefineTable <TodoItem>(); this.client.SyncContext.InitializeAsync(store); this.todoTable = client.GetSyncTable <TodoItem>(); }
public AzureServiceClient() { _client = new MobileServiceClient(serviceUri); var store = new MobileServiceSQLiteStore(localDbPath); store.DefineTable <Customer>(); _client.SyncContext.InitializeAsync(store); _customerTable = _client.GetSyncTable <Customer>(); }
public WebApiSyncPageViewModel() { _mobileServiceClient = MobileServiceClient.Instance; _crudTodotTable = _mobileServiceClient.GetSyncTable <CustomItem>(); Device.BeginInvokeOnMainThread(async() => { await LoadTasks(); }); }
public ODataQueryStatusPageViewModel() { _mobileServiceClient = MobileServiceClient.Instance; _crudTodotTable = _mobileServiceClient.GetSyncTable <TodoItem>(); Device.BeginInvokeOnMainThread(async() => { await LoadTasks(); }); }
public ODataFunctionPageViewModel( IMobileServiceClient mobileServiceClient, IDeviceService deviceService, IPageDialogService dialogService) { _mobileServiceClient = mobileServiceClient; _deviceService = deviceService; _dialogService = dialogService; _crudTodotTable = mobileServiceClient.GetSyncTable <TodoItem>(); }
public async Task PushAsync_PushesAllTables_WhenEmptyListIsGiven() { ResetDatabase(TestTable); TestUtilities.DropTestTable(TestDbName, "someTable"); TestUtilities.DropTestTable(TestDbName, "StringIdType"); var hijack = new TestHttpHandler(); hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}"); hijack.AddResponseContent("{\"id\":\"abc\",\"String\":\"Hey\"}"); var store = new MobileServiceSQLiteStore(TestDbName); store.DefineTable("someTable", new JObject() { { "id", String.Empty } }); store.DefineTable <StringIdType>(); IMobileServiceClient client = await CreateClient(hijack, store); // insert item in pull table IMobileServiceSyncTable table1 = client.GetSyncTable("someTable"); await table1.InsertAsync(new JObject() { { "id", "abc" } }); // then insert item in other table MobileServiceSyncTable <StringIdType> table2 = client.GetSyncTable <StringIdType>() as MobileServiceSyncTable <StringIdType>; var item = new StringIdType() { Id = "abc", String = "what?" }; await table2.InsertAsync(item); await(client.SyncContext as MobileServiceSyncContext).PushAsync(CancellationToken.None); Assert.Equal(2, hijack.Requests.Count); QueryEquals(hijack.Requests[0].RequestUri.AbsolutePath, "/tables/someTable"); QueryEquals(hijack.Requests[1].RequestUri.AbsolutePath, "/tables/StringIdType"); Assert.Equal(0L, client.SyncContext.PendingOperations); }
public InfiniteScrollPageViewModel() { _mobileServiceClient = MobileServiceClient.Instance; _crudTodotTable = _mobileServiceClient.GetSyncTable <TodoItem>(); Device.BeginInvokeOnMainThread(async() => { TodoItems = new ObservableCollection <TodoItem>(); await LoadTasks(); }); }
public async Task InitializeAsync() { this.MobileService = new MobileServiceClient(MobileUrl, new LoggingHandler()); var store = new MobileServiceSQLiteStore("local.db"); store.DefineTable<Job>(); await MobileService.SyncContext.InitializeAsync(store, StoreTrackingOptions.NotifyLocalAndServerOperations); jobTable = MobileService.GetSyncTable<Job>(); }
public async Task InitializeAsync() { this.MobileService = new MobileServiceClient(MobileUrl, new LoggingHandler()); var store = new MobileServiceSQLiteStore("local.db"); store.DefineTable<Job>(); await MobileService.SyncContext.InitializeAsync(store, StoreTrackingOptions.NotifyLocalAndServerOperations); jobTable = MobileService.GetSyncTable<Job>(); // This sample doesn't do any authentication. To add it, see // https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-forms-get-started-users/ }
public async Task InitializeAsync() { this.MobileService = AppService.CreateMobileServiceClient( MobileAppURL, ""); // 3. initialize local store var store = new MobileServiceSQLiteStore("local-db-" + MobileAppName); store.DefineTable<Job>(); await MobileService.SyncContext.InitializeAsync(store); jobTable = MobileService.GetSyncTable<Job>(); }
public async Task InitializeAsync() { this.MobileService = AppService.CreateMobileServiceClient( "https://fetechnician-code.azurewebsites.net/", "OtFsjAFDBBMENsPCBQFJmItwjvAfaX77"); // 3. initialize local store var store = new MobileServiceSQLiteStore("local-db-fabrikam80"); store.DefineTable<Job>(); await MobileService.SyncContext.InitializeAsync(store); jobTable = MobileService.GetSyncTable<Job>(); }