private void GetTrackingDetails(string html) { var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.InterGlobal; /*Tracking.ShippedUnit = Functions.TidyText(node.SelectNodeById("LabelIlkCikis").InnerText); * Tracking.ShippedAt = Extensions.GetDate(node.SelectNodeById("cikis_tarihi").InnerText); * Tracking.ArrivalUnit = Functions.TidyText(node.SelectNodeById("varis_subesi").InnerText); * Tracking.LastState = Functions.TidyText(node.SelectNodeById("Son_Durum").InnerText);*/ var nodes = node.SelectNodeById("kargo_takip_sonuc").SelectNodesByTag("tr"); for (int i = 0; i < nodes.Count(); i++) { var item = nodes[i] as HtmlNode; var movement = new Movement(); movement.Date = Extensions.GetDate(item.SelectNodesByTag("span")[0].InnerText); movement.State = Functions.TidyText(item.SelectNodesByTag("span")[1].InnerText); Tracking.Movements.Add(movement); } if (Tracking.Movements.Any()) { Tracking.LastState = Tracking.Movements.First().State; } if (Tracking.LastState.Contains("Teslim Alındı")) { Tracking.IsDelivered = true; } }
private void GetTrackingDetails(string html) { if (html.Contains("Aradığınız Alım Belgesi Numarasına Ait Kayıt Bulunamadı.") || html.Contains("Giriş Yaptığınız Numara Geçerli Bir Fatura Numarası Değildir.") || html.Contains("Aradığınız Gönderi Numarasına Ait Kayıt Bulunamadı.")) { Tracking = null; return; } var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Mng; Tracking.ShippedUnit = Functions.TidyText(node.SelectNodeByClass("tkp-fatura-birim").InnerText); Tracking.ArrivalUnit = Functions.TidyText(node.SelectNodeByClass("tkp-teslim-birim").InnerText); Tracking.ShippedAt = Extensions.GetDate(node.SelectNodeByClass("tkp-fatura-tarih").InnerText); if (node.SelectNodeByClass("tkp-teslim-tarih").InnerText.Trim() != "-") { string dateString = node.SelectNodeByClass("tkp-teslim-tarih").InnerText + " " + node.SelectNodeByClass("tkp-teslim-saat").InnerText; Tracking.DeliveredAt = Extensions.GetDate(dateString); Tracking.DeliveredBy = Functions.TidyText(node.SelectNodeByClass("tkp-teslim-alan").InnerText); } try { var movement = new Movement(); if (node.SelectNodeByClass("tkp-teslim-tarih").InnerText.Trim() != "-") { movement.Location = Tracking.ArrivalUnit; movement.Date = Tracking.DeliveredAt; movement.State = "Teslim edildi."; Tracking.Movements.Add(movement); Tracking.IsDelivered = true; } Tracking.LastState = Functions.TidyText(node.SelectNodeByClass("tkp-hareket-aciklama").InnerText); movement = new Movement(); if (node.SelectNodeByClass("tkp-hareket-tarih").InnerText.Trim() != "-") { movement.Date = Extensions.GetDate(node.SelectNodeByClass("tkp-hareket-tarih").InnerText.Trim() + " " + node.SelectNodeByClass("tkp-hareket-saat").InnerText.Trim()); } else { movement.Date = null; } if (!string.IsNullOrEmpty(node.SelectNodeByClass("tkp-hareket-tur").InnerText)) { movement.State = Functions.TidyText(node.SelectNodeByClass("tkp-hareket-tur").InnerText); } Tracking.Movements.Add(movement); } catch (Exception) { } }
public void GetTrackingDetails(string html) { if (html.Contains("Kayıt Bulunamadı")) { Tracking = null; return; } var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Yurtici; var nodes = node.SelectNodesByTag("tr"); for (int i = 0; i < nodes.Count; i++) { var item = nodes[i]; string text = item.SelectNodesByTag("td")[1].InnerText; if (i == 5) { Tracking.ShippedUnit = Functions.TidyText(text); } else if (i == 4) { Tracking.ArrivalUnit = Functions.TidyText(text); } else if (i == 0) { Tracking.ShippedAt = Extensions.GetDate(text.Replace(" -", "")); } else if (i == 16) { Tracking.DeliveredAt = Extensions.GetDate(text.Replace(" -", "")); } else if (i == 7) { Tracking.DeliveredBy = Functions.TidyText(text); } else if (i == 14) { Tracking.LastState = Functions.TidyText(text); } } if (Tracking.LastState.Contains("Teslim Edildi")) { Tracking.IsDelivered = true; } }
private void GetMovements(string html) { var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; var nodes = node.SelectNodeById("transactionsDataGrid").SelectNodesByTag("tr"); for (int i = 1; i < nodes.Count(); i++) { var item = nodes[i] as HtmlNode; var movement = new Movement(); movement.Location = Functions.TidyText(item.SelectNodesByTag("td")[2].InnerText) + " - " + Functions.TidyText(item.SelectNodesByTag("td")[1].InnerText); movement.Date = Extensions.GetDate(item.SelectNodesByTag("td")[0].InnerText); movement.State = Functions.TidyText(item.SelectNodesByTag("td")[3].InnerText); Tracking.Movements.Add(movement); } }
private void GetTrackingDetails(string html) { if (html.Contains("Takip Numarasına ait bilgi bulunamamaktadır")) { Tracking = null; return; } if (!html.Contains("ctl00_MainContent_PanelSorguSonucTeslimEdilmedi")) { Tracking.IsDelivered = true; } string subfix = ""; if (!Tracking.IsDelivered) { subfix = "TeslimEdilmedi"; } var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Ups; Tracking.ShippedUnit = Functions.TidyText(node.SelectNodeById("ctl00_MainContent_Label" + subfix + "AliciIl").InnerText) + " - " + Functions.TidyText(node.SelectNodeById("ctl00_MainContent_Label" + subfix + "AliciIlce").InnerText); if (node.SelectNodeById("ctl00_MainContent_Label3") != null) { Tracking.LastState = Functions.TidyText(node.SelectNodeById("ctl00_MainContent_Label3").InnerText); } if (node.SelectNodeById("ctl00_MainContent_LabelTeslimAlan") != null) { Tracking.DeliveredBy = Functions.TidyText(node.SelectNodeById("ctl00_MainContent_LabelTeslimAlan").InnerText); Tracking.DeliveredAt = Extensions.GetDate(node.SelectNodeById("ctl00_MainContent_LabelTeslimTarihi").InnerText); } if (node.SelectNodeById("ctl00_MainContent_DataListSonIslem") != null) { GetMovements(html); } }
public void GetMovements(string result) { var doc = new HtmlDocument(); doc.LoadHtml(result); var node = doc.DocumentNode; var col = node.SelectNodesByTag("table")[0].SelectNodesByTag("tr"); for (int i = 1; i < col.Count; i++) { var item = col[i]; var movement = new Movement(); movement.Date = Extensions.GetDate(item.SelectNodesByTag("td")[1].InnerText + " " + item.SelectNodesByTag("td")[2].InnerText); movement.State = Functions.TidyText(item.SelectNodesByTag("td")[3].InnerText); movement.Location = Functions.TidyText(item.SelectNodesByTag("td")[5].InnerText) + " - " + Functions.TidyText(item.SelectNodesByTag("td")[6].InnerText) + " " + Functions.TidyText(item.SelectNodesByTag("td")[7].InnerText); Tracking.Movements.Insert(0, movement); } }
private void GetTrackingDetails(string html) { if (html.Contains("Kayıt Bulunamadı")) { Tracking = null; return; } var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Surat; Tracking.ShippedUnit = Functions.TidyText(node.SelectNodeByClass("online_bg_orta").SelectNodesByTag("div")[1].SelectNodesByTag("div")[13].InnerText); Tracking.ShippedAt = Extensions.GetDate(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[1].InnerHtml.Replace("<br>", " ")); Tracking.ArrivalUnit = Functions.TidyText(node.SelectNodeByClass("online_bg_orta").SelectNodesByTag("div")[1].SelectNodesByTag("div")[31].InnerText); if (!string.IsNullOrEmpty(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[5].InnerText)) { Tracking.DeliveredBy = Functions.TidyText(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[5].InnerText); Tracking.DeliveredAt = Extensions.GetDate(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[3].InnerHtml.Replace("<br>", " ")); } Tracking.LastState = Functions.TidyText(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[6].InnerText); if (node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[6].InnerHtml.Contains("Teslim Edildi")) { Tracking.IsDelivered = true; } var movement = new Movement(); movement.Date = Extensions.GetDate(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[3].InnerHtml.Replace("<br>", " ")); movement.Location = Functions.TidyText(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[8].InnerText); movement.State = Functions.TidyText(node.SelectNodesByTag("tr")[1].SelectNodesByTag("td")[7].InnerText); Tracking.Movements.Add(movement); }
private void GetTrackingDetails(string html) { var doc = new HtmlDocument(); doc.LoadHtml(html); var node = doc.DocumentNode; Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Aras; Tracking.ShippedUnit = Functions.TidyText(node.SelectNodeById("LabelIlkCikis").InnerText); Tracking.ShippedAt = Extensions.GetDate(node.SelectNodeById("cikis_tarihi").InnerText); Tracking.ArrivalUnit = Functions.TidyText(node.SelectNodeById("varis_subesi").InnerText); Tracking.LastState = Functions.TidyText(node.SelectNodeById("Son_Durum").InnerText); if (!string.IsNullOrEmpty(node.SelectNodeById("Teslim_Alan").InnerText)) { Tracking.DeliveredBy = Functions.TidyText(node.SelectNodeById("Teslim_Alan").InnerText); Tracking.DeliveredAt = Extensions.GetDate(node.SelectNodeById("Teslim_Tarihi").InnerText); } if (Tracking.LastState.Contains("Teslim Edildi")) { Tracking.IsDelivered = true; } }
private void GetTrackingDetails(string html) { if (this.IsInternational) { var obj = JObject.Parse(html); if (obj["sonucAciklama"].ToString().ToLower().Contains("bulunamadı")) { Tracking = null; return; } Tracking.Code = this.Code; Tracking.Factory = CargoFactories.PttInternational; Tracking.DeliveredBy = Functions.TidyText(obj["teslim_alan"].ToString()); Tracking.ShippedUnit = " - "; Tracking.ArrivalUnit = " - "; Tracking.ShippedAt = null; try { JArray array = obj["dongu"] as JArray; for (int i = 0; i < array.Count; i++) { var obj2 = array[i] as JObject; Tracking.ShippedUnit = Functions.TidyText(array[0]["islemYeri"].ToString()); Tracking.ArrivalUnit = !string.IsNullOrEmpty(obj["teslim_alan"].ToString()) ? Functions.TidyText(array[array.Count - 1]["islemYeri"].ToString()) : " - "; Tracking.ShippedAt = Convert.ToDateTime(array[0]["tarih"].ToString()); Tracking.LastState = array[array.Count - 1]["yapilanIslem"].ToString(); var movement = new Movement(); try { movement.Location = Functions.TidyText(obj2["ofis"].ToString()) + " - " + Functions.TidyText(obj2["islemYeri"].ToString()); } catch { } movement.Date = Convert.ToDateTime(obj2["tarih"].ToString()); movement.State = obj2["yapilanIslem"].ToString(); if (movement.State.ToLower().Contains("teslim edildi")) { Tracking.IsDelivered = true; } Tracking.Movements.Insert(0, movement); } } catch (Exception) { } } else { var obj = JObject.Parse(html); if (obj["sonucAciklama"].ToString().ToLower().Contains("bulunamadı")) { Tracking = null; return; } Tracking.Code = this.Code; Tracking.Factory = CargoFactories.Ptt; Tracking.DeliveredBy = Functions.TidyText(obj["TESALAN"].ToString()); Tracking.ShippedUnit = Functions.TidyText(obj["IMERK"].ToString()); Tracking.ArrivalUnit = Functions.TidyText(obj["VMERK"].ToString()); string dateString = obj["ITARIH"].ToString(); Tracking.ShippedAt = Extensions.GetDate(dateString.Substring(6) + "." + dateString.Substring(4, 2) + "." + dateString.Substring(0, 4)); try { JArray array = obj["dongu"] as JArray; for (int i = 0; i < array.Count; i++) { var obj2 = array[i] as JObject; var movement = new Movement(); try { movement.Location = Functions.TidyText(obj2["IMERK"].ToString()); } catch { } movement.Date = Extensions.GetDate(obj2["ITARIH"].ToString()); movement.State = obj2["ISLEM"].ToString(); if (movement.State.ToLower().Contains("teslim edildi")) { Tracking.IsDelivered = true; } Tracking.Movements.Insert(0, movement); } } catch (Exception) { } } }