Weighing: Set Date/Time of scales at startup
This commit is contained in:
+7
-1
@@ -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)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Elwig.Helpers.Weighing {
|
|||||||
/// <returns><[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time></returns>
|
/// <returns><[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time></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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user