Compare commits

21 Commits

Author SHA1 Message Date
6c216ca189 absturz mit X behoben 2023-09-09 09:47:48 +02:00
b6d36d7bf5 Cardmarket artikelparser umgeschrieben 2023-09-06 15:19:11 +02:00
839080392b Programm erweitert
über bestellnummer angabe prüft der Bot die Bestellung
2023-08-27 10:12:58 +02:00
b0e27caf9f fehlerhafte url war hinterlegtr. Diente zur Debug 2023-08-18 15:41:24 +02:00
81ed7ae8d1 Chrome driver geupdatet.
Vorbereitet für Tests um den Artikelparser zuverlässiger zu erstellen
2023-08-18 09:45:11 +02:00
ff8649b314 Slowenien hinzugefügt 2023-08-16 23:05:19 +02:00
744ce5a687 Kroatien hinzugefügt 2023-08-14 17:15:54 +02:00
dd7bd99595 Spanien hinzugefügt 2023-08-09 12:25:51 +02:00
Lukas Winkelmann
e6611f6c18 Batchdatei geht nicht mehr ins Projektornder 2023-08-08 19:54:16 +02:00
e48b6e9fae CSV Dateien ignoriert 2023-08-08 12:12:15 +02:00
34e5fb588d CSV Dateien sollen nicht ins Git 2023-08-08 12:09:21 +02:00
2de8b4adde Renaming
start.bat added
2023-08-08 12:05:06 +02:00
ee6eb210b7 Nullverweise warnings bereinigt 2023-08-08 11:58:09 +02:00
4af2bae8cd CSS selektor von login angepasst 2023-08-07 20:11:56 +02:00
966514148d Fehler in Ländercode behoben 2023-08-02 19:49:36 +02:00
1e115bddee public list fertig gestellt 2023-08-02 19:24:48 +02:00
2f2524a5c4 public list fertig gestellt 2023-08-01 14:20:27 +02:00
f4a0af33b0 WIP public list 2023-07-25 09:24:18 +02:00
e44385473f Adresse parser aktualisiert
Es werden nun alle Bestellungen CSV dateien erstellt
ledig nicht alle Rechnungen werden angelegt.
2023-07-23 13:52:37 +02:00
324f01df5e Funktionstüchtig 2023-07-22 20:32:47 +02:00
19e6a43847 Remove old dependency 2023-07-17 19:12:19 +02:00
37 changed files with 656 additions and 301 deletions

5
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/.vs/
/ConsoleApp3/bin/
/ConsoleApp3/obj/
*/bin/
*/obj/
*.csv

View File

@@ -1,6 +1,6 @@
// See https://aka.ms/new-console-template for more information
internal class Artikel
public class Artikel
{
public int Amount { get; set; }
public string GERName { get; set; } = "";

View File

@@ -8,14 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.10.0" />
</ItemGroup>
<ItemGroup>
<None Update="usedList.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<PackageReference Include="Selenium.WebDriver" Version="4.11.0" />
</ItemGroup>
</Project>

View File

@@ -12,7 +12,6 @@ namespace CardmarketBot
{
private readonly string username;
private readonly string password;
private readonly IUsedRepository _usedRepository;
Dictionary<string, Helper.Porto> portoberechnung = new Dictionary<string, Helper.Porto>()
{
@@ -24,18 +23,21 @@ namespace CardmarketBot
{"3,20 €", Helper.Porto.PRIO270 },
};
public CardMarketParser(string username, string password, IUsedRepository repository)
public CardMarketParser(string username, string password)
{
this.username = username;
this.password = password;
_usedRepository = repository;
}
public List<Kunde> ParseCardMarket()
public List<Kunde> ParseCardMarket(string forceid = "")
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("start-maximized");
options.AddArgument("incognito");
options.AddArgument("disable-popup-blocking");
options.AddArgument("force-device-scale-factor=0.8");
IWebDriver cd = new ChromeDriver(options);
cd.Url = @"https://www.cardmarket.com/de/OnePiece";
cd.Navigate();
@@ -48,7 +50,7 @@ namespace CardmarketBot
cd.FindElement(By.Name("userPassword")).Click();
cd.FindElement(By.Name("userPassword")).SendKeys(password);
cd.FindElement(By.CssSelector("#header-login > input.btn.AB-login-btn.btn-outline-primary.btn-sm")).Click();
cd.FindElement(By.CssSelector("#header-login > input.btn.btn-outline-primary.btn-sm")).Click();
CookieContainer cookieContainer = new CookieContainer();
@@ -59,40 +61,40 @@ namespace CardmarketBot
cookieContainer.Add(new System.Net.Cookie(name, value, c.Path, c.Domain));
}
cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
//cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Sent");
List<string> ids = new List<string>();
List<Kunde> kunden = new List<Kunde>();
IWebElement element;
if (forceid != "")
{
ids.Add(forceid);
}
else
{
cd.Navigate().GoToUrl(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
try
{
element = cd.FindElement(By.XPath("/html/body/main/section/div[3]/div[3]/div[2]"));
string content = element.Text;
element = cd.FindElement(By.XPath("/html/body/main/section/div[3]/div[4]"));
List<string> bereitsbearbeitet = _usedRepository.Query;
string content = element.Text;
string[] datas = content.Split("\r\n");
for (int i = 0; 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]);
}
}
catch(OpenQA.Selenium.NotFoundException ex)
catch (OpenQA.Selenium.NotFoundException)
{
Console.WriteLine("Keine Verkäufe aktuell");
return kunden;
}
}
foreach (string id in ids)
{
Console.WriteLine(id);
cd.Navigate().GoToUrl(string.Format(@"https://www.cardmarket.com/de/OnePiece/Orders/{0}", id));
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[3]/div[2]/div[2]/div/div"));
@@ -113,7 +115,7 @@ namespace CardmarketBot
else
{
kunde.OverrideVersandskosten = element.Text;
Console.WriteLine(@"Achtung bei ID {id} wurde kein Richtige Porto berechnet. Liegt es im Ausland?");
Console.WriteLine($"Achtung bei ID {id} wurde kein Richtige Porto berechnet. Liegt es im Ausland?");
}
//kunde.Versandskosten = portoberechnung[element.Text];
kunde.BestellungID = id;
@@ -127,8 +129,9 @@ namespace CardmarketBot
kunden.Add(kunde);
Thread.Sleep(TimeSpan.FromSeconds(5));
Thread.Sleep(TimeSpan.FromSeconds(3));
}
cd.Quit();
return kunden;
}
}

View File

@@ -0,0 +1,118 @@
using ConsoleApp3.Contracts;
using OpenQA.Selenium.DevTools;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace CardMarketBot
{
internal class CheckSevDeskPublicList : ICheckSevDesk
{
private static readonly object _lock = new object();
private static bool _closed;
enum EResult
{
FAILED,
AVAIBLE,
OK,
WRITTEN
}
private static void Write(TcpClient client, string str)
{
try
{
//SocketShutdown reason = SocketShutdown.Send;
lock (_lock)
{
BinaryWriter writer = new BinaryWriter(client.GetStream());
writer.Write(str);
if (_closed)
{
//reason = SocketShutdown.Both;
}
}
//client.Client.Shutdown(reason);
}
catch (IOException e)
{
Console.WriteLine($"IOException writing to socket: {e.Message}");
}
}
private static EResult Read(TcpClient client)
{
try
{
//while(true)
//{
try
{
if (!client.Connected)
{
lock (_lock)
{
_closed = true;
//break;
}
}
BinaryReader reader = new BinaryReader(client.GetStream());
string res = reader.ReadString();
if (res.Contains("OK"))
return EResult.OK;
return EResult.FAILED;
}
catch (EndOfStreamException)
{
lock (_lock)
{
_closed = true;
}
return EResult.FAILED;
}
//client.Client.Shutdown(SocketShutdown.Receive);
//}
}
catch (IOException e)
{
Console.WriteLine(e.Message);
return EResult.FAILED;
}
}
public bool AlreadyKnown(string verkaufsnummer)
{
try
{
TcpClient client = new TcpClient("nas.cosysda.de", 4000);
Write(client, string.Format("#TEST#{0}", verkaufsnummer));
EResult result = Read(client);
client.Client.Shutdown(SocketShutdown.Both);
client.Close();
return result == EResult.OK;
}
catch(SocketException)
{
throw new SocketException();
}
}
public bool Write(string verkaufsnummer)
{
TcpClient client = new TcpClient("nas.cosysda.de", 4000);
Write(client, string.Format("#WRITE#{0}", verkaufsnummer));
EResult result = Read(client);
client.Client.Shutdown(SocketShutdown.Both);
client.Close();
return result == EResult.OK;
}
}
}

View File

@@ -0,0 +1,8 @@
namespace ConsoleApp3.Contracts
{
internal interface ICheckSevDesk
{
bool AlreadyKnown(string verkaufsnummer);
bool Write(string verkaufsnummer);
}
}

View File

@@ -15,14 +15,14 @@ namespace ConsoleApp3.DataContracts
public int? Id { get; set; }
[JsonProperty(PropertyName = "objectName")]
public string ObjectName { get; set; }
public string ObjectName { get; set; } = "";
/// <summary>
///
/// </summary>
/// <value></value>
[DataMember(Name = "invoiceNumber", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "invoiceNumber")]
public string InvoiceNumber { get; set; }
public string InvoiceNumber { get; set; } = "";
/// <summary>
/// the contact the invoice belongs to
@@ -30,7 +30,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the contact the invoice belongs to</value>
[DataMember(Name = "contact", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "contact")]
public ModelContact Contact { get; set; }
public ModelContact? Contact { get; set; }
/// <summary>
/// the date the invoice was created
@@ -62,7 +62,7 @@ namespace ConsoleApp3.DataContracts
/// <value>header/subject of the invoice</value>
[DataMember(Name = "header", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "header")]
public string Header { get; set; }
public string Header { get; set; } = "";
/// <summary>
/// head text of the invoice
@@ -70,7 +70,7 @@ namespace ConsoleApp3.DataContracts
/// <value>head text of the invoice</value>
[DataMember(Name = "headText", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "headText")]
public string HeadText { get; set; }
public string HeadText { get; set; } = "";
/// <summary>
/// foot text of the invoice
@@ -78,7 +78,7 @@ namespace ConsoleApp3.DataContracts
/// <value>foot text of the invoice</value>
[DataMember(Name = "footText", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "footText")]
public string FootText { get; set; }
public string FootText { get; set; } = "";
/// <summary>
/// time left for paying the invoice, use format dd.MM.yyyy or number for number of days left
@@ -86,7 +86,7 @@ namespace ConsoleApp3.DataContracts
/// <value>time left for paying the invoice, use format dd.MM.yyyy or number for number of days left</value>
[DataMember(Name = "timeToPay", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "timeToPay")]
public DateTime? TimeToPay { get; set; }
public int? TimeToPay { get; set; }
/// <summary>
///
@@ -110,7 +110,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the name in the address, equals the contacts name</value>
[DataMember(Name = "addressName", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressName")]
public string AddressName { get; set; }
public string AddressName { get; set; } = "";
/// <summary>
/// the street in the address, equals the contacts street
@@ -118,7 +118,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the street in the address, equals the contacts street</value>
[DataMember(Name = "addressStreet", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressStreet")]
public string AddressStreet { get; set; }
public string AddressStreet { get; set; } = "";
/// <summary>
/// the zip-code in the address, equals the contacts zip
@@ -126,7 +126,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the zip-code in the address, equals the contacts zip</value>
[DataMember(Name = "addressZip", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressZip")]
public string AddressZip { get; set; }
public string AddressZip { get; set; } = "";
/// <summary>
/// the city in the address, equals the contacts city
@@ -134,7 +134,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the city in the address, equals the contacts city</value>
[DataMember(Name = "addressCity", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressCity")]
public string AddressCity { get; set; }
public string AddressCity { get; set; } = "";
/// <summary>
/// the country in the address, equals the contacts country
@@ -142,7 +142,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the country in the address, equals the contacts country</value>
[DataMember(Name = "addressCountry", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressCountry")]
public ModelStaticCountry AddressCountry { get; set; }
public ModelStaticCountry? AddressCountry { get; set; }
/// <summary>
/// time left for paying the invoice, use format DD.MM.YYYY or number for number of days left
@@ -158,7 +158,7 @@ namespace ConsoleApp3.DataContracts
/// <value>SevUser who created the invoice</value>
[DataMember(Name = "createUser", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "createUser")]
public ModelSevUser CreateUser { get; set; }
public ModelSevUser? CreateUser { get; set; }
/// <summary>
/// sevClient is the unique id every customer has and is used in nearly all operations
@@ -166,7 +166,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
/// delivery date of the goods from the invoice, please use dd.MM.yyyy
@@ -182,7 +182,7 @@ namespace ConsoleApp3.DataContracts
/// <value>status of the invoice</value>
[DataMember(Name = "status", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "status")]
public EInvoiceStatus Status { get; set; }
public EInvoiceStatus? Status { get; set; }
/// <summary>
///
@@ -198,7 +198,7 @@ namespace ConsoleApp3.DataContracts
/// <value>SevUser who created the invoice and therefore is the contact person</value>
[DataMember(Name = "contactPerson", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "contactPerson")]
public ModelSevUser ContactPerson { get; set; } = new ModelSevUser()
public ModelSevUser? ContactPerson { get; set; } = new ModelSevUser()
{
};
@@ -217,7 +217,7 @@ namespace ConsoleApp3.DataContracts
/// <value>additional text when adding a value added tax regulation</value>
[DataMember(Name = "taxText", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "taxText")]
public string TaxText { get; set; }
public string TaxText { get; set; } = "";
/// <summary>
/// dunning level of the invoice
@@ -233,7 +233,7 @@ namespace ConsoleApp3.DataContracts
/// <value>name of the contacts address</value>
[DataMember(Name = "addressParentName", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressParentName")]
public string AddressParentName { get; set; }
public string AddressParentName { get; set; } = "";
/// <summary>
/// a reference to the contacts address
@@ -241,7 +241,7 @@ namespace ConsoleApp3.DataContracts
/// <value>a reference to the contacts address</value>
[DataMember(Name = "addressContactRef", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressContactRef")]
public ModelContactAddress AddressContactRef { get; set; }
public ModelContactAddress? AddressContactRef { get; set; }
/// <summary>
///
@@ -249,7 +249,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "taxType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "taxType")]
public string TaxType { get; set; }
public string TaxType { get; set; } = "";
/// <summary>
///
@@ -257,7 +257,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "paymentMethod", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "paymentMethod")]
public ModelPaymentMethod PaymentMethod { get; set; }
public ModelPaymentMethod? PaymentMethod { get; set; }
/// <summary>
///
@@ -265,7 +265,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "costCentre", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "costCentre")]
public ModelCostCentre CostCentre { get; set; }
public ModelCostCentre? CostCentre { get; set; }
/// <summary>
///
@@ -281,7 +281,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "origin", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "origin")]
public Object Origin { get; set; }
public Object? Origin { get; set; }
/// <summary>
/// type of the invoice
@@ -289,7 +289,7 @@ namespace ConsoleApp3.DataContracts
/// <value>type of the invoice</value>
[DataMember(Name = "invoiceType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "invoiceType")]
public string InvoiceType { get; set; }
public string InvoiceType { get; set; } = "";
/// <summary>
///
@@ -353,7 +353,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "addressParentName2", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressParentName2")]
public string AddressParentName2 { get; set; }
public string AddressParentName2 { get; set; } = "";
/// <summary>
///
@@ -361,7 +361,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "addressName2", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressName2")]
public string AddressName2 { get; set; }
public string AddressName2 { get; set; } = "";
/// <summary>
///
@@ -369,7 +369,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "taxSet", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "taxSet")]
public ModelTaxSet TaxSet { get; set; }
public ModelTaxSet? TaxSet { get; set; }
/// <summary>
///
@@ -377,7 +377,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "addressGender", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "addressGender")]
public string AddressGender { get; set; }
public string AddressGender { get; set; } = "";
/// <summary>
///
@@ -393,7 +393,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "address", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "address")]
public string Address { get; set; }
public string Address { get; set; } = "";
/// <summary>
///
@@ -497,7 +497,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "entryType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "entryType")]
public ModelEntryType EntryType { get; set; }
public ModelEntryType? EntryType { get; set; }
/// <summary>
///
@@ -505,7 +505,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "costumerInternalNote", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "costumerInternalNote")]
public string CostumerInternalNote { get; set; }
public string CostumerInternalNote { get; set; } = "";
/// <summary>
///
@@ -530,7 +530,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "sendType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sendType")]
public string SendType { get; set; }
public string SendType { get; set; } = "";
/// <summary>
///

View File

@@ -1,11 +1,5 @@
using Newtonsoft.Json;
using OpenQA.Selenium.DevTools.V112.DOM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3.DataContracts
{

View File

@@ -6,7 +6,7 @@ namespace ConsoleApp3.DataContracts
{
internal class Invoices
{
[JsonProperty("objects")] public Invoice[] Invoice { get; set; }
[JsonProperty("objects")] public Invoice[]? Invoice { get; set; }
}
}

View File

@@ -24,7 +24,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "parent", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "parent")]
public ModelCategory Parent { get; set; }
public ModelCategory? Parent { get; set; }
/// <summary>
///
@@ -32,7 +32,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
///
@@ -40,7 +40,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "objectType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "objectType")]
public string ObjectType { get; set; }
public string ObjectType { get; set; } = "";
/// <summary>
///
@@ -56,7 +56,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "code", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "code")]
public string Code { get; set; }
public string Code { get; set; } = "";
/// <summary>
///
@@ -64,7 +64,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "color", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "color")]
public string Color { get; set; }
public string Color { get; set; } = "";
/// <summary>
///
@@ -72,7 +72,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
///
@@ -80,7 +80,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "postingAccount", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "postingAccount")]
public string PostingAccount { get; set; }
public string PostingAccount { get; set; } = "";
/// <summary>
///
@@ -88,7 +88,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "type", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "type")]
public string Type { get; set; }
public string Type { get; set; } = "";
/// <summary>
///
@@ -96,7 +96,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "translationCode", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "translationCode")]
public string TranslationCode { get; set; }
public string TranslationCode { get; set; } = "";
/// <summary>
///
@@ -104,7 +104,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "entryType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "entryType")]
public ModelEntryType EntryType { get; set; }
public ModelEntryType? EntryType { get; set; }
}
}

View File

@@ -19,7 +19,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the contact address</value>
[DataMember(Name = "address", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "address")]
public ModelContactAddress Address { get; set; }
public ModelContactAddress? Address { get; set; }
/// <summary>
/// the creation date of the contact
@@ -43,7 +43,7 @@ namespace ConsoleApp3.DataContracts
/// <value>name of the contact</value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
/// status of the contact
@@ -67,7 +67,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "parent", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "parent")]
public ModelContact Parent { get; set; }
public ModelContact? Parent { get; set; }
/// <summary>
/// surname of the contact
@@ -75,7 +75,7 @@ namespace ConsoleApp3.DataContracts
/// <value>surname of the contact</value>
[DataMember(Name = "surename", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "surename")]
public string Surename { get; set; }
public string Surename { get; set; } = "";
/// <summary>
/// family name of the contact
@@ -83,7 +83,7 @@ namespace ConsoleApp3.DataContracts
/// <value>family name of the contact</value>
[DataMember(Name = "familyname", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "familyname")]
public string Familyname { get; set; }
public string Familyname { get; set; } = "";
/// <summary>
/// title of the contact
@@ -91,7 +91,7 @@ namespace ConsoleApp3.DataContracts
/// <value>title of the contact</value>
[DataMember(Name = "titel", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "titel")]
public string Titel { get; set; }
public string Titel { get; set; } = "";
/// <summary>
/// category of the contact
@@ -99,7 +99,7 @@ namespace ConsoleApp3.DataContracts
/// <value>category of the contact</value>
[DataMember(Name = "category", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "category")]
public ModelCategory Category { get; set; }
public ModelCategory? Category { get; set; }
/// <summary>
/// description of the contact
@@ -107,7 +107,7 @@ namespace ConsoleApp3.DataContracts
/// <value>description of the contact</value>
[DataMember(Name = "description", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
public string Description { get; set; } = "";
/// <summary>
/// any academic title of the contact
@@ -115,7 +115,7 @@ namespace ConsoleApp3.DataContracts
/// <value>any academic title of the contact</value>
[DataMember(Name = "academicTitle", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "academicTitle")]
public string AcademicTitle { get; set; }
public string AcademicTitle { get; set; } = "";
/// <summary>
/// gender of the contact
@@ -123,7 +123,7 @@ namespace ConsoleApp3.DataContracts
/// <value>gender of the contact</value>
[DataMember(Name = "gender", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "gender")]
public string Gender { get; set; }
public string Gender { get; set; } = "";
/// <summary>
/// sevClient is the unique id every customer has and is used in nearly all operations
@@ -131,7 +131,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
/// second name of the contact
@@ -139,7 +139,7 @@ namespace ConsoleApp3.DataContracts
/// <value>second name of the contact</value>
[DataMember(Name = "name2", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name2")]
public string Name2 { get; set; }
public string Name2 { get; set; } = "";
/// <summary>
/// birthday of the contact
@@ -155,7 +155,7 @@ namespace ConsoleApp3.DataContracts
/// <value>vat number of the contact</value>
[DataMember(Name = "vatNumber", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "vatNumber")]
public string VatNumber { get; set; }
public string VatNumber { get; set; } = "";
/// <summary>
/// bank account of the contact
@@ -163,7 +163,7 @@ namespace ConsoleApp3.DataContracts
/// <value>bank account of the contact</value>
[DataMember(Name = "bankAccount", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "bankAccount")]
public string BankAccount { get; set; }
public string BankAccount { get; set; } = "";
/// <summary>
/// bank number of the contact
@@ -171,7 +171,7 @@ namespace ConsoleApp3.DataContracts
/// <value>bank number of the contact</value>
[DataMember(Name = "bankNumber", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "bankNumber")]
public string BankNumber { get; set; }
public string BankNumber { get; set; } = "";
/// <summary>
/// desired payment method of the customer
@@ -179,7 +179,7 @@ namespace ConsoleApp3.DataContracts
/// <value>desired payment method of the customer</value>
[DataMember(Name = "paymentMethod", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "paymentMethod")]
public ModelPaymentMethod PaymentMethod { get; set; }
public ModelPaymentMethod? PaymentMethod { get; set; }
/// <summary>
///
@@ -187,7 +187,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "entryType", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "entryType")]
public ModelEntryType EntryType { get; set; }
public ModelEntryType? EntryType { get; set; }
/// <summary>
/// default cashback time of the contact
@@ -219,7 +219,7 @@ namespace ConsoleApp3.DataContracts
/// <value>tax number of the contact</value>
[DataMember(Name = "taxNumber", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "taxNumber")]
public string TaxNumber { get; set; }
public string TaxNumber { get; set; } = "";
/// <summary>
/// tax office of the contact
@@ -227,6 +227,6 @@ namespace ConsoleApp3.DataContracts
/// <value>tax office of the contact</value>
[DataMember(Name = "taxOffice", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "taxOffice")]
public string TaxOffice { get; set; }
public string TaxOffice { get; set; } = "";
}
}

View File

@@ -28,7 +28,7 @@ namespace ConsoleApp3.DataContracts
/// <value>the contact the address belongs to</value>
[DataMember(Name = "contact", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "contact")]
public ModelContact Contact { get; set; }
public ModelContact? Contact { get; set; }
/// <summary>
///
@@ -36,7 +36,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "street", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "street")]
public string Street { get; set; }
public string Street { get; set; } = "";
/// <summary>
/// zip of the city/village
@@ -44,7 +44,7 @@ namespace ConsoleApp3.DataContracts
/// <value>zip of the city/village</value>
[DataMember(Name = "zip", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "zip")]
public string Zip { get; set; }
public string Zip { get; set; } = "";
/// <summary>
///
@@ -52,7 +52,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "city", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "city")]
public string City { get; set; }
public string City { get; set; } = "";
/// <summary>
///
@@ -60,7 +60,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "country", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "country")]
public ModelStaticCountry Country { get; set; }
public ModelStaticCountry? Country { get; set; }
/// <summary>
/// category of the address
@@ -68,7 +68,7 @@ namespace ConsoleApp3.DataContracts
/// <value>category of the address</value>
[DataMember(Name = "category", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "category")]
public ModelCategory Category { get; set; }
public ModelCategory? Category { get; set; }
/// <summary>
///
@@ -76,7 +76,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
/// sevClient is the unique id every customer has and is used in nearly all operations
@@ -84,7 +84,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object SevClient { get; set; } = new object();
/// <summary>
///
@@ -92,7 +92,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name2", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name2")]
public string Name2 { get; set; }
public string Name2 { get; set; } = "";
/// <summary>
///
@@ -100,7 +100,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name3", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name3")]
public string Name3 { get; set; }
public string Name3 { get; set; } = "";
/// <summary>
///
@@ -108,7 +108,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name4", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name4")]
public string Name4 { get; set; }
public string Name4 { get; set; } = "";
}
}

View File

@@ -25,7 +25,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
///
@@ -33,7 +33,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "number", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "number")]
public string Number { get; set; }
public string Number { get; set; } = "";
/// <summary>
///
@@ -41,7 +41,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
///
@@ -49,7 +49,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "color", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "color")]
public string Color { get; set; }
public string Color { get; set; } = "";
/// <summary>
///
@@ -57,6 +57,6 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "postingAccount", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "postingAccount")]
public string PostingAccount { get; set; }
public string PostingAccount { get; set; } = "";
}
}

View File

@@ -24,7 +24,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
///
@@ -32,6 +32,6 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
}
}

View File

@@ -28,7 +28,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
///
@@ -36,7 +36,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
///
@@ -44,7 +44,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "text", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "text")]
public string Text { get; set; }
public string Text { get; set; } = "";
}
}

View File

@@ -13,10 +13,10 @@ namespace ConsoleApp3.DataContracts
{
[DataMember(Name = "invoice", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "invoice")]
public Invoice Invoice { get; set; }
public Invoice? Invoice { get; set; }
[DataMember(Name = "invoicePosSave", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "invoicePosSave")]
public InvoicePosSave[] InvoicePosSaves { get; set; }
public InvoicePosSave[]? InvoicePosSaves { get; set; }
}
}

View File

@@ -21,6 +21,6 @@ namespace ConsoleApp3.DataContracts
/// <value>This information is not visible for you</value>
[DataMember(Name = "hidden", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "hidden")]
public string Hidden { get; set; }
public string Hidden { get; set; } = "";
}
}

View File

@@ -20,7 +20,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "code", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "code")]
public string Code { get; set; }
public string Code { get; set; } = "";
/// <summary>
///
@@ -28,7 +28,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "name", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
///
@@ -36,7 +36,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "nameEn", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "nameEn")]
public string NameEn { get; set; }
public string NameEn { get; set; } = "";
/// <summary>
///
@@ -44,7 +44,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "translationCode", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "translationCode")]
public string TranslationCode { get; set; }
public string TranslationCode { get; set; } = "";
/// <summary>
///
@@ -52,7 +52,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "locale", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "locale")]
public string Locale { get; set; }
public string Locale { get; set; } = "";
/// <summary>
///

View File

@@ -29,7 +29,7 @@ namespace ConsoleApp3.DataContracts
/// <value>sevClient is the unique id every customer has and is used in nearly all operations</value>
[DataMember(Name = "sevClient", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sevClient")]
public Object SevClient { get; set; }
public Object? SevClient { get; set; }
/// <summary>
///
@@ -37,7 +37,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "text", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "text")]
public string Text { get; set; }
public string Text { get; set; } = "";
/// <summary>
///
@@ -61,7 +61,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "displayText", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "displayText")]
public string DisplayText { get; set; }
public string DisplayText { get; set; } = "";
/// <summary>
///
@@ -69,7 +69,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "vatReportFieldNet", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "vatReportFieldNet")]
public string VatReportFieldNet { get; set; }
public string VatReportFieldNet { get; set; } = "";
/// <summary>
///
@@ -77,7 +77,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "vatReportFieldTax", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "vatReportFieldTax")]
public string VatReportFieldTax { get; set; }
public string VatReportFieldTax { get; set; } = "";
/// <summary>
///
@@ -85,7 +85,7 @@ namespace ConsoleApp3.DataContracts
/// <value></value>
[DataMember(Name = "accountingExportVatField", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "accountingExportVatField")]
public string AccountingExportVatField { get; set; }
public string AccountingExportVatField { get; set; } = "";
/// <summary>
///

154
CardMarketBot/Helper.cs Normal file
View File

@@ -0,0 +1,154 @@
// See https://aka.ms/new-console-template for more information
using System.Diagnostics;
using System.Text.RegularExpressions;
public static class Helper
{
public enum Porto
{
FAILED,
BRIEF085,
BRIEF100,
BRIEF160,
BRIEF275,
PRIO210,
PRIO270
}
internal static Kunde ConvertToKunde(string text)
{
string[] datas = text.Split("\r\n");
string name = datas[0];
string adresseUNDHausnummer = datas[datas.Length-3];
string plzUNDOrt = datas[datas.Length-2];
string land = datas[datas.Length-1];
datas = plzUNDOrt.Split(" ");
string plz = datas[0];
string ort = datas[1];
datas = adresseUNDHausnummer.Split(" ");
string strasse = "";
string hausnummer = "";
Trace.WriteLine(datas.Length);
if (datas.Length <= 1)
{
Regex myRegex = new Regex("[0-9]*$");
var matched = myRegex.Match(adresseUNDHausnummer);
strasse = adresseUNDHausnummer.Substring(0, matched.Index);
hausnummer = adresseUNDHausnummer.Substring(matched.Index);
}
else
{
for (int i = 0; i < datas.Length - 1; i++)
{
strasse += datas[i] + " ";
}
strasse = strasse.Trim();
hausnummer = datas[datas.Length - 1];
}
return new Kunde(name, strasse, hausnummer, plz, ort, land);
}
public static List<Artikel> ParseArtikeln(string text)
{
List<Artikel> result = new List<Artikel>();
string[] datas = text.Split("\r\n");
for(int i = 0; i < datas.Length; i++)
{
Artikel temp = new Artikel();
int internalCounter = 0;
bool SourceFounded = false;
for(int j = i; j < datas.Length; j++)
{
var nFound = datas[j].IndexOf("€");
if(nFound == -1)
{
if (temp.Amount == 0)
{
var xFound = datas[j].IndexOf("x");
if (xFound >= 1 && xFound <= 2)
{
temp.Amount = Convert.ToInt32(datas[j].Substring(0, xFound));
temp.GERName = datas[j].Substring(xFound + 1).Trim();
}
}
if(internalCounter == 1)
{
temp.ENGName = datas[j];
}
if(internalCounter == 2)
{
if (datas[j].IndexOf("#") > -1)
{
temp.CardNumber = datas[j];
SourceFounded = false;
}
else
{
temp.Source = datas[j];
SourceFounded = true;
}
}
if(internalCounter == 3)
{
if(SourceFounded)
{
temp.Raritaet = datas[j];
}
else
{
temp.Source = datas[j];
}
}
Trace.WriteLine(j + " " + datas[j]);
}
else
{
temp.Preis = datas[j].Split(' ')[0];
result.Add(temp);
i = j;
break;
}
internalCounter++;
}
}
return result;
}
internal static DateTime ConvertBezahlDatum(string text)
{
//21.06.202308:39
int uhrzeitsignature = text.IndexOf(':');
string datum = text.Substring(0, uhrzeitsignature - 2);
string uhrzeit = text.Substring(uhrzeitsignature-2,text.Length - uhrzeitsignature + 2);
return DateTime.Parse(string.Format("{0} {1}", datum, uhrzeit));
}
}
/*
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
hwr.CookieContainer = cookieContainer;
hwr.Method = "GET";
hwr.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
WebResponse wr = hwr.GetResponse();
string s = new StreamReader(wr.GetResponseStream()).ReadToEnd();
Console.WriteLine(s);
string GetHashKey(string line)
{
var x = line.IndexOf("__cmtkn");
var d = line.Substring(x + 16);
var m = d.IndexOf("\"");
var a = d.Substring(0, m);
return a;
}
*/

View File

@@ -1,6 +1,7 @@
// See https://aka.ms/new-console-template for more information
using ConsoleApp3.DataContracts;
using System.Diagnostics;
/*
*
@@ -48,6 +49,36 @@ namespace CardmarketBot
{
List<ModelRechnung> result = new List<ModelRechnung>();
// 1 => Deutschland
// 2 => Schweiz
// 3 => Österreich
// 6 => Belgien
// 11 => Frankreich
// 13 => Irland
// 14 => Italien
// 17 => Luxemburg
// 28 => Slowenien
// 29 => Spanien
// 48 => Kroatien
Dictionary<string, int> LaenderCodes = new Dictionary<string, int>()
{
{ "Deutschland", 1 },
{ "Schweiz", 2 },
{ "Österreich", 3 },
{ "Belgien",6 },
{ "Dänemark", 8 },
{ "Frankreich", 11 },
{ "Irland", 13 },
{ "Italien", 14 },
{ "Luxemburg", 17 },
{ "Slowenien", 28 },
{ "Spanien", 29 },
{ "Kroatien", 48 }
};
foreach (Kunde kunde in kunden)
{
ModelRechnung temp = new ModelRechnung();
@@ -57,17 +88,27 @@ namespace CardmarketBot
//rechnung.InvoiceNumber = string.Format("RE-{0}", await GetNextInvoiceNumber()); => Should be done by services.
rechnung.InvoiceDate = kunde.Bezahldatum;
rechnung.Header = string.Format("Verkauf #{0}",kunde.BestellungID);
rechnung.HeadText = "Sehr geehrte Damen und Herren," +
"Wir stellen Ihnen für Ihre bestellung folgende Rechnung." +
"Bitte Beachte, dass der Lieferdatum die Bestelldatum entspricht.";
rechnung.HeadText = "Sehr geehrte Damen und Herren, " +
"wir stellen Ihnen für ihre Bestellung folgende Rechnung. " +
"Bitte Beachte, dass das Lieferdatum dem Bestelldatum entspricht.";
rechnung.FootText = "Ihre Rechnung ist bereits über Cardmarket beglichen worden.";
rechnung.TimeToPay = new DateTime(0);
rechnung.TimeToPay = 14;
rechnung.Discount = 0;
rechnung.Address = string.Format("{0}\n{1} {2}\n{3} {4}", kunde.Name, kunde.Strasse, kunde.Hausnummer, kunde.Plz, kunde.Ort); //"Damian Wessels\nDät Haartje 27A\n26683 Saterland";
rechnung.AddressCountry = new ModelStaticCountry()
rechnung.AddressCountry = new ModelStaticCountry();
if(LaenderCodes.ContainsKey(kunde.Land))
{
Id = 1
};
rechnung.AddressCountry.Id = LaenderCodes[kunde.Land];
}
else
{
rechnung.AddressCountry.Id = 1;
Console.WriteLine($"Fehler Land wurde nicht richtig gefunden {kunde.Land} Bitte in Sevdesk kontrollieren und Damian die\n" +
$"Fehlercode #LC01#{kunde.BestellungID} melden");
}
//rechnung.PayDate = new DateTime(2019, 08, 24, 14, 15, 22);
rechnung.DeliveryDate = kunde.Bezahldatum;
rechnung.Status = EInvoiceStatus.OPEN;
@@ -110,14 +151,22 @@ namespace CardmarketBot
Id = null,
MapAll = true,
Quantity = 1,
Price = PortoPreis[kunde.Versandskosten],
Name = "Versandskosten",
PositionNumber = 0,
Discount = 0,
TaxRate = 19,
PriceGross = PortoPreis[kunde.Versandskosten],
PriceTax = 19
};
if(kunde.OverrideVersandskosten != null)
{
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = Convert.ToDecimal(kunde.OverrideVersandskosten);
}
else
{
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].Price = PortoPreis[kunde.Versandskosten];
temp.InvoicePosSaves[temp.InvoicePosSaves.Length - 1].PriceGross = PortoPreis[kunde.Versandskosten];
}
result.Add(temp);
}

View File

@@ -11,6 +11,7 @@ class Kunde
string plz;
string ort;
string land;
List<Artikel> artikels = new List<Artikel>();
public DateTime Bezahldatum { get; set; }
@@ -28,6 +29,7 @@ class Kunde
get => overrideVersandskosten;
set
{
if (value == null) return;
string[] parts = value.Split(' ');
if(parts.Length < 2)
{
@@ -48,5 +50,6 @@ class Kunde
plz = PLZ;
ort = Ort;
land = Land;
Versandskosten = Helper.Porto.FAILED;
}
}

95
CardMarketBot/Program.cs Normal file
View File

@@ -0,0 +1,95 @@
using ConsoleApp3.DataContracts;
using ConsoleApp3.Contracts;
using System.Text.RegularExpressions;
using CardMarketBot;
using OpenQA.Selenium.DevTools.V113.Network;
using System.Reflection.Metadata.Ecma335;
namespace CardmarketBot
{
internal class Programm
{
static void Main(string[] args)
{
ICheckSevDesk checkSevDesk = new CheckSevDeskPublicList();
Console.WriteLine("Hallo Herzlich willkommen beim Junker sein Junker der im Junkerloch junkert");
Console.WriteLine("Was kann ich für dich tun?");
bool programmexited = false;
List<Kunde> kunden = new List<Kunde>();
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!");
while (!programmexited)
{
Console.WriteLine("1) Starte den Hugo, der alle bezahlte Artikeln erfasst");
Console.WriteLine("2) Starte den Rolfes der Bestellnummern nachkontrolliert");
Console.WriteLine("3) Beende");
string? input = Console.ReadLine();
if (input == null)
{
continue;
}
switch (input)
{
case "1":
kunden = cardMarketParser.ParseCardMarket();
break;
case "2":
{
Console.Write("Verkaufsnummer: ");
string? verkaufsnummer = Console.ReadLine();
if (verkaufsnummer == null)
{
Console.WriteLine("Fehler");
continue;
}
kunden = cardMarketParser.ParseCardMarket(verkaufsnummer);
}
break;
case "3":
programmexited = true;
continue;
default: continue;
}
// Rechnungen generieren
List<ModelRechnung> rechnungen = new List<ModelRechnung>();
InvoiceParser invoiceParser = new InvoiceParser(kunden);
rechnungen = invoiceParser.GetInvoices();
foreach (ModelRechnung item in rechnungen)
{
if (item.Invoice == null) continue;
var str_header = item.Invoice.Header;
if (str_header != null)
{
Regex regex = new Regex("[0-9]*$");
Match matched = regex.Match(str_header);
string verkaufnummer = str_header.Substring(matched.Index);
Console.Write($"Teste {verkaufnummer} : ");
if (checkSevDesk.AlreadyKnown(verkaufnummer))
{
Console.Write("wurde noch nicht in Sevdesk erfasst ");
SevdeskService sevdeskService = new SevdeskService("7251554968610b78ca865b2b774b4134");
sevdeskService.Create(item);
Console.WriteLine("nun in Sevdesk eingetragen");
checkSevDesk.Write(verkaufnummer);
}
else
{
Console.WriteLine("wurde bereits in Sevdesk erfasst, wird somit übersprungen. Jedoch wird PostCSV erstellt");
}
}
}
// Post CSV Erstellen
DeutschePost deutschePost = new DeutschePost(kunden);
deutschePost.GenerateCSV();
Console.WriteLine("Fertig");
}
}
}
}

View File

@@ -26,7 +26,7 @@ namespace CardmarketBot
public async void Create(ModelRechnung rechnung)
{
if (rechnung.Invoice == null) return;
rechnung.Invoice.InvoiceNumber = string.Format("RE-{0}", await GetNextInvoiceNumber());
await WriteInv(rechnung);
}
@@ -60,7 +60,9 @@ namespace CardmarketBot
{
MissingMemberHandling = MissingMemberHandling.Ignore
};
#pragma warning disable CS8603 // Mögliche Nullverweisrückgabe.
return JsonConvert.DeserializeObject<Invoices>(contents, jsonSerializerSettings);
#pragma warning restore CS8603 // Mögliche Nullverweisrückgabe.
}
private async Task<string> GetNextInvoiceNumber()
@@ -76,6 +78,8 @@ namespace CardmarketBot
};
var ob = JsonConvert.DeserializeObject<RNumbers>(contents, jsonSerializerSettings);
if (ob == null) return "";
if (ob.ConfigRechnungsnummer == null) return "";
return ob.ConfigRechnungsnummer.NextNumber;
}
@@ -84,7 +88,7 @@ namespace CardmarketBot
[DataContract]
class RNumbers
{
[JsonProperty("objects")] public ConfigRechnungnummer ConfigRechnungsnummer { get; set; }
[JsonProperty("objects")] public ConfigRechnungnummer? ConfigRechnungsnummer { get; set; }
}
[DataContract]

View 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
{
}
}

View File

@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CardMarketBot", "ConsoleApp3\CardMarketBot.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CardMarketBot", "CardMarketBot\CardMarketBot.csproj", "{4CB462A0-22BB-4E70-9C0B-203560329AFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardMarketBotTests", "CardMarketBotTests\CardMarketBotTests.csproj", "{778573E1-5691-44C2-A897-C84FCC73FAC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CB462A0-22BB-4E70-9C0B-203560329AFE}.Release|Any CPU.Build.0 = Release|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{778573E1-5691-44C2-A897-C84FCC73FAC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CardMarketBot\CardMarketBot.csproj" />
</ItemGroup>
</Project>

File diff suppressed because one or more lines are too long

View File

@@ -1,96 +0,0 @@
// See https://aka.ms/new-console-template for more information
static class Helper
{
public enum Porto
{
BRIEF085,
BRIEF100,
BRIEF160,
BRIEF275,
PRIO210,
PRIO270
}
internal static Kunde ConvertToKunde(string text)
{
string[] datas = text.Split("\r\n");
string name = datas[0];
string adresseUNDHausnummer = datas[1];
string plzUNDOrt = datas[2];
string land = datas[3];
datas = plzUNDOrt.Split(" ");
string plz = datas[0];
string ort = datas[1];
datas = adresseUNDHausnummer.Split(" ");
string strasse = "";
for (int i = 0; i < datas.Length - 1; i++)
{
strasse += datas[i] + " ";
}
strasse = strasse.Trim();
string hausnummer = datas[datas.Length - 1];
return new Kunde(name, strasse, hausnummer, plz, ort, land);
}
internal static List<Artikel> ParseArtikeln(string text)
{
List<Artikel> result = new List<Artikel>();
string[] datas = text.Split("\r\n");
int anzahl = datas.Length / 6;
for (int i = 0; i < datas.Length; i += 6)
{
Artikel temp = new Artikel();
var xFound = datas[i].IndexOf("x");
var am = datas[i].Substring(0, xFound);
temp.Amount = Convert.ToInt32(am);
temp.GERName = datas[i].Substring(xFound + 1);
temp.ENGName = datas[i + 1];
temp.CardNumber = datas[i + 2];
temp.Source = datas[i + 3];
temp.Raritaet = datas[i + 4];
temp.Preis = datas[i + 5].Split(' ')[0];
result.Add(temp);
}
return result;
}
internal static DateTime ConvertBezahlDatum(string text)
{
//21.06.202308:39
int uhrzeitsignature = text.IndexOf(':');
string datum = text.Substring(0, uhrzeitsignature - 2);
string uhrzeit = text.Substring(uhrzeitsignature-2,text.Length - uhrzeitsignature + 2);
return DateTime.Parse(string.Format("{0} {1}", datum, uhrzeit));
}
}
/*
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
hwr.CookieContainer = cookieContainer;
hwr.Method = "GET";
hwr.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
WebResponse wr = hwr.GetResponse();
string s = new StreamReader(wr.GetResponseStream()).ReadToEnd();
Console.WriteLine(s);
string GetHashKey(string line)
{
var x = line.IndexOf("__cmtkn");
var d = line.Substring(x + 16);
var m = d.IndexOf("\"");
var a = d.Substring(0, m);
return a;
}
*/

View File

@@ -1,47 +0,0 @@
using ConsoleApp3.DataContracts;
using ConsoleApp3;
using ConsoleApp3.Contracts;
namespace CardmarketBot
{
internal class Programm
{
static void Main(string[] args)
{
IUsedRepository usedRepository = new UsedRepository();
// Kunden aus Cardmarket erstellen
List<Kunde> kunden = new List<Kunde>();
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!", usedRepository);
kunden = cardMarketParser.ParseCardMarket();
// Rechnungen generieren
List<ModelRechnung> rechnungen = new List<ModelRechnung>();
InvoiceParser invoiceParser = new InvoiceParser(kunden);
rechnungen = invoiceParser.GetInvoices();
foreach (var item in rechnungen)
{
SevdeskService sevdeskService = new SevdeskService("7251554968610b78ca865b2b774b4134");
sevdeskService.Create(item);
}
// Post CSV Erstellen
DeutschePost deutschePost = new DeutschePost(kunden);
deutschePost.GenerateCSV();
usedRepository.Insert(kunden);
Console.WriteLine("Fertig");
Console.ReadLine();
}
}
}

View File

@@ -1 +0,0 @@


4
StartDenHugo.bat Normal file
View File

@@ -0,0 +1,4 @@
@echo off
git pull
dotnet run --project CardMarketBot