コード例 #1
0
        void Register_DoWork(object sender, DoWorkEventArgs e)
        {
            var curName = UserName;
            var curPassword = Password;
            var curEmail = Email;

            var svc = new AccountService();

            var result = svc.IsRegistrationValid(UserName, Password, Email);

            if (result == null)
            {
                _successfulLogOn = false;

                Error = "A connection to the server could not be made.";
                IsLoading = false;
                return;
            }

            if (!result.IsValid)
            {
                if (result.Errors.Length > 0)
                    Error = result.Errors[0];

                _successfulLogOn = false;
            }
            else
            {
                svc.RegisterUser(result.UserId, curName, curPassword, curEmail);
                Error = String.Empty;
                _userId = result.UserId;
                _successfulLogOn = true;

                var settings = _settingsManager.LoadSettings<LogOnSettings>(EmulationContext.Empty);
                settings.Username = UserName;
                settings.Password = Password;
                _settingsManager.ApplySettings(settings);
            }

            IsLoading = false;
        }
コード例 #2
0
        void LogOn_DoWork(object sender, DoWorkEventArgs e)
        {
            var svc = new AccountService();

            var result = svc.LogOn(UserName, Password);

            if (result == null)
            {
                WrenCore.IsOffline = true;
                var settings = _settingsManager.LoadSettings<LogOnSettings>(EmulationContext.Empty);

                _successfulLogOn = true;

                if (settings == null)
                {
                    Error = "A connection to the server could not be made.";
                    _successfulLogOn = false;
                }

                if (String.IsNullOrEmpty(settings.UserId))
                {
                    Error = "A connection to the server could not be made.";
                    _successfulLogOn = false;
                }

                IsLoading = false;
                return;
            }

            if (!result.IsSuccessful)
            {
                if (result.Errors.Length > 0)
                    Error = result.Errors[0];

                _successfulLogOn = false;
            }
            else
            {
                _userId = result.UserId;
                _successfulLogOn = true;

                var settings = _settingsManager.LoadSettings<LogOnSettings>(EmulationContext.Empty);
                settings.Username = UserName;
                settings.Password = Password;
                settings.UserId = result.UserId;
                _settingsManager.ApplySettings(settings);
            }

            IsLoading = false;
        }