public EInvoiceClient readEInvoiceGIBAsync(long IdNo) { EInvoiceClient eRow = new EInvoiceClient(); try { Task <string> task = Task.Run <string>(async() => await makeCall(IdNo)); string responseString = task.Result; HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(responseString); List <List <string> > table = doc.DocumentNode.SelectSingleNode("//table[@class='kurumlar']") .Descendants("tr") .Skip(1) .Where(tr => tr.Elements("td").Count() > 1) .Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList()) .ToList(); if (table[0][0] == IdNo.ToString()) { eRow.Identifier = IdNo; eRow.Alias = ""; eRow.Email = ""; eRow.Title = table[0][2]; eRow.Type = table[0][1]; eRow = base.Create(eRow); } return(eRow); } catch { return(eRow); } }
public void ProcessCashRegisterEInvoice() { using (IDAL dal = this.DAL) { DataTable dt = dal.ExecuteDataset("ACC_LST_NEWINVOICES_SP").Tables[0]; foreach (DataRow dr in dt.Rows) { try { EInvoiceOperations invOp = new EInvoiceOperations(dal); EInvoiceClient eInvCli = invOp.CheckIfEInvoiceCustomer(long.Parse(dr["IDENTITYNO_TXT"].ToString())); // kaydı oluştur. dal.BeginTransaction(); try { SaleInvoice i = new SaleInvoice(); i.EInvoiceFlag = (eInvCli.EInvoiceClientId != 0); if (eInvCli.EInvoiceClientId != 0) { i.EInvoiceClient = eInvCli.EInvoiceClientId; } i.CustomerIdNumber = long.Parse(dr["IDENTITYNO_TXT"].ToString()); i.Email = dr["EMAIL_TXT"].ToString(); i.Event = 1; i.Organization = 1; i.PhoneNumber = dr["PHONENUMBER_TXT"].ToString(); i.Sale = (long)dr["SALE"]; i.Title = dr["CUSTOMER_NM"].ToString(); i.StatusCode = 1; i.Address = dr["ADDRESS_TXT"].ToString(); i.SaleStore = int.Parse(dr["STORE"].ToString()); i.SaleAmount = decimal.Parse(dr["SALE_AMT"].ToString()); i.SaleDate = (DateTime)dr["TRANSACTION_DT"]; i.SaleInvoiceId = dal.Create <SaleInvoice>(i); startEInvoiceProcess(i, dal); dal.CommitTransaction(); } catch (Exception ex) { dal.RollbackTransaction(); throw ex; } } catch (Exception ex) { _logger.Error($"serviceName : SaleInvoiceService, methodName : ProcessCashRegisterEInvoice, identityInfo : {dr["IDENTITYNO_TXT"].ToString()}, Exception : {ex.ToString()}"); } } } }
public EInvoiceClient CheckIfEInvoiceCustomer(long customerId) { // kimlik numarasının e-fatura mükellefi olup olmadığını kontrol et. IUniParameter prmIdNo = _dal.CreateParameter("IdNo", customerId); EInvoiceClient e = _dal.Read <EInvoiceClient>("ACC_SEL_EINVOICECLIENTFROMID_SP", prmIdNo); if (e == null) { e = readEInvoiceGIBAsync(customerId); } else { e = new EInvoiceClient(); e.EInvoiceClientId = 0; } return(e); }