private void processInvoice(string dir, string invoiceno, int rowNum) { WindowsFormsSynchronizationContext mUiContext = this.mUiContext; SendOrPostCallback d = new SendOrPostCallback(this.UpdateGridText); string filename = dir + Path.DirectorySeparatorChar.ToString() + invoiceno + ".pdf"; InvoiceInfo objA = this.ReadPDF(filename, rowNum); if (!ReferenceEquals(objA, null)) { objA.invFile = filename; Tuple <bool, string> tuple = objA.ValidateReadedData(invoiceno); if (!tuple.Item1) { mUiContext.Post(d, new Tuple <int, string>(rowNum, tuple.Item2)); } else { Tuple <bool, string> tuple2 = objA.FindFiles(dir, objA); if (!tuple2.Item1) { mUiContext.Post(d, new Tuple <int, string>(rowNum, tuple2.Item2)); } else { InvoicePrcessor prcessor = new InvoicePrcessor(); string str2 = prcessor.ProcessInvoice(objA); mUiContext.Post(d, new Tuple <int, string>(rowNum, str2)); prcessor.Dispose(); } } } }
public bool Login(InvoiceInfo info) { bool flag = false; try { this.driver.Navigate().GoToUrl(this.SignInUrl); if (this.driver.Url == this.HomePageUrl) { this.ShowDriverState(); return(true); } else { this.takescreenshot("login screen"); this.ShowDriverState(); IWebElement objA = this.FindElementIfExists(By.Id("UserName")); if (!ReferenceEquals(objA, null)) { objA.SendKeys(info.username); IWebElement element2 = this.FindElementIfExists(By.Id("Password")); if (!ReferenceEquals(objA, null)) { element2.SendKeys(info.password); this.driver.FindElementByCssSelector("button.btn.btn-default[type='submit']").Click(); bool flag2 = new WebDriverWait(this.driver, TimeSpan.FromSeconds((double)this.submit_wait)).Until <bool>(ExpectedConditions.UrlToBe(this.HomePageUrl)); if (this.driver.Url != this.HomePageUrl) { this.ShowDriverState(); flag = false; } else { this.ShowDriverState(); flag = true; } } else { return(false); } } else { return(false); } } } catch (Exception exception) { this.takescreenshot("exception login"); this.ShowDriverState(); Console.WriteLine(exception.Message); flag = false; } this.takescreenshot("afterLoginScreen"); return(flag); }
public string ProcessInvoice(InvoiceInfo info) { this.invoice_no = info.invoice; Console.WriteLine(info.Display()); this.RefreshDriver(); bool flag = false; int num = 0; while (true) { string formFillingErrorMSG; if (num < 3) { flag = this.Login(info); if (!flag) { num++; continue; } } if (!flag) { formFillingErrorMSG = "unable to do Login"; } else if (!this.OpenCreateBillPage()) { formFillingErrorMSG = "Unable to open Create Bill Page"; } else if (!this.FillCreateBillForm(info)) { this.takescreenshot(this.FormFillingErrorMSG); formFillingErrorMSG = this.FormFillingErrorMSG; } else if (!this.attachFiles(info)) { this.takescreenshot(this.FormFillingErrorMSG); formFillingErrorMSG = this.FormFillingErrorMSG; } else if (this.createBillAndDownloadFile(info)) { formFillingErrorMSG = "Bill Created"; } else { this.takescreenshot(this.FormFillingErrorMSG); formFillingErrorMSG = this.FormFillingErrorMSG; } return(formFillingErrorMSG); } }
public bool createBillAndDownloadFile(InvoiceInfo info) { bool flag3; try { IWebElement objA = this.FindElementIfExists(By.CssSelector(".create-billing-file-row > div:nth-child(1) > a:nth-child(1)")); if (!ReferenceEquals(objA, null)) { objA.Click(); Thread.Sleep(0x7d0); IWebElement element2 = this.FindElementIfExists(By.CssSelector("#span-billing-file-link > a:nth-child(1)")); if (ReferenceEquals(element2, null)) { Thread.Sleep(0x3e8); element2 = this.FindElementIfExists(By.CssSelector("#span-billing-file-link > a:nth-child(1)")); if (ReferenceEquals(element2, null)) { this.FormFillingErrorMSG = "Billing File Link not found"; return(false); } } this.takescreenshot("downloadLinkElemCreated"); string text = element2.Text; string url = string.Format(this.DownloadLink, text); if (this.TryDownloadFile(url, Path.Combine(Path.GetDirectoryName(info.BOLFile), text))) { flag3 = true; } else { this.FormFillingErrorMSG = "Billing Created Unable to download Billing File"; flag3 = false; } } else { this.FormFillingErrorMSG = "Create Bill from supported Doc button not found"; flag3 = false; } } catch (Exception) { flag3 = false; } return(flag3); }
public Tuple <bool, string> FindFiles(string dir, InvoiceInfo inv) { Tuple <bool, string> tuple; try { List <string> list = (from x in Directory.GetFiles(dir) where Path.GetFileName(x).ToLower().Contains(inv.loadNmber.ToLower()) select x).ToList <string>(); if (list.Count < 2) { tuple = new Tuple <bool, string>(false, "Unable to find files with loadnumber : " + inv.loadNmber); } else { string objA = (from x in list where Path.GetFileName(x).ToLower().Contains("bol") select x).First <string>(); if (ReferenceEquals(objA, null)) { tuple = new Tuple <bool, string>(false, "BOL file not found"); } else { inv.BOLFile = objA; string str2 = (from x in list where Path.GetFileName(x).ToLower().Contains("rate") select x).First <string>(); if (ReferenceEquals(str2, null)) { tuple = new Tuple <bool, string>(false, "Rate File not found"); } else { inv.RateConfFile = str2; tuple = new Tuple <bool, string>(true, ""); } } } } catch { tuple = new Tuple <bool, string>(false, "Error in finding Files"); } return(tuple); }
public bool FillCreateBillForm(InvoiceInfo info) { bool flag2; try { IWebElement objA = this.FindElementIfExists(By.Id("txt_load")); if (!ReferenceEquals(objA, null)) { objA.SendKeys(info.loadNmber); Thread.Sleep(500); this.takescreenshot("Load # enterred"); IWebElement element2 = this.FindElementIfExists(By.Id("txt_invoice")); if (!ReferenceEquals(element2, null)) { element2.Click(); element2.SendKeys(info.invoice); Thread.Sleep(500); this.takescreenshot("Invoice no enterred"); Thread.Sleep(0x7d0); IWebElement element3 = this.FindElementIfExists(By.Id("myModal")); if ((element2 == null) || !element3.Displayed) { IWebElement element4 = this.FindElementIfExists(By.Id("txt_inv_date")); if (!ReferenceEquals(element4, null)) { this.driver.ExecuteScript("document.getElementById('txt_inv_date').removeAttribute('readonly')", Array.Empty <object>()); element4.SendKeys(info.date); Thread.Sleep(500); this.takescreenshot("invoice date enterred"); IWebElement element5 = this.FindElementIfExists(By.Id("txt_inv_amt")); if (!ReferenceEquals(element5, null)) { element5.SendKeys(info.totalAmount); Thread.Sleep(500); this.takescreenshot("total amount enterred"); IWebElement element6 = this.FindElementIfExists(By.XPath("/html/body/div[3]/a")); if (!ReferenceEquals(element6, null)) { element6.Click(); Thread.Sleep(500); this.takescreenshot("search button clicked"); IWebElement element7 = this.FindElementIfExists(By.Id("txtDbName")); if (ReferenceEquals(element7, null)) { element7 = this.FindElementIfExists(By.Id("txtDbName")); if (ReferenceEquals(element7, null)) { this.FormFillingErrorMSG = "Debtor Name Input Not found"; return(false); } } element7.SendKeys(info.debtorName); Thread.Sleep(500); this.takescreenshot("debtor name enterred"); if (this.SearchDebtorandGetCount() > 1) { IWebElement element10 = this.FindElementIfExists(By.Id("txtDbPostalCode")); if (!ReferenceEquals(element10, null)) { element10.SendKeys(info.debtorPostalCode); Thread.Sleep(500); this.takescreenshot("debtor postal code enterred"); IWebElement element11 = this.FindElementIfExists(By.XPath("/html/body/div[1]/div/div/div[2]/center/button")); if (!ReferenceEquals(element11, null)) { element11.Click(); Thread.Sleep(0x9c4); this.takescreenshot("search debtor clicked"); } else { this.FormFillingErrorMSG = "Search Debtor Dialog Search Button Not Found"; return(false); } } else { this.FormFillingErrorMSG = "Postal Code Input Not Found"; return(false); } } IWebElement element8 = this.FindElementIfExists(By.Id("span_debtors")); if (ReferenceEquals(element8, null)) { element8 = this.FindElementIfExists(By.Id("span_debtors")); if (ReferenceEquals(element8, null)) { this.FormFillingErrorMSG = "List Debtors Not Found"; return(false); } } ReadOnlyCollection <IWebElement> onlys = element8.FindElements(By.CssSelector("input")); if (onlys.Count == 0) { this.FormFillingErrorMSG = "Debtor Not Found"; flag2 = false; } else { onlys[0].Click(); Thread.Sleep(0x5dc); this.takescreenshot("debtor radio clicked"); IWebElement element9 = this.FindElementIfExists(By.XPath("/html/body/div[1]/div/div/div[3]/button[3]")); if (ReferenceEquals(element9, null)) { this.FormFillingErrorMSG = "debtor select button not found"; flag2 = false; } else { element9.Click(); Thread.Sleep(0x9c4); this.takescreenshot("debtor selected"); this.takescreenshot("Form Filled"); flag2 = true; } } } else { this.FormFillingErrorMSG = "search Debtor Button Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Amount Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Date Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Billing Load Number Already Exists"; flag2 = false; } } else { this.FormFillingErrorMSG = "Invoice Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Load Inut Not found"; flag2 = false; } } catch (Exception) { this.takescreenshot("Error Form Filling"); this.FormFillingErrorMSG = "Error in Filling Create Bill Form"; flag2 = false; } return(flag2); }
public bool attachFiles(InvoiceInfo info) { bool flag2; try { IWebElement element4; IWebElement objA = this.FindElementIfExists(By.CssSelector("#tbd_docs > tr:nth-child(1) > td:nth-child(1) > img:nth-child(1)")); if (!ReferenceEquals(objA, null)) { objA.Click(); Thread.Sleep(0x7d0); IWebElement element2 = this.FindElementIfExists(By.Id("rd_doc_file")); if (!ReferenceEquals(element2, null)) { element2.Click(); IWebElement element3 = this.FindElementIfExists(By.Id("FileUpload")); if (!ReferenceEquals(element3, null)) { element3.SendKeys(info.invFile); element4 = this.FindElementIfExists(By.CssSelector(".attach-doc-submit")); if (!ReferenceEquals(element4, null)) { goto TR_002B; } else { element4 = this.FindElementIfExists(By.XPath("/html/body/div[1]/div/div/div[3]/button[2]")); if (!ReferenceEquals(element4, null)) { goto TR_002B; } else { this.FormFillingErrorMSG = "Invoice File Submit Button Not found"; flag2 = false; } } } else { this.FormFillingErrorMSG = "File Upload Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Attach File From PC Button Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Invoice Attach Button Not found"; flag2 = false; } return(flag2); TR_002B: element4.Click(); Thread.Sleep(0xfa0); this.takescreenshot("invoiceFileAttached"); try { IWebElement element8; IWebElement element5 = this.FindElementIfExists(By.CssSelector("#tbd_docs > tr:nth-child(2) > td:nth-child(1) > img:nth-child(1)")); if (!ReferenceEquals(element5, null)) { element5.Click(); Thread.Sleep(0x7d0); IWebElement element6 = this.FindElementIfExists(By.Id("rd_doc_file")); if (!ReferenceEquals(element6, null)) { element6.Click(); IWebElement element7 = this.FindElementIfExists(By.Id("FileUpload")); if (!ReferenceEquals(element7, null)) { element7.SendKeys(info.RateConfFile); element8 = this.FindElementIfExists(By.CssSelector(".attach-doc-submit")); if (!ReferenceEquals(element8, null)) { goto TR_001E; } else { element8 = this.FindElementIfExists(By.XPath("/html/body/div[1]/div/div/div[3]/button[2]")); if (!ReferenceEquals(element8, null)) { goto TR_001E; } else { this.FormFillingErrorMSG = "Invoice File Submit Button Not found"; flag2 = false; } } } else { this.FormFillingErrorMSG = "File Upload Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Attach File From PC Button Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Invoice Attach Button Not found"; flag2 = false; } return(flag2); TR_001E: element8.Click(); Thread.Sleep(0xfa0); this.takescreenshot("RateFileAttached"); try { IWebElement element12; IWebElement element9 = this.FindElementIfExists(By.CssSelector("#tbd_docs > tr:nth-child(3) > td:nth-child(1) > img:nth-child(1)")); if (!ReferenceEquals(element9, null)) { element9.Click(); Thread.Sleep(0x7d0); IWebElement element10 = this.FindElementIfExists(By.Id("rd_doc_file")); if (!ReferenceEquals(element10, null)) { element10.Click(); IWebElement element11 = this.FindElementIfExists(By.Id("FileUpload")); if (!ReferenceEquals(element11, null)) { element11.SendKeys(info.BOLFile); element12 = this.FindElementIfExists(By.CssSelector(".attach-doc-submit")); if (!ReferenceEquals(element12, null)) { goto TR_0011; } else { element12 = this.FindElementIfExists(By.XPath("/html/body/div[1]/div/div/div[3]/button[2]")); if (!ReferenceEquals(element12, null)) { goto TR_0011; } else { this.FormFillingErrorMSG = "Invoice File Submit Button Not found"; flag2 = false; } } } else { this.FormFillingErrorMSG = "File Upload Input Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Attach File From PC Button Not found"; flag2 = false; } } else { this.FormFillingErrorMSG = "Invoice Attach Button Not found"; flag2 = false; } return(flag2); TR_0011: element12.Click(); Thread.Sleep(0xfa0); this.takescreenshot("BOLAttached"); return(true); } catch { this.takescreenshot("ErrorBOLAttached"); this.FormFillingErrorMSG = "Erro attaching BOL File"; flag2 = false; } return(flag2); } catch { this.takescreenshot("ErrorRateFileAttached"); this.FormFillingErrorMSG = "Erro attaching Rate File"; flag2 = false; } return(flag2); } catch { this.takescreenshot("errorInvoiceFileAttached"); this.FormFillingErrorMSG = "Erro attaching Invoice File"; flag2 = false; } return(flag2); }