/// /// Copyright (c) 2018-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Xml.Serialization; using log4net; using Common; using TBF.BenchControl; using TBF.BenchControl.Generic; using TBF.Resources; namespace TBF.BenchControl.DataContainers.BenchInfo.iPerl { /// /// Holds information identifying the test bench. /// public class Component : ComponentBase, GenericDevices.IBenchInfo, GenericDevices.IHasCalendarEvents { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); } readonly ComponentCfg myCfg; public string TestBenchName { get { return myCfg.TestBenchName; } } public int TestBenchId { get { return myCfg.TestBenchId; } } public string Address1 { get { return myCfg.Address1; } } public string Address2 { get { return myCfg.Address2; } } public string Address3 { get { return myCfg.Address3; } } public string Address4 { get { return myCfg.Address4; } } public string Address5 { get { return myCfg.Address5; } } public RemoteDBUse RemoteDBUse { get { return myCfg.RemoteDBUse; } } public Side Side { get { return myCfg.Side; } } public int MaxTestIndex { get { return myCfg.MaxTestIndex; } } /// (MaxPruefindex % 100) value when to reject water meters completely if they are NOK public Component() { } public Component(Generic.IComponentCfg cfg) : base(cfg) { myCfg = cfg as ComponentCfg; } public override void Initialize() { Events.DB.SetBenchName(myCfg.TestBenchName); log.FatalFormat("{0} initialized: {1}", Name, this); } public IList GetCalendarEvents() { DateTime calibrationDue = myCfg.CalibValidDate; IList calendarEvents = new List(); if (calibrationDue > TBF.UI.Constants.MinDate) { /// Calibration due date calendar event calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name, string.Format(Strings.Calibration_due_date_is_0, calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)))); if (DateTime.Now.Date <= calibrationDue.AddDays(-7)) { /// Weekly reminders (last 5 weeks) calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name, string.Format(Strings.Calibration_due_date_is_0, calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)), false)); } if (DateTime.Now.Date <= calibrationDue.Date) { /// Daily reminders (last 5 days) calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name, string.Format(Strings.Calibration_due_date_is_0, calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)), true)); } } return calendarEvents; } } }