예제 #1
0
        void cEXWB1_DocumentComplete(object sender, csExWB.DocumentCompleteEventArgs e)
        {
            cEXWB browser = (cEXWB)sender;
            bool ok = false;

            IHTMLDocument2 doc22 = browser.GetActiveDocument();
            ExtractCompanies(doc22);

            switch (_status)
            {
                case mBankStatus.Login:
                    {
                        ok = browser.AutomationTask_PerformAuthentication("customer", "password",
                            _settings.UserId.ToString(), _settings.Password, 
                            false, true);
                        _status = mBankStatus.MainScreen;
                        _settings = null;
                        break;
                    }
                case mBankStatus.MainScreen:
                    {
                        if (browser.AutomationTask_PerformClickLink(Names.PapieryWartLink))
                            _status = mBankStatus.PapieryOff;
                        break;
                    }
                case mBankStatus.PapieryOff:
                    {
                        IHTMLDocument2 doc = GetFunctionFrame(browser);
                        IHTMLElementCollection elements = (IHTMLElementCollection)doc.links;
                        foreach (IHTMLElement element in elements)
                        {
                            if (element.innerText != null)
                                if (element.innerText == "Historia transakcji")
                                {
                                    _status = mBankStatus.HistoriaTransOff;
                                    element.click();
                                }
                        }
                        break;
                    }
                case mBankStatus.HistoriaTransOff:
                    {
                        IHTMLDocument2 doc = GetFunctionFrame(browser);
                        ok = browser.AutomationTask_PerformEnterData("daysCount", "3");
                        if (browser.AutomationTask_PerformSelectRadio2("dateType", "days"))
                        {
                            _status = mBankStatus.ListaTrans;
                            _aktualnaTranzakcja = 0;
                            browser.GetElementsByNameOrId("Submit")[0].click();
                        }
                        break;
                    }
                case mBankStatus.ListaTrans:
                    {
                        int znalezionaTransakcja = 0;
                        IHTMLDocument2 doc = GetFunctionFrame(browser);
                        IHTMLElementCollection coll = (IHTMLElementCollection) doc.links;

                        if (AllTransactionsProcessed(coll))
                            return;

                        foreach (IHTMLElement el in coll)
                        {
                            if(el.title == "Zobacz szczegóły transakcji")
                            {
                                if (znalezionaTransakcja == _aktualnaTranzakcja)
                                {
                                    _aktualnaTranzakcja++;
                                    _status = mBankStatus.TransZlisty;
                                    el.click();
                                    break;
                                }
                                znalezionaTransakcja++;
                            }
                        }
                        break;
                    }
                case mBankStatus.TransZlisty:
                    {
                        IHTMLDocument2 doc = GetFunctionFrame(browser);
                        Transaction t = ProcessTransaction(doc.body.innerText);
                        _transFound.Add(t);
                        
                        _status = mBankStatus.ListaTrans;
                        browser.GetElementsByNameOrId("Submit")[0].click(); //powrot
                        break;
                    }
                case mBankStatus.KoniecListy:
                    {
                        _transFound = new List<Transaction>();
                        _status = mBankStatus.End;
                        break;
                    }
                case mBankStatus.End:
                    {
                        break;
                    }
            }

        }
예제 #2
0
 private bool AllTransactionsProcessed(IHTMLElementCollection coll)
 {
     if (_transacOnPage == 0)
     {
         foreach (IHTMLElement el in coll) //count how many transactions on page
         {
             if (el.title == "Zobacz szczegóły transakcji")
             {
                 _transacOnPage++;
             }
         }
     }
     else if (_aktualnaTranzakcja == _transacOnPage) //wyjscie z petli
     {
         _status = mBankStatus.KoniecListy;
         return true;
     }
     
     return false;
 }