using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace MP.Prog.Data { public class SelectData { #region Public Properties public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1); public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7); public string FileName { get; set; } = ""; /// /// Primo record x selezione paginata, tipicamente primo della "decina" della pagina corrente /// public int FirstRecord { get { int primaPag = PageNum % 10; int decina = PageNum - primaPag; return PageSize * decina + 1; } } public string IdxMacchina { get; set; } = ""; /// /// Recorda da saltare x arrivare alla pagina corrente /// public int NumSkip { get { return PageSize * (PageNum - 1); } } public bool OnlyActive { get; set; } = true; public bool OnlyMod { get; set; } = false; public bool OnlyNoTag { get; set; } = false; public int PageNum { get; set; } = 1; public int PageSize { get; set; } = 10; public string SearchVal { get; set; } = ""; public string Tag { get; set; } = ""; #endregion Public Properties #region Public Methods /// /// Inizializzazione con periodo e arrotondamento /// /// /// /// public static SelectData Init(int minRound, int numDayPrev) { TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today); int minDay = (int)((DayElapsed.TotalMinutes / minRound) + 1) * minRound; DateTime endRounded = DateTime.Today.AddMinutes(minDay); SelectData answ = new SelectData() { DateEnd = endRounded, DateStart = endRounded.AddDays(-numDayPrev), SearchVal = "" }; return answ; } public override bool Equals(object obj) { if (!(obj is SelectData item)) return false; if (PageSize != item.PageSize) return false; if (PageNum != item.PageNum) return false; if (OnlyActive != item.OnlyActive) return false; if (OnlyMod != item.OnlyMod) return false; if (OnlyNoTag != item.OnlyNoTag) return false; if (SearchVal != item.SearchVal) return false; if (FileName != item.FileName) return false; if (IdxMacchina != item.IdxMacchina) return false; if (Tag != item.Tag) return false; if (DateEnd != item.DateEnd) return false; if (DateStart != item.DateStart) return false; return true; } public override int GetHashCode() { return base.GetHashCode(); } #endregion Public Methods } }