예제 #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = this.usernameTxtBox.Text;
            string password = this.paswordTxtBox.Password;

            if (username.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty.");
                return;
            }

            if (password.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty.");
                return;
            }
            string token;
            BackupServiceClient server = null;

            try
            {
                if (Const <BackupServiceClient> .Instance().get() == null)
                {
                    server = logIn(username, password, out token);
                }
            }
            catch (LoginExcpetion ex)
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, ex.Message);
            }
            if (server != null)
            {
                Const <BackupServiceClient> .Instance().set(server);

                UsefullMethods.setLabelAlert("success", this.errorBox, "Log in succeed!");
                conf.userName.set(this.usernameTxtBox.Text);
                await Task.Delay(500);

                this.Hide();
                string targetPath = conf.targetPath.get();
                // if the path is not setted a windows for selecting the path must be shown
                if (targetPath == null)
                {
                    WelcomeWindows ww = new WelcomeWindows();
                    ww.parent = this;
                    ww.Show();
                    ww.Activate();
                }
                else
                {
                    TrayiconMode.Instance();
                }
            }
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = this.usernameTxtBox.Text;
            string password = this.paswordTxtBox.Password;

            if (username.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty.");
                return;
            }

            if (password.Equals(""))
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty.");
                return;
            }
            string token;
            BackupServiceClient server = null;
            try
            {
                server = logIn(username, password, out token);
            }
            catch (LoginExcpetion ex)
            {
                UsefullMethods.setLabelAlert("danger", this.errorBox, ex.Message);

            }
            if (server != null)
            {

                Const<BackupServiceClient>.Instance().set(server);
                UsefullMethods.setLabelAlert("success", this.errorBox, "Log in succeed!");
                conf.userName.set(this.usernameTxtBox.Text);
                Thread.Sleep(500);
                this.Hide();
                string targetPath = conf.targetPath.get();
                // if the path is not setted a windows for selecting the path must be shown
                if (targetPath == null)
                {
                    WelcomeWindows ww = new WelcomeWindows();
                    ww.parent = this;
                    ww.Show();
                    ww.Activate();
                }
                else
                {
                    TrayiconMode.Instance();
                }
            }
        }