public static async void RefetchUserStatusLazily(int tryCountUntilFoundUser) { try { bool loggedIn = await IsLoggedOn(true); if (!loggedIn && tryCountUntilFoundUser > 0) { tryCountUntilFoundUser -= 1; Task.Delay(1000 * 10).ContinueWith((task) => { RefetchUserStatusLazily(tryCountUntilFoundUser); }); } else { checkingLoginState = false; if (loggedIn) { SoftwareLoginCommand.UpdateEnabledState(true); SoftwareLaunchCommand.UpdateEnabledState(true); // show they've logged on string msg = "Successfully logged on to Code Time."; const string caption = "Code Time"; MessageBox.Show(msg, caption, MessageBoxButtons.OK); SoftwareUserSession.SendHeartbeat("STATE_CHANGE: LOGGED_IN:true"); // fetch the session summary to get the user's averages WallclockManager.Instance.UpdateSessionSummaryFromServerAsync(); SoftwareCoPackage.SendOfflinePluginBatchData(); } } } catch (Exception ex) { Logger.Error("RefetchUserStatusLazily ,error : " + ex.Message, ex); } }
public async Task GetNewDayCheckerAsync() { if (SoftwareCoUtil.IsNewDay()) { SessionSummaryManager.Instance.ÇlearSessionSummaryData(); // send the offline data SoftwareCoPackage.SendOfflinePluginBatchData(); // clear the last payload in memory FileManager.ClearLastSavedKeystrokeStats(); // send the offline events EventManager.Instance.SendOfflineEvents(); // send the offline TimeData payloads // this will clear the time data summary as well TimeDataManager.Instance.SendTimeDataAsync(); // day does't match. clear the wall clock time, // the session summary, time data summary, // and the file change info summary data ClearWcTime(); // set the current day NowTime nowTime = SoftwareCoUtil.GetNowTime(); _currentDay = nowTime.day; // update the current day FileManager.setItem("currentDay", _currentDay); // update the last payload timestamp FileManager.setNumericItem("latestPayloadTimestampEndUtc", 0); // update the session summary global and averages for the new day Task.Delay(ONE_MINUTE).ContinueWith((task) => { WallclockManager.Instance.UpdateSessionSummaryFromServerAsync(); }); } }