コード例 #1
0
        public bool GetLogin()
        {
            try
            {
                var streamReader = new StreamReader("LoginsCsv.csv");

                while (true)
                {
                    var splits = streamReader.ReadLine()?.Split(';');
                    if (splits == null)
                    {
                        break;
                    }
                    var newPassLog = new PasswordLogin()
                    {
                        Login    = Guid.Parse(splits[0]),
                        Password = int.Parse(splits[1])
                    };

                    _concurrentCollection.Enqueue(newPassLog);
                }
            }
            catch
            {
                Console.WriteLine("File don`t founded");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public void GenerateLoginsPasswords()
        {
            var ranNum = new Random();

            for (int i = 0; i < 2000; i++)
            {
                var newPasLogin = new PasswordLogin()
                {
                    Login    = Guid.NewGuid(),
                    Password = ranNum.Next(1, 10000000)
                };
                _listOfLoginsPasswords.Add(newPasLogin);
            }
        }
コード例 #3
0
        public static void StartLogin(ConcurrentQueue <PasswordLogin> collection, CountdownEvent cdEvent)
        {
            var elem = new PasswordLogin();

            while (collection.TryDequeue(out elem))
            {
                var token = Login(elem.Login, elem.Password);
                if (token == null)
                {
                    Interlocked.Increment(ref _login);
                }
                else
                {
                    Interlocked.Increment(ref _notLogin);
                }
                cdEvent.Signal();
            }
        }