Provides basic access to Mobile Services.
        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.º 2
0
    public AzureService()
    {
            //comment back in to enable Azure Mobile Services.
            MobileService = new MobileServiceClient("https://javusdemands.azurewebsites.net/");      

      expenseTable = MobileService.GetTable<Expense>();
    }
        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);
            }
        }
Ejemplo n.º 4
0
		public AzureDataStore()
		{
			// This is a sample read-only azure site for demo
			// Follow the readme.md in the GitHub repo on how to setup your own.
			MobileService =  new MobileServiceClient(
            "http://myshoppe-demo.azurewebsites.net");
		}
        public void Construction()
        {
            string appUrl = "http://www.test.com/";
            string appKey = "secret...";

            MobileServiceClient service = new MobileServiceClient(new Uri(appUrl), appKey);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(appKey, service.ApplicationKey);

            service = new MobileServiceClient(appUrl, appKey);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(appKey, service.ApplicationKey);

            service = new MobileServiceClient(new Uri(appUrl));
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(null, service.ApplicationKey);

            service = new MobileServiceClient(appUrl);
            Assert.AreEqual(appUrl, service.ApplicationUri.ToString());
            Assert.AreEqual(null, service.ApplicationKey);

            Uri none = null;
            Throws<ArgumentNullException>(() => new MobileServiceClient(none));
            Throws<FormatException>(() => new MobileServiceClient("not a valid uri!!!@#!@#"));
        }
 private async void Login(MobileServiceAuthenticationProvider provider)
 {
     var client = new MobileServiceClient(this.uriEntry.Value, this.keyEntry.Value);
     var user = await client.LoginAsync(this, provider);
     var alert = new UIAlertView("Welcome", "Your userId is: " + user.UserId, null, "OK");
     alert.Show();
 }
        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();
        }
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            ToggableNetworkInformation networkInfo = new ToggableNetworkInformation();

            SimpleIoc.Default.Register<INetworkInformation>(() => networkInfo);

            SimpleIoc.Default.Register<ICacheProvider, TimestampCacheProvider>();

            SimpleIoc.Default.Register<IStructuredStorage, SQLiteStructuredStorage>();

            SimpleIoc.Default.Register<NetworkInformationDelegate>(() =>
            {
                return new NetworkInformationDelegate(() => networkInfo.IsOnline, b => networkInfo.IsOnline = b);
            });

            SimpleIoc.Default.Register<MainViewModel>();

            DelegatingHandler handler = new CacheHandler(SimpleIoc.Default.GetInstance<ICacheProvider>());
                        
            // This MobileServiceClient has been configured to communicate with your Mobile Service's url
            // and application key. You're all set to start working with your Mobile Service!
            MobileServiceClient MobileService = new MobileServiceClient(
                "https://YOURAPP.azure-mobile.net/",
                "YOURKEY",
                handler
            );

            SimpleIoc.Default.Register<IMobileServiceClient>(() => MobileService);
        }
        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;
        }
		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;
		}
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            ToggableNetworkInformation networkInfo = new ToggableNetworkInformation();

            SimpleIoc.Default.Register<INetworkInformation>(() => networkInfo);

            SimpleIoc.Default.Register<IStructuredStorage>(() => new SQLiteStructuredStorage("cache"));
            SimpleIoc.Default.Register<ISynchronizer, TimestampSynchronizer>();
            SimpleIoc.Default.Register<Func<Uri, bool>>(() => (u => true));
            //SimpleIoc.Default.Register<ICacheProvider, DisabledCacheProvider>();
            SimpleIoc.Default.Register<ICacheProvider, TimestampCacheProvider>();

            SimpleIoc.Default.Register<NetworkInformationDelegate>(() =>
            {
                return new NetworkInformationDelegate(() => networkInfo.IsOnline, b => networkInfo.IsOnline = b);
            });

            SimpleIoc.Default.Register<MainViewModel>();

            DelegatingHandler handler = new CacheHandler(SimpleIoc.Default.GetInstance<ICacheProvider>());

            // Configure your mobile service here
            MobileServiceClient MobileService = new MobileServiceClient(
                Constants.MobileServiceUrl,
                Constants.MobileServiceKey,
                handler
            );

            SimpleIoc.Default.Register<IMobileServiceClient>(() => MobileService);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            mobileServiceClient = new MobileServiceClient("AZURE_URL_GOES_HERE", "AZURE_API_KEY_GOES_HERE");
        }
Ejemplo n.º 13
0
        public async Task<MobileServiceUser> LoginAsync(MobileServiceClient client, MobileServiceAuthenticationProvider provider)
        {
            try
            {
                var window = UIKit.UIApplication.SharedApplication.KeyWindow;
                var root = window.RootViewController;
                if(root != null)
                {
                    var current = root;
                    while(current.PresentedViewController != null)
                    {
                        current = current.PresentedViewController;
                    }


                    Settings.LoginAttempts++;

                    var user = await client.LoginAsync(current, provider);

                    Settings.AuthToken = user?.MobileServiceAuthenticationToken ?? string.Empty;
                    Settings.UserId = user?.UserId ?? string.Empty;

                    return user;
                }
            }
            catch(Exception e)
            {
                e.Data["method"] = "LoginAsync";
                Xamarin.Insights.Report(e);
            }

            return null;
        }
        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();
        }
Ejemplo n.º 15
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> ();
		}
Ejemplo n.º 16
0
        public App()
        {

            TelemetryConfiguration.Active.InstrumentationKey = "5afcb70e-e5b7-41c5-9e57-aa6fb9f08c2a";
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session |
                Microsoft.ApplicationInsights.WindowsCollectors.PageView |
                Microsoft.ApplicationInsights.WindowsCollectors.UnhandledException
        );
            InitializeComponent();
            SplashFactory = (e) => new Views.Splash(e);
            #region TelemetryClient Init
            Telemetry = new TelemetryClient();
            #endregion
           MobileService =
new MobileServiceClient(
    "https://petrolheadappuwp.azurewebsites.net"
);
            #region App settings

            var _settings = SettingsService.Instance;
            RequestedTheme = _settings.AppTheme;
            CacheMaxDuration = _settings.CacheMaxDuration;
            ShowShellBackButton = _settings.UseShellBackButton;

            #endregion
        }
Ejemplo n.º 17
0
      public MainPage()
      {
         this.InitializeComponent();

         _mobileService = new MobileServiceClient( PixelPrinterPlugin.GetServiceUrl( _environment ) );
         _mobileService.AlternateLoginHost = new Uri( PixelPrinterPlugin.GetServiceUrl( PixelPrinterPlugin.TargetEnvironment.Live ) );
      }
Ejemplo n.º 18
0
 public void RegisterForRemotePushNotifications(MobileServiceClient client, string channelName)
 {
     // Register for push with Mobile Services
     IEnumerable<string> tag = new List<string>() { channelName };
     var push = client.GetPush();
     push.RegisterNativeAsync(DeviceToken, tag);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Singleton 응용 프로그램 개체를 초기화합니다.  이것은 실행되는 작성 코드의 첫 번째
        /// 줄이며 따라서 main() 또는 WinMain()과 논리적으로 동일합니다.
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            /*** Injecting objects to public static instances ***/

            // App
            MobileService = new MobileServiceClient(
                "https://pinthecloud.azure-mobile.net/",
                "yvulzHAGRgNsGnPLHKcEFCPJcuyzKj23"
            );
            ApplicationSessions = new WSApplicationSessions();
            ApplicationSettings = new WSApplicationSettings();

            // Manager
            SpotManager = new SpotManager();
            Geolocator = new Geolocator();
            BlobStorageManager = new BlobStorageManager();
            LocalStorageManager = new LocalStorageManager();

            OneDriveManager = new OneDriveManager();
            DropBoxManager = new DropboxManager();
            GoogleDriveManger = new GoogleDriveManager();

            /////////////////////////////////////////////////////
            // This order will be displayed at every App Pages
            /////////////////////////////////////////////////////
            StorageHelper.AddStorageManager(OneDriveManager.GetStorageName(), OneDriveManager);
            StorageHelper.AddStorageManager(DropBoxManager.GetStorageName(), DropBoxManager);
            StorageHelper.AddStorageManager(GoogleDriveManger.GetStorageName(), GoogleDriveManger);
            Switcher.SetStorageToMainPlatform();
            AccountManager = new AccountManager();
        }
 /// <summary>
 /// Initializes a new instance of the MobileServiceTables class.
 /// </summary>
 /// <param name="tableName">The name of the table.</param>
 /// <param name="client">
 /// Reference to the MobileServiceClient associated with this table.
 /// </param>
 public MobileServiceTable(string tableName, MobileServiceClient client)
 {
     Debug.Assert(tableName != null, "tableName cannot be null!");
     Debug.Assert(client != null, "client cannot be null!");
     this.TableName = tableName;
     this.MobileServiceClient = client;            
 }
Ejemplo n.º 21
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.º 22
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.º 23
0
        protected override void OnCreate(Bundle bundle)
        {
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;
            FormsAppCompatActivity.ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);



            // 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 ProjectPandaClient = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
                "https://projectpanda.azurewebsites.net");

            //auth code for android
            global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);



            global::Xamarin.Forms.Forms.Init(this, bundle);
            //Calender view code
            XamForms.Controls.Droid.Calendar.Init();

            //Lottie Animation android code
            AnimationViewRenderer.Init();

            #region Local database for android devices
            string dbName     = "userSettingsdb.sqlite";
            string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            string fullPath   = Path.Combine(folderPath, dbName);
            #endregion


            LoadApplication(new ProjectPanda.App(fullPath));
        }
Ejemplo n.º 24
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            ClearTextbox();
            
            try
            {
                SelLoginIDDupeCheck selLoginIDDupeCheck = new SelLoginIDDupeCheck();
                //selLoginIDDupeCheck.memberID = crypto
                
                var client = new MobileServiceClient(serverURL.Text, serverKey.Password);
                string j = @"{""memberID"": ""aaa"" }";

                //토큰 = body 텍스트 - 으로 바로 로드
                inputTextbox.Text = j;
                JToken token = JObject.Parse(j);

                var orderResult = await client.InvokeApiAsync("CBSelLoginIDDupeCheck", token);
                outputTextbox.Text = orderResult.ToString();

            }
                catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
 public ServicioDatosImpl()
 {
     
     client=new MobileServiceClient(Cadenas.UrlServicio,
         Cadenas.TokenServicio);
     
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Versucht Login, ohne einen entsprechenden Dialog zu zu zeigen.
        /// </summary>
        /// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
        internal static async Task<MobileServiceUser> AuthenticateSilent(MobileServiceClient mobileService)
        {
            LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
            session = (await liveAuthClient.InitializeAsync()).Session;
            return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);

        }
Ejemplo n.º 27
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();
        }
Ejemplo n.º 28
0
        public ImagesListViewModel(MobileServiceClient client)
        {
            _client = client;

            //_UserName = "******";
            //_AlbumName = "Demo Album";
        }
        /// <summary>
        /// Utility method that can be used to execute a test.  It will capture any exceptions throw
        /// during the execution of the test and return a message with details of the exception thrown.
        /// </summary>
        /// <param name="testName">The name of the test being executed.
        /// </param>
        /// <param name="test">A test to execute.
        /// </param>
        /// <returns>
        /// Either the result of the test if the test passed, or a message with the exception
        /// that was thrown.
        /// </returns>
        public static async Task<string> ExecuteTest(string testName, Func<Task<string>> test)
        {
            string resultText = null;
            bool didPass = false;

            if (client == null)
            {
                string appUrl = null;
                App.Harness.Settings.Custom.TryGetValue("MobileServiceRuntimeUrl", out appUrl);

                client = new MobileServiceClient(appUrl);
            }

            try
            {
                resultText = await test();
                didPass = true;
            }
            catch (Exception exception)
            {
                resultText = string.Format("ExceptionType: {0} Message: {1} StackTrace: {2}",
                                               exception.GetType().ToString(),
                                               exception.Message,
                                               exception.StackTrace);
            }

            return string.Format("Test '{0}' {1}.\n{2}",
                                 testName,
                                 didPass ? "PASSED" : "FAILED",
                                 resultText);
        }
Ejemplo n.º 30
0
		static AzureDB ()
		{
			CurrentPlatform.Init ();
			MobileService = new MobileServiceClient (ApplicationURL, ApplicationKey);
			GetScoreTable ();
			GetUserAuthenticationTable ();
		}
Ejemplo n.º 31
0
partial         void AddClientSecrets(ref MobileServiceClient client)
        {
            client = new MobileServiceClient(
                "{ Mobile Service URL }",
                "{ Mobile Service key }"
            );
        }
Ejemplo n.º 32
0
 public static void Connect(string applicationUri, string applicationKey)
 {
     // the initialization should be done only once really, so locking the whole initial connection effort
     lock (syncLock)
     {
         if (mobileServiceClientInitialized != true)
         {
             mobileServiceClient            = new MobileServiceClient(applicationUri, applicationKey);
             mobileServiceClientInitialized = true;
         }
     }
 }
Ejemplo n.º 33
0
        protected override async void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            // 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 Mercury2Client = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
                "https://mercury2.azurewebsites.net");

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());

            await CrossMedia.Current.Initialize();

            //Initialize the azure mobile client
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
        }
Ejemplo n.º 34
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);
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="provider">
 /// Authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The uri scheme.
 /// </param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, MobileServiceAuthenticationProvider provider, string uriScheme, IDictionary <string, string> parameters)
 {
     return(LoginAsync(client, provider.ToString(), uriScheme, parameters));
 }
 /// <summary>
 /// Extension method to get a <see cref="Push"/> object made from an existing <see cref="MobileServiceClient"/>.
 /// </summary>
 /// <param name="client">
 /// The <see cref="MobileServiceClient"/> to create with.
 /// </param>
 /// <returns>
 /// The <see cref="Push"/> object used for registering for notifications.
 /// </returns>
 public static Push GetPush(this MobileServiceClient client)
 {
     return(new Push(client));
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="provider">
 /// Authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The uri scheme.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, string provider, string uriScheme)
 {
     return(LoginAsync(client, provider, uriScheme, null));
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Log a user into a Mobile Services application given a provider name.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="provider">
        /// Authentication provider to use.
        /// </param>
        /// <param name="uriScheme">
        /// The uri scheme.
        /// </param>
        /// <param name="parameters">
        /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
        /// </param>
        /// <returns>
        /// Task that will complete when the user has finished authentication.
        /// </returns>
        public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, string provider, string uriScheme, IDictionary <string, string> parameters)
        {
            MobileServiceUIAuthentication auth = new MobileServiceUIAuthentication(client, provider, uriScheme, parameters);

            return(auth.LoginAsync());
        }
Ejemplo n.º 39
0
 /// <summary>
 /// Initializes a new instance of the MobileServiceTables class.
 /// </summary>
 /// <param name="tableName">The name of the table.</param>
 /// <param name="client">
 /// Reference to the MobileServiceClient associated with this table.
 /// </param>
 public MobileServiceTable(string tableName, MobileServiceClient client)
     : base(tableName, client)
 {
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Resume login process with the specified URL.
 /// </summary>
 public static void ResumeWithURL(this MobileServiceClient client, Uri uri)
 {
     MobileServiceUIAuthentication.CurrentAuthenticator?.OnResponseReceived(uri);
 }
Ejemplo n.º 41
0
 internal Push(MobileServiceClient client)
     : this(client, string.Empty, null)
 {
 }
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">The MobileServiceClient instance to login with</param>
 /// <param name="rectangle">The area in <paramref name="view"/> to anchor to.</param>
 /// <param name="view">UIView used to display a popover from on iPad.</param>
 /// <param name="provider">Authentication provider to use.</param>
 /// <param name="uriScheme">The URL scheme of the application.</param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, RectangleF rectangle, UIView view, string provider, string uriScheme, IDictionary <string, string> parameters)
 => LoginAsync(client, rectangle, (object)view, provider, uriScheme, parameters);
 public MobileServiceUIAuthentication(Context context, MobileServiceClient client, string providerName, string uriScheme, IDictionary <string, string> parameters)
     : base(client, providerName, uriScheme, parameters)
 {
     this.context = context;
 }
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">The MobileServiceClient instance to login with</param>
 /// <param name="viewController">UIViewController used to display modal login UI on iPhone/iPods.</param>
 /// <param name="provider">Authentication provider to use.</param>
 /// <param name="uriScheme">The URL scheme of the application.</param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, UIViewController viewController, string provider, string uriScheme)
 => LoginAsync(client, viewController, provider, uriScheme, parameters: null);
        /// <summary>
        /// Resume login process with the specified URL.
        /// </summary>
#pragma warning disable IDE0060 // Remove unused parameter
        public static bool ResumeWithURL(this MobileServiceClient client,
#pragma warning restore IDE0060 // Remove unused parameter
                                         UIApplication app, NSUrl url, NSDictionary options)
        {
            return(Xamarin.Essentials.Platform.OpenUrl(app, url, options));
        }
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">The MobileServiceClient instance to login with</param>
 /// <param name="viewController">UIViewController used to display modal login UI on iPhone/iPods.</param>
 /// <param name="provider">Authentication provider to use.</param>
 /// <param name="uriScheme">The URL scheme of the application.</param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, UIViewController viewController, string provider, string uriScheme, IDictionary <string, string> parameters)
 => LoginAsync(client, default, viewController, provider, uriScheme, parameters);
 /// <summary>
 /// Initializes a new instance of the MobileServiceLogin class.
 /// </summary>
 /// <param name="client">
 /// Reference to the MobileServiceClient associated with this table.
 /// </param>
 /// <param name="ignoreFilters">
 /// Optional parameter to indicate if the client filters should be ignored
 /// and requests should be sent directly. Is <c>true</c> by default. This should
 /// only be set to false for testing purposes when filters are needed to intercept
 /// and validate requests and responses.
 /// </param>
 public MobileServiceLogin(MobileServiceClient client, bool ignoreFilters = true)
 {
     Debug.Assert(client != null, "client should not be null.");
     this.Client        = client;
     this.IgnoreFilters = ignoreFilters;
 }
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">The MobileServiceClient instance to login with</param>
 /// <param name="rectangle">The area in <paramref name="view"/> to anchor to.</param>
 /// <param name="view">UIView used to display a popover from on iPad.</param>
 /// <param name="provider">Authentication provider to use.</param>
 /// <param name="uriScheme">The URL scheme of the application.</param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, RectangleF rectangle, UIView view, MobileServiceAuthenticationProvider provider, string uriScheme)
 => LoginAsync(client, rectangle, view, provider, uriScheme, parameters: null);
Ejemplo n.º 49
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="provider">
 /// Authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The uri scheme.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, MobileServiceAuthenticationProvider provider, string uriScheme)
 {
     return(LoginAsync(client, provider, uriScheme, parameters: null));
 }
 /// <summary>
 /// Instantiates a new instance of <see cref="MobileServiceUIAuthentication"/>.
 /// </summary>
 /// <param name="client">
 /// The client.
 /// </param>
 /// <param name="provider">
 /// The authentication provider.
 /// </param>
 /// <param name="uriScheme">
 /// The uri scheme.
 /// </param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 public MobileServiceUIAuthentication(MobileServiceClient client, string provider, string uriScheme, IDictionary <string, string> parameters)
     : base(client, provider, uriScheme, parameters)
 {
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Initializes a new instance of the MobileServiceTables class.
 /// </summary>
 /// <param name="tableName">
 /// The name of the table.
 /// </param>
 /// <param name="client">
 /// The <see cref="MobileServiceClient"/> associated with this table.
 /// </param>
 public MobileServiceTable(string tableName, MobileServiceClient client)
     : base(tableName, client)
 {
     this.queryProvider = new MobileServiceTableQueryProvider();
 }
 public MobileServiceUIAuthentication(RectangleF rect, object view, MobileServiceClient client, string providerName, string uriScheme, IDictionary <string, string> parameters)
     : base(client, providerName, uriScheme, parameters)
 {
     this.rect = rect;
     this.view = view;
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="viewController" type="MonoTouch.UIKit.UIViewController">
 /// UIViewController used to display modal login UI on iPhone/iPods.
 /// </param>
 /// <param name="provider" type="MobileServiceAuthenticationProvider">
 /// Authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, UIViewController viewController, MobileServiceAuthenticationProvider provider, string uriScheme, IDictionary <string, string> parameters)
 {
     return(LoginAsync(client, default(RectangleF), viewController, provider.ToString(), uriScheme, parameters));
 }
 internal PushHttpClient(MobileServiceClient client)
 {
     this.client = client;
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="barButtonItem" type="MonoTouch.UIKit.UIBarButtonItem">
 /// UIBarButtonItem used to display a popover from on iPad.
 /// </param>
 /// <param name="provider" type="string">
 /// The name of the authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, UIBarButtonItem barButtonItem, string provider, string uriScheme, IDictionary <string, string> parameters)
 {
     return(LoginAsync(client, default(RectangleF), barButtonItem, provider, uriScheme, parameters));
 }
Ejemplo n.º 56
0
        internal static Task <MobileServiceUser> LoginAsync(MobileServiceClient client, RectangleF rect, object view, string provider, string uriScheme, IDictionary <string, string> parameters)
        {
            var auth = new MobileServiceUIAuthentication(rect, view, client, provider, uriScheme, parameters);

            return(auth.LoginAsync());
        }
Ejemplo n.º 57
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="rectangle" type="System.Drawing.RectangleF">
 /// The area in <paramref name="view"/> to anchor to.
 /// </param>
 /// <param name="view" type="MonoTouch.UIKit.UIView">
 /// UIView used to display a popover from on iPad.
 /// </param>
 /// <param name="provider" type="string">
 /// The name of the authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, RectangleF rectangle, UIView view, string provider, string uriScheme)
 {
     return(LoginAsync(client, rectangle, view, provider, uriScheme, parameters: null));
 }
Ejemplo n.º 58
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="barButtonItem" type="MonoTouch.UIKit.UIBarButtonItem">
 /// UIBarButtonItem used to display a popover from on iPad.
 /// </param>
 /// <param name="provider" type="string">
 /// The name of the authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, UIBarButtonItem barButtonItem, string provider, string uriScheme)
 {
     return(LoginAsync(client, barButtonItem, provider, uriScheme, parameters: null));
 }
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="context" type="Android.Content.Context">
 /// The Context to display the Login UI in.
 /// </param>
 /// <param name="provider" type="string">
 /// The name of the authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, Context context, string provider, string uriScheme)
 {
     return(LoginAsync(client, context, provider, uriScheme, parameters: null));
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Log a user into a Mobile Services application given a provider name.
 /// </summary>
 /// <param name="client" type="Microsoft.WindowsAzure.MobileServices.MobileServiceClient">
 /// The MobileServiceClient instance to login with
 /// </param>
 /// <param name="rectangle" type="System.Drawing.RectangleF">
 /// The area in <paramref name="view"/> to anchor to.
 /// </param>
 /// <param name="view" type="MonoTouch.UIKit.UIView">
 /// UIView used to display a popover from on iPad.
 /// </param>
 /// <param name="provider" type="MobileServiceAuthenticationProvider">
 /// Authentication provider to use.
 /// </param>
 /// <param name="uriScheme">
 /// The URL scheme of the application.
 /// </param>
 /// <param name="parameters">
 /// Provider specific extra parameters that are sent as query string parameters to login endpoint.
 /// </param>
 /// <returns>
 /// Task that will complete when the user has finished authentication.
 /// </returns>
 public static Task <MobileServiceUser> LoginAsync(this MobileServiceClient client, RectangleF rectangle, UIView view, MobileServiceAuthenticationProvider provider, string uriScheme, IDictionary <string, string> parameters)
 {
     return(LoginAsync(client, rectangle, (object)view, provider.ToString(), uriScheme, parameters));
 }