public NotificationResultModel CheckEndOfShiftTasks() { var result = new NotificationResultModel(); var activeGroupCode = AssignedShiftBLO.Current.GetActiveGroup(); if (string.IsNullOrEmpty(activeGroupCode)) { return(result); } var activeStaffs = AccountBLO.Current.GetAccountsByGroup(activeGroupCode) .Where(x => x.Role == Constants.Role.STAFF) .Select(x => x.Username) .ToList(); var pendingTasks = dao.Query(x => activeStaffs.Contains(x.AssignedStaff) && (x.StatusCode == Constants.StatusCode.TASK_DOING || x.StatusCode == Constants.StatusCode.TASK_NOTFINISH)); var staffPendingTasks = pendingTasks.GroupBy(x => x.AssignedStaff) .ToList(); foreach (var staffPendingTask in staffPendingTasks) { var message = string.Format("You have {0} taks need to be completed before your shift ends", staffPendingTask.Count()); var notifCode = NotificationBLO.Current.AddNotification(string.Empty, Constants.Object.OBJECT_TASK_LIST, staffPendingTask.Key, message); result.NotificationCodes.Add(notifCode); } return(result); }
public void Execute(IJobExecutionContext context) { //Add log Log logSchedule = new Log { Object = Constants.Object.OBJECT_SCHEDULE, ChangedValueOfObject = "Check offline request.", LogTime = DateTime.Now }; var dataMap = context.JobDetail.JobDataMap; var requestCode = dataMap.GetString("requestcode"); var request = RequestBLO.Current.GetByKeys(new Request { RequestCode = requestCode }); //notification var result = new NotificationResultModel(); var activeGroupCode = AssignedShiftBLO.Current.GetActiveGroup(); var activeStaff = AccountBLO.Current.GetAccountsByGroup(activeGroupCode) .Where(x => x.Role == Constants.Role.SHIFT_HEAD) .ToList(); var desc = "Customer will come at " + request.AppointmentTime; foreach (var shiftHead in activeStaff) { var notifCode = NotificationBLO.Current.AddNotification(requestCode, Constants.Object.OBJECT_REQUEST, shiftHead.Username, desc); result.NotificationCodes.Add(notifCode); } //DOING Notify(result.NotificationCodes); }