Weighing: Set Date/Time of scales at startup

This commit is contained in:
2026-08-03 10:56:42 +02:00
parent 309f118739
commit 0fc4106cd2
4 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -145,7 +145,13 @@ namespace Elwig {
var list = new List<IScale>(); var list = new List<IScale>();
foreach (var s in Config.Scales) { foreach (var s in Config.Scales) {
try { try {
list.Add(Scale.FromConfig(s)); var scale = Scale.FromConfig(s);
if (scale is ICommandScale cmd) {
try {
await cmd.SetDateAndTime(DateTime.Now);
} catch { }
}
list.Add(scale);
} catch (Exception exc) { } catch (Exception exc) {
list.Add(new InvalidScale(s.Id)); list.Add(new InvalidScale(s.Id));
if (s.Required) if (s.Required)
+1 -1
View File
@@ -188,7 +188,7 @@ namespace Elwig.Documents {
if (info.Date != null || info.Time != null) if (info.Date != null || info.Time != null)
weighing.Add(Normal(" \u2013 ")); weighing.Add(Normal(" \u2013 "));
if (info.Time != null) if (info.Time != null)
weighing.Add(Normal($"{info.Time:HH:mm}")); weighing.Add(Normal($"{info.Time:HH:mm:ss}"));
if (info.Date != null) if (info.Date != null)
weighing.Add(Normal($", {info.Date:dd.MM.yyyy}")); weighing.Add(Normal($", {info.Date:dd.MM.yyyy}"));
if (info.Gross != null && info.Tare != null && info.Net != null) { if (info.Gross != null && info.Tare != null && info.Net != null) {
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Elwig.Helpers.Weighing {
/// <returns>&lt;[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time&gt;</returns> /// <returns>&lt;[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time&gt;</returns>
public override readonly string ToString() { public override readonly string ToString() {
var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : ""; var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : "";
return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm}>"; return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm:ss}>";
} }
public readonly JsonObject ToJson() { public readonly JsonObject ToJson() {
@@ -23,7 +23,7 @@ namespace Tests.UnitTests.DocumentTests {
1 Grüner Veltliner Qualitätswein 73 15,0 3 219 1 Grüner Veltliner Qualitätswein 73 15,0 3 219
Herkunft: Österreich / Weinland / Niederösterreich Herkunft: Österreich / Weinland / Niederösterreich
/ Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf
Waage/Terminal: ?/1, ID: 321 09:02, 01.10.2020 Waage/Terminal: ?/1, ID: 321 09:02:46, 01.10.2020
Brutto: 3 219 kg Tara: 0 kg Netto: 3 219 kg gerebelt gewogen Brutto: 3 219 kg Tara: 0 kg Netto: 3 219 kg gerebelt gewogen
""")); """));
}); });