示例#1
0
        private async Task GetAccounts()
        {
            const string script = @"(function(){
                        var select = document.getElementById('ddlAccounts_m_ddl');
                        var result = [];

                        for(i = 0; i < select.options.length; i++) {
                            if (select.options[i].value != -1){
                                result[i] = select.options[i].text;
                            }
                         }
                        return result;
                    })()";

            await Browser.EvaluateScriptAsync(script)
            .ContinueWith(res =>
            {
                if (!res.IsFaulted && res.Result.Result != null)
                {
                    var accountNames = ((List <object>)res.Result.Result).Select(i => i.ToString());
                    foreach (var account in accountNames)
                    {
                        var ac = account.Split('-', '/');
                        _accounts.Add(new AccountBasic
                        {
                            Label         = $"{CommonScraper.IntParseSafe(ac[0])} {CommonScraper.IntParseSafe(ac[1])}/{CommonScraper.IntParseSafe(ac[2])}",
                            BranchNumber  = CommonScraper.IntParseSafe(ac[0]),
                            AccountNumber = $"{CommonScraper.IntParseSafe(ac[1])}/{CommonScraper.IntParseSafe(ac[2])}"
                        });
                    }
                }
            }, TaskScheduler.Default);
        }
示例#2
0
        private async Task <AccountBasic> GetSelectedAccount()
        {
            AccountBasic result = null;

            const string script = @"(function(){
                        var select = document.getElementById('ddlAccounts_m_ddl');
                        return select.options[select.selectedIndex].text;
                    })()";

            await Browser.EvaluateScriptAsync(script)
            .ContinueWith(res =>
            {
                if (!res.IsFaulted && res.Result.Result != null)
                {
                    var accountNumber = CommonScraper.ToUtf8((String)res.Result.Result);
                    var ac            = accountNumber.Split('-', '/');

                    if (ac.Length == 3)
                    {
                        var searchFor = $"{CommonScraper.IntParseSafe(ac[1])}/{CommonScraper.IntParseSafe(ac[2])}";
                        result        = _accounts.Find(a => a.AccountNumber.Equals(searchFor));
                    }
                }
            }, TaskScheduler.Default);

            return(result);
        }
示例#3
0
        protected async Task UpdateBalanceForSelectedAccount(AccountBasic selectedAccount)
        {
            const string script = @"(function(){
                        var balance = document.getElementById('lblBalancesVal').innerHTML;
                        return balance;
                    })()";

            await Browser.EvaluateScriptAsync(script)
            .ContinueWith(res =>
            {
                if (!res.IsFaulted && res.Result.Result != null)
                {
                    var balance             = CommonScraper.ToUtf8((String)res.Result.Result).TrimStart('₪');
                    selectedAccount.Balance = Convert.ToDecimal(balance);
                }
            }, TaskScheduler.Default);
        }