Exemplo n.º 1
0
        private void AddUser()
        {
            var user = new Model.Entity.User();

            user.Name = _view.CharacterName;
            _service.AddUser(user);
        }
Exemplo n.º 2
0
 public bool ValidLogin(Login parameter, out Model.Entity.User user)
 {
     if (parameter.LoginName == "eeroom")
     {
         var count = this.DbContext.User.Count();
         if (count != 0)
         {
             throw new ArgumentException("用户名或密码错误");
         }
         var xcpwd = Environment.GetEnvironmentVariable("xcpwd");
         if (string.IsNullOrEmpty(xcpwd))
         {
             throw new ArgumentException("请登录服务器,配置环境变量xcpwd");
         }
         if (xcpwd != parameter.PassWord)
         {
             throw new ArgumentException("用户名或密码错误");
         }
         user = new Model.Entity.User()
         {
             Id        = Guid.Empty,
             LoginName = "eeroom",
             NikeName  = "eeroom"
         };
         return(user != null);
     }
     user = this.DbContext.User.Where(x => x.LoginName == parameter.LoginName)
            .Where(x => x.Password == parameter.PassWord)
            .FirstOrDefault();
     return(user != null);
 }
Exemplo n.º 3
0
        public int SaveUser(UserDTO user)
        {
            string passwordSalt = CreateSalt(5);
            string pasword      = CreatePasswordHash(user.Password, passwordSalt);

            Model.Entity.User objUser = new Model.Entity.User();
            objUser.UserID        = getNewUserId();
            objUser.PasswordHash  = pasword;
            objUser.PasswordSalt  = passwordSalt;
            objUser.FirstName     = user.FirstName;
            objUser.MiddleName    = user.MiddleName;
            objUser.LastName      = user.LastName;
            objUser.EmailAddress  = user.EmailAddress;
            objUser.Mobile        = user.Mobile;
            objUser.CreatedOnDate = DateTime.Now;
            objUser.ModifiedDate  = DateTime.Now;

            _userRepository.Add(objUser);
            _unitOfWork.Commit();

            Model.Entity.UserRoleMapping roleMapping = new Model.Entity.UserRoleMapping();
            roleMapping.UserRoleMappingID = getNewUserRoleMappingId();
            roleMapping.RoleID            = 2;
            roleMapping.UserID            = objUser.UserID;

            _userRoleMappingRepository.Add(roleMapping);
            _unitOfWork.Commit();


            return(objUser.UserID);
        }
Exemplo n.º 4
0
 public User(Model.Entity.User entity)
 {
     if (entity == null)
     {
         return;
     }
     Id      = entity.Id;
     Name    = entity.Name;
     Email   = entity.Email;
     Picture = entity.Picture;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 推送系统消息
        /// </summary>
        /// <param name="notification">消息</param>
        /// <param name="user">用户</param>
        public void Send(Model.Entity.Notification notification, Model.Entity.User user)
        {
            if (notification.NotificationID == 0)
            {
                this.Save(notification);
            }

            if (user == null)
            {
                return;
            }

            var un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                DeviceID     = notification.DeviceID,
                Type         = notification.DeviceID == 0 ? 5 : 1,
                ObjectId     = notification.NotificationID,
                Get          = false,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Notification = false
            };

            this.NewUserNotification(un);
            return;

#pragma warning disable CS0162 // 检测到无法访问的代码
            if (user.LoginType == 2 && !string.IsNullOrEmpty(user.AppID) && user.AppID.Length == 64 && user.Notification)
#pragma warning restore CS0162 // 检测到无法访问的代码
            {
                var getList  = Logic.Notification.GetInstance().GetNotificationCount(user.UserID);
                var getTotal = getList.Sum(s => s.Message + s.Voice + s.SMS + s.Photo);
                YW.Notification.Notification alert = new YW.Notification.Notification(user.AppID);
                alert.Payload.Alert.Body = GetNotificationDescription(notification.Type,
                                                                      notification);
                if (user.NotificationSound)
                {
                    alert.Payload.Sound = "default";
                }
                alert.Payload.CustomItems.Add("Content",
                                              new object[]
                {
                    notification.Type, notification.DeviceID, notification.Content
                });
                alert.UserNotification = un;
                alert.Tag           = notification;
                alert.Payload.Badge = getTotal;
                this.GetServer(user.Project).QueueNotification(alert);
            }
        }
Exemplo n.º 6
0
        public virtual ActionResult Login(Model.VO.Account.Login parameter)
        {
            Model.Entity.User user = null;
            if (!this.bllUser.ValidLogin(parameter, out user))
            {
                return(this.Json(ApiResult.Error("用户名或密码错误")));
            }
            //表单校验,写人信息
            System.Web.Security.FormsAuthentication.SetAuthCookie(user.LoginName, parameter.IsPersistent ?? false);
            var targetUrl = System.Web.Security.FormsAuthentication.GetRedirectUrl(user.LoginName, parameter.IsPersistent ?? false);

            this.HttpContext.Session[Azeroth.Util.UtilConst.UserSessionFlag] = user;
            return(this.Json(ApiResult.OK(new { targetUrl })));
        }
 public CommandResult Handle(CreateAccountCommand command)
 {
     using (var ctx = new BookshelfDbContext(connectionString))
     {
         var user = new Model.Entity.User
         {
             AspNetGuid = command.AspNetGuid,
             FirstName  = command.FirstName,
             LastName   = command.LastName,
             CardId     = new Random().Next(1, 99999999), // TODO: In the future check if number is not used yet.
         };
         ctx.Users.Add(user);
         ctx.SaveChanges();
         return(CommandResult.Ok(user.Id));
     }
 }
Exemplo n.º 8
0
        public void DelByBindNumber(string bindNumber)
        {
            Model.Entity.User user = GetByBindNumber(bindNumber);
            if (user != null)
            {
                _dictionaryById.TryRemove(user.UserID, out var res);
            }

            const string sqlCommond = "Delete from [User] where BindNumber=@BindNumber";
            var          dp         = new DbParameter[]
            {
                DBHelper.CreateInDbParameter("@BindNumber", DbType.String, bindNumber),
            };

            DBHelper.GetInstance().ExecuteNonQuery(sqlCommond, dp);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 推送语音信息
        /// </summary>
        /// <param name="voice">语音</param>
        /// <param name="user">用户</param>
        public void Send(Model.Entity.DeviceVoice voice, Model.Entity.User user)
        {
            if (user == null || voice == null)
            {
                return;
            }

            Model.Entity.UserNotification un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                Type         = 2,
                DeviceID     = voice.DeviceID,
                ObjectId     = voice.DeviceVoiceId,
                Get          = false,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Notification = false
            };
            if (voice.Type == 3 && user.UserID == voice.ObjectId) //如果是自己发的,则不通知自己
            {
                un.Notification = true;
            }
            this.NewUserNotification(un);
            return;

#pragma warning disable CS0162 // 检测到无法访问的代码
            if (!un.Notification && user.LoginType == 2 && !string.IsNullOrEmpty(user.AppID) && user.AppID.Length == 64 && user.Notification)
#pragma warning restore CS0162 // 检测到无法访问的代码
            {
                var getList  = Logic.Notification.GetInstance().GetNotificationCount(user.UserID);
                var getTotal = getList.Sum(s => s.Message + s.Voice + s.SMS + s.Photo);
                YW.Notification.Notification alert = new YW.Notification.Notification(user.AppID);
                alert.Payload.Alert.Body = GetNotificationDescription(1, voice);
                if (user.NotificationSound)
                {
                    alert.Payload.Sound = "default";
                }
                alert.Payload.CustomItems.Add("Content",
                                              new object[] { 1, voice.DeviceID, "" });

                alert.UserNotification = un;
                alert.Payload.Badge    = getTotal;
                this.GetServer(user.Project).QueueNotification(alert);
            }
        }
Exemplo n.º 10
0
        public UserDTO ValidateUser(string email, string password)
        {
            Model.Entity.User objUser = _userRepository.Get(user => user.EmailAddress.Equals(email));
            if (objUser == null)
            {
                return(null);
            }
            string strPasswordHash = objUser.PasswordHash;
            string strPasswordSalt = strPasswordHash.Substring(strPasswordHash.Length - 8);
            string strPasword      = CreatePasswordHash(password, strPasswordSalt);

            if (strPasword.Equals(strPasswordHash))
            {
                return(CreateUserDTO(objUser));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 11
0
        public void DeleteUser(int userId)
        {
            Model.Entity.User user = _userRepository.Get(u => u.UserID == userId);
            if (user != null)
            {
                //Remove posts
                var posts = _postService.PostsByUserId(userId);
                posts.ForEach(post => _postService.DeletePost(post.PostID));

                //Delete all referral created by user
                _referralService.DeleteReferrals(userId);

                //Delete user role mapping
                _userRoleMappingRepository.Delete(rm => rm.UserID == userId);

                //Now Delete user object
                _userRepository.Delete(u => u.UserID == userId);
                _unitOfWork.Commit();
            }
        }
Exemplo n.º 12
0
        private UserDTO CreateUserDTO(Model.Entity.User user)
        {
            UserDTO objCustomerDTO = new UserDTO();

            if (user != null)
            {
                int roleId = user.UserRoleMapping.First().RoleID;
                objCustomerDTO.UserID       = user.UserID;
                objCustomerDTO.FirstName    = user.FirstName;
                objCustomerDTO.MiddleName   = user.MiddleName;
                objCustomerDTO.LastName     = user.LastName;
                objCustomerDTO.EmailAddress = user.EmailAddress;
                objCustomerDTO.Mobile       = user.Mobile;
                objCustomerDTO.ProfilePath  = user.ProfileImagePath;
                objCustomerDTO.ResumePath   = user.ResumePath;
                objCustomerDTO.UserRoleID   = this._roleRepository.Get(r => r.RoleID == roleId).RoleID;
                objCustomerDTO.UserRole     = this._roleRepository.Get(r => r.RoleID == roleId).RoleName;
            }
            return(objCustomerDTO);
        }
Exemplo n.º 13
0
        public int UpdateUser(UserDTO user)
        {
            Model.Entity.User objUser = _userRepository.GetById(user.UserID);
            objUser.FirstName    = user.FirstName;
            objUser.MiddleName   = user.MiddleName;
            objUser.LastName     = user.LastName;
            objUser.EmailAddress = user.EmailAddress;
            objUser.Mobile       = user.Mobile;
            objUser.ModifiedDate = DateTime.Now;

            _userRepository.Update(objUser);
            _unitOfWork.Commit();

            Model.Entity.UserRoleMapping userRoleMapping = _userRoleMappingRepository.Get(m => m.UserID == user.UserID);
            userRoleMapping.RoleID = user.UserRoleID;

            _userRoleMappingRepository.Update(userRoleMapping);
            _unitOfWork.Commit();

            return(objUser.UserID);
        }
Exemplo n.º 14
0
 public void Save(Model.Entity.User obj)
 {
     base.Save(obj);
     if (obj.UserID != 0)
     {
         if (_dictionaryById.ContainsKey(obj.UserID))
         {
             obj.UpdateTime = DateTime.Now;
             if (obj != _dictionaryById[obj.UserID])
             {
                 base.CopyValue <Model.Entity.User>(obj, _dictionaryById[obj.UserID]);
             }
         }
         else
         {
             obj.CreateTime = DateTime.Now;
             obj.UpdateTime = DateTime.Now;
             _dictionaryById.TryAdd(obj.UserID, obj);
         }
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 推送更新通知
        /// </summary>
        /// <param name="deviceId">设备编号</param>
        /// <param name="type">类型</param>
        /// <param name="user">用户</param>
        public void Send(int deviceId, int type, Model.Entity.User user)
        {
            if (user == null)
            {
                return;
            }

            var un = new Model.Entity.UserNotification
            {
                UserID       = user.UserID,
                DeviceID     = deviceId,
                Type         = 6,
                ObjectId     = type,
                Get          = false,
                CreateTime   = DateTime.Now,
                UpdateTime   = DateTime.Now,
                Notification = false
            };

            this.NewUserNotification(un);
        }
Exemplo n.º 16
0
        public int UpdateProfile(UserDTO user)
        {
            Model.Entity.User objUser = _userRepository.GetById(user.UserID);
            objUser.FirstName  = user.FirstName;
            objUser.MiddleName = user.MiddleName;
            objUser.LastName   = user.LastName;
            objUser.Mobile     = user.Mobile;

            if (!string.IsNullOrWhiteSpace(user.ProfilePath))
            {
                objUser.ProfileImagePath = user.ProfilePath;
            }
            if (!string.IsNullOrWhiteSpace(user.ResumePath))
            {
                objUser.ResumePath = user.ResumePath;
            }

            objUser.ModifiedDate = DateTime.Now;

            _userRepository.Update(objUser);
            _unitOfWork.Commit();

            return(objUser.UserID);
        }
Exemplo n.º 17
0
 public UserDTO GetUserByUserId(int userId)
 {
     Model.Entity.User user = new Model.Entity.User();
     user = _userRepository.GetAll().FirstOrDefault(u => u.UserID == userId);
     return(CreateUserDTO(user));
 }
Exemplo n.º 18
0
 public UserDTO GetUserByEmail(string email)
 {
     Model.Entity.User user = new Model.Entity.User();
     user = _userRepository.GetAll().FirstOrDefault(u => u.EmailAddress == email);
     return(CreateUserDTO(user));
 }