コード例 #1
0
        public static IdentityView ToView(Identity req, IdentityView view = null)
        {
            if (view == null)
            {
                view = new IdentityView();
            }

            view.Title          = req.Title;
            view.FirstName      = req.FirstName;
            view.MiddleName     = req.MiddleName;
            view.LastName       = req.LastName;
            view.Address1       = req.Address1;
            view.Address2       = req.Address2;
            view.Address3       = req.Address3;
            view.City           = req.City;
            view.State          = req.State;
            view.PostalCode     = req.PostalCode;
            view.Country        = req.Country;
            view.Company        = req.Company;
            view.Email          = req.Email;
            view.Phone          = req.Phone;
            view.SSN            = req.SSN;
            view.Username       = req.Username;
            view.PassportNumber = req.PassportNumber;
            view.LicenseNumber  = req.LicenseNumber;
            return(view);
        }
コード例 #2
0
        public async Task PlayerMobEnterZone(long mobId)
        {
            var identityView = IdentityView.FromObjectId(_dbContext, (SHIdentity.FromPrincipal(Context.User)).ObjectId);

            if (identityView.Identity == null)
            {
                return;
            }
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }

            if (mobId < 1)
            {
                return;
            }

            var mob = _dbContext.Mob.FirstOrDefault(e => e.Id == mobId && e.AccountId == identityView.Identity.Id);

            if (mob == null)
            {
                return;
            }

            var zone = _dbContext.Zone.FirstOrDefault(e => e.Id == mob.ZoneId);

            var response = new LoadZoneResponse();

            response.MobId     = mob.Id;
            response.ZoneId    = mob.ZoneId;
            response.SceneName = zone.SceneName;

            await Clients.Client(Context.ConnectionId).SendAsync("LoadZoneResponse", "", JsonConvert.SerializeObject(response));
        }
コード例 #3
0
        public async Task DeleteCharacter(long id)
        {
            var identityView = IdentityView.FromObjectId(_dbContext, (SHIdentity.FromPrincipal(Context.User)).ObjectId);

            if (identityView.Identity == null)
            {
                return;
            }
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }

            if (id < 1)
            {
                return;
            }

            var mob = _dbContext.Mob.FirstOrDefault(e => e.Id == id && e.AccountId == identityView.Identity.Id);

            if (mob == null)
            {
                return;
            }

            _dbContext.Mob.Remove(mob);
            _dbContext.SaveChanges();

            await Clients.Client(Context.ConnectionId).SendAsync("DeleteCharacterResponse", "", JsonConvert.SerializeObject(id));
        }
コード例 #4
0
ファイル: IdentityService.cs プロジェクト: 2644783865/alabo
        /// <summary>
        ///     Adds the or update.
        ///     添加实名认证
        /// </summary>
        /// <returns>ServiceResult.</returns>
        //public ServiceResult AddOrUpdate(IdentityView identityView) {
        //    if (identityView == null) {
        //        throw new ValidException("输入不能为空");
        //    }

        //    Identity input = AutoMapping.SetValue<Identity>(identityView);

        //    input.UserId = input.LoginUserId;

        //    var userdetail = Resolve<IUserDetailService>().GetSingle(e => e.UserId == input.UserId);
        //    if (userdetail == null) {
        //        return ServiceResult.FailedWithMessage("当前用户不存在!");
        //    }

        //    var find = GetSingle(r => r.UserId == input.UserId);
        //    if (find == null) {
        //        find = input;
        //    }

        //    find.Status = identityView.Status;
        //    find.UserId = userdetail.UserId;
        //    //find.CheckTime = DateTime.Now;
        //    // 添加或新增实名认证。一个用户只能有一个
        //    if (AddOrUpdate(find, find.Id != ObjectId.Empty)) {
        //        //userdetail.Sex = input.Sex;
        //        var result = Resolve<IUserDetailService>().Update(userdetail);
        //        if (result) {
        //            // 实名认证成功,修该用户的姓名和性别
        //            var user = Resolve<IUserService>().GetSingle(r => r.Id == userdetail.UserId);
        //            if (input.Status == IdentityStatus.Succeed) {
        //                user.Name = input.RealName;
        //                Resolve<IUserService>().Update(user);
        //            }
        //            //修改成功,清空缓存

        //            Resolve<IUserService>().DeleteUserCache(userdetail.UserId, user.UserName);

        //            return ServiceResult.Success;
        //        }
        //    }

        //    return ServiceResult.FailedWithMessage("实名认证失败");
        //}
        public IdentityView GetView(string id)
        {
            var view = new IdentityView();

            if (!id.IsNullOrEmpty())
            {
                var identity = Resolve <IIdentityService>().GetSingle(u => u.Id == id.ToObjectId());
                view = AutoMapping.SetValue <IdentityView>(identity);
            }

            return(view);
        }
コード例 #5
0
        public async Task CreateCharacter(CreateCharacterRequest request)
        {
            var identityView = IdentityView.FromObjectId(_dbContext, (SHIdentity.FromPrincipal(Context.User)).ObjectId);

            if (identityView.Identity == null)
            {
                return;
            }
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }

            if (request == null || String.IsNullOrEmpty(request.Name))
            {
                return;
            }

            if (_dbContext.Mob.Count(e => e.AccountId == identityView.Identity.Id) > 2)
            {
                return;
            }

            var mob = new Mob()
            {
                MobClassId = request.MobClassId,
                MobRaceId  = request.MobRaceId,
                AccountId  = identityView.Identity.Id,
                Name       = request.Name,
                ZoneId     = 1
            };

            if (_dbContext.Mob.Any(e => e.AccountId == identityView.Identity.Id && e.Name.Equals(mob.Name)))
            {
                return;
            }

            mob = _dbContext.Mob.Add(mob).Entity;
            _dbContext.SaveChanges();
            var response = new CreateCharacterResponse();

            response.Mob = mob;

            await Clients.Client(Context.ConnectionId).SendAsync("CreateCharacterResponse", "", JsonConvert.SerializeObject(response));
        }
コード例 #6
0
 public Identity(IdentityView obj)
 {
     Title          = obj.Title;
     FirstName      = obj.FirstName;
     MiddleName     = obj.MiddleName;
     LastName       = obj.LastName;
     Address1       = obj.Address1;
     Address2       = obj.Address2;
     Address3       = obj.Address3;
     City           = obj.City;
     State          = obj.State;
     PostalCode     = obj.PostalCode;
     Country        = obj.Country;
     Company        = obj.Company;
     Email          = obj.Email;
     Phone          = obj.Phone;
     SSN            = obj.SSN;
     Username       = obj.Username;
     PassportNumber = obj.PassportNumber;
     LicenseNumber  = obj.LicenseNumber;
 }
コード例 #7
0
        public async Task GetMobRaces()
        {
            var identityView = IdentityView.FromObjectId(_dbContext, (SHIdentity.FromPrincipal(Context.User)).ObjectId);

            if (identityView.Identity == null)
            {
                return;
            }
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }

            if (_dbContext.MobRace != null)
            {
                await Clients.Client(Context.ConnectionId).SendAsync("MobRacesResponse", "", JsonConvert.SerializeObject(_dbContext.MobRace.ToList()));
            }
            else
            {
                await Clients.Client(Context.ConnectionId).SendAsync("MobRacesResponse", "", JsonConvert.SerializeObject(new List <MobRace>()));
            }
        }
コード例 #8
0
        public async Task GetMobsByOwnerId()
        {
            var identityView = IdentityView.FromObjectId(_dbContext, (SHIdentity.FromPrincipal(Context.User)).ObjectId);

            if (identityView.Identity == null)
            {
                return;
            }
            if (!Context.User.Identity.IsAuthenticated)
            {
                return;
            }

            var mobs = _dbContext.Mob.Where(e => e.AccountId == identityView.Identity.Id);

            if (mobs != null)
            {
                await Clients.Client(Context.ConnectionId).SendAsync("MobsByOwnerIdResponse", "", JsonConvert.SerializeObject(mobs.ToList()));
            }
            else
            {
                await Clients.Client(Context.ConnectionId).SendAsync("MobsByOwnerIdResponse", "", JsonConvert.SerializeObject(new List <Mob>()));
            }
        }