Compare commits
2 Commits
1d97f3c422
...
86f7f693a0
Author | SHA1 | Date | |
---|---|---|---|
86f7f693a0 | |||
8680e51052 |
@ -183,6 +183,9 @@ namespace Elwig {
|
||||
}
|
||||
|
||||
private async void Application_Exit(object sender, ExitEventArgs evt) {
|
||||
foreach (var s in EventScales) {
|
||||
s.Dispose();
|
||||
}
|
||||
await Pdf.Cleanup();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Elwig.Helpers.Export {
|
||||
""";
|
||||
var c = App.Client;
|
||||
var (a1, a2) = Utils.SplitAddress(c.Address);
|
||||
_clientData = $"{c.LfbisNr};{c.NameFull};;{a1};{a2};{c.Plz};{c.Ort}";
|
||||
_clientData = $"{c.LfbisNr};{c.NameFull};;{a1};\t{a2};{c.Plz};{c.Ort}";
|
||||
}
|
||||
|
||||
public async Task ExportAsync(int year) {
|
||||
@ -35,7 +35,7 @@ namespace Elwig.Helpers.Export {
|
||||
WHERE year = {year}
|
||||
""";
|
||||
var r = await cmd.ExecuteReaderAsync();
|
||||
List<Row> rows = new();
|
||||
List<Row> rows = [];
|
||||
while (await r.ReadAsync()) {
|
||||
rows.Add(new(
|
||||
(r.IsDBNull(0) ? null : r.GetString(0), r.IsDBNull(1) ? null : r.GetString(1), r.IsDBNull(2) ? null : r.GetString(2), r.IsDBNull(3) ? null : r.GetString(3), r.GetString(4), r.GetInt32(5), r.GetString(6), r.GetInt32(7)),
|
||||
@ -57,7 +57,7 @@ namespace Elwig.Helpers.Export {
|
||||
|
||||
var (n1, n2) = billingName == null ? (familyName, name) : Utils.SplitName(billingName, familyName);
|
||||
var (a1, a2) = Utils.SplitAddress(address);
|
||||
var memberData = $"{lfBisNr};{n1};{n2};{a1};{a2};{plz};{ort}";
|
||||
var memberData = $"{lfBisNr};{n1};{n2};{a1};\t{a2};{plz};{ort}";
|
||||
var deliveryData = $"{string.Join(".", date.Split("-").Reverse())};{weight};TB;{(type == "W" ? "J" : "")};{(type == "R" ? "J" : "")};{sortid};;;{qualid};{year};{hkid};{kmw:0.0};{oe:0}";
|
||||
var vollData = $"N;;;{area / 10_000.0}";
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public static string? ReadUntil(this StreamReader reader, char delimiter) {
|
||||
return ReadUntil(reader, new char[] { delimiter });
|
||||
return ReadUntil(reader, [ delimiter ]);
|
||||
}
|
||||
|
||||
public static string? ReadUntil(this StreamReader reader, char[] delimiter) {
|
||||
@ -45,7 +45,7 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public static Task<string?> ReadUntilAsync(this StreamReader reader, char delimiter) {
|
||||
return ReadUntilAsync(reader, new char[] { delimiter });
|
||||
return ReadUntilAsync(reader, [ delimiter ]);
|
||||
}
|
||||
|
||||
public static async Task<string?> ReadUntilAsync(this StreamReader reader, char[] delimiter) {
|
||||
|
@ -58,11 +58,19 @@ namespace Elwig.Helpers.Weighing {
|
||||
}
|
||||
|
||||
protected async Task<WeighingResult?> Receive() {
|
||||
var line = await Reader.ReadUntilAsync("\r\n");
|
||||
var line = "";
|
||||
while (line.Length < 33) {
|
||||
var ch = Reader.Read();
|
||||
if (ch == -1) {
|
||||
return null;
|
||||
} else if (line.Length > 0 || ch == ' ') {
|
||||
line += char.ToString((char)ch);
|
||||
}
|
||||
}
|
||||
if (LogPath != null) await File.AppendAllTextAsync(LogPath, line);
|
||||
if (line == null || line == "") {
|
||||
return null;
|
||||
} else if (line.Length != 35 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
|
||||
} else if (line.Length != 33 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
|
||||
throw new IOException($"Invalid event from scale: '{line}'");
|
||||
}
|
||||
|
||||
|
@ -171,11 +171,11 @@ namespace Tests.WeighingTests {
|
||||
Thread.Sleep(100);
|
||||
|
||||
if (invalid) {
|
||||
return ("abcd\r\n", false);
|
||||
return ("abcd", false);
|
||||
}
|
||||
|
||||
bool incr = true;
|
||||
return ($" {new DateTime(2020, 9, 28, 9, 8, 0):dd.MM.yy HH:mm} {identNr,4} {weight,9}{(unit ? "lb" : "kg")} \r\n", incr);
|
||||
return ($" {new DateTime(2020, 9, 28, 9, 8, 0):dd.MM.yy HH:mm} {identNr,4} {weight,9}{(unit ? "lb" : "kg")} ", incr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user