Ejemplo n.º 1
0
 private async void getSavedClouds()
 {
     var saveFileKey = new SaveFileDictionary();
     savedCloudList = new List<string>();
     var fileSystem = FileSystem.Current.LocalStorage;
     var exists = await fileSystem.CheckExistsAsync("PhoneData.txt");
     if (exists.Equals(ExistenceCheckResult.FileExists))
     {
         var file = await fileSystem.GetFileAsync("PhoneData.txt");
         var text = await file.ReadAllTextAsync();
         var fileLines = text.Split('\n');
         var cloudsList = fileLines[saveFileKey.dict["CLOUDREGION"]].Split(',');
         System.Diagnostics.Debug.WriteLine(cloudsList[0].ToString());
         savedCloudList= cloudsList.ToList<string>();
     }
     else throw new System.IO.IOException();
 }
Ejemplo n.º 2
0
        private async void S_OnChanged(object sender, ToggledEventArgs e)
        {
            var s = (SwitchCell)sender;
            var saveFileKey = new SaveFileDictionary();

            var fileSystem = FileSystem.Current.LocalStorage;
            var exists = fileSystem.CheckExistsAsync("PhoneData.txt");
            if (exists.Equals(ExistenceCheckResult.FileExists))
            {
                var file = await fileSystem.GetFileAsync("PhoneData.txt");
                var text = await file.ReadAllTextAsync();
                var fileLines = text.Split('\n');
                var savedClouds = fileLines[saveFileKey.dict["CLOUDREGION"]].Split(',').ToList<string>();
                if (s.On == true) //Add cloud to file
                {
                    bool notYetSaved = false;
                    for (int i = 0; i < savedClouds.Count; i++)
                    {
                        if (!savedClouds[i].Equals(s.Text))
                        {
                            notYetSaved = true;

                        }

                    }
                    if (notYetSaved)
                    {
                        savedClouds.Add(s.Text);
                        string saveString = "";
                        for (int j = 0; j < savedClouds.Count; j++)
                        {
                            saveString += savedClouds + ",";
                        }

                        fileLines[saveFileKey.dict["CLOUDREGION"]] = saveString;
                        saveString = "";
                        for (int j = 0; j < fileLines.Length; j++)
                        {
                            saveString += fileLines[j] + "\n";
                        }
                        await file.WriteAllTextAsync(saveString);


                    }
                    }
                    else //Remove cloud from file
                    {
                        if (savedClouds.Count == 0) throw new IndexOutOfRangeException("No Clouds Were In List");

                        bool aleadySaved = true;
                        for (int i = 0; i < savedClouds.Count; i++)
                        {
                            if (!savedClouds[i].Equals(s.Text))
                            {
                                aleadySaved = false;

                            }
                        }
                        if (aleadySaved) //TODO make compile savestring method
                        {
                            var index = savedClouds.IndexOf(s.Text);
                            savedClouds.RemoveAt(index);
                            var saveString = "";
                            for (int i = 0; i < savedClouds.Count; i++)
                            {
                                saveString += savedClouds[i] + ",";
                            }

                            fileLines[saveFileKey.dict["CLOUDREGION"]] = saveString;
                            saveString = "";
                            for (int i = 0; i < fileLines.Length; i++)
                            {
                                saveString += fileLines[i] + "\n";
                            }
                            await file.WriteAllTextAsync(saveString);
                        }

                    }
                }
                else
                {
                    throw new System.IO.FileNotFoundException("PhoneData.txt");
                }
            
        }
Ejemplo n.º 3
0
        private async void ContinueSignUpB_Clicked(object sender, EventArgs e)
        {
            string email = emailEntry.Text;

            this.username = userNameEntry.Text;
            this.password = passwordEntry.Text;


            bool emailValidity = checkEmailValidity(email);
            string validityText = "valid";//await checkUserPassValidity(username, password);
            if (validityText.Equals("valid") && emailValidity)
            {
                invalidSignup = false;
                System.Diagnostics.Debug.WriteLine(email);
                await App.dbWrapper.CreateAccount(username, password, email);
                await App.dbWrapper.LoginAccount(username, password);
                var userId = App.dbWrapper.GetUser().Id;

                var sfd = new SaveFileDictionary();
                var fileSystem = FileSystem.Current.LocalStorage;
                var exists = await fileSystem.CheckExistsAsync("PhoneData.txt");

                if (exists.Equals(ExistenceCheckResult.FileExists))
                {
                    IFile file = await fileSystem.GetFileAsync("PhoneData.txt");
                    var fileCopy = await file.ReadAllTextAsync();
                    var fileLines = fileCopy.Split('\n');
                    fileLines[sfd.dict["USERID"]] = userId.ToString();
                    string contents = "";
                    for (int i = 0; i < fileLines.Length; i++)
                    {
                        contents += fileLines[i] + '\n';
                    }
                    System.Diagnostics.Debug.WriteLine(contents);
                    await file.WriteAllTextAsync(contents);

                    //write contents to file

                }

                await Navigation.PushModalAsync(new AlternateCustomizeProfilePage());

            }
            else
            {
                invalidSignup = true;
                invalidSignupText = validityText;
                this.displaySignUpContent();
            }


        }
Ejemplo n.º 4
0
        protected override async void OnStart()
        {
            ch = new ColorHandler();
           
            var saveFileKey = new SaveFileDictionary();

            System.Diagnostics.Debug.WriteLine(FileSystem.Current.LocalStorage.Path);
            var fileSystem = FileSystem.Current.LocalStorage;
            var fileExists = await fileSystem.CheckExistsAsync("PhoneData.txt");
          //  createCleanFileSystem(fileSystem);
            if (fileExists.Equals(ExistenceCheckResult.FileExists))
            {
                IFile file = await fileSystem.GetFileAsync("PhoneData.txt");
                var data = await file.ReadAllTextAsync();
                var dataLines = data.Split('\n');
                //      var idLoc = dataLines[saveFileKey.dict["USERID"]].Split(':');
                //  string id = idLoc[1];
                string id = dataLines[saveFileKey.dict["USERID"]];
             //   if (id[id.Length - 1] == ';') id = id.Substring(0, id.Length - 2);
                System.Diagnostics.Debug.WriteLine(id);
                if (!id.Equals("a"))
                {
                    var userAccount = await dbWrapper.GetAccount(id);
                    await App.dbWrapper.LoginAccount(userAccount.Username, userAccount.Password);

                    var clubs = await App.dbWrapper.GetClubs();
                    var popularClubs = await App.dbWrapper.GetPopularClubs();
                    var newestClubs = await App.dbWrapper.GetNewestClubs();
                    var memberClubsList = await App.dbWrapper.GetAccountClubs(App.dbWrapper.GetUser().Id);
                    var pendingClubList = new List<string>();
                    //TODO check if get clubs returns all clubs
                    for (int i = 0; i < clubs.Count; i++)
                    {
                        if (await App.dbWrapper.IsPendingClubRequest(clubs[i].Id))
                        {
                            pendingClubList.Add(clubs[i].Id);
                        }

                    }
                    var firstLineCommentList = await App.getMostRecentComment(memberClubsList);
                    var navPage = new NavigationPage(new TabbedMainClubPages(clubs, memberClubsList, popularClubs, newestClubs, pendingClubList, firstLineCommentList));

                    navPage.BarBackgroundColor = ch.fromStringToColor("purple");
                    MainPage = navPage;
                }
                else
                {
                    createCleanFileSystem(fileSystem);
                }


            }
            else
            {

                createFileSystem(fileSystem);
            }


            // Handle when your app starts

        }
Ejemplo n.º 5
0
        private async void ContinueLoginB_Clicked(object sender, EventArgs e)
        {
            username = userNameEntry.Text;
            password = userNameEntry.Text;

            if (await App.dbWrapper.LoginAccount(username, password))
            {
                invalidLogin = false;
                var sfd = new SaveFileDictionary();
                var fileSystem = FileSystem.Current.LocalStorage;
                var exists = await fileSystem.CheckExistsAsync("PhoneData.txt");

                if (exists.Equals(ExistenceCheckResult.FileExists))
                {
                    IFile file = await fileSystem.GetFileAsync("PhoneData.txt");
                    var fileCopy = await file.ReadAllTextAsync();
                    var fileLines = fileCopy.Split('\n');
                   
                    fileLines[sfd.dict["USERID"]] = App.dbWrapper.GetUser().Id.ToString();
                    string contents = "";
                    for (int i = 0; i < fileLines.Length; i++)
                    {
                        contents += fileLines[i] + '\n';
                    }
                    System.Diagnostics.Debug.WriteLine(contents);
                    await file.WriteAllTextAsync(contents);

                    //write contents to file

                }




                List<Club> clubs = await App.dbWrapper.GetClubs();
                var popularClubs = await App.dbWrapper.GetPopularClubs();
                var newestClubs = await App.dbWrapper.GetNewestClubs();
                var memberClubList = await App.dbWrapper.GetAccountClubs(App.dbWrapper.GetUser().Id);

                //    var userAccount = await App.dbWrapper.
                var memberClubsList = await App.dbWrapper.GetAccountClubs(App.dbWrapper.GetUser().Id);

                List<string> pendingInviteList = new List<string>();

                for (int i = 0; i < clubs.Count; i++)
                {
                    if (await App.dbWrapper.IsPendingClubRequest(clubs[i].Id))
                    {
                        pendingInviteList.Add(clubs[i].Id);
                    }
                }

                List<string> firstLineCommentList = new List<string>();
                for (int i = 0; i < memberClubsList.Count; i++)
                {
                    var comment = await App.dbWrapper.GetRecentComment(memberClubsList[i].Id);

                    firstLineCommentList.Add(comment.Text);
                }

                var navPage = new NavigationPage(new TabbedMainClubPages(clubs, memberClubsList, popularClubs, newestClubs, pendingInviteList, firstLineCommentList));
                navPage.BarBackgroundColor = ch.fromStringToColor("purple");
                Application.Current.MainPage = navPage;

            }/// return value if dne check 
            else
            {
                invalidLoginLabel.Text = "Invaild Username or Password";
                invalidLogin = true;
                displayLoginContent();
            }
        }