Exemplo n.º 1
0
 /// <summary>
 /// Executes a first save of current timestamp and launche regular autosave.
 /// </summary>
 public static void Start()
 {
     Save(null, null);
     Timer.Tick    += new EventHandler(Save);
     Timer.Interval = HTime.inMilliseconds(Ini.GetString("AutoBackupData", "SaveInterval", "5 minutes"), "minutes");
     Timer.Start();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if last saved time is more than twice older than the save interval
        /// </summary>
        /// <returns>True if NOT OLD => time OK or NOT SAVED</returns>
        public static bool CheckLastSavedTime()
        {
            DateTime lastSavedTime;
            TimeSpan saveInterval;

            saveInterval  = new TimeSpan(0, 0, 0, 0, HTime.inMilliseconds(Ini.GetString("AutoBackupData", "SaveInterval", "5 mins")));
            lastSavedTime = LastSavedTime();

            if (lastSavedTime == DateTime.MinValue)
            {
                return(true);
            }

            if (DateTime.Now.Subtract(lastSavedTime) > saveInterval.Add(saveInterval))
            {
                return(false);
            }

            return(true);
        }