private void CreateNpc(IDbConnection connection, NpcModel npc) { // _dbProvider.Exec(connection, sqlResetIdentity); var npcKey = npc.NpcUser.Id; // npc.NpcUser.Id = 0; var insertedUser = _gameUserService.AddOrUpdate(connection, npc.NpcUser); if (insertedUser.Id != npcKey && npcKey != 0) { throw new NotImplementedException("insertedUser.Id!= npcKey"); } npc.NpcUser.Id = insertedUser.Id; var npcAlliance = _allianceService.AddOrUpdate(connection, npc.NpcAlliance); if (npcAlliance.Id != npcKey) { throw new NotImplementedException("npcAlliance.Id != npcKey"); } npc.NpcAlliance.Id = npcKey; var npcAllianceUser = _allianceService.GetAllianceUserById(connection, npcKey); if (npcAllianceUser == null) { throw new NotImplementedException("creator alliance user incorrect"); } var password = Guid.NewGuid().ToString(); var npcChannel = _channelService.CreateAllianceChannel(connection, npcAlliance, password); if (npc.NpcUser.Id == Npc.ConfederationGameUserId) { _channelService.CreateMessage(connection, new ChannelMessageDataModel { UserId = npc.NpcUser.Id, DateCreate = UnixTime.UtcNow(), ChannelId = npcChannel.Id, UserName = npc.NpcUser.Nickname, Message = "Welcome to Confederation!", UserIcon = npc.NpcUser.Avatar.Icon }); } }