Example #1
0
File: Amo.cs Project: u705708/MZPO
        public Amo(IServiceScopeFactory scopeFactory, int concurrentConnections = 7)
        {
            _concurrentConnections = concurrentConnections;

            amoProvider  = new AmoProvider(scopeFactory);
            dataProvider = new DataProvider(scopeFactory);

            var authAccounts = amoProvider.GetAllAmoAccountsAsync().Result;

            _accounts = new List <AmoAccount>();
            if (authAccounts.Any())
            {
                foreach (var acc in authAccounts)
                {
                    _accounts.Add(new AmoAccount()
                    {
                        id           = acc.id,
                        name         = acc.name,
                        subdomain    = acc.subdomain,
                        auth         = new AuthProvider(acc, amoProvider, _concurrentConnections),
                        dataProvider = dataProvider
                    });
                }
            }
        }
Example #2
0
 public AuthProvider(AmoAccountAuth acc, AmoProvider prov, int concurrentConnections)
 {
     _concurrentRequestsAmount = concurrentConnections;
     _amoProvider             = prov;
     _amoConnectionsSemaphore = new(_concurrentRequestsAmount, _concurrentRequestsAmount);
     _tokenUpdateSemaphore    = new(1, 1);
     _amoAccountAuth          = acc;
     _authToken = acc.authToken;
     _refrToken = acc.refrToken;
     _validity  = acc.validity;
 }