pszczyg

Untitled

Jun 29th, 2017
301
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SystemTimeDependendProductionCode
  2.     {
  3.         private readonly IAmActiveMetersLoader _meterLoader;
  4.  
  5.         public SystemTimeDependendProductionCode(IAmActiveMetersLoader meterLoader)
  6.         {
  7.             _meterLoader = meterLoader;
  8.             TimeForNextPeriodicCheck = SystemTime.Now.Date.AddHours(22);
  9.         }
  10.  
  11.         public void DoPeriodicCheckIfNeeded()
  12.         {
  13.             var isItTimeForPeriodicCheck = TimeForNextPeriodicCheck < SystemTime.Now;
  14.             if (!isItTimeForPeriodicCheck)
  15.                 return;
  16.  
  17.             _meterLoader.ReloadAllActiveMeters();
  18.  
  19.             TimeForNextPeriodicCheck = ComputeTimeForNextCheck();
  20.         }
  21.  
  22.         #region Irrelevant
  23.         private DateTime TimeForNextPeriodicCheck { get; set; }        
  24.         private static DateTime ComputeTimeForNextCheck()
  25.         {
  26.             return DateTime.Now.AddMinutes(1);
  27.         }
  28.         #endregion Irrelevant
  29.     }
RAW Paste Data