//private ActiveDirectoryUtil ActiveDirectory { get; } = new ActiveDirectoryUtil();

        public async Task Login()
        {
            //if (ValidateCachedCredentials())
            //{
            //    //Setup ApplicationUser with the cached credentials.
            //    InitializeApplicationUser();
            //    return;
            //}

            LoginDialogData loginDialogResult = null;
            var             isUserValid       = false;


            while (!isUserValid)
            {
                //Display login modul
                loginDialogResult = await DisplayLoginDialog();

                //Check if user clicked Cancel
                if (loginDialogResult == null)
                {
                    Application.Current.Shutdown();
                }


                isUserValid = ValidateCredentials(loginDialogResult.Username, loginDialogResult.Password);
            }
        }
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
Label:
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your credentials", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme });

            if (result != null)
            {
                SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True");
                con.Open();
                string        q   = "select * from Login where User_Name='" + result.Username + "' and Password='******'";
                SqlCommand    cmd = new SqlCommand(q, con);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (dr.HasRows == true)
                    {
                        MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));
                    }
                }
                if (dr.HasRows == false)
                {
                    MessageDialogResult messageResult = await this.ShowMessageAsync("wrong Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));

                    goto Label;
                }
            }
            else if (result == null)
            {
                this.Close();
            }
        }
예제 #3
0
        private async void Msgm()
        {
            LoginDialogData result = await this.ShowLoginAsync("Autenticação", "Entre com suas Credenciais", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, UsernameWatermark = "Login" });


            while (result == null || !(result.Username.Equals("Teste")))
            {
                await this.ShowMessageAsync("Erro de Autenticação", "Usuario ou Senha Invalidos");

                result = await this.ShowLoginAsync("Autenticação", "Entre com suas credenciais", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, UsernameWatermark = "Login" });
            }


            if (result == null)
            {
            }


            //var CONTROLLER = await this.ShowMessageAsync("teste", "Processando", MessageDialogStyle.Affirmative, new MetroDialogSettings
            //{
            //    AnimateHide = false
            //});

            // var controll = await this.ShowProgressAsync("Processando", "Aguarde ...", true);

            // for (int i = 0; i < 100; i++)
            // {
            //     await Task.Delay(2000);
            //     controll.SetProgress(.25);

            // }
            // await controll.CloseAsync();
        }
예제 #4
0
        private async Task <ProtectedSecret> TryReKeySecretsAsync(ProtectedSecret secret, string name, object context)
        {
            try
            {
                string rawEmail = this.secretProvider.UnprotectSecret(secret);
                return(this.secretProvider.ProtectSecret(rawEmail));
            }
            catch (Exception ex)
            {
                this.logger.LogError(EventIDs.UIGenericError, ex, $"Unable to re-encrypt {name}");

                LoginDialogData data = await this.dialogCoordinator.ShowLoginAsync(context, "Error", $"The {name} could not be automatically re-encrypted. Please re-enter the {name}",
                                                                                   new LoginDialogSettings
                {
                    ShouldHideUsername         = true,
                    RememberCheckBoxVisibility = System.Windows.Visibility.Hidden,
                    AffirmativeButtonText      = "OK",
                    NegativeButtonVisibility   = System.Windows.Visibility.Visible,
                    NegativeButtonText         = "Cancel"
                });

                if (data != null)
                {
                    return(this.secretProvider.ProtectSecret(data.Password));
                }
            }

            return(null);
        }
예제 #5
0
 private bool PerformLogin(LoginData credentials)
 {
     if (!failedLogin.Contains(credentials.User))
     {
         if (credentials.IsManual)
         {
             GameModel model = ProfileManager.CurrentProfile.GameModel;
             if (ConfigurationManager.GetConfiguration(model).IsManualLoginSupported)
             {
                 Login(credentials.User, PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword), true);
                 return(true);
             }
         }
         if (credentials.IsCorrect)
         {
             LoginDialogData loginData = new LoginDialogData()
             {
                 Username = credentials.User,
                 Password = PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword)
             };
             ShowLoggingInDialog(loginData);
             return(true);
         }
     }
     return(false);
 }
        private async void UpdateAuthCommand(object sender, ExecutedRoutedEventArgs e)
        {
            LoginDialogData loginData = await this.ShowLoginAsync("Authentication details", "Username & password:"******"username",
                PasswordWatermark        = "password",
                AffirmativeButtonText    = "Save",
                NegativeButtonVisibility = Visibility.Visible,
                NegativeButtonText       = "Cancel",
                InitialUsername          = Properties.Settings.Default.Username,
                InitialPassword          = Properties.Settings.Default.Password,
                EnablePasswordPreview    = true
            });

            if (loginData != null)
            {
                if (loginData.Username != Properties.Settings.Default.Username ||
                    loginData.Password != Properties.Settings.Default.Password)
                {
                    StartProgressRing();
                    Properties.Settings.Default.Username = loginData.Username;
                    Properties.Settings.Default.Password = loginData.Password;
                    Properties.Settings.Default.Save();
                    await UpdateServerInfo();
                    await Refresh();

                    StopProgressRing();
                }
            }
            e.Handled = true;
        }
예제 #7
0
 public async Task<List<string>> ShowLogin(string Title, string PasswordWatermark = "请输入你的密码", bool isAccented = true)
 {
     LoginDialogData result = await ((MetroWindow)Application.Current.MainWindow).ShowLoginAsync(Title, "输入你的凭证:", new LoginDialogSettings { ColorScheme = isAccented ? MetroDialogColorScheme.Accented : MetroDialogColorScheme.Theme, AffirmativeButtonText = "确  认", PasswordWatermark = PasswordWatermark, NegativeButtonText = "取  消", InitialUsername = "******" });
     List<string> rst = new List<string>();
     rst.Add(result?.Username);
     rst.Add(result?.Password);
     return rst;
 }
예제 #8
0
        private async void metroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            LoginDialogData x = new LoginDialogData();

            x = await this.ShowLoginAsync("Login", "Please Login to Use the Application", null);

            //MessageBox.Show("UserName: "******" Password: " + x.Password);
        }
예제 #9
0
        private async Task <bool> LoginScreen()
        {
            LoginDialogSettings ms = new LoginDialogSettings()
            {
                ColorScheme              = MetroDialogColorScheme.Accented,
                EnablePasswordPreview    = true,
                NegativeButtonVisibility = Visibility.Visible,
                NegativeButtonText       = "Cancel"
            };

            try
            {   //Create Login dialog
                LoginDialogData ldata = await this.ShowLoginAsync("Login to Galaxis", "Enter your credentials", ms);

                if (ldata == null)
                {
                    Application.Current.Shutdown();
                }
                else
                {
                    Password = ldata.SecurePassword;
                    UserName = ldata.Username;
                }

                using (ClientContext ctx = new ClientContext("https://galaxis.axis.com/sites/Suppliers/manufacturing/"))
                {
                    // SharePoint Online Credentials
                    ctx.Credentials = new NetworkCredential(UserName, Password, "AXISNET");

                    // Get the SharePoint web
                    Web web = ctx.Web;
                    ctx.Load(web, website => website.Webs, website => website.Title);
                    try
                    {
                        // Execute the query to the server
                        ctx.ExecuteQuery();
                        return(true);
                    }
                    catch (Exception)
                    {
                        MetroDialogSettings ff = new MetroDialogSettings()
                        {
                            ColorScheme = MetroDialogColorScheme.Accented
                        };
                        await this.ShowMessageAsync("LOGIN INCORRECT:", "Application will close down", MessageDialogStyle.Affirmative, ff);

                        Application.Current.Shutdown();
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
        private async void LoginAsyn()
        {
            LoginDialogSettings aSetting = new LoginDialogSettings {
                ColorScheme = MetroDialogOptions.ColorScheme, InitialUsername = "******", NegativeButtonVisibility = Visibility.Visible, EnablePasswordPreview = true
            };
            LoginDialogData result = await this.ShowLoginAsync("登入验证", "输入用户名和密码", aSetting);

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                string   strurl   = m_strLoginUrl;
                Encoding encoding = Encoding.UTF8;

                try
                {
                    var controller = await this.ShowProgressAsync("请稍后...", "正在登入系统!");

                    controller.SetIndeterminate();
                    controller.SetCancelable(true);
                    Hashtable loginReturnData = await RealsunClientNet.Login(result.Username, result.Password);

                    // Hashtable loginReturnData = new Hashtable () ;
                    //loginReturnData.Add("error", 0);
                    if (Convert.ToInt16(loginReturnData["error"]) == 0)
                    {
                        await controller.CloseAsync();

                        homepage.IsEnabled  = true;
                        homepage.IsSelected = true;
                        clock.Controller.Stop();
                        Tiles.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        await controller.CloseAsync();

                        homepage.IsEnabled     = false;
                        homepage.IsSelected    = false;
                        welcomepage.IsSelected = true;
                        clock.Controller.Begin();
                        Tiles.Visibility = Visibility.Hidden;

                        await this.ShowMessageAsync("登入失败", Convert.ToString(loginReturnData["message"]));
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        /// <summary>
        /// ログインダイヤログを表示する
        /// </summary>
        /// <remarks>
        /// パスワードの処理はSecureStringを使った方が良い
        /// パスワードの復号化が出来ないと、Exceptionが発生し落ちる
        /// </remarks>
        private async void login()
        {
            if (string.IsNullOrEmpty(Properties.Settings.Default.username) &&
                string.IsNullOrEmpty(Properties.Settings.Default.password))
            {
                // Login
                LoginDialogData result = await dialogCoordinator.ShowLoginAsync(
                    this,
                    "ログイン",
                    "ユーザ名とパスワードを入力してください。",
                    new LoginDialogSettings
                {
                    InitialUsername            = Properties.Settings.Default.username ?? "",
                    InitialPassword            = Library.StringEncryption.DecryptString(Properties.Settings.Default.password) ?? "",
                    EnablePasswordPreview      = true,
                    RememberCheckBoxVisibility = Visibility.Visible,
                    RememberCheckBoxText       = "ログイン情報を保存し、ログインを維持する"
                });

                if (result != null)
                {
                    // ログイン情報を保存するか
                    if (result.ShouldRemember)
                    {
                        Properties.Settings.Default.username = result.Username;
                        Properties.Settings.Default.password = Library.StringEncryption.EncryptString(result.Password);
                        Properties.Settings.Default.Save();
                    }
                }
                else
                {
                    // ログイン情報入力無し
                    return;
                }
            }

            // ログイン
            var loginResult = await this.Model.WebAPI.Login(
                Properties.Settings.Default.username,
                Library.StringEncryption.DecryptString(Properties.Settings.Default.password)
                );

            if (!loginResult)
            {
                await dialogCoordinator.ShowMessageAsync(this, "エラー", "ログインできませんでした。");

                return;
            }

            // ログイン情報更新
            this.isLogin.Value = true;
        }
예제 #12
0
        private async void ShowLoginDialog(object sender, RoutedEventArgs e)
        {
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your credentials", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, InitialUsername = "******" });

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));
            }
        }
예제 #13
0
        private async void ShowLoginDialogWithRememberCheckBox(object sender, RoutedEventArgs e)
        {
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your password", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, RememberCheckBoxVisibility = Visibility.Visible });

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Username: {0}\nPassword: {1}\nShouldRemember: {2}", result.Username, result.Password, result.ShouldRemember));
            }
        }
예제 #14
0
        private async void ShowLoggingInDialog(LoginDialogData loginData)
        {
            MainWindow          MainWindow = App.Kernel.Get <MainWindow>();
            MetroDialogSettings settings   = new MetroDialogSettings()
            {
                ColorScheme        = MetroDialogColorScheme.Accented,
                NegativeButtonText = LanguageManager.Model.CancelButton
            };

            controller = await MainWindow.ShowProgressAsync(LanguageManager.Model.LoginLogIn, String.Empty, true, settings);

            Login(loginData.Username, loginData.Password, false);
        }
예제 #15
0
        private async void ShowLoginDialogOnlyPassword(object sender, RoutedEventArgs e)
        {
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your password", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, ShouldHideUsername = true });

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Password: {0}", result.Password));
            }
        }
예제 #16
0
        private async void ShowLoginDialogPasswordPreview(object sender, RoutedEventArgs e)
        {
            this.MetroDialogOptions.ColorScheme = UseAccentForDialogsMenuItem.IsChecked ? MetroDialogColorScheme.Accented : MetroDialogColorScheme.Theme;
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your credentials", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, InitialUsername = "******", EnablePasswordPreview = true });

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));
            }
        }
예제 #17
0
        private void ShowLoginDialogOutside(object sender, RoutedEventArgs e)
        {
            LoginDialogData result = this.ShowModalLoginExternal("Authentication", "Enter your credentials", new LoginDialogSettings {
                ColorScheme = this.MetroDialogOptions.ColorScheme, InitialUsername = "******", EnablePasswordPreview = true
            });

            if (result == null)
            {
                //User pressed cancel
            }
            else
            {
                MessageDialogResult messageResult = this.ShowModalMessageExternal("Authentication Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));
            }
        }
예제 #18
0
        private async void AuthorizeAsync(string message)
        {
            LoginDialogData result = await this.ShowLoginAsync("Login", message, new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, EnablePasswordPreview = true });

            if (result != null)
            {
                controller = await this.ShowProgressAsync("Logging in", "Please wait...");

                controller.SetIndeterminate();
                await Task.Run(() =>
                {
                    ValidateLoginAsync(result.Username, result.Password);
                });
            }
        }
        public async void ShowLoginDialogWithRememberCheckBox(object obj)
        {
            LoginDialogSettings settings = new LoginDialogSettings
            {
                ColorScheme = metroWindow.MetroDialogOptions.ColorScheme,
                RememberCheckBoxVisibility = System.Windows.Visibility.Visible,
                NegativeButtonVisibility   = System.Windows.Visibility.Visible,
            };

            LoginDialogData result = await metroWindow.ShowLoginAsync("Authentication", "Enter your password", settings);

            if (result == null)
            {
                MessageDialogResult messageResult = await metroWindow.ShowMessageAsync("Authentication Information", String.Format("You have canceled"));
            }
            else
            {
                Users = new ObservableCollection <GetUser_Result>(St.GetUser(result.Username, result.Password).ToList());
                try
                {
                    St.UpdateStarDay(Users[0].ID);
                }
                catch
                {
                    MessageDialogResult messageResult = await metroWindow.ShowMessageAsync("Authentication Information", String.Format("Error occured, please try again.."));
                }

                if (Users.Count() != 0 && isLoggedIn == false)
                {
                    isLoggedIn = true;
                    MessageDialogResult messageResult = await metroWindow.ShowMessageAsync("Authentication Information", String.Format("Log in successfully.."));

                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window.GetType() == typeof(MainWindow))
                        {
                            (window as MainWindow).cmbChangeUC.SelectedIndex = 1;
                            (window as MainWindow).WindowState        = System.Windows.WindowState.Maximized;
                            (window as MainWindow).Account.Visibility = System.Windows.Visibility.Visible;
                        }
                    }
                }
                else
                {
                    MessageDialogResult messageResult = await metroWindow.ShowMessageAsync("Authentication Information", String.Format("Valid Username or Password.."));
                }
            }
        }
예제 #20
0
        public async void ShowLogin()
        {
            LoginDialogData x = await this.ShowLoginAsync("Login", "Enter your credentials", new LoginDialogSettings
            {
                ColorScheme           = MetroDialogColorScheme.Accented,
                EnablePasswordPreview = true,
                PasswordWatermark     = "password",
                UsernameWatermark     = "user name",
                InitialPassword       = "",
                InitialUsername       = "",
                DefaultButtonFocus    = MessageDialogResult.Affirmative,
                AnimateShow           = true
            });

            if ((x == null))
            {
                ShowLogin();
            }
            else
            {
                IDbManager       dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand     db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                List <UserModel> result    = db.Query <UserModel>("GetUser", new { Username = x.Username, Password = x.Password });
                if (result.Any())
                {
                    //string[] accessLevel;
                    switch (result[0].Type)
                    {
                    case 100:
                        ObjectPool.Instance.Register <MasterCollaborator>().ImplementedBy(new MasterCollaborator());

                        break;

                    case 900:
                        ObjectPool.Instance.Register <MasterCollaborator>().ImplementedBy(new MasterCollaborator());
                        ObjectPool.Instance.Register <DashboardCollaborator>().ImplementedBy(new DashboardCollaborator());
                        break;
                    }
                    //AuthorizationProvider.Initialize<DefaultAuthorizationProvider>(accessLevel);
                    db.Close();
                }
                else
                {
                    db.Close();
                    ShowLogin();
                }
            }
        }
예제 #21
0
 private bool IsValidateLoginData(LoginDialogData data)
 {
     if (data == null)
     {
         return(false);
     }
     if (string.IsNullOrWhiteSpace(data.Username))
     {
         return(false);
     }
     if (string.IsNullOrWhiteSpace(data.Password))
     {
         return(false);
     }
     return(true);
 }
예제 #22
0
        private bool PasswordAuthentication()
        {
            LoginDialogData result = this.ShowModalLoginExternal("身份验证", "输入密码", new LoginDialogSettings {
                ColorScheme = this.MetroDialogOptions.ColorScheme, ShouldHideUsername = true
            });

            if (result != null)
            {
                if (result.Password == adminPwd)
                {
                    return(true);
                }
            }
            this.ShowModalMessageExternal("提示", "密码错误");
            return(false);
        }
예제 #23
0
        private async Task ShowLoginDialog()
        {
            string login;
            string pass;

            while (!IsLoged)
            {
                LoginDialogData result = await this.ShowLoginAsync("Аутентификация", "Введите ваши данные. Нажмите \"Esc\", чтобы вернуться назад.", new LoginDialogSettings { NegativeButtonText = "Отмена", ColorScheme = this.MetroDialogOptions.ColorScheme, EnablePasswordPreview = true });

                if (result == null)
                {
                    break;
                }
                else
                {
                    login = result.Username;
                    pass  = result.Password;
                    if (login.Trim(' ') == "" || pass.Trim(' ') == "")
                    {
                        await this.ShowMessageAsync("Ошибка!", "Заполните все поля!");

                        continue;
                    }
                    string resp = client.Auth(login, pass);
                    if (resp == "true")
                    {
                        await this.ShowMessageAsync("Уведомление", "Успех!");

                        Login = login;
                        GetThemeSettings();
                        GetNotificationSettings();
                        IsLoged = true;
                    }
                    else if (resp == "online")
                    {
                        await this.ShowMessageAsync("Уведомление", "Пользователь с такими данными уже в сети!");

                        continue;
                    }
                    else
                    {
                        await this.ShowMessageAsync("Уведомление", "Введён неправильный логин или пароль!");
                    }
                }
            }
        }
예제 #24
0
        // 로그인 버튼 클릭시 웹 브라우저 숨기고 로그인 다이얼로그 표시
        async private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.mainBrowser.Visibility = System.Windows.Visibility.Hidden;
            LoginDialogData result = await this.ShowLoginAsync("로그인", "아이디와 비밀번호를 입력해주세요.", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, InitialUsername = "", RememberCheckBoxVisibility = Visibility.Visible, UsernameWatermark = "아이디", PasswordWatermark = "비밀번호" });

            if (result == null)
            {
                MainWindow.Instance.mainBrowser.Visibility = System.Windows.Visibility.Visible; return;
            }

            if (lp == null)
            {
                lp = new Login();
            }
            lp.InjectionResult(result);

            mainBrowser.Navigate(loginUrl);
        }
        private async void ExecuteWindowLoaded()
        {
            ClientService.GetInstance().OnUpdateReceived += OnUpdateReceived;
            ClientService.GetInstance().OnCandleStickDataEventHandler          += MainWindowViewModel_OnCandleStickDataEventHandler;
            ClientService.GetInstance().OnConnectionClosedByServerEventHandler += MainWindowViewModel_OnConnectionClosedByServerEventHandler;

            DealerService.GetInstance().OnOfficePositionsUpdateReceived  += OnOfficePositionsUpdateReceived;
            DealerService.GetInstance().OnConnectionsInformationReceived += MainWindowViewModel_OnConnectionsInformationReceived;
            DealerService.GetInstance().OnNotificationReceived           += MainWindowViewModel_OnNotificationReceived;

            AuthService.GetInstance().OnGenericResponseReceived += MainWindow_OnGenericResponseReceived;

            LoginDialogData creds = await _dialogCoord.ShowLoginAsync(this, "Backoffice Login", "Login to continue using your account");

            if (creds != null && !string.IsNullOrEmpty(creds.Username) && !string.IsNullOrEmpty(creds.Password))
            {
                progressController = await _dialogCoord.ShowProgressAsync(this, "Please wait...", "Authenticating with server.");

                progressController.SetIndeterminate();

                if (!AuthService.GetInstance().init(creds.Username, creds.Password)
                    ||
                    !AuthService.GetInstance().ResolveUserEndpoints()
                    )
                {
                    await progressController.CloseAsync();

                    await _dialogCoord.ShowMessageAsync(this, "Authentication", "Incorrect username/password.");

                    App.Current.Shutdown();
                }
                else
                {
                    username = creds.Username;
                    password = creds.Password;
                }
            }
            else
            {
                await _dialogCoord.ShowMessageAsync(this, "Authentication", "Credentials are needed to continue.");

                App.Current.Shutdown();
            }
        }
예제 #26
0
        private async void ToMonlist_Button_Click(object sender, RoutedEventArgs e)
        {
            var message = "Hierduch wird der gesamte, aktuell angezeigte Monat in MonList ersetzt. Alle Daten in MonList werden hierdurch überschrieben!";

            if (this.ViewModel.MonlistImportLoginData != null)
            {
                var settings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Importieren",
                    NegativeButtonText    = "Abbrechen",
                };
                MessageDialogResult result = await this.ShowMessageAsync("Monlist Daten-Import", message, MessageDialogStyle.AffirmativeAndNegative, settings);

                if (result == MessageDialogResult.Affirmative)
                {
                    this.UploadToMonlist(this.ViewModel.MonlistImportLoginData.Password);
                }
            }
            else
            {
                var settings = new LoginDialogSettings
                {
                    ShouldHideUsername       = !string.IsNullOrWhiteSpace(this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber),
                    EnablePasswordPreview    = true,
                    AffirmativeButtonText    = "Importieren",
                    NegativeButtonText       = "Abbrechen",
                    NegativeButtonVisibility = Visibility.Visible
                };
                LoginDialogData result = await this.ShowLoginAsync("Monlist Daten-Import", message + "\n\nPasswort", settings);

                if (result != null && !string.IsNullOrWhiteSpace(result.Password))
                {
                    // user pressed ok
                    if (!settings.ShouldHideUsername)
                    {
                        this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber = result.Username;
                    }

                    this.ViewModel.MonlistImportLoginData = result;

                    this.UploadToMonlist(result.Password);
                }
            }
        }
예제 #27
0
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            LoginDialogSettings loginDialogSettings = new LoginDialogSettings()
            {
                ColorScheme = this.MetroDialogOptions.ColorScheme,
                RememberCheckBoxVisibility = Visibility.Visible,
                NegativeButtonVisibility   = Visibility.Visible,
                RememberCheckBoxText       = "记住账号",
                AffirmativeButtonText      = "登录",
                NegativeButtonText         = "退出",
                // DialogResultOnCancel =
            };

            LoginDialogData result = await this.ShowLoginAsync("身份验证", "请输入账号与密码", loginDialogSettings);

            if (result != null)
            {
                var s = WtdlSqlServices.UserLoging(new LoginData()
                {
                    Username = result.Username, Password = result.Password
                });

                if (s != null)
                {
                    //MessageDialogResult messageResult = await this.ShowMessageAsync("身份信息验证通过", String.Format("账号: {0}\n密码: {1}\n记住我: {2}", result.Username, result.Password, result.ShouldRemember));
                    this.SearchButton.Command.Execute(null);
                    this.UserMenu.DataContext    = s;
                    this.WinTabControl.IsEnabled = true;
                }
                else
                {
                    MessageDialogResult messageResult = await this.ShowMessageAsync("身份信息验证失败", "请填写正确得账号与密码\n忘记账号密码请与管理员联系");

                    MetroWindow_Loaded(null, null);
                }
            }
            else
            {
                this.Close();
            }
        }
예제 #28
0
        private async void ShowDialog()
        {
            var result = await((MetroWindow)Application.Current.MainWindow).ShowInputAsync("Input your IP and port", "Example : 1.1.1.1:3000");

            if (result == null || result.Length == 0)
            {
                return;
            }
            LoginDialogData data = await((MetroWindow)Application.Current.MainWindow).ShowLoginAsync("Login", "Your IP is " + (result));

            if (data == null || data.Username == null || data.Password == null)
            {
                return;
            }

            var mSetting = new MetroDialogSettings()
            {
                NegativeButtonText    = "Cancel",
                AnimateShow           = false,
                AnimateHide           = false,
                DialogTitleFontSize   = 20,
                DialogMessageFontSize = 16
            };

            var controller = await((MetroWindow)Application.Current.MainWindow).ShowProgressAsync("Please wait...", "Connecting to the server...", settings: mSetting);

            controller.SetIndeterminate();
            controller.SetCancelable(true);
            ServerBack back = await Utils.NetUtils.LoginAsync(result + "/v1/login", data.Username, data.Password);

            await controller.CloseAsync();

            var conn = new SQLiteAsyncConnection(App.DB_NAME);
            await conn.InsertAsync(new SettingModel
            {
                Token = back.Message,
                URL   = result
            });

            MessageDialogResult msg = await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("SERVER BACK", back.Message);
        }
예제 #29
0
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            MainFrame.Content = new DesktopPage();

            // Вход в систему

            while (true)
            {
                LoginDialogData resultLogin = await MessageService.MetroLoginDialog();

                if (resultLogin != null)
                {
                    ProgressDialogController controller = await this.ShowProgressAsync("Пожалуйста ожидайте", "Идет проверка данных...");

                    Staff staff = await Task <Staff> .Factory.StartNew(() => _databasenEtities.Staff.SingleOrDefault(a => a.Login == resultLogin.Username));

                    using (MD5 md5Hash = MD5.Create())
                    {
                        await controller.CloseAsync();

                        if (staff != null && HashMD5.VerifyMd5Hash(md5Hash, resultLogin.Password, staff.Password))
                        {
                            Application.Current.Properties["ID_User"] = _ID_User = staff.ID;
                            break;
                        }
                        else
                        {
                            await MessageService.MetroMessageDialog("Результат входа", "Вы ввели неверный логин или пароль!");
                        }
                    }
                }
                else
                {
                    Close();
                }
            }

            _dispatcherTimer.Interval = new TimeSpan(0, 5, 0);
            _dispatcherTimer.Tick    += dispatcherTimer_Tick;
            _dispatcherTimer.Start();
        }
예제 #30
0
        private async void HideWindow()
        {
            if (!string.IsNullOrEmpty(ServiceProvider.Settings.FullScreenPassword))
            {
                KeyDown -= image1_KeyDown;
                LoginDialogData result = await this.ShowLoginAsync("Closing fullscreen ...", "Enter your password", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, ShouldHideUsername = true, AffirmativeButtonText = "Close" });

                if (result != null)
                {
                    if (result.Password == ServiceProvider.Settings.FullScreenPassword)
                    {
                        ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_Hide);
                    }
                }
                KeyDown += image1_KeyDown;
            }
            else
            {
                ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.FullScreenWnd_Hide);
            }
        }