Esempio n. 1
0
        private async void LoginOnTapped(object sender, TappedRoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(uID_tb.Text) || string.IsNullOrWhiteSpace(Pass_tb.Password))
            {
                MessageDialog ms = new MessageDialog("Username and/or password is empty.", "Drive2Wellness");
                await ms.ShowAsync();
            }
            else
            {
                uID  = uID_tb.Text;
                pass = Pass_tb.Password;

                //var response = WebRequest.Create(string.Format("http://drive2wellness.com/ws/ws_login.php?uname={0}&pwd={1}", uID, pass));

                HttpClient hc  = new HttpClient();
                var        req = await hc.GetAsync(string.Format("http://drive2wellness.com/ws/ws_login.php?uname={0}&pwd={1}", uID, pass));

                LoginModel objLoginModel;

                if (req.IsSuccessStatusCode)
                {
                    var res = await req.Content.ReadAsStringAsync();

                    objLoginModel = JsonHelper.Deserialize <LoginModel>(res);

                    if (objLoginModel.status == "true")
                    {
                        App.userName = objLoginModel.username;

                        #region saving state

                        oStorage.username = App.userName;
                        var objectStorageHelper = new ObjectStorageHelper <objStorageHelper>(StorageType.Local);
                        await objectStorageHelper.SaveAsync(oStorage);

                        #endregion

                        this.Frame.Navigate(typeof(MainPage));
                    }
                    else if (objLoginModel.status == "expire")
                    {
                        MessageDialog ms = new MessageDialog("Your Subscription is expired.", "Drive2Wellness");
                        await ms.ShowAsync();
                    }
                    else
                    {
                        MessageDialog ms = new MessageDialog("Username or password incorrect.", "Drive2Wellness");
                        await ms.ShowAsync();
                    }
                }
                else
                {
                    MessageDialog ms = new MessageDialog("Something went wrong, please try again.", "Drive2Wellness");
                    await ms.ShowAsync();
                }
            }
        }
Esempio n. 2
0
        public async Task SaveObjectUsingAHandle()
        {
            //Instantiate an object that we want to save
            var myPoco = new Poco();
            //new up ObjectStorageHelper specifying that we want to interact with the Local storage folder
            var osh = new ObjectStorageHelper <Poco>(StorageType.Local);
            //Save the object (via XML Serialization) to the specified folder, asynchronously
            await osh.SaveAsync(myPoco, handle);

            //No assertion. Just want to make sure that this completes successfully!
        }
Esempio n. 3
0
        public async Task SaveAndDeletePocoWithAHandle()
        {
            var osh  = new ObjectStorageHelper <Poco>(StorageType.Local);
            var poco = new Poco();
            await osh.SaveAsync(poco, handle);

            await osh.DeleteAsync(handle);

            var result = await osh.LoadAsync(handle);

            Assert.AreEqual(result, default(Poco));
        }
Esempio n. 4
0
        private void SaveButtonClick(object sender, RoutedEventArgs e)
        {
            var ircServer = CreateIrcServer();

            if (ircServer.invalid)
            {
                return;
            }

            if (servers == null)
            {
                servers     = new ObservableCollection <string>();
                serversList = new List <IrcServer>();
                serversSavedCombo.ItemsSource = servers;
            }

            foreach (var serverCheck in serversList)
            {
                if (serverCheck.name == server.Text)
                {
                    var name = serverCheck.name;
                    serversList.Remove(serverCheck);
                    servers.Remove(name);

                    serversListOSH.SaveAsync(serversList, Config.ServersListStore);
                    serversOSH.SaveAsync(servers, Config.ServersStore);
                    break;
                }
            }

            servers.Add(ircServer.name);
            serversList.Add(ircServer);

            serversSavedCombo.SelectedItem = ircServer.name;

            serversListOSH.SaveAsync(serversList, Config.ServersListStore);
            serversOSH.SaveAsync(servers, Config.ServersStore);
        }
Esempio n. 5
0
        public async Task SaveAndLoadTwoObjectsOfSameTypeUsingDifferentHandles()
        {
            var poco = new Poco()
            {
                IntProp = 1, StringProp = "one"
            };
            var anotherPoco = new Poco()
            {
                IntProp = 2, StringProp = "two"
            };
            var osh = new ObjectStorageHelper <Poco>(StorageType.Local);

            await osh.SaveAsync(poco, handle);

            await osh.SaveAsync(anotherPoco, handle2);

            var result = await osh.LoadAsync(handle);

            var anotherResult = await osh.LoadAsync(handle2);

            Assert.AreEqual(poco, result);
            Assert.AreEqual(anotherPoco, anotherResult);
        }
Esempio n. 6
0
        public async Task SaveListOfObjectsWhenObjectClassIsDefinedInAnotherProject()
        {
            var listOfPocos = new List <Poco>();

            listOfPocos.Add(new Poco());
            listOfPocos.Add(new Poco());

            var osh = new ObjectStorageHelper <List <Poco> >(StorageType.Local);
            await osh.SaveAsync(listOfPocos);

            var result = await osh.LoadAsync();

            CollectionAssert.AreEqual(listOfPocos, result);
        }
Esempio n. 7
0
        public async Task SaveAndLoadPocoUsingAHandle()
        {
            var poco = new Poco()
            {
                IntProp = 1, StringProp = "one"
            };
            var osh = new ObjectStorageHelper <Poco>(StorageType.Local);

            await osh.SaveAsync(poco, handle);

            var result = await osh.LoadAsync(handle);

            Assert.AreEqual(poco, result);
        }
Esempio n. 8
0
        public async Task SaveAndLoadListOfPocosUsingAHandle()
        {
            var listOfPocos = new List <Poco>();

            listOfPocos.Add(new Poco());
            listOfPocos.Add(new Poco());

            var osh = new ObjectStorageHelper <List <Poco> >(StorageType.Local);
            await osh.SaveAsync(listOfPocos, handle);

            var result = await osh.LoadAsync(handle);

            CollectionAssert.AreEqual(listOfPocos, result);
        }
Esempio n. 9
0
        public async Task HandleUnSerializableObject()
        {
            var dictionaryObj = new Dictionary <string, string>();

            dictionaryObj.Add("key", "value");
            string errMsg = null;

            try
            {
                var osh = new ObjectStorageHelper <Dictionary <string, string> >(StorageType.Local);
                await osh.SaveAsync(dictionaryObj);
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }
            Assert.AreEqual(true, errMsg.Contains("is not supported because it implements IDictionary"));
        }
Esempio n. 10
0
        public async Task SaveAndLoadTwoObjectsOfDifferentTypesUsingTheSameHandle()
        {
            var poco = new Poco()
            {
                IntProp = 1, StringProp = "one"
            };
            var poco2 = new Poco2()
            {
                IntProp = 2, StringProp = "two"
            };
            var osh  = new ObjectStorageHelper <Poco>(StorageType.Local);
            var osh2 = new ObjectStorageHelper <Poco2>(StorageType.Local);

            await osh.SaveAsync(poco, handle);

            await osh2.SaveAsync(poco2, handle);

            var result = await osh.LoadAsync(handle);

            var result2 = await osh2.LoadAsync(handle);

            Assert.AreEqual(poco, result);
            Assert.AreEqual(poco2, result2);
        }
Esempio n. 11
0
 public async Task Save <T>(T data)
 {
     var objectStorageHelper = new ObjectStorageHelper <T>(StorageType.Roaming);
     await objectStorageHelper.SaveAsync(data);
 }
Esempio n. 12
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity

            var saver = new ObjectStorageHelper<List<Card>>(StorageType.Roaming);

            await saver.SaveAsync(SimpleIoc.Default.GetInstance<MainViewModel>().Cards.ToList(), "Cards");

            deferral.Complete();
        }
Esempio n. 13
0
 /// <summary>
 /// Sauvegarde l'utilisateur dans l'espace de stockage local
 /// Afin d'éviter de recharcher plusieurs fois un même utilisateur
 /// </summary>
 /// <param name="userToSave"></param>
 public static async void SaveUserToTemporaryStorage(User userToSave)
 {
     var osh = new ObjectStorageHelper <User>(StorageType.Temporary);
     await osh.SaveAsync(userToSave, userToSave.pseudo);
 }
 public async Task Adicionar(MultaRealizada multaRealizada)
 {
     multasRealizadas.Add(multaRealizada);
     await objectStorageHelper.SaveAsync(multasRealizadas);
 }