public static ApplicationDateModel GetApplicationDates(int officeId) { Collection <ApplicationDateModel> applicationDates = CacheFactory.GetApplicationDates(); bool persist = false; if (applicationDates == null || applicationDates.Count.Equals(0)) { applicationDates = Data.Frequency.GetApplicationDates(); persist = true; } else { for (int i = 0; i < applicationDates.Count; i++) { if (applicationDates[i].NewDayStarted) { int modelOfficeId = applicationDates[i].OfficeId; applicationDates.Remove(applicationDates[i]); applicationDates.Add(Data.Frequency.GetApplicationDates(modelOfficeId)); persist = true; } } } if (persist) { CacheFactory.SetApplicationDates(applicationDates); } return(applicationDates.FirstOrDefault(c => c.OfficeId.Equals(officeId))); }
private void ForceLogOff(int officeId) { Collection <ApplicationDateModel> applicationDates = CacheFactory.GetApplicationDates(); DateTime forcedLogOffOn = DateTime.Now.AddMinutes(2); if (applicationDates != null) { ApplicationDateModel model = applicationDates.FirstOrDefault(c => c.OfficeId.Equals(officeId)); if (model != null) { ApplicationDateModel item = model.Clone() as ApplicationDateModel; if (item != null) { item.ForcedLogOffTimestamp = forcedLogOffOn; item.NewDayStarted = false; applicationDates.Add(item); applicationDates.Remove(model); } CacheFactory.SetApplicationDates(applicationDates); } } }
private void CheckForceLogOffFlags() { int officeId = CurrentUser.GetSignInView().OfficeId.ToInt(); Collection <ApplicationDateModel> applicationDates = CacheFactory.GetApplicationDates(); if (applicationDates != null) { ApplicationDateModel model = applicationDates.FirstOrDefault(c => c.OfficeId.Equals(officeId)); if (model != null) { if (model.ForcedLogOffTimestamp != null && !model.ForcedLogOffTimestamp.Equals(DateTime.MinValue)) { if (model.ForcedLogOffTimestamp <= DateTime.Now && model.ForcedLogOffTimestamp >= CurrentUser.GetSignInView().LoginDateTime) { RequestLogOnPage(); } } } } }
private void SuggestDateReload() { int officeId = CurrentUser.GetSignInView().OfficeId.ToInt(); Collection <ApplicationDateModel> applicationDates = CacheFactory.GetApplicationDates(); if (applicationDates != null) { ApplicationDateModel model = applicationDates.FirstOrDefault(c => c.OfficeId.Equals(officeId)); if (model != null) { ApplicationDateModel item = model.Clone() as ApplicationDateModel; if (item != null) { item.NewDayStarted = true; applicationDates.Add(item); applicationDates.Remove(model); } CacheFactory.SetApplicationDates(applicationDates); } } }