示例#1
0
        public Account getAccount(string accountName)
        {
            if (string.IsNullOrEmpty(accountName))
            {
                ExceptionUtils.SetState(Error.E_DATA_NOT_FOUND, ErrorsContract.ACC_NAME);
                System.ArgumentException argEx = new System.ArgumentException(ErrorsContract.ACC_NAME);
                throw argEx;
            }
            Profile profile = new Profile();

            profile = dbhelper.GetProfileByName(accountName);
            if (string.IsNullOrEmpty(profile.name))
            {
                ExceptionUtils.SetState(Error.E_DATA_NOT_FOUND, ErrorsContract.ACC_NAME);
                System.ArgumentException argEx = new System.ArgumentException(ErrorsContract.ACC_NAME);
                throw argEx;
            }
            if (string.IsNullOrEmpty(profile.password))
            {
                ExceptionUtils.SetState(Error.E_DATA_NOT_FOUND, ErrorsContract.ACC_PASSWORD);
                System.ArgumentException argEx = new System.ArgumentException(ErrorsContract.ACC_PASSWORD);
                throw argEx;
            }
            UserSessionData userSession = new UserSessionData
            {
                UserName = profile.name,
                Password = profile.password
            };

            if (!string.IsNullOrEmpty(profile.proxyHost))
            {
                ProxyData data    = new ProxyData(profile.proxyHost, profile.proxyPort, profile.proxyUsername, profile.proxyPassword);
                Account   account = new Account(userSession, proxyhandler.getProxy(data), data);
                return(account);
            }
            else
            {
                Account account = new Account(userSession);
                return(account);
            }
        }
示例#2
0
        private void SetAccounts(string tag)
        {
            Clear();
            profiles = dbhelper.GetProfilesByTag(tag);  //получаем данные аккаунтов из базы данных
            foreach (var item in profiles)
            {
                UserSessionData userSession = new UserSessionData
                {
                    UserName = item.name,
                    Password = item.password
                };

                if (item.proxyHost != null)
                {
                    ProxyData data = new ProxyData(item.proxyHost, item.proxyPort, item.proxyUsername, item.proxyPassword);
                    accounts.Add(new Account(userSession, proxyhandler.getProxy(data), data));
                    Console.WriteLine("Proxies added to session");
                }
                if (item.proxyHost == null)
                {
                    accounts.Add(new Account(userSession));
                }
            }
        }