Exemplo n.º 1
0
        public async void LoggingIn()
        {
            StorageFolder MainFolder      = ApplicationData.Current.LocalFolder;
            StorageFile   OutputNamesfile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"OutputNames.xml"); // Path is file path

            StorageFile Settingsfile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"SettingsData.xml");     // Path is file path

            StorageFile profileFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"profile.jpg");           // Path is file path

            if (await FileExistAsync(OutputNamesfile.Name) == false)
            {
                await OutputNamesfile.CopyAsync(MainFolder, OutputNamesfile.Name, NameCollisionOption.GenerateUniqueName);

                //  Weather theWeather = new Weather("Beirut", true);
            }
            if (await FileExistAsync(Settingsfile.Name) == false)
            {
                await Settingsfile.CopyAsync(MainFolder, Settingsfile.Name, NameCollisionOption.GenerateUniqueName);
            }
            if (await FileExistAsync(profileFile.Name) == false)
            {
                await profileFile.CopyAsync(MainFolder, profileFile.Name, NameCollisionOption.GenerateUniqueName);
            }


            LoggingIn theLogin;

            theLogin = new LoggingIn("test", "theTest.");
            theLogin.ConnectAndGetLatest();


            for (int i = 0; i < 15; i++)
            {
                await Task.Delay(1000);

                if (theLogin.isConnected)
                {
                    Assert.IsTrue(theLogin.isConnected);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            var vault = new Windows.Security.Credentials.PasswordVault();


            LogInButton.IsEnabled        = false;
            TextBoxUsername.IsEnabled    = false;
            PassBoxLoginPass.IsEnabled   = false;
            CheckBoxRememberMe.IsEnabled = false;
            TSMainHub.IsEnabled          = false;


            StatusText.Text = "";

            theLogin = new LoggingIn(TextBoxUsername.Text, PassBoxLoginPass.Password);
            theLogin.ConnectAndGetLatest();

            if (CheckBoxRememberMe.IsChecked == true)
            {
                SaveCredential(TextBoxUsername.Text, PassBoxLoginPass.Password);
            }
            else if (CheckBoxRememberMe.IsChecked == false)
            {
                RemoveCredential(TextBoxUsername.Text);
            }

            for (int i = 0; i < 30; i++)
            {
                await Task.Delay(1000);

                if (theLogin.isConnected)
                {
                    break;
                }
            }

            if (theLogin.isConnected)
            {
                await Task.Delay(2000);

                (App.Current as App).isFirstLogin = false;
                (App.Current as App).Email        = TextBoxUsername.Text;
                (App.Current as App).Password     = PassBoxLoginPass.Password;

                if (TSMainHub.IsOn)
                {
                    this.Frame.Navigate(typeof(AutomatedPage));
                }

                else if (!TSMainHub.IsOn)
                {
                    this.Frame.Navigate(typeof(MainPage));
                }
            }
            else
            {
                LogInButton.IsEnabled        = true;
                TextBoxUsername.IsEnabled    = true;
                PassBoxLoginPass.IsEnabled   = true;
                CheckBoxRememberMe.IsEnabled = true;
                TSMainHub.IsEnabled          = true;
                StatusText.Text = "Something Went Wrong and We Couldn't\n Log You In";
            }
        }