private void AppTimer_Elapsed(object sender, ElapsedEventArgs e) { if (TimeManager.GetTimeManager().Usage != null) { //Console.WriteLine(TimeManager.GetTimeManager().Usage.IdleMinutes); var api = ApiHelper.GetApiHelper(); api.PostUsageTime(TimeManager.GetTimeManager().Usage, _user); TimeManager.GetTimeManager().Usage = null; } TimeSpan nowtime = DateTime.Now.TimeOfDay; if (isConnected) { if (DateTime.Now.Second % 10 == 0) { if (logMngr.IsSync == false) { logMngr.SyncLogs(_user); } } if (DateTime.Now.Minute % 30 == 0) { if (!_shouldSkip) { _shouldSkip = true; filelMngr.CreateLocalFile(stateMngr.GetSessions()); filelMngr.DeleteLiveDataFile(); stateMngr.ClearData(); if (filelMngr.IsSync == false) { filelMngr.SyncFiles(_user); } } } else { _shouldSkip = false; } } if (isPaused) { pauseCountDown--; if (pauseCountDown == 0) { isPaused = false; //IsControlable = true; StartTime = UIStrings.StartTime; StartTimeLabel = UIStrings.StartTimeLabel; LoggingStatus = LoggingStatus.Running; logMngr.AddLog(new Log { Severity = LogSeverity.Low, Type = LogType.LoggerStarted, Text = "Logger Started automatically after being paused." }); } else { TimeSpan time = TimeSpan.FromSeconds(pauseCountDown); StartTime = time.ToString(@"hh\:mm\:ss"); } } if (LoggingStatus == LoggingStatus.Stopped && nowtime > startTime.TimeOfDay && nowtime < endTime.TimeOfDay /*&& DateTime.Now.DayOfWeek != DayOfWeek.Saturday*/ /*&& DateTime.Now.DayOfWeek != DayOfWeek.Sunday*/) { isConnected = true; LoggingStatus = LoggingStatus.Running; IsControlable = true; logMngr.AddLog(new Log { Severity = LogSeverity.Low, Type = LogType.LoggerStarted, Text = "Logger Started automatically." }); return; } if ( (LoggingStatus == LoggingStatus.Running || LoggingStatus == LoggingStatus.Paused) && (nowtime > endTime.TimeOfDay || nowtime < startTime.TimeOfDay)) { LoggingStatus = LoggingStatus.Stopped; filelMngr.CreateLocalFile(stateMngr.GetSessions()); filelMngr.DeleteLiveDataFile(); stateMngr.ClearData(); isConnected = false; IsControlable = false; logMngr.AddLog(new Log { Severity = LogSeverity.Low, Type = LogType.LoggerStopped, Text = "Logger Stopped automatically." }); return; } }