GetTable() 공개 메소드

Gets a reference to a table and its data operations.
public GetTable ( string tableName ) : IMobileServiceTable
tableName string The name of the table.
리턴 IMobileServiceTable
예제 #1
0
 public ConnectedChatService()
 {
     client = new MobileServiceClient(MobileServiceConfig.ApplicationUri,
         MobileServiceConfig.ApplicationKey);
     usersTable = client.GetTable<User>();
     contentsTable = client.GetTable<PhotoContent>();
     recordsTable = client.GetTable<PhotoRecord>();
 }
        public static ZumoTestGroup CreateTests()
        {
            ZumoTestGroup result = new ZumoTestGroup("Misc tests");
            
            result.AddTest(CreateFilterTestWithMultipleRequests(true));
            result.AddTest(CreateFilterTestWithMultipleRequests(false));

            result.AddTest(new ZumoTest("Validate that filter can bypass service", async delegate(ZumoTest test)
            {
                string json = "{'id':1,'name':'John Doe','age':33}".Replace('\'', '\"');
                var client = new MobileServiceClient(
                    ZumoTestGlobals.Instance.Client.ApplicationUri,
                    ZumoTestGlobals.Instance.Client.ApplicationKey,
                    new HandlerToBypassService(201, "application/json", json));
                var table = client.GetTable("TableWhichDoesNotExist");
                var item = new JObject();
                var inserted = await table.InsertAsync(item);
                List<string> errors = new List<string>();
                if (!Util.CompareJson(JObject.Parse(json), inserted, errors))
                {
                    foreach (var error in errors)
                    {
                        test.AddLog(error);
                    }

                    test.AddLog("Error comparing object returned by the filter");
                    return false;
                }
                else
                {
                    return true;
                }
            }));

            result.AddTest(CreateUserAgentValidationTest());
            result.AddTest(CreateParameterPassingTest(true));
            result.AddTest(CreateParameterPassingTest(false));

            result.AddTest(CreateOptimisticConcurrencyTest("Conflicts - client wins", (clientItem, serverItem) =>
            {
                var mergeResult = clientItem.Clone();
                mergeResult.Version = serverItem.Version;
                return mergeResult;
            }));
            result.AddTest(CreateOptimisticConcurrencyTest("Conflicts - server wins", (clientItem, serverItem) =>
            {
                return serverItem;
            }));
            result.AddTest(CreateOptimisticConcurrencyTest("Conflicts - Name from client, Number from server", (clientItem, serverItem) =>
            {
                var mergeResult = serverItem.Clone();
                mergeResult.Name = clientItem.Name;
                return mergeResult;
            }));

            result.AddTest(CreateSystemPropertiesTest(true));
            result.AddTest(CreateSystemPropertiesTest(false));

            return result;
        }
예제 #3
0
        private async void PerformUserLogin(object sender, System.Windows.Input.GestureEventArgs e)
        {
            username = userName.Text;
            phoneNo = userPhone.Text;

            if (MainPage.online == true)
            {
                Users user = new Users();
                user.Name = username;
                user.Phone_no = phoneNo;
                user.uri = "uri here";
                MobileService = new MobileServiceClient(
                     "https://shopappdata.azure-mobile.net/",
                       "dkwwuiuHYYQwbozjKaWRJYYpEiTjFt73"
                );
                userTable = MobileService.GetTable<Users>();

                await userTable.InsertAsync(user);
                user_id = user.Id;

                MainPage.settings.Add("id", user_id);
                MainPage.settings.Add("Pnumber", phoneNo);
                MainPage.settings.Add("name", username);
            }
            else
            {
                // Prompt
            }

            // TODO: send this username and phoneno. to be added into the database


            NavigationService.GoBack();
        }
        private async Task PrepareTableAsync(MobileServiceClient client)
        {
            // Make sure the table is empty
            IMobileServiceTable<Product> table = client.GetTable<Product>();
            IEnumerable<Product> results = await table.ReadAsync();

            foreach (Product item in results)
            {
                await table.DeleteAsync(item);
            }

            products = new Product[50];

            for (int i = 0; i < 50; i++)
            {
                string id = Guid.NewGuid().ToString();
                Product p = new Product()
                {
                    AvailableTime = TimeSpan.FromHours(i),
                    Id = id,
                    DisplayAisle = (short)(i + 10),
                    InStock = i % 2 == 0,
                    Name = "Product" + i,
                    OptionFlags = (byte)i,
                    OtherId = i,
                    Price = 30.09M,
                    Type = i % 2 == 0 ? ProductType.Food : ProductType.Furniture,
                    Weight = i % 2 == 0 ? 35.7f : (float?)null,
                };

                products[i] = p;

                await table.InsertAsync(p);
            }
        }
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);


			#region Azure stuff
			CurrentPlatform.Init ();
			Client = new MobileServiceClient (
				Constants.Url, 
				Constants.Key);	
			todoTable = Client.GetTable<TodoItem>(); 
			todoItemManager = new TodoItemManager(todoTable);

			App.SetTodoItemManager (todoItemManager);
			#endregion region

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

			// If you have defined a view, add it here:
			// window.RootViewController  = navigationController;
			window.RootViewController = App.GetMainPage ().CreateViewController ();

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
        private async Task PrepareTableAsync(MobileServiceClient client)
        {
            // Make sure the table is empty
            IMobileServiceTable<Product> table = client.GetTable<Product>();
            IEnumerable<Product> results = await table.ReadAsync();

            foreach (Product item in results)
            {
                await table.DeleteAsync(item);
            }

            for (int i = 0; i < 50; i++)
            {
                await table.InsertAsync(new Product()
                {
                    AvailableTime = TimeSpan.FromHours(i),
                    Id = Guid.NewGuid().ToString(),
                    DisplayAisle = (short)(i + 10),
                    InStock = i % 2 == 0,
                    Name = "Product" + i,
                    OptionFlags = (byte)i,
                    OtherId = i,
                    Price = 30.09M,
                    Type = i % 2 == 0 ? ProductType.Food : ProductType.Furniture,
                    Weight = i % 2 == 0 ? 35.7f : (float?)null,
                });
            }

            //make sure we do not have any timestamps saved for requests
            await this.CacheProvider.Purge();
        }
        public void WithFilter()
        {
            string appUrl = "http://www.test.com/";
            string appKey = "secret...";
            TestServiceFilter hijack = new TestServiceFilter();

            MobileServiceClient service =
                new MobileServiceClient(new Uri(appUrl), appKey)
                .WithFilter(hijack);

            // Ensure properties are copied over
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(appKey, service.ApplicationKey);

            // Set the filter to return an empty array
            hijack.Response.Content = new JsonArray().Stringify();

            service.GetTable("foo").ReadAsync("bar")
                .ContinueWith (t =>
                {
                    // Verify the filter was in the loop
                    Assert.That (hijack.Request.Uri.ToString(), Is.StringStarting (appUrl));
                    
                    Assert.Throws<ArgumentNullException>(() => service.WithFilter(null));
                }).WaitOrFail (Timeout);
            
        }
예제 #8
0
    public AzureService()
    {
            //comment back in to enable Azure Mobile Services.
            MobileService = new MobileServiceClient("https://javusdemands.azurewebsites.net/");      

      expenseTable = MobileService.GetTable<Expense>();
    }
        private async void RefreshItems()
        {
            // Verbinden zum MobileService:
            MobileServiceClient mobileServiceClient = new MobileServiceClient(
                  "https://machapp.azure-mobile.net/",
                  "wpLplVeEPPeUkElYJRSPrdrrDBIPDy95"
            );


            // Employee Tabelle laden. 
            IMobileServiceTable<Employee> employeeTable = mobileServiceClient.GetTable<Employee>();
            // Neuen Datensatz anlegen
            Employee em = new Employee() { Firstname = "Sebastian", Lastname = "Küsters" };
            // em in Datenbank speichern
            await employeeTable.InsertAsync(em);
            // Daten aus Tabelle Employee laden
            var empList = await employeeTable.ToCollectionAsync();
            // Neuen Datensatz ändern
            empList.Last().Firstname = "Sebastian Update :)";
            // Geänderten Datensatz speichern 
            await employeeTable.UpdateAsync(empList.Last());
            // Ersten Datensatz löschen 
            await employeeTable.DeleteAsync(empList.First());
            // Aktuellen Daten aus Tabelle laden 
            var updatedList = await employeeTable.ToCollectionAsync();

            // Einfach Breakpoint setzen und die Listen vergleichen ;) 
        }
예제 #10
0
        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

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

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			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 
            {
                // PUSH NOTIFICATIONS: Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
				// Initialize our Gcm Service Hub
				GcmService.Initialize(this);
				GcmService.Register(this);


				// MOBILE SERVICES: Setup azure mobile services - this is separate from push notifications
				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<TodoItem>();


				// USER INTERFACE: setup the Android UI
				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");
			}
		}
예제 #11
0
        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

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

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

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

			try 
            {
                // Check to ensure everything's setup right
                PushClient.CheckDevice(this);
                PushClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<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");
			}
		}
		public TodoItemManager ()
		{
			client = new MobileServiceClient (
				Constants.ApplicationURL,
				Constants.ApplicationKey);

			todoTable = client.GetTable<TodoItem> ();
		}
 private async void QueryHighscoreAndUpdateTile() {
     MobileServiceClient client = new MobileServiceClient("https://microchopper.azure-mobile.net/", "foobar");
     JToken token = await client.GetTable("highscores").ReadAsync("$orderby=score desc&$top=1");
     if (token[0] != null) {
         float highscore = (float)token[0]["score"];
         UpdateTileWithHighscore(highscore);
     }
 }
예제 #14
0
		public MonkeyService ()
		{
			CurrentPlatform.Init ();

			client = new MobileServiceClient (Constants.applicationUrl, this);

			// Create an MSTable instance to allow us to work with the TodoItem table
			monkeyTable = client.GetTable <MonkeyItem> ();
		}
		public MusicStoreManager()
		{
			client = new MobileServiceClient(
				Constants.ApplicationURL,
                Constants.GatewayURL,
				Constants.ApplicationKey);

			this.todoTable = client.GetTable<TodoItem>();
		}
예제 #16
0
    public AzureWebService()
    {
      // Update MobileServiceClient with your tables URL and Cliet Key.
      podcastClient = new MobileServiceClient(
        "https://<YOUR URL HERE>.azure-mobile.net/",
        "<YOUR CLIENT KEY HERE>");

      podcastTable = podcastClient.GetTable<PodcastEpisode>();
    }
 public ToDoItemManager()
 {
     _client = new MobileServiceClient(
         Constants.ApplicationURL,
         Constants.ApplicationKey);
         
     this._todoTable = _client.GetTable<ToDoItem>();
     App.SetTodoItemManager(this);
 }
예제 #18
0
		QSTodoService ()
		{
			CurrentPlatform.Init ();

			// Initialize the Mobile Service client with your URL and key
			client = new MobileServiceClient (applicationURL, applicationKey, this);

			// Create an MSTable instance to allow us to work with the TodoItem table
			todoTable = client.GetTable <ToDoItem> ();
		}
        private IMobileServiceTable<DataEntity> GetTable()
        {
            MobileServiceClient client = null;
#if WIN_APPS
            client = new MobileServiceClient((string)ApplicationData.Current.LocalSettings.Values["MobileAppUrl"]);
#else
             client = new MobileServiceClient(ConfigurationManager.AppSettings["MobileAppUrl"]);
#endif
            return client.GetTable<DataEntity>();
        }
예제 #20
0
		public TodoItemManager ()
		{
			// Establish a link to Azure
			client = new MobileServiceClient (
				Constants.ApplicationURL		// Azure no longer requires an Application Key
			);

			// Read any existing todo items from the Azure client
			todoTable = client.GetTable<TodoItem> ();
		}
예제 #21
0
        // Constructor
		protected TodoService()
		{
			CurrentPlatform.Init ();

            Items = new List<TodoItem>();

            // TODO:: Uncomment these lines to use Mobile Services			
			client = new MobileServiceClient (Constants.ApplicationURL, Constants.ApplicationKey, this);	
            todoTable = client.GetTable<TodoItem>(); // Create an MSTable instance to allow us to work with the TodoItem table
		}
예제 #22
0
        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
		protected override async void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

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

            // Initialize the progress bar
			progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
			progressBar.Visibility = ViewStates.Gone;

            // TODO:: Uncomment the following code when using a mobile service
            
			// Create ProgressFilter to handle busy state
			var progressHandler = new ProgressHandler ();
			progressHandler.BusyStateChange += (busy) => {
				if (progressBar != null) 
					progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
			};
                     

			try 
            {
                // TODO:: Uncomment the following code to create the mobile services client

				CurrentPlatform.Init ();
				// Create the Mobile Service Client instance, using the provided
				// Mobile Service URL and key
				client = new MobileServiceClient(
					Constants.ApplicationURL,
					Constants.ApplicationKey, progressHandler);

				// Get the Mobile Service Table instance to use
				todoTable = client.GetTable<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");
			}
		}
예제 #23
0
        private static async Task AsyncMain()
        {
            // Use this constructor instead after publishing to the cloud
            var mobileService = new MobileServiceClient(
                "https://wheresmytrain.azure-mobile.net/",
                "EPeYbipHNSFHMFJDrVcDlYVrxyUNzf38"
                );

            var obj = await mobileService.GetTable<TransitAlert>().ReadAsync();
            Console.WriteLine("Object Count: {0}", obj.Count());
        }
		// Constructor
		protected AzureStorageImplementation()
		{
			CurrentPlatform.Init ();

			Items = new List<TodoItem>();

			Client = new MobileServiceClient ("https://xamarin-todo.azure-mobile.net/", "", this);	
			//Client = new MobileServiceClient ("https://xamarin-todo.azure-mobile.net/", "555", this);	

			todoTable = Client.GetTable<TodoItem>(); // Create an MSTable instance to allow us to work with the TodoItem table
		}
예제 #25
0
        private async Task PrepareTableAsync(MobileServiceClient client)
        {
            // Make sure the table is empty
            IMobileServiceTable<Product> table = client.GetTable<Product>();
            IEnumerable<Product> results = await table.ReadAsync();

            foreach (Product item in results)
            {
                await table.DeleteAsync(item);
            }
        }
		QSTodoService ()
		{
			CurrentPlatform.Init ();

			// Initialize the Mobile Service client with your URL and key
			Common.InitializeClient (this);
			client = Common.MobileService;

			// Create an MSTable instance to allow us to work with the TodoItem table
			todoTable = client.GetTable <ToDoItem> ();
		}
예제 #27
0
        // Constructor
		protected TodoService()
		{
            Items = new List<TodoItem>();

			CurrentPlatform.Init ();
			// Initialize the Mobile Service client with your URL and key
			client = new MobileServiceClient(Constants.ApplicationURL, Constants.ApplicationKey, this);

			// Create an MSTable instance to allow us to work with the TodoItem table
			todoTable = client.GetTable <TodoItem>();
		}
        public AzureMobileService()
        {
            MobileServiceClient = new MobileServiceClient(
                             AppSettings.MobileServiceAddress,
                             AppSettings.MobileServiceApplicationKey
                    );

            itemsTable = MobileServiceClient.GetTable<Item>();
            
            if(AppSettings.CreateInitialSchemaForAzureMobileService)
                CreateInitialSchema();
        }
        private AzureClient()
        {
            try
            {
                _client = new MobileServiceClient("http://mouselight.azurewebsites.net");

                _imageQualityTable = _client.GetTable<ImageQualityError>();
            }
            catch (Exception)
            {
            }
        }
        public MainViewModel(IPopupService popupService, SynchronizationContext synchonizationContext)
        {
            var client = new MobileServiceClient(
                _mobileServiceUrl,
                _mobileServiceKey);

            _liveAuthClient = new LiveAuthClient(_mobileServiceUrl);
            
            // Apply a ServiceFilter to the mobile client to help with our busy indication
            _mobileServiceClient = client.WithFilter(new DotoServiceFilter(
                busy =>
                {
                    IsBusy = busy;
                }));
            _popupService = popupService;
            _synchronizationContext = synchonizationContext;
            _invitesTable = _mobileServiceClient.GetTable<Invite>();
            _itemsTable = _mobileServiceClient.GetTable<Item>();
            _profilesTable = _mobileServiceClient.GetTable<Profile>();
            _listMembersTable = _mobileServiceClient.GetTable<ListMembership>();
            _devicesTable = _mobileServiceClient.GetTable<Device>();
            _settingsTable = _mobileServiceClient.GetTable<Setting>();

            SetupCommands();

            LoadSettings();
        }
예제 #31
0
        public static void Insert <T>(T item, Action <CallbackResponse> OnInsertFinished)
        {
            Task.Run(() =>
            {
                Utils.RunOnWindowsUIThread(async() =>
                {
                    try
                    {
                        await mobileServiceClient.GetTable <T>().InsertAsync(item);
                    }
                    catch (Exception ex)
                    {
                        if (OnInsertFinished != null)
                        {
                            Utils.RunOnUnityAppThread(() =>
                            {
                                OnInsertFinished(new CallbackResponse {
                                    Status = CallbackStatus.Failure, Exception = ex
                                });
                            });
                        }
                        return;
                    }

                    if (OnInsertFinished != null)
                    {
                        Utils.RunOnUnityAppThread(() =>
                        {
                            OnInsertFinished(new CallbackResponse {
                                Status = CallbackStatus.Success, Exception = null
                            });
                        });
                    }
                });
            });
        }
예제 #32
0
        public List <Users> RetrieveUserData()
        {
            Task.Run(async() =>
            {
                // Initialization for Azure Mobile Apps
                Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
                // This MobileServiceClient has been configured to communicate with the Azure Mobile App and
                // Azure Gateway using the application url. You're all set to start working with your Mobile App!
                Microsoft.WindowsAzure.MobileServices.MobileServiceClient BopAppClient = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
                    "https://bopapp.azurewebsites.net");

                Console.WriteLine("MOBILE SERVICE CLIENT CONNECTED");

                //Mobile stored version of database.
                IMobileServiceTable <Users> table = BopAppClient.GetTable <Users>();

                Console.WriteLine("MOBILE SERVICE TABLE CONNECTED");

                try
                {
                    users = await table.ToListAsync();

                    Console.WriteLine("LOCATL TABLE CONNECTED. Size of array is == " + users.Count);
                }

                catch (System.Exception e)
                {
                    Console.WriteLine("ERROR: " + e.Message);
                }

                Console.WriteLine($"Are we on the UI thread? {Looper.MainLooper.Thread == Looper.MyLooper()?.Thread}");

                Console.WriteLine("Done fetching/calculating data");
            }).Wait();

            Console.WriteLine("retrievedUserData");
            return(users);
        }