Example #1
0
 public void InsertUser(UserDTO dto)
 {
     var newUser = UserFactory.CreateUser(dto.UserName, EncodePassword(dto.Password), dto.Question,
         EncodePassword(dto.Answer), DateTime.Now);
     newUser.SetName(null, null, dto.DisplayName);
     newUser.SetOrganization(dto.OrganizationNo);
     newUser.SetContact(dto.Email, dto.Mobile);
     newUser.SetComment(dto.Description);
     newUser.SetApproved(true);
     _userRepository.Add(newUser);
 }
Example #2
0
 public void SyncUserInfo()
 {
     var users = new List<UserDTO>();
     var found = new FoundLdapUserInfoClient();
     var message = found.foundLdapUsers(ConfigurationManager.AppSettings["SyncUserLdapHost"],
         ConfigurationManager.AppSettings["SyncUserLdapPort"],
         ConfigurationManager.AppSettings["SyncUserAdminAccount"],
         ConfigurationManager.AppSettings["SyncUserAdminPwd"], ConfigurationManager.AppSettings["SyncUserOrgNo"]);
     if (string.IsNullOrEmpty(message))
     {
         return;
     }
     var doc = new XmlDocument();
     doc.LoadXml(message);
     var userNodeList = doc.SelectNodes("/root/row");
     if (userNodeList != null)
     {
         foreach (var userNode in userNodeList)
         {
             var user = new UserDTO();
             var element = userNode as XmlElement;
             if (element != null)
                 foreach (var childNode in element.ChildNodes)
                 {
                     var childElement = childNode as XmlElement;
                     if (childElement != null)
                         switch (childElement.Name.ToLower())
                         {
                             case "empid":
                                 user.Id = Int32.Parse(childElement.InnerText);
                                 break;
                             case "empno":
                                 user.UserName = childElement.InnerText;
                                 break;
                             case "empname":
                                 user.DisplayName = childElement.InnerText;
                                 break;
                             case "emppwd":
                                 user.Password = childElement.InnerText;
                                 break;
                             case "orgno":
                                 user.OrganizationNo = childElement.InnerText;
                                 break;
                         }
                 }
             users.Add(user);
         }
         _userAppService.SyncUserInfo(users);
     }
 }
Example #3
0
 public void DeleteUser(UserDTO user)
 {
     var deleteUser = _userRepository.Get(user.Id); //获取需要删除的对象。
     _userRepository.Remove(deleteUser); //删除User。
 }
Example #4
0
        public void ModifyUser(UserDTO user)
        {
            var updateUser = _userRepository.Get(user.Id);
            updateUser.SetOrganization(user.OrganizationNo);
            updateUser.SetContact(user.Email, user.Mobile);
            updateUser.SetComment(user.Description);

            var dtoUserRoles = user.UserRoles;
            var userRoles = updateUser.UserRoles;
            DataHelper.DetailHandle(dtoUserRoles.ToArray(),
                userRoles.ToArray(),
                c => c.Id, p => p.Id,
                i => InsertUserRole(updateUser, i),
                UpdateUserRole,
                d => _userRepository.DeleteUserRole(d));
            _userRepository.Modify(updateUser);
        }