Example #1
0
        public void queryPage(PageInfoOfuserCLUigIiY record)
        {
            ServiceUserClient client = new ServiceUserClient();

            client.queryPageCompleted += (sender, e) =>
            {
                ServicesEventArgs <PageInfoOfuserCLUigIiY> arg = new ServicesEventArgs <PageInfoOfuserCLUigIiY>();

                if (e.Error == null)
                {
                    arg.Result   = e.Result;
                    arg.Succesed = true;
                }
                else
                {
                    arg.Succesed = false;
                    arg.Error    = e.Error;
                }
                if (queryPageCompleted != null)
                {
                    queryPageCompleted.Invoke(this, arg);
                }
            };
            client.queryPageAsync(record);
        }
Example #2
0
        public void query(user record)
        {
            ServiceUserClient client = new ServiceUserClient();

            client.queryCompleted += (sender, e) =>
            {
                ServicesEventArgs <user[]> arg = new ServicesEventArgs <user[]>();

                if (e.Error == null)
                {
                    arg.Result   = e.Result;
                    arg.Succesed = true;
                }
                else
                {
                    arg.Succesed = false;
                    arg.Error    = e.Error;
                }
                if (queryCompleted != null)
                {
                    queryCompleted.Invoke(this, arg);
                }
            };
            client.queryAsync(record);
        }
Example #3
0
        public static ObservableCollection <Model.User> GetAllUsers()
        {
            ObservableCollection <Model.User> result = new ObservableCollection <Model.User>();
            ServiceUserClient serviceUser            = new ServiceUserClient();

            try
            {
                var users = serviceUser.GetListUser();
                foreach (var user in users)
                {
                    Model.User Muser = new Model.User()
                    {
                        login     = user.Login,
                        pwd       = user.Pwd,
                        name      = user.Name,
                        firstname = user.Firstname,
                        picture   = user.Picture,
                        connected = user.Connected,
                        role      = user.Role
                    };
                    result.Add(Muser);
                }
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
            return(result);
        }
Example #4
0
        public static bool Ping()
        {
            ServiceUserClient client = null;

            try
            {
                client = new ServiceUserClient();
                client.Open();

                return(client.Ping());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (client != null)
                {
                    if (client.State == CommunicationState.Faulted)
                    {
                        client.Abort();
                    }
                    else
                    {
                        client.Close();
                    }
                }
            }
        }
Example #5
0
        public static void DisconnectUser(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                serviceUser.Disconnect(login);
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
        }
        public static void Disconnect(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                serviceUser.Disconnect(login);
            }
            catch (Exception)
            { }
        }
Example #7
0
        public static string GetRole(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();
            string            role        = "";

            try
            {
                role = serviceUser.GetRole(login);
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
            return(role);
        }
        public static bool AddUser(User user)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.AddUser(user);
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static string GetRole(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.GetRole(login);
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }
        public static User[] GetListUser()
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.GetListUser();
            }
            catch (Exception)
            {
                return new User[0];
            }
        }
        public static bool DeleteUser(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.DeleteUser(login);
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool Connect(string login, string pwd)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.Connect(login, pwd);
            }
            catch (Exception)
            {
                return false;
            }
        }
Example #13
0
        public static bool DeleteUser(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();
            bool response = false;

            try
            {
                response = serviceUser.DeleteUser(login);
            }
            catch (Exception) { }
            finally
            {
                serviceUser.Close();
            }
            return(response);
        }
        private void addUser()
        {
            if (!string.IsNullOrEmpty(FirstnameInput) && !string.IsNullOrEmpty(NameInput) &&
                !string.IsNullOrEmpty(RoleInput) && !string.IsNullOrEmpty(LoginInput) &&
                !string.IsNullOrEmpty(PasswordInput) && !string.IsNullOrEmpty(PasswordConfirmInput))
            {
                if (string.Compare(PasswordInput, PasswordConfirmInput) == 0)
                {
                    ServiceUserClient service = new ServiceUserClient();
                    User     new_user         = new User();
                    string[] roleTab          = this._roleInput.Split(' ');

                    new_user.Connected = false;
                    new_user.Firstname = _firstNameInput;
                    new_user.Name      = _nameInput;
                    new_user.Role      = roleTab[roleTab.Length - 1];
                    new_user.Pwd       = _passwordInput;
                    new_user.Login     = _loginInput;
                    new_user.Picture   = Pict;

                    if (service.AddUser(new_user))
                    {
                        View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow;

                        View.Personnel view             = new colle_tMedecine.View.Personnel();
                        ViewModel.PersonnelViewModel vm = new colle_tMedecine.ViewModel.PersonnelViewModel();
                        view.DataContext = vm;
                        mainwindow.contentcontrol.Content = view;
                    }
                }
                else
                {
                    ErrorMessage     = "Les mots de passe sont différents.";
                    ShowConnectError = 1;
                    ShowConnectError = 0;
                }
            }
            else
            {
                ErrorMessage     = "Veuillez remplir tous les champs.";
                ShowConnectError = 1;
                ShowConnectError = 0;
            }
        }
Example #15
0
        public static Model.User GetUser(string login)
        {
            Model.User        user        = new Model.User();
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                var userS = serviceUser.GetUser(login);
                user.login     = userS.Login;
                user.pwd       = userS.Pwd;
                user.role      = userS.Role;
                user.name      = userS.Name;
                user.picture   = userS.Picture;
                user.firstname = userS.Firstname;
                return(user);
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
            return(user);
        }
Example #16
0
        public static bool CreateUser(Model.User user)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();
            bool result = false;

            try
            {
                result = serviceUser.AddUser(new ServiceUser.User()
                {
                    Login     = user.login + i.ToString(),
                    Pwd       = user.pwd,
                    Name      = user.name,
                    Firstname = user.firstname,
                    Picture   = user.picture,
                    Role      = user.role
                });
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
            return(result);
        }
        public static User GetUser(string login)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.GetUser(login);
            }
            catch (Exception)
            {
                return null;
            }
        }
        private void addUser()
        {
            if (!string.IsNullOrEmpty(FirstnameInput) && !string.IsNullOrEmpty(NameInput) &&
                !string.IsNullOrEmpty(RoleInput) && !string.IsNullOrEmpty(LoginInput) &&
                !string.IsNullOrEmpty(PasswordInput) && !string.IsNullOrEmpty(PasswordConfirmInput))
            {
                if (string.Compare(PasswordInput, PasswordConfirmInput) == 0)
                {
                    ServiceUserClient service = new ServiceUserClient();
                    User new_user = new User();
                    string[] roleTab = this._roleInput.Split(' ');

                    new_user.Connected = false;
                    new_user.Firstname = _firstNameInput;
                    new_user.Name = _nameInput;
                    new_user.Role = roleTab[roleTab.Length - 1];
                    new_user.Pwd = _passwordInput;
                    new_user.Login = _loginInput;
                    new_user.Picture = Pict;

                    if (service.AddUser(new_user))
                    {
                        View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow;

                        View.Personnel view = new colle_tMedecine.View.Personnel();
                        ViewModel.PersonnelViewModel vm = new colle_tMedecine.ViewModel.PersonnelViewModel();
                        view.DataContext = vm;
                        mainwindow.contentcontrol.Content = view;
                    }
                }
                else
                {
                    ErrorMessage = "Les mots de passe sont différents.";
                    ShowConnectError = 1;
                    ShowConnectError = 0;
                }
            }
            else
            {
                ErrorMessage = "Veuillez remplir tous les champs.";
                ShowConnectError = 1;
                ShowConnectError = 0;
            }
        }
Example #19
0
 public UserDA()
 {
     _service = new ServiceUserClient();
 }