public void Go(MbankSettings settings) { _settings = settings; cEXWB1.DocumentComplete += new csExWB.DocumentCompleteEventHandler(cEXWB1_DocumentComplete); //cEXWB1.Navigate("https://www.mbank.com.pl"); cEXWB1.Navigate("http://www.parkiet.com/temat/63.html"); //cEXWB1.Navigate("http://www.parkiet.com/notowania/ciagle.jsp"); }
private void btnSave_Click(object sender, EventArgs e) { using (MbankSettings settings = new MbankSettings()) { settings.UserId = txbLogin.Text.Trim().Parse<Int32>(); settings.Password = txbPass.Text.Trim(); Settings.Default.MyMbankSettings = settings; Settings.Default.Save(); } }
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; } } }