/// /// Copyright (c) 2019-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; using TBF.Resources; namespace TBF.BenchControl.DataContainers.Buoyancy { /// /// Holds measured (true) buoyancy value. /// public class Component : ComponentBase, GenericDevices.IHasCalendarEvents { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); public override string ToString() { return string.Format("{0}({1})", this.GetType().Namespace.Substring(32), Cfg.ToString(1)); } readonly ComponentCfg myCfg; public double Buoyancy { get { return myCfg.Buoyancy; } } public Component() { } public Component(Generic.IComponentCfg cfg) : base(cfg) { myCfg = cfg as ComponentCfg; /// This is to use data in formulas Config.Data.Buoyancy = Buoyancy; log.Warn(this.ToString()); } 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; } } }