public ActionResult _StatusList(bool showOnlyLoggedInUsers, string sortOrder = "") { var list = _physician.GetPhysicianStatusDashboard(sortOrder); if (showOnlyLoggedInUsers) { list = list.Where(m => OnlineUserIds.Contains(m.physician.Id)); } var statusList = list.Where(m => m.physician.physician_status != null).Select(m => m.physician.physician_status).Distinct(); ViewBag.OnlineUsers = OnlineUserIds; ViewBag.statusList = statusList.ToList(); ViewBag.defaultStatus = _physicianStatusService.GetDefault(); return(PartialView(list.ToList())); }
public void MovePhysicianStatuses() { try { // create log _logger.AddLogEntry(_serviceName, "INPROGRESS", _serviceName + " Started", ""); var snoozePoupUsersIds = new List <PhysicianStatusSnoozeViewModel>(); var movedUserIds = new List <string>(); using (var objService = new PhysicianService()) { objService.GetPhysicianStatusDashboard() .Where(m => m.physician.physician_status.phs_move_status_key != null && m.physician.status_key != m.physician.physician_status.phs_move_status_key) .ToList() .ForEach(item => { var status_key = item.physician.status_key; var isSendSnoozeNotification = false; var snoozeTime = item.physician.physician_status_snooze.Where(m => m.pss_processed_date == null && m.pss_phs_key == status_key ); double snoozeMinutes = 0; if (snoozeTime.Count() > 0) { snoozeMinutes = snoozeTime.Sum(m => m.pss_snooze_time.TotalMinutes); } if (item.physician.physician_status.phs_move_threshhold_time.HasValue && item.physician.physician_status.phs_enable_snooze) { // this condition will be rechecked after the task is completed. little bit doubt on it var elapsedTime = DateTime.Now.ToEST() - item.physician.status_change_date_forAll.Value.AddMinutes(snoozeMinutes); var difference = item.physician.physician_status.phs_move_threshhold_time.Value.TotalMinutes - elapsedTime.TotalMinutes; var currentSnooze = item.physician.physician_status_snooze.Where(m => m.pss_processed_date == null && m.pss_phs_key == status_key && m.pss_is_latest_snooze ) .FirstOrDefault(); if (difference <= 2.1 && difference >= 1.5 && currentSnooze == null) { isSendSnoozeNotification = true; } } if (isSendSnoozeNotification && snoozeTime.Count() < item.physician.physician_status.phs_max_snooze_count.Value) { snoozePoupUsersIds.Add(new PhysicianStatusSnoozeViewModel { phs_key = item.physician.status_key.Value, UserId = item.physician.Id }); } else { if (RunStatusUpdateCode(item, snoozeMinutes)) { snoozeTime.ToList().ForEach(m => { m.pss_processed_date = DateTime.Now.ToEST(); m.pss_is_latest_snooze = false; m.pss_modified_by = "physician status move service"; m.pss_modified_by_name = "physician status move service"; m.pss_modified_date = DateTime.Now.ToEST(); }); movedUserIds.Add(item.physician.Id); } } }); objService.SaveChanges(); } if (snoozePoupUsersIds.Count() > 0) { RunSnoozePopupCode(snoozePoupUsersIds); snoozePoupUsersIds.Clear(); } if (movedUserIds.Count() > 0) { // sending request to signal r controller to update the status of online physician string url = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(movedUserIds); scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json); } } catch (Exception exception) { _logger.AddLogEntry(_serviceName, "ERROR", exception, ""); } finally { _logger.AddLogEntry(_serviceName, "COMPLETED", "", ""); } }