Exemplo n.º 1
0
        /// <summary>
        /// 扮演用户
        /// </summary>
        /// <param name="id">用户主键</param>
        /// <returns>用户类</returns>
        public BaseUserInfo Impersonation(string id, out string statusCode)
        {
            BaseUserInfo userInfo = null;
            // 获得登录信息
            DataTable      dataTableLogOn = this.GetDataTableById(id);
            BaseUserEntity userEntity     = new BaseUserEntity();

            userEntity.GetSingle(dataTableLogOn);
            // 只允许登录一次,需要检查是否自己重新登录了,或者自己扮演自己了
            if (!UserInfo.Id.Equals(id))
            {
                if (BaseSystemInfo.CheckOnLine)
                {
                    if (userEntity.UserOnLine > 0)
                    {
                        statusCode = StatusCode.ErrorOnLine.ToString();
                        return(userInfo);
                    }
                }
            }
            userInfo = this.ConvertToUserInfo(userEntity);
            if (userEntity.IsStaff.Equals("1"))
            {
                // 获得员工的信息
                BaseStaffEntity  staffEntity    = new BaseStaffEntity();
                BaseStaffManager staffManager   = new BaseStaffManager(DbHelper, UserInfo);
                DataTable        dataTableStaff = staffManager.GetDataTableById(id);
                staffEntity.GetSingle(dataTableStaff);
                userInfo = staffManager.ConvertToUserInfo(staffEntity, userInfo);
            }
            statusCode = StatusCode.OK.ToString();
            // 登录、重新登录、扮演时的在线状态进行更新
            this.ChangeOnLine(id);
            return(userInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 扮演用户
        /// </summary>
        /// <param name="id">用户主键</param>
        /// <param name="status">状态</param>
        /// <returns>用户类</returns>
        public BaseUserInfo Impersonation(int id, out Status status)
        {
            BaseUserInfo userInfo = null;
            // 获得登录信息
            var entity = new BaseUserLogonManager(DbHelper, UserInfo).GetEntityByUserId(id.ToString());

            // 只允许登录一次,需要检查是否自己重新登录了,或者自己扮演自己了
            if (!UserInfo.Id.Equals(id))
            {
                if (BaseSystemInfo.CheckOnline)
                {
                    if (entity.UserOnline > 0)
                    {
                        status = Status.ErrorOnline;
                        return(userInfo);
                    }
                }
            }

            var userEntity = GetEntity(id);

            userInfo = ConvertToUserInfo(userEntity);
            if (userEntity.IsStaff.Equals("1"))
            {
                // 获得员工的信息
                var staffEntity    = new BaseStaffEntity();
                var staffManager   = new BaseStaffManager(DbHelper, UserInfo);
                var dataTableStaff = staffManager.GetDataTableById(id.ToString());
                staffEntity.GetSingle(dataTableStaff);
                userInfo = staffManager.ConvertToUserInfo(userInfo, staffEntity);
            }
            status = Status.Ok;
            // 登录、重新登录、扮演时的在线状态进行更新
            var userLogonManager = new BaseUserLogonManager(DbHelper, UserInfo);

            userLogonManager.ChangeOnline(id);
            return(userInfo);
        }