tbf/TBF/Rig/DataEntry/Uni/DEUtils.cs

84 lines
3.9 KiB
C#

///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using Results.Entities;
namespace TBF.Rig.DataEntry.Uni
{
public class DEUtils
{
public static string GetContent(Ct content, WaterMeter wm)
{
if (wm == null) return string.Empty;
switch (content)
{
default:
case Ct.None: return string.Empty;
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
#if ORACLE_DB
case Content.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Content.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
#endif
}
}
public static void PutContent(Ct content, WaterMeter wm, string value)
{
if (wm == null || wm.Disabled) return;
int year;
switch (content)
{
default:
case Ct.None: return;
case Ct.SerialNr: wm.SerialNr = value; return;
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
case Ct.RadioAddress: wm.RadioAddress = value; return;
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
case Ct.StartState: wm.SetStartState(value); return;
case Ct.EndState: wm.EndState = value; return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
wm.PurchaseOrder = value;
return;
case Ct.BatchOrder:
case Ct.BatchAndWmOrder:
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
return;
case Ct.WmRemark:
wm.Remark = value;
return;
case Ct.BatchRemark:
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
#if ORACLE_DB
case Content.Prefix: wm.Prefix = value; return;
case Content.Suffix: wm.Suffix = value; return;
#endif
}
}
}
}