Example #1
0
        public static YodleeAccounts GetAccount(Customer customer, YodleeBanks bank)
        {
            YodleeAccounts res             = null;
            bool           verifiedAccount = false;
            int            attemptsCounter = 0;

            while (!verifiedAccount && attemptsCounter < 50)
            {
                attemptsCounter++;
                lock (accountsLock)
                {
                    res = accounts[0];
                    accounts.RemoveAt(0);
                    res.Bank         = bank;
                    res.CreationDate = DateTime.UtcNow;
                    AccountRepository.SaveOrUpdate(res);
                    accounts.Add(CreateUnallocatedAccount());
                }
                log.InfoFormat("Trying to verify Yodlee account:{0}. Attempt number:{1} for customer:{2}", res.Username, attemptsCounter, customer.Id);
                verifiedAccount = VerifyAccount(res);
                if (verifiedAccount)
                {
                    res.Customer = customer;
                    log.InfoFormat("Allocated yodlee account: {0} to customer:{1}", res.Id, customer.Id);
                    AccountRepository.SaveOrUpdate(res);
                }
                else
                {
                    log.InfoFormat("Failed to allocate yodlee account: {0} to customer:{1}. The account will be deleted from our DB", res.Id, customer.Id);
                    AccountRepository.Delete(res);
                }
            }
            return(res);
        }
Example #2
0
        public ActionResult AttachYodlee(int csId, string bankName)
        {
            try
            {
                var oEsi = new YodleeServiceInfo();
                this.mpChecker.Check(oEsi.InternalId, this.customer, csId);
            }
            catch (MarketPlaceAddedByThisCustomerException e)
            {
                Log.Debug(e);
                return(View((object)DbStrings.AccountAddedByYou));
            }

            var yodleeMain    = new YodleeMain();
            var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id);

            if (yodleeAccount == null)
            {
                YodleeBanks bank = this.yodleeBanksRepository.Search(csId);
                yodleeAccount = YodleeAccountPool.GetAccount(this.customer, bank);
            }

            var    callback = Url.Action("YodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https");
            string finalUrl = yodleeMain.GetAddAccountUrl(csId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            Log.InfoFormat("Redirecting to yodlee: {0}", finalUrl);
            return(Redirect(finalUrl));
        }