WIP public list
This commit is contained in:
@@ -12,7 +12,6 @@ namespace CardmarketBot
|
|||||||
{
|
{
|
||||||
private readonly string username;
|
private readonly string username;
|
||||||
private readonly string password;
|
private readonly string password;
|
||||||
private readonly IUsedRepository _usedRepository;
|
|
||||||
|
|
||||||
Dictionary<string, Helper.Porto> portoberechnung = new Dictionary<string, Helper.Porto>()
|
Dictionary<string, Helper.Porto> portoberechnung = new Dictionary<string, Helper.Porto>()
|
||||||
{
|
{
|
||||||
@@ -24,11 +23,10 @@ namespace CardmarketBot
|
|||||||
{"3,20 €", Helper.Porto.PRIO270 },
|
{"3,20 €", Helper.Porto.PRIO270 },
|
||||||
};
|
};
|
||||||
|
|
||||||
public CardMarketParser(string username, string password, IUsedRepository repository)
|
public CardMarketParser(string username, string password)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
_usedRepository = repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Kunde> ParseCardMarket()
|
public List<Kunde> ParseCardMarket()
|
||||||
@@ -64,7 +62,7 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
List<string> ids = new List<string>();
|
List<string> ids = new List<string>();
|
||||||
List<Kunde> kunden = new List<Kunde>();
|
List<Kunde> kunden = new List<Kunde>();
|
||||||
List<string> bereitsbearbeitet = _usedRepository.Query;
|
|
||||||
IWebElement element;
|
IWebElement element;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -78,7 +76,6 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
for (int i = 8; i < datas.Length; i += 7)
|
for (int i = 8; i < datas.Length; i += 7)
|
||||||
{
|
{
|
||||||
//if (bereitsbearbeitet.Find(x => x.Equals(datas[i])) != null) continue;
|
|
||||||
ids.Add(datas[i]);
|
ids.Add(datas[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,8 +94,6 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
Kunde kunde = Helper.ConvertToKunde(element.Text);
|
Kunde kunde = Helper.ConvertToKunde(element.Text);
|
||||||
|
|
||||||
if (bereitsbearbeitet.Find(x => x.Equals(id)) != null) kunde.Rechnungerstellt = true;
|
|
||||||
|
|
||||||
// Bezahldatum
|
// Bezahldatum
|
||||||
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[2]/div/div[2]/div[2]"));
|
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[2]/div/div[2]/div[2]"));
|
||||||
kunde.Bezahldatum = Helper.ConvertBezahlDatum(element.Text);
|
kunde.Bezahldatum = Helper.ConvertBezahlDatum(element.Text);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace CardmarketBot
|
|||||||
List<Kunde> kunden;
|
List<Kunde> kunden;
|
||||||
public InvoiceParser(List<Kunde> kunden)
|
public InvoiceParser(List<Kunde> kunden)
|
||||||
{
|
{
|
||||||
this.kunden = kunden.FindAll(x => x.Rechnungerstellt != true);
|
this.kunden = kunden;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ModelRechnung> GetInvoices()
|
public List<ModelRechnung> GetInvoices()
|
||||||
@@ -111,20 +111,16 @@ namespace CardmarketBot
|
|||||||
Id = null,
|
Id = null,
|
||||||
MapAll = true,
|
MapAll = true,
|
||||||
Quantity = 1,
|
Quantity = 1,
|
||||||
//Price = PortoPreis[kunde.Versandskosten],
|
|
||||||
Name = "Versandskosten",
|
Name = "Versandskosten",
|
||||||
PositionNumber = 0,
|
PositionNumber = 0,
|
||||||
Discount = 0,
|
Discount = 0,
|
||||||
TaxRate = 19,
|
TaxRate = 19,
|
||||||
//PriceGross = PortoPreis[kunde.Versandskosten],
|
|
||||||
PriceTax = 19
|
PriceTax = 19
|
||||||
};
|
};
|
||||||
if(kunde.OverrideVersandskosten != null)
|
if(kunde.OverrideVersandskosten != null)
|
||||||
{
|
{
|
||||||
//Debugger.Break();
|
|
||||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
||||||
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
|
||||||
//Debugger.Break();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Kunde
|
|||||||
string plz;
|
string plz;
|
||||||
string ort;
|
string ort;
|
||||||
string land;
|
string land;
|
||||||
bool rechnungerstellt = false;
|
|
||||||
List<Artikel> artikels = new List<Artikel>();
|
List<Artikel> artikels = new List<Artikel>();
|
||||||
public DateTime Bezahldatum { get; set; }
|
public DateTime Bezahldatum { get; set; }
|
||||||
|
|
||||||
@@ -41,8 +41,6 @@ class Kunde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Rechnungerstellt { get => rechnungerstellt; set => rechnungerstellt = value; }
|
|
||||||
|
|
||||||
public Kunde(string Name, string Strasse, string Hausnummer, string PLZ, string Ort, string Land)
|
public Kunde(string Name, string Strasse, string Hausnummer, string PLZ, string Ort, string Land)
|
||||||
{
|
{
|
||||||
name = Name;
|
name = Name;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ using ConsoleApp3;
|
|||||||
using ConsoleApp3.Contracts;
|
using ConsoleApp3.Contracts;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace CardmarketBot
|
namespace CardmarketBot
|
||||||
{
|
{
|
||||||
@@ -10,12 +13,13 @@ namespace CardmarketBot
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
IUsedRepository usedRepository = new UsedRepository();
|
CheckVerkauf("120202");
|
||||||
|
//IUsedRepository usedRepository = new UsedRepository();
|
||||||
|
|
||||||
|
|
||||||
// Kunden aus Cardmarket erstellen
|
// Kunden aus Cardmarket erstellen
|
||||||
List<Kunde> kunden = new List<Kunde>();
|
List<Kunde> kunden = new List<Kunde>();
|
||||||
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!", usedRepository);
|
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!");
|
||||||
kunden = cardMarketParser.ParseCardMarket();
|
kunden = cardMarketParser.ParseCardMarket();
|
||||||
|
|
||||||
|
|
||||||
@@ -29,21 +33,67 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
foreach (ModelRechnung item in rechnungen)
|
foreach (ModelRechnung item in rechnungen)
|
||||||
{
|
{
|
||||||
SevdeskService sevdeskService = new SevdeskService("7251554968610b78ca865b2b774b4134");
|
var str_header = item.Invoice.Header;
|
||||||
sevdeskService.Create(item);
|
if (str_header != null)
|
||||||
|
{
|
||||||
|
Regex regex = new Regex("[0-9]*$");
|
||||||
|
Match matched = regex.Match(str_header);
|
||||||
|
string verkaufnummer = str_header.Substring(matched.Index);
|
||||||
|
if(!CheckVerkauf(verkaufnummer))
|
||||||
|
{
|
||||||
|
Debugger.Break();
|
||||||
|
SevdeskService sevdeskService = new SevdeskService("7251554968610b78ca865b2b774b4134");
|
||||||
|
sevdeskService.Create(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post CSV Erstellen
|
// Post CSV Erstellen
|
||||||
DeutschePost deutschePost = new DeutschePost(kunden);
|
DeutschePost deutschePost = new DeutschePost(kunden);
|
||||||
deutschePost.GenerateCSV();
|
deutschePost.GenerateCSV();
|
||||||
|
|
||||||
|
|
||||||
usedRepository.Insert(kunden);
|
|
||||||
|
|
||||||
Console.WriteLine("Fertig");
|
Console.WriteLine("Fertig");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool CheckVerkauf(string verkaufnummer)
|
||||||
|
{
|
||||||
|
byte[] bytes = new byte[1024];
|
||||||
|
|
||||||
|
IPHostEntry host = Dns.GetHostEntry("server");
|
||||||
|
IPAddress iPAddress = host.AddressList[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IPEndPoint remoteEP = new IPEndPoint(iPAddress, 4000);
|
||||||
|
|
||||||
|
Socket sender = new Socket(iPAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sender.Connect(remoteEP);
|
||||||
|
Console.WriteLine("Socket connected to {0}", sender.RemoteEndPoint.ToString());
|
||||||
|
byte[] msg = Encoding.ASCII.GetBytes(string.Format("TEST #{0}<EOF>", verkaufnummer));
|
||||||
|
int bytesSent = sender.Send(msg);
|
||||||
|
int bytesRec = sender.Receive(bytes);
|
||||||
|
Console.WriteLine("Replying = {0}", Encoding.ASCII.GetString(bytes, 0, bytesRec));
|
||||||
|
sender.Shutdown(SocketShutdown.Both);
|
||||||
|
sender.Close();
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException ane)
|
||||||
|
{
|
||||||
|
Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
|
||||||
|
}
|
||||||
|
catch (SocketException se)
|
||||||
|
{
|
||||||
|
Console.WriteLine("SocketException : {0}", se.ToString());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unexpected exception : {0}", e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
12
ConsoleApp3/SocketClient.cs
Normal file
12
ConsoleApp3/SocketClient.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CardMarketBot
|
||||||
|
{
|
||||||
|
internal class SocketClient
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user