async void RemoveList(object sender, EventArgs e)
        {
            try
            {
                var file = await FileHandling.getFile("Crazy88Data", "AssignmentList.txt");

                await file.DeleteAsync();
            }
            catch (Exception es)
            {
                await DisplayAlert("Error", es.ToString(), "Ok");
            }
        }
Ejemplo n.º 2
0
        public async void AddAdventureToText(Adventure adventure)
        {
            var file = await FileHandling.getFile("Adventure", "Adventures");

            var text = await file.ReadAllTextAsync();

            text = text +
                   adventure.AmountOfKm.ToString() + "*" +
                   adventure.EndLocation + "*" +
                   adventure.EndTime.ToString() + "*" +
                   adventure.StartLocation.ToString() + "*" +
                   adventure.StartTime + ";";
        }
        async void TestIsClicked(object sender, EventArgs e)
        {
            try
            {
                var file = await FileHandling.getFile("InlogFolder", "login.txt");

                await file.DeleteAsync();

                Navigation.InsertPageBefore(new MainPage(), this);
                await Navigation.PopAsync();
            }
            catch (Exception es)
            {
                await DisplayAlert("Error", es.ToString(), "Ok");
            }
        }
Ejemplo n.º 4
0
        async void CheckIfLogedIn()
        {
            var data  = new Data();
            var check = await data.ReadTheFile();

            while (check != 1)
            {
            }
            ;
            //First we check if theres a file with something in it.
            //If there's nothing in it we go to the log in
            var file = await FileHandling.getFile("InlogFolder", "login.txt");

            var username = await file.ReadAllTextAsync();

            if (username.Equals(""))
            {
                try
                {
                    Navigation.InsertPageBefore(new MainPage(), this);
                    await Navigation.PopToRootAsync();
                }
                catch (Exception e)
                {
                    Debug.WriteLine("{0} Exception found", e);
                }
            }

            //If there's something in it, we go to the main app.
            else
            {
                Debug.WriteLine("Username is: " + username);
                App.MainUsername = username;
                try {
                    Navigation.InsertPageBefore(new TabbedContent(), this);
                    await Navigation.PopToRootAsync();
                }
                catch (Exception e)
                {
                    Debug.WriteLine("{0} Exception found", e);

                    //await Navigation.PushAsync(new TabbedContent());
                }
            }
        }
Ejemplo n.º 5
0
        async void updaten()
        {
            string text = "";

            foreach (Crazy88Assignments dinges in Data.crazy88list)
            {
                Debug.WriteLine("Item: " + dinges.Item + " ID: " + dinges.IsChecked);
                text += dinges.Item + "*" + dinges.Description + "*" + dinges.Points + "*" + dinges.IsChecked + ";";
            }
            try
            {
                IFile file = await FileHandling.getFile("Crazy88Data", "AssignmentList.txt");

                await file.WriteAllTextAsync(text);
            }
            catch (Exception e)
            {
                await DisplayAlert("Updaten 2", e.ToString(), "Ok");
            }
        }
        async void LoginClicked(object sender, EventArgs e)
        {
            var username = LoginUsername.Text;
            var password = LoginPassword.Text;
            var received = await PostInlog(username, password);     //send the typed in data to the server and waits for response

            var temp = "1";

            if (String.Compare(received, temp) + 1 == 1)        //f*****g C# with its string comparison: Checks if we got the user in the database
            {
                //Write the username in a file and to a variable
                try
                {
                    var file = await FileHandling.getFile("InlogFolder", "login.txt");

                    await file.WriteAllTextAsync(username);

                    App.MainUsername = username;
                }
                catch (Exception er)
                {
                    await DisplayAlert("log in File handling", er.ToString(), "Ok");
                }
                //Go to the next page
                try
                {
                    Navigation.InsertPageBefore(new TabbedContent(), this);
                    await Navigation.PopToRootAsync();
                }
                catch (Exception er) {
                    await DisplayAlert("log in Next page", er.ToString(), "Ok");
                }
            }
            else
            {
                WrongCode.Text = "Login is not vallid";
            }
        }