Наследование: INotifyPropertyChanging, INotifyPropertyChanged
Пример #1
0
        public static void AuthentificateUser(User user, AuthentificateUserCallback callback)
        {

            _authCallback = callback;
            _authUser = user;
            new AuthentitficationDataService().AuthentificateUser(user.Name, user.Password, user.Server.Address, AuthentificateUserCallback);
        }
 public void GetNewSurveys(User user, GetSurveysCallback callback)
 {
     _callback = callback;
     _currentUser = user;
     var request = HttpWebRequest.Create(string.Concat(user.Server.Address,ServerMethodAddresses.CheckForNewSurveys));
     request.Credentials = new NetworkCredential(user.Name, user.Password);
     request.BeginGetResponse(GetNewSurveysCallback, request);
 }
Пример #3
0
        public static void CheckUserData(string userName, string password, string serverUrl, AuthentificateUserCallback callback)
        {
            _authCallback = callback;
            Server server = null;
            _authUser = new User();
            using (var serverRepository = new ServerRepository())
            {
                server = serverRepository.TryGetServerByAddress(serverUrl);

            }
            if (server != null)
            {

                User user = null;
                using (var userRepository = new UserRepository())
                {
                    user = userRepository.TryGetUserByNamePasswordAndServerID(userName, password, server.ID);
                }
                if (user != null)
                {
                    _authUser = user;
                    AuthentificateUserCallback(AuthentificationCode.LoginSuccessed);
                    return;
                }

                _authUser.ServerID = server.ID;
            }
            else
            {
                server = new Server
                {
                    Address = serverUrl,
                };
                _authUser.Server = server;
            }

            _authUser.Name = userName;
            _authUser.Password = password;
            if (InternetChecker.IsInernetActive)
                new AuthentitficationDataService().AuthentificateUser(_authUser.Name, _authUser.Password, serverUrl, CheckUserDataCallback);
            else
                InvokeCallbackWithAuthCodeParameter(AuthentificationCode.NoInternetConnection);
        }
Пример #4
0
        public  void TestInitialize()
        {
            if (Membership.CurrentUser == null)
            {
                UserRepository repository = new UserRepository();
                User user = new User();
                user = repository.TryGetCurrentUser();
                if (user == null)
                {
                    user = new User();
                    user.Name = LoginViewModelTest.LOGIN;
                    user.Password = LoginViewModelTest.PASSWORD;
                    Server server = new Server();
                    server.Address = LoginViewModelTest.SERVER_PATH;
                    user.ID = 0;
                    user.Server = server;
                    user.IsCurrent = true;
                    repository.AddNewUser(user);
                }

                Membership.CheckUserData(user.Name, user.Password, user.Server.Address, this.OnUserAuthenticated);
            }
        }
Пример #5
0
        private static void CheckUserDataCallback(AuthentificationCode result)
        {
            if (result == AuthentificationCode.LoginSuccessed)
            {
                using (var userRepository = new UserRepository())
                    _authUser = userRepository.AddNewUser(_authUser);
                SetCurrentUser(_authUser);
            }

            InvokeCallbackWithAuthCodeParameter(result);
        }
Пример #6
0
 public static void ResetCurrentUser()
 {
     CurrentUser = null;
     using (var userRepository = new UserRepository())
         userRepository.ResetCurrentUser();
 }
Пример #7
0
 private static void SetCurrentUser(User user)
 {
     ResetCurrentUser();
     CurrentUser = user;
     using (var userRepository = new UserRepository())
         userRepository.SetUserToCurrentByUserID(user.ID);
 }
 partial void DeleteUser(User instance);
 partial void UpdateUser(User instance);
 partial void InsertUser(User instance);
 private void detach_User(User entity)
 {
     this.SendPropertyChanging();
     entity.Server = null;
 }
 private void attach_User(User entity)
 {
     this.SendPropertyChanging();
     entity.Server = this;
 }