Пример #1
0
        private void Login()
        {
            if (IsNullFill())
            {
                MessageBox.Show(Language.NullFill, Language.Notification);
                return;
            }
            ConnectData.RandomToken();
            string ID          = LoginM.Id; ConnectData.Username = ID;
            string Password    = LoginM.Password; ConnectData.Password = Password;
            string loginResult = ConnectData.Login();

            switch (loginResult)
            {
            case "NullFill":
                MessageBox.Show(Language.NullFill, Language.Notification);
                return;

            case "false":
                MessageBox.Show(Language.ErrorConnect, Language.Notification);
                return;

            case "Exception":
                MessageBox.Show(Language.ErrorAccount, Language.Notification);
                return;

            case "wrong":
                LoadWor.Read = true;
                MessageBox.Show(Language.Wrong, Language.Notification, MessageBoxButton.OK, MessageBoxImage.Error);
                return;

            case "Shell":
                LoadWor.Read = true;
                MessageBox.Show(Language.Wrong, Language.ShellNew, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            dynamic data = JsonConvert.DeserializeObject(loginResult);

            if (data.banned == "1")
            {
                MessageBox.Show(Language.BannedAccount, Language.Notification, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            LoginM.Type    = Language.TypeMember[data.is_admin];
            LoginM.Email   = data.email;
            LoginM.Gender  = data.gender;
            LoginM.RegDate = data.register_date;
            LoginM.Server  = ConnectData.ServerName;

            dynamic Online = ConnectData.Online();

            if (Online.Online == "true")
            {
                MessageBoxResult _returnReg = MessageBox.Show(Language.Set(Language.OutNow, ID), Language.Notification, MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (_returnReg == MessageBoxResult.No)
                {
                    return;
                }
                if (_returnReg == MessageBoxResult.Yes)
                {
                    ConnectData.Logout(true);
                    return;
                }
            }
            else if (Online.Online == "Error")
            {
                MessageBox.Show(Language.ErrorConnect, Language.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            GetDataInfo();
            string InOnline = ConnectData.InInsertOnline();

            if (InOnline == "false" || InOnline == "Error")
            {
                MessageBox.Show(Language.ErrorConnect, Language.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ConnectData.LogoutKey = true;
            if (Mill.FilePath())
            {
                Mill.CreateXaml(LoginM.Id);
            }
            else
            {
                Mill.SetXaml(LoginM.Id);
            }

            Start();
        }