81 lines
3.8 KiB
C#
81 lines
3.8 KiB
C#
///
|
|
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.BenchControl;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.DataContainers.BenchInfo.iPerl
|
|
{
|
|
/// <summary>
|
|
/// Holds information identifying the test bench.
|
|
/// </summary>
|
|
public class Component : ComponentBase, GenericDevices.IBenchInfo, GenericDevices.IHasCalendarEvents
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
|
|
public override string ToString() { return string.Format("BenchInfo.iPerl({0})", 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;
|
|
Events.DB.SetBenchName(myCfg.TestBenchName);
|
|
log.Warn(this.ToString());
|
|
}
|
|
|
|
|
|
public IList<Config.CalendarEvent.ICalendarEvent> GetCalendarEvents()
|
|
{
|
|
DateTime calibrationDue = myCfg.CalibValidDate;
|
|
IList<Config.CalendarEvent.ICalendarEvent> calendarEvents = new List<Config.CalendarEvent.ICalendarEvent>();
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|