public LoginController(ShoppingCartDbContext db, UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ILoginData loginData)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _loginData     = loginData;
     _db            = db;
 }
Example #2
0
        public static void ShouldUpdateLoginDataToDbCorrectly()
        {
            //Arrange
            IGameDataRepository _gameDataRepository = MockData.GetIGameDataRepository(true);

            ILoginData loginData = MockData.GetILoginData();

            // Act
            _gameDataRepository.UpdateLoginData(loginData);


            using (var db = MockData.GetDbContext())
            {
                var characterList = db.Characters.ToList();

                Assert.NotNull(characterList.FirstOrDefault(
                                   x => x.CharacterId == 999888 &&
                                   x.CharacterName == "FAKENAME" &&
                                   x.WorldId == "nl33"));

                Assert.NotNull(characterList.FirstOrDefault(
                                   x => x.CharacterId == 999888 &&
                                   x.CharacterName == "FAKENAME" &&
                                   x.WorldId == "nl35"));

                Assert.NotNull(characterList.FirstOrDefault(
                                   x => x.CharacterId == 999888 &&
                                   x.CharacterName == "FAKENAME" &&
                                   x.WorldId == "nl37"));
            }
        }
Example #3
0
        public async void Login(ILoginData loginData)
        {
            var result = new LoginResult();

            var postContent = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "name", loginData.Identifier },
                { "password", loginData.Secret },
                { "cookie", "on" }
            });

            try
            {
                var response = await client.PostAsync(LoginAddress, postContent);

                var abloadCookies = cookieContainer.GetCookies(new Uri(Address));
                var sessionCookie = abloadCookies[SessionCookieName];

                result.Success = true;
            }
            catch (HttpRequestException ex)
            {
                result.Success = false;
                result.Reason  = ex.Message;
            }

            LoginComplete(this, result);
        }
        private void ParseCharacters(ILoginData loginData)
        {
            // Parse the characters
            List <Character> characterList = new List <Character>();

            foreach (ICharacter character in loginData.Characters)
            {
                characterList.Add(_mapper.Map <Character>(character));
            }

            if (characterList.Count > 0)
            {
                // Add or update the worlds
                using (var db = GetDBContext())
                {
                    foreach (Character character in characterList)
                    {
                        var entity = db.Characters.FirstOrDefault(
                            item => item.CharacterId == character.CharacterId &&
                            item.WorldId == character.WorldId);

                        if (entity != null)
                        {
                            // Make changes on entity
                            entity.CharacterName      = character.CharacterName;
                            entity.CharacterOwnerId   = character.CharacterOwnerId;
                            entity.CharacterOwnerName = character.CharacterOwnerName;
                            entity.AllowLogin         = character.AllowLogin;
                            entity.WorldId            = character.WorldId;

                            Account accountOwner = GetAccount(character.CharacterOwnerId, true);
                            if (accountOwner != null)
                            {
                                character.AccountOwnerId = accountOwner.Id;
                            }
                        }
                        else
                        {
                            db.Attach(character);
                            Account accountOwner = GetAccount(character.CharacterOwnerId, true);
                            if (accountOwner != null)
                            {
                                character.AccountOwnerId = accountOwner.Id;
                            }
                            db.Characters.Add(character);
                        }
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                //TODO add logger here
            }
        }
 /// <summary>
 /// ����
 /// </summary>
 /// <param name="loginData"></param>
 /// <returns></returns>
 public bool Contents(ILoginData loginData)
 {
     foreach (ILoginData _loginData in List)
     {
         if (_loginData.DeviceIP == loginData.DeviceIP
             && _loginData.DevicePort== loginData.DevicePort
             )
         {
             return true;
         }
     }
     return false;
 }
        private void ParseWorlds(ILoginData loginData)
        {
            List <World> worldList = new List <World>();

            // TW2 regards used worlds by the player as characters and empty worlds as world objects
            // This will parse the world data from a characterDTO to a world entities.
            foreach (IWorld world in loginData.Worlds)
            {
                worldList.Add(_mapper.Map <World>(world));
            }
            foreach (ICharacter character in loginData.Characters)
            {
                worldList.Add(_mapper.Map <World>(character));
            }

            // Filter on unique WorldCode, they are duplicates anyway.
            worldList = worldList.GroupBy(p => p.WorldId)
                        .Select(g => g.First())
                        .ToList();
            if (worldList.Count > 0)
            {
                // Add or update the worlds
                using (var db = GetDBContext())
                {
                    foreach (World world in worldList)
                    {
                        var entity = db.Worlds.FirstOrDefault(item => item.WorldId == world.WorldId);
                        if (entity != null)
                        {
                            // Make changes on entity
                            entity.Name        = world.Name;
                            entity.Full        = world.Full;
                            entity.KeyRequired = world.KeyRequired;
                            entity.Maintenance = world.Maintenance;
                            entity.OnServerId  = GetServer(world.WorldId.Substring(0, 2)).Id;
                        }
                        else
                        {
                            db.Attach(world);
                            world.OnServerId = GetServer(world.WorldId.Substring(0, 2)).Id;
                            db.Worlds.Add(world);
                        }
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                //TODO add logger here
            }
        }
Example #7
0
        private void PerformConnect(string fileName)
        {
            var        config    = ConfigurationService.ReadTaskboardConfiguration(fileName);
            ILoginData loginData = Factory.CreateObject <ILoginData>();

            loginData.TeamProjectCollectionUri = new Uri(config.TeamProjectCollection);
            loginData.TeamProjectName          = config.TeamProject;
            TaskboardService.LoginData         = loginData;
            IsConnecting = true;
            TaskboardService.Connect();
            OnConnectCompleted();
            OnPropertyChanged("IsConnected");
            OpenConfiguration(fileName);
            IsConnecting = false;
        }
        public IList <string> PrepareDataForSave(ISession session, ILoginData loginData)
        {
            IList <string> buffer = new List <string>();

            buffer.Add(string.Format("{0}={1}{2}", "username", loginData.Login, Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "password", loginData.Password, Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "start_timestamp",
                                     session.StartTimestamp.ToString(), Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "stop_time",
                                     session.StopTime.ToString(), Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "post_time",
                                     session.PostTime.ToString(), Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "key_times",
                                     ConvertListToString(session.KeyboardTimes), Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "mouse_times",
                                     ConvertListToString(session.MouseTimes), Environment.NewLine));
            buffer.Add(string.Format("{0}={1}{2}", "active_app_titles",
                                     ConvertStringListToString(session.ActiveAppTitles), Environment.NewLine));
            return(buffer);
        }
        public void UpdateLoginData(ILoginData loginData)
        {
            using (var db = GetDBContext())
            {
                // Update the logged in account
                Account account = GetAccount(loginData.Name);
                if (account != null)
                {
                    db.Attach(account);
                    account.TW2AccountID = loginData.PlayerId;
                    account.IsConfirmed  = true;
                    db.SaveChanges();
                }
            }

            ParseWorlds(loginData);

            ParseCharacters(loginData);

            DataEvents.InvokeLoginDataIsUpdated();
        }
        private IDictionary <string, string> CreatePostSessionParamsToDic(ISession session, ILoginData loginData)
        {
            IDictionary <string, string> postParams = new Dictionary <string, string>();

            postParams.Add("username", loginData.Login);
            postParams.Add("password", loginData.Password);
            postParams.Add("start_timestamp", session.StartTimestamp.ToString());
            postParams.Add("stop_time", session.StopTime.ToString());
            postParams.Add("post_time", TimingHelper.GetCurrentTimestamp().ToString() /*session.PostTime.ToString()*/);

            string keyTimes = ConvertListToString(session.KeyboardTimes);

            if (!string.IsNullOrEmpty(keyTimes))
            {
                postParams.Add("key_times", keyTimes);
            }

            string mouseTimes = ConvertListToString(session.MouseTimes);

            if (!string.IsNullOrEmpty(mouseTimes))
            {
                postParams.Add("mouse_times", mouseTimes);
            }

            // Ahmed
            string activeAppTitles = ConvertStringListToString(session.ActiveAppTitles);

            if (!string.IsNullOrEmpty(activeAppTitles))
            {
                postParams.Add("active_app_titles", activeAppTitles);
            }

            return(postParams);
        }
 public NameValueCollection CreatePostSessionParams(ISession session, ILoginData loginData)
 {
     return(WebUtils.ToNameValueCollection(CreatePostSessionParamsToDic(session, loginData)));
 }
 public NameValueCollection AppendPostSessionParams(List <string> loadedData, ISession session, ILoginData loginData)
 {
     return(WebUtils.ToNameValueCollection(AppendDataForSaveToDic(loadedData, session, loginData)));
 }
        private IDictionary <string, string> AppendDataForSaveToDic(List <string> loadedData, ISession session, ILoginData loginData)
        {
            IDictionary <string, string> postParams = new Dictionary <string, string>();

            postParams.Add("username", loginData.Login);
            postParams.Add("password", loginData.Password);
            postParams.Add("start_timestamp", session.StartTimestamp.ToString());
            postParams.Add("stop_time", session.StopTime.ToString());
            postParams.Add("post_time", TimingHelper.GetCurrentTimestamp().ToString() /*session.PostTime.ToString()*/);

            string keyTimes = CombineData(session.KeyboardTimes, loadedData, "key_times");

            if (!string.IsNullOrEmpty(keyTimes))
            {
                postParams.Add("key_times", keyTimes);
            }

            string mouseTimes = CombineData(session.MouseTimes, loadedData, "mouse_times");

            if (!string.IsNullOrEmpty(mouseTimes))
            {
                postParams.Add("mouse_times", mouseTimes);
            }

            string activeAppTitles = CombineStringData(session.ActiveAppTitles, loadedData, "active_app_titles");

            if (!string.IsNullOrEmpty(activeAppTitles))
            {
                postParams.Add("active_app_titles", activeAppTitles);
            }

            return(postParams);
        }
Example #14
0
 public LoginBusiness()
 {
     _loginData = new LoginData();
 }
 /// <summary>
 /// ���LoginData ����
 /// </summary>
 /// <param name="loginData">LoginData ����</param>
 public void Add(ILoginData loginData)
 {
     num = List.Add(loginData);
 }
Example #16
0
 public LoginController(ILoginData loginData)
 {
     _loginData = loginData;
 }
Example #17
0
 public LoginController(ILoginData _loginservice)
 {
     loginservice = _loginservice;
 }
 /// <summary>
 /// ɾ��LoginData ����
 /// </summary>
 /// <param name="loginData">LoginData ����</param>
 public void Remove(ILoginData loginData)
 {
     List.Remove(loginData);
 }
 public LoginController()
 {
     _loginData = new LoginData();
 }
Example #20
0
 public HomeController(ILoginData loginData)
 {
     _loginData = loginData;
 }
 public static void InvokeLoginDataAvailable(ILoginData loginDataDto, object sender = null)
 {
     LoginDataAvailable?.Invoke(sender, loginDataDto);
 }
        ILoginData ObjILoginData;//Referencia a la interfaz para el acceso a datos

        public LoginController()
        {
            ObjILoginData = new LoginData();
        }
 public AdminController(IAdminData adminData, ILoginData loginData, IItemCategoryData itemCategoryData)
 {
     _itemCategoryData = itemCategoryData;
     _adminData        = adminData;
     _loginData        = loginData;
 }