Ejemplo n.º 1
0
//==============================================================================================
/// <summary>
/// Initialize the _controller table.
/// </summary>
/// <returns></returns>
//==============================================================================================
        private async Task InitializeAsync()
        {
            if (_controller == null)
            {             
                _controller = _dataStore.CloudService.GetSyncTable<Organization>();                
            }
        }
        protected override async void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init ();

            // Create the Mobile Service Client instance, using the provided
            // Mobile Service URL
            client = new MobileServiceClient(applicationURL);
            await InitLocalStoreAsync();

            // Set the current instance of TodoActivity.
            instance = this;

            // Make sure the GCM client is set up correctly.
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            // Get the Mobile Service sync table instance to use
            toDoTable = client.GetSyncTable <ToDoItem> ();

            textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
            listViewToDo.Adapter = adapter;

            //// Load the items from the Mobile App backend.
            //OnRefreshItemsSelected ();
        }
Ejemplo n.º 3
0
        public async Task Initialize()
        {
            if (isInitialized)
                return;

            var time = Xamarin.Insights.TrackTime("InitializeTime");
            time.Start();
            
            //Create our client
            MobileService = new MobileServiceClient("https://mycoffeeapp.azurewebsites.net");

            const string path = "syncstore.db";
            //setup our local sqlite store and intialize our table
            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable<CupOfCoffee>();

            await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            //Get our sync table that will call out to azure
            coffeeTable = MobileService.GetSyncTable<CupOfCoffee>();

            isInitialized = true;
            time.Stop();
        }
Ejemplo n.º 4
0
        protected override async void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init ();

            // Create the Mobile Service Client instance, using the provided
            // Mobile Service URL and key
            client = new MobileServiceClient (applicationURL, applicationKey);
            await InitLocalStoreAsync();

            // Get the Mobile Service sync table instance to use
            toDoTable = client.GetSyncTable <ToDoItem> ();

            textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
            listViewToDo.Adapter = adapter;

            // Load the items from the Mobile Service
            OnRefreshItemsSelected ();
        }
Ejemplo n.º 5
0
        public async Task Initialize()
        {
            if (isInitialized)
                return;

            var time = Xamarin.Insights.TrackTime("InitializeTime");
            time.Start();
            

            var handler = new AuthHandler();
            //Create our client
            MobileService = new MobileServiceClient("https://mycoffeeapp.azurewebsites.net", handler);
            handler.Client = MobileService;

            if (!string.IsNullOrWhiteSpace (Settings.AuthToken) && !string.IsNullOrWhiteSpace (Settings.UserId)) {
                MobileService.CurrentUser = new MobileServiceUser (Settings.UserId);
                MobileService.CurrentUser.MobileServiceAuthenticationToken = Settings.AuthToken;
            }
            
            const string path = "syncstore.db";
            //setup our local sqlite store and intialize our table
            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable<CupOfCoffee>();

            await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            //Get our sync table that will call out to azure
            coffeeTable = MobileService.GetSyncTable<CupOfCoffee>();

            isInitialized = true;
            time.Stop();
        }
Ejemplo n.º 6
0
      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>();
      }
Ejemplo n.º 7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ToDo.TodoItemManager"/> class.
		/// </summary>
		public TodoItemManager ()
		{
			// Create the service client and make sure to use the native network stack via ModernHttpClient's NativeMessageHandler.
			this.client = new MobileServiceClient (Constants.ApplicationURL, Constants.GatewayURL, new CustomMessageHandler ());

			// This is where we want to store our local data.
			this.store = new MobileServiceSQLiteStore (((App)App.Current).databaseFolderAndName);

			// Create the tables.
			this.store.DefineTable<TodoItem> ();

			// Initializes the SyncContext using a specific IMobileServiceSyncHandler which handles sync errors.
			this.client.SyncContext.InitializeAsync (store, new SyncHandler ());

			// The ToDo items should be synced.
			this.todoTable = client.GetSyncTable<TodoItem> ();

			// Uncomment to clear all local data to have a fresh start. Then comment out again.
			//this.todoTable.PurgeAsync();


			// Create a Sqlite-Net connection to the SAME DB that is also used for syncing.
			// Everything that gets inserted via this connection will not be synced.
			// Azure Mobile always syncs everything, so we have to either use an alternative database or use  another API to acces the same DB.
			this.sqliteNetConn = new SQLiteAsyncConnection (((App)App.Current).databaseFolderAndName);
			this.sqliteNetConn.CreateTableAsync<ConfigItem> ();
		}
		public async Task InitializeAsync()
		{
			var store = new MobileServiceSQLiteStore("localdata.db");
			store.DefineTable<PolicyHistory> ();
			await this.MobileService.SyncContext.InitializeAsync(store);

			phTable = this.MobileService.GetSyncTable<PolicyHistory>();
		}
Ejemplo n.º 9
0
        public async Task InitializeAsync()
        {
            var store = new MobileServiceSQLiteStoreWithLogging("localdata.db");
            store.DefineTable<Job> ();
            await this.MobileService.SyncContext.InitializeAsync(store);

            jobTable = this.MobileService.GetSyncTable<Job>();
        }
		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>();
		}
        protected override async void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Activity_To_Do);

            progressBar = FindViewById<ProgressBar> (Resource.Id.loadingProgressBar);

            // Initialize the progress bar
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler ();
            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null) 
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
            };

            try {
                CurrentPlatform.Init ();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient (
                    applicationURL,
                    applicationKey, progressHandler);

                string path = 
                    Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "localstore.db");
                
                if (!File.Exists(path))
                {
                    File.Create(path).Dispose();
                }
                var store = new MobileServiceSQLiteStore(path);
                store.DefineTable<ToDoItem>();
                await client.SyncContext.InitializeAsync(store, new SyncHandler(this));

                // Get the Mobile Service Table instance to use
                toDoTable = client.GetSyncTable <ToDoItem> ();

                textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);

                // Create an adapter to bind the items with the view
                adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
                var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
                listViewToDo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync ();

            } catch (Java.Net.MalformedURLException) {
                CreateAndShowDialog (new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error");
            } catch (Exception e) {
                CreateAndShowDialog (e, "Error");
            }
        }
        //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>();
        }
Ejemplo n.º 13
0
		public ServicesRepository()
		{
			_mobileService = new MobileServiceClient("YOUR URL HERE", "YOUR APP SECRET HERE");
			_categoryTable = _mobileService.GetSyncTable<Category>();
			_serviceTypeTable = _mobileService.GetSyncTable<ServiceType>();
			_productTable = _mobileService.GetSyncTable<Product>();
			_productInfoTable = _mobileService.GetSyncTable<ProductInformation>();
			InitLocalStore();
		}
    public async Task Init()
    {
      initialized = true;
      string path = "syncstore.db";
      var store = new MobileServiceSQLiteStore(path);
      store.DefineTable<TripExpense>();
      await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

      expenseTable = MobileService.GetSyncTable<TripExpense>();
    }
 // currently only tests that a single file has been added
 private async Task TestFiles(IMobileServiceSyncTable<DataEntity> table, string name, string content)
 {
     var files = await table.GetFilesAsync(item);
     Assert.Equal(1, files.Count());
     Assert.Equal(name, files.ElementAt(0).Name);
     using (var stream = await table.GetFileAsync(item, name))
     {
         Assert.Equal(content, new StreamReader(stream).ReadToEnd());
     }
 }
        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>();
        }
        private QSTodoService ()
        {
            CurrentPlatform.Init ();
            SQLitePCL.CurrentPlatform.Init(); 

            // Initialize the Mobile Service client with the Mobile App URL, Gateway URL and key
            client = new MobileServiceClient (applicationURL);

            // Create an MSTable instance to allow us to work with the TodoItem table
            todoTable = client.GetSyncTable <ToDoItem> ();
        }
        private QSTodoService ()
        {
            CurrentPlatform.Init ();
            SQLitePCL.Batteries.Init(); 

            // Initialize the client with the mobile app backend URL.
            client = new MobileServiceClient (applicationURL);

            // Create an MSTable instance to allow us to work with the TodoItem table
            todoTable = client.GetSyncTable <ToDoItem> ();
        }
        public async Task InitLocalDBSyncTables()
        {
            await InitLocalStoreAsync();

            // Get the Mobile Service sync table instance to use
            employeeSyncTable = client.GetSyncTable<EmployeeItem>();
            eventSyncTable = client.GetSyncTable<EventItem>();
            recipientListSyncTable = client.GetSyncTable<RecipientListItem>();

            // Load the items from the Mobile Service
            await SyncAsync(pullData: true);
        }
Ejemplo n.º 20
0
 public AzureDataService()
 {
     this.client = new MobileServiceClient(App.ApplicationURL);
     var store = new MobileServiceSQLiteStore("gomonkeystore.db");
     store.DefineTable<Monkey>(); 
     this.monkeyTable = this.client.GetSyncTable<Monkey>();
     this.client.InitializeFileSyncContext(new ImagesFileSyncHandler<Monkey>(monkeyTable), store);
     this.client.SyncContext.InitializeAsync(store, StoreTrackingOptions.AllNotifications);
     var dispose = this.client.EventManager.Subscribe<Microsoft.WindowsAzure.MobileServices.Eventing.IMobileServiceEvent>((e) => {
         System.Diagnostics.Debug.WriteLine("Event Handled: " + e.Name);
     });
 }
Ejemplo n.º 21
0
		public async Task Init()
		{
			initialized = true;
			const string path = "syncstore.db";
			var store = new MobileServiceSQLiteStore(path);
			store.DefineTable<Store>();
			store.DefineTable<Feedback> ();
			await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

			storeTable = MobileService.GetSyncTable<Store>();
			feedbackTable = MobileService.GetSyncTable<Feedback> ();
		}
Ejemplo n.º 22
0
        public SensorModel()
        {
            // initialize mobile services and SQLLite store
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
#if __IOS__
            SQLitePCL.CurrentPlatform.Init();
#endif

            // initialize the client with your app url and key
            client = new MobileServiceClient(applicationURL, applicationKey);
            // create sync table instance
            sensorDataTable = client.GetSyncTable<SensorDataItem>();
        }
Ejemplo n.º 23
0
        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>();
        }
Ejemplo n.º 24
0
        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/
        }
Ejemplo n.º 25
0
        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>();
        }
        private LocationMeasurementManager()
        {
            this._client = new MobileServiceClient(ConstantsRt.ApplicationUrl);

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore(offlineDbPath);
            store.DefineTable <LocationMeasurement>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.locationMeasurementTable = client.GetSyncTable <LocationMeasurement>();
#else
            this._locationMeasurementTable = _client.GetTable <LocationMeasurement>();
#endif
        }
Ejemplo n.º 27
0
        public async Task Initialize()
        {
            //Create our client
            MobileService = new MobileServiceClient("http://empleadomobile.azurewebsites.net");

            const string path = "syncstore.db";

            //setup our local sqlite store and intialize our table
            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable <Job>();
            await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            //Get our sync table that will call out to azure
            JobsTable = MobileService.GetSyncTable <Job>();
        }
Ejemplo n.º 28
0
        //Nuevo Constructor
        public App(string db)
        {
            InitializeComponent();
            MainPage = new NavigationPage(new MainPage());
            //asignamos la dirección que recibe el constructor
            DbLocation = db;
            //el data store necesita la dirección de la bdd en el celular
            var store = new MobileServiceSQLiteStore(db);

            //definición de la tabla en el mobile Service
            store.DefineTable <Post>();
            //Contexto de la tabla
            MobileService.SyncContext.InitializeAsync(store);
            //Metodo que permite leer a tabla de local y si se puede de la nube
            postsTable = MobileService.GetSyncTable <Post>();
        }
Ejemplo n.º 29
0
        private SBAManager()
        {
            this.client = new MobileServiceClient("https://sbat1.azurewebsites.net");

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore("localstore.db");
            store.DefineTable <TodoItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.todoTable = client.GetSyncTable <TodoItem>();
#else
            this.todoTable = client.GetTable <String>();
#endif
        }
Ejemplo n.º 30
0
        public bool CheckServiceAccess()
        {
            try
            {
                this.itemTable   = this.client.GetSyncTable <Item>();
                this.statusTable = this.client.GetSyncTable <Status>();

                return(this.itemTable is IMobileServiceSyncTable <Item>);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(false);
        }
Ejemplo n.º 31
0
        public App(string databaseLocation)
        {
            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());

            DatabaseLocation = databaseLocation;

            var store = new MobileServiceSQLiteStore(databaseLocation);

            store.DefineTable <Post>();

            MobileService.SyncContext.InitializeAsync(store);

            postsTable = MobileService.GetSyncTable <Post>();
        }
        public async Task Initialize()
        {
            DefaultManager = new MobileServiceClient(BaseUrl);

            var path = "baches.db";

            path = Path.Combine(MobileServiceClient.DefaultDatabasePath, path);

            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable <Bache>();

            await DefaultManager.SyncContext.InitializeAsync(store);

            bacheTable = DefaultManager.GetSyncTable <Bache>();
        }
Ejemplo n.º 33
0
        private TodoItemManager()
        {
            this.client = new MobileServiceClient(Constants.ApplicationURL);

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore(offlineDbPath);
            store.DefineTable <TodoItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.todoTable = client.GetSyncTable <TodoItem>();
#else
            this.todoTable = client.GetTable <TodoItem>();
#endif
        }
Ejemplo n.º 34
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            //TODO show IOC vs Dependency injection
            //			SimpleIoc.Default.Register<ISqlite> (new SqliteDroid ());
            SimpleIoc.Default.Register<Data.ISqlite>(() => new SqliteDroid());

			activityTable = client.GetSyncTable<CaAPA.Data.Activities> ();

            await InitLocalStoreAsync();

            LoadApplication(new App());

        }
Ejemplo n.º 35
0
        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);
        }
Ejemplo n.º 36
0
        public async Task PushAsync_DiscardsOperationAndDeletesTheItem_WhenCancelAndDiscardItemAsync()
        {
            ResetDatabase(TestTable);

            var    hijack         = new TestHttpHandler();
            string conflictResult = "{\"id\":\"b\",\"String\":\"Wow\",\"version\":\"def\"}";

            hijack.Responses.Add(new HttpResponseMessage(HttpStatusCode.PreconditionFailed)
            {
                Content = new StringContent(conflictResult)
            });                                                                                                                               // first push

            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"
            };
            await table.UpdateAsync(updatedItem);

            // then push it to server
            var ex = await Assert.ThrowsAsync <MobileServicePushFailedException>(service.SyncContext.PushAsync);

            Assert.NotNull(ex.PushResult);
            MobileServiceTableOperationError error = ex.PushResult.Errors.FirstOrDefault();

            Assert.NotNull(error);

            Assert.Equal(1L, service.SyncContext.PendingOperations); // operation is not removed
            updatedItem = await table.LookupAsync("b");

            Assert.Equal("Hey", updatedItem.String); // item is not updated

            await error.CancelAndDiscardItemAsync();

            Assert.Equal(0L, service.SyncContext.PendingOperations); // operation is removed
            updatedItem = await table.LookupAsync("b");

            Assert.Null(updatedItem); // item is deleted
        }
Ejemplo n.º 37
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init();

            // Create the client instance, using the mobile app backend URL.
            client = new MobileServiceClient(applicationURL);

            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            manager = ItemManager.DefaultManager;

            // Set the current instance of TodoActivity.
            instance = this;
            // Make sure the GCM client is set up correctly.
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);
            // Register the app for push notifications.
            GcmClient.Register(this, ToDoBroadcastReceiver.senderIDs);


#if OFFLINE_SYNC_ENABLED
            await InitLocalStoreAsync();

            // Get the sync table instance to use to store TodoItem rows.
            todoTable = client.GetSyncTable <ToDoItem>();
#else
            todoTable = client.GetTable <ToDoItem>();
#endif

            textNewToDo = FindViewById <EditText>(Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById <ListView>(Resource.Id.listViewToDo);
            listViewToDo.Adapter = adapter;

            Button btnRegistrar = FindViewById <Button>(Resource.Id.btnRegistrar);

            btnRegistrar.Click += btnRegistrar_ClickAsync;

            // Load the items from the mobile app backend.
            OnRefreshItemsSelected();
        }
    protected async void LocalInsertReportableFocusEvent(ReportableFocusEvent rfe)
    {
        Assert.IsNotNull <ReportableFocusEvent>(rfe);

        IMobileServiceSyncTable <ReportableFocusEvent> localTable = Client.GetSyncTable <ReportableFocusEvent>();

        try
        {
            await localTable.InsertAsync(rfe);

            Debug.Log($"Recording: {rfe.EventType} on {rfe.EntityName} at {rfe.LocalPosition}");
        }
        catch (Exception e)
        {
            Debug.LogError(e.ToString());
        }
    }
Ejemplo n.º 39
0
        private QSTodoService()
        {
            CurrentPlatform.Init();

            // Initialize the client with the mobile app backend URL.
            client = PinnacleApp.Client;

#if OFFLINE_SYNC_ENABLED
            // Initialize the store
            //Task.Run(async() => await InitStoreAsync());

            // Create an MSTable instance to allow us to work with the TodoItem table
            //todoTable = client.GetSyncTable<ToDoItem>();
#else
            todoTable = client.GetTable <ToDoItem>();
#endif
        }
Ejemplo n.º 40
0
        private AzureDataStore()
        {
            this.client = new MobileServiceClient(
                "https://ourtaskstemp.azurewebsites.net");

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore(offlineDbPath);
            store.DefineTable <ToDoItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.itemTable = client.GetSyncTable <ToDoItem>();
#else
            this.itemTable = client.GetTable <ToDoItem>();
#endif
        }
Ejemplo n.º 41
0
        private BudgetCategoryManager()
        {
            this.client = new MobileServiceClient(
                Constants.ApplicationURL);

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore("localstore.db");
            store.DefineTable <BudgetItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.todoTable = client.GetSyncTable <BudgetCategory>();
#else
            this.budgetCategoryTable = client.GetTable <BudgetCategory>();
#endif
        }
        public async Task Initialize()
        {
            if (_mobileServiceClient?.SyncContext?.IsInitialized ?? false)
            {
                return;
            }

            const string path = "syncstore.db";
            //setup our local sqlite store and intialize our table
            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable <Message>();
            await _mobileServiceClient.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            //Get our sync table that will call out to azure
            _messageTable = _mobileServiceClient.GetSyncTable <Message>();
        }
Ejemplo n.º 43
0
        async Task InitializeDataStore()
        {
            if (azureClient.SyncContext.IsInitialized)
            {
                return;
            }

            var store = new MobileServiceSQLiteStore("foodie.db");

            store.DefineTable <Recipe>();

            await azureClient.SyncContext.InitializeAsync(store);

            recipeTable = azureClient.GetSyncTable <Recipe>();

            await SyncOfflineCache();
        }
        public async Task InitAsync()
        {
            // Setup local database
            var path  = Path.Combine(MobileServiceClient.DefaultDatabasePath, "syncstore.db");
            var store = new MobileServiceSQLiteStore(path);

            // Define local tables to sync with
            store.DefineTable <Session>();
            store.DefineTable <Speaker>();

            // Initialize SyncContext
            await client.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            // Get our sync table that will call out to azure
            sessionTable = client.GetSyncTable <Session>();
            speakerTable = client.GetSyncTable <Speaker>();
        }
Ejemplo n.º 45
0
        private void Initialize()
        {
            this.client = new MobileServiceClient(
                Constants.ApplicationURL);

            var store = new MobileServiceSQLiteStore("localstore.db");

            if (!client.SyncContext.IsInitialized)
            {
                store.DefineTable <Sessions>();
                store.DefineTable <Speakers>();
                client.SyncContext.InitializeAsync(store);
            }

            tablaSesion  = client.GetSyncTable <Sessions>();
            tablaSpeaker = client.GetSyncTable <Speakers>();
        }
Ejemplo n.º 46
0
        private AzureCouponManager()
        {
            this.client = new MobileServiceClient(Constants.AzureMobileService);

#if OFFLINE_SYNC_ENABLED
            var store = new MobileServiceSQLiteStore(offlineDbPath);
            store.DefineTable <TodoItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            this.client.SyncContext.InitializeAsync(store);

            this.todoTable = client.GetSyncTable <TodoItem>();
            Console.WriteLine("inside constructor");
#else
            this.couponTable = client.GetTable <CouponSchedule>();
#endif
        }
Ejemplo n.º 47
0
        public void Init()
        {
            if (_startedIniting)
            {
                return;
            }
            _startedIniting = true;
            CurrentPlatform.Init();

            SQLitePCL.CurrentPlatform.Init();

            // Initialize the Mobile Service client with your URL and key
            _client = new MobileServiceClient(ApplicationUrl, ApplicationKey, _instance);

            // Create an MSTable instance to allow us to work with the TodoItem table
            _table = _instance._client.GetSyncTable <EventItem>();
        }
Ejemplo n.º 48
0
        public async Task DownloadFileAsync <T>(IMobileServiceSyncTable <T> table, MobileServiceFile file, string targetPath, int attempt = 0)
        {
            try
            {
                await table.DownloadFileAsync(file, targetPath);
            }
            catch (UnauthorizedAccessException)
            {
                DeleteLocalFile(file);

                if (attempt < 3)
                {
                    await Task.Delay(300)
                    .ContinueWith(async t => await DownloadFileAsync(table, file, targetPath, attempt++));
                }
            }
        }
Ejemplo n.º 49
0
        private FavoritesManager()
        {
            this.client = new MobileServiceClient(CoreConstants.ApplicationURL);

#if OFFLINE_SYNC_ENABLED
            MobileServiceSQLiteStore store = new MobileServiceSQLiteStore("localfavorites.db");
            store.DefineTable <Favorite>();
            store.DefineTable <Registration>();

            this.client.SyncContext.InitializeAsync(store);
            this.favoritesTable     = client.GetSyncTable <Favorite>();
            this.registrationsTable = client.GetSyncTable <Registration>();
#else
            this.favoritesTable     = client.GetTable <Favorite>();
            this.registrationsTable = client.GetTable <Registration>();
#endif
        }
Ejemplo n.º 50
0
        public async Task InitializeAsync()
        {
            if (MobileService?.SyncContext?.IsInitialized ?? false)
            {
                return;
            }

            MobileService = new MobileServiceClient(PCL_AppConstants.sCurrentServiceURL);
            string path = "appX007.db";

            var store = new MobileServiceSQLiteStoreWithLogging(path, PCL_AppConstants.bLogSqlLite);

            store.DefineTable <TodoItem>();
            await MobileService.SyncContext.InitializeAsync(store);

            itemsTable = MobileService.GetSyncTable <T>();
        }
Ejemplo n.º 51
0
        private QSTodoService()
        {
            CurrentPlatform.Init();

            // Initialize the client with the mobile app backend URL.
            client = new MobileServiceClient(applicationURL);

#if OFFLINE_SYNC_ENABLED
            // Initialize the store
            InitializeStoreAsync().Wait();

            // Create an MSTable instance to allow us to work with the TodoItem table
            todoTable = client.GetSyncTable <ToDoItem>();
#else
            todoTable = client.GetTable <ToDoItem>();
#endif
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Resets the local store.
        /// </summary>
        async Task ResetLocalStoreAsync()
        {
            _AcquaintanceTable = null;

            // On UWP, it's necessary to Dispose() and nullify the MobileServiceSQLiteStore before
            // trying to delete the database file, otherwise an access exception will occur
            // because of an open file handle. It's okay to do for iOS and Android as well, but not necessary.
            _MobileServiceSQLiteStore?.Dispose();
            _MobileServiceSQLiteStore = null;


            await DeleteOldLocalDatabase().ConfigureAwait(false);

            _IsInitialized = false;
            Settings.LocalDataResetIsRequested = false;
            Settings.DataIsSeeded = false;
        }
        public async Task InitializeAsync()
        {
            if (isInitialized)
            {
                return;
            }

            var store = new MobileServiceSQLiteStore(_dbPath);

            store.DefineTable <ToDoItem>();

            await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            itemsTable = MobileService.GetSyncTable <ToDoItem>();

            isInitialized = true;
        }
Ejemplo n.º 54
0
        public async Task Initialize()
        {
            if (MobileService?.SyncContext?.IsInitialized ?? false)
            {
                return;
            }

            MobileService = new MobileServiceClient("http://projectservermobile.azurewebsites.net");

            const string path = "offlinetimesheetstore.db";

            storez = new MobileServiceSQLiteStore(path);
            storez.DefineTable <OfflineTimesheetModel>();
            await MobileService.SyncContext.InitializeAsync(storez);

            offlineTimesheet = MobileService.GetSyncTable <OfflineTimesheetModel>();
        }
Ejemplo n.º 55
0
        public async Task Init()
        {
            initialized = true;
            const string path  = "syncstore.db";
            var          store = new MobileServiceSQLiteStore(path);

            store.DefineTable <Store>();
            store.DefineTable <Feedback> ();
            //store.DefineTable<Region>();
            store.DefineTable <Favourites>();
            await MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            storeTable    = MobileService.GetSyncTable <Store>();
            feedbackTable = MobileService.GetSyncTable <Feedback> ();
            //regionTable = MobileService.GetSyncTable<Region>();
            favouriteTable = MobileService.GetSyncTable <Favourites>();
        }
Ejemplo n.º 56
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Create the Mobile Service Client instance, using the provided
            // Mobile Service URL
            client = new MobileServiceClient(applicationURL);

            // Get the Mobile Service sync table instance to use
            torneoItemTable = client.GetSyncTable <TorneoItem>();

            // Obtener una referencia al botón Siguiente
            btnRegistro = FindViewById <Button>(Resource.Id.BtnRegistro);
            // Registrar el manejador de evento click del botón Siguiente
            btnRegistro.Click += BtnSiguienteClick;
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			Xamarin.Forms.Forms.Init (this, bundle);

			#region Azure stuff
			CurrentPlatform.Init ();

			Client = new MobileServiceClient (
				Constants.Url, 
				Constants.Key);		


			#region Azure Sync stuff
			// http://azure.microsoft.com/en-us/documentation/articles/mobile-services-xamarin-android-get-started-offline-data/
			// new code to initialize the SQLite store
			string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "test1.db");

			if (!File.Exists(path))
			{
				File.Create(path).Dispose();
			}

			var store = new MobileServiceSQLiteStore(path);
			store.DefineTable<TodoItem>();

			Client.SyncContext.InitializeAsync(store).Wait();
			#endregion


			todoTable = Client.GetSyncTable<TodoItem>(); 
			todoItemManager = new TodoItemManager(Client, todoTable);

			App.SetTodoItemManager (todoItemManager);
			#endregion region

			#region Text to Speech stuff
			App.SetTextToSpeech (new Speech ());
			#endregion

			SetPage (App.GetMainPage ());
		}
		/// <summary>
		/// Initializes the backend service and connects with Azure
		/// </summary>
		/// <returns></returns>
		public static async Task InitAsync()
		{
			if (_IsInitialized)
				return;

			// Create the mobile client
			_MobileService = new MobileServiceClient("http://YOUR-MOBILE-SERVICE-URL");

			// Setup the local SQLite database
			var store = new MobileServiceSQLiteStore("mynotestore.db");
			store.DefineTable<Note>();
			await _MobileService.SyncContext.InitializeAsync(store);

			// Get tables for local database
			_NoteTable = _MobileService.GetSyncTable<Note>();		

			// Set initialized flag to avoid double initialisation
			_IsInitialized = true;
		}
        protected override async void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init ();

            // Create the Mobile Service Client instance, using the provided
            // Mobile Service URL and key
			client = new MobileServiceClient (AppConstant.applicationURL, AppConstant.applicationKey);
            await InitLocalStoreAsync();

			user = new MobileServiceUser(Intent.GetStringExtra("UserID"));
			user.MobileServiceAuthenticationToken = Intent.GetStringExtra("UserToken");

			client.CurrentUser = user;

			// Set the current instance of TodoActivity.
			instance = this;

			// Make sure the GCM client is set up correctly.
			GcmClient.CheckDevice(this);
			GcmClient.CheckManifest(this);

			// Register the app for push notifications.
			GcmClient.Register(this, ToDoBroadcastReceiver.senderIDs);

            // Get the Mobile Service sync table instance to use
            toDoTable = client.GetSyncTable <ToDoItem> ();

            textNewToDo = FindViewById<EditText> (Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter (this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById<ListView> (Resource.Id.listViewToDo);
            listViewToDo.Adapter = adapter;

            // Load the items from the Mobile Service
            OnRefreshItemsSelected ();
        }
Ejemplo n.º 60
0
        public async Task Initialize()
        {
            if (Client?.SyncContext?.IsInitialized ?? false)
                return;


            var appUrl = "https://ilovecoffee.azurewebsites.net";

#if AUTH      
            Client = new MobileServiceClient(appUrl, new AuthHandler());

            if (!string.IsNullOrWhiteSpace (Settings.AuthToken) && !string.IsNullOrWhiteSpace (Settings.UserId)) {
                Client.CurrentUser = new MobileServiceUser (Settings.UserId);
                Client.CurrentUser.MobileServiceAuthenticationToken = Settings.AuthToken;
            }
#else
            //Create our client

            Client = new MobileServiceClient(appUrl);

#endif

            //InitialzeDatabase for path
            var path = "syncstore.db";
            path = Path.Combine(MobileServiceClient.DefaultDatabasePath, path);

            //setup our local sqlite store and intialize our table
            var store = new MobileServiceSQLiteStore(path);

            //Define table
            store.DefineTable<CupOfCoffee>();


            //Initialize SyncContext
            await Client.SyncContext.InitializeAsync(store);

            //Get our sync table that will call out to azure
            coffeeTable = Client.GetSyncTable<CupOfCoffee>();

            
        }