private async System.Threading.Tasks.Task loadLookups() { if (IsBusy) { return; } IsBusy = true; try { var lookups = await DataService.GetLookups(4); lookups.Shifts.ForEach(s => Shifts.Add(s)); lookups.Tasks.ForEach(t => Tasks.Add(t)); lookups.Users.ForEach(u => Users.Add(u)); } catch (Exception ex) { IsBusy = false; ExceptionHelper.ShowException(ex); } finally { IsBusy = false; } }
private void PopulateShifts(ActiveShifts shifts) { _activeShiftsModel = shifts; var startTime = DateTime.Now; _log.Info("PopulateShifts method call started"); LoginModel.Shifts = new List <string>(); foreach (var shift in _activeShiftsModel.Shifts) { LoginModel.Shifts.Add(shift.DisplayFormat); if (!Shifts.ContainsKey(shift.DisplayFormat)) { Shifts.Add(shift.DisplayFormat, shift.ShiftNumber); } } LoginModel.TillFloat = _activeShiftsModel.CashFloat.ToString("0.00", CultureInfo.InvariantCulture); var endTime = DateTime.Now; MessengerInstance.Send(new CloseKeyboardMessage()); _log.Info(string.Format("PopulateShifts method call ended in {0}ms", (endTime - startTime).TotalMilliseconds)); }
public void LoadCollections() { Areas.Clear(); Operations.Clear(); Personal.Clear(); Shifts.Clear(); foreach (var area in _collectionsRepository.LoadWorkAreas()) { Areas.Add(area); } foreach (var operation in _collectionsRepository.LoadWorks()) { Operations.Add(operation); } foreach (var employee in _collectionsRepository.LoadPersonal()) { Personal.Add(employee); } foreach (var shift in _collectionsRepository.LoadShiftSet()) { Shifts.Add(shift); } }
async System.Threading.Tasks.Task ExecuteLoadScreen() { if (Users.Count < 1) { if (IsBusy) { return; } IsBusy = true; try { var lookups = await DataService.GetLookups(this.EntryType); if (lookups.Shifts != null) { lookups.Shifts.ForEach(s => Shifts.Add(s)); if (Entry.ShiftId != null) { Shift = lookups.Shifts.FirstOrDefault(x => x.ShiftId == Entry.ShiftId); } } if (lookups.Statuses != null) { lookups.Statuses.ForEach(s => Statuses.Add(s)); } lookups.Tasks.ForEach(t => Tasks.Add(t)); if (Entry.TaskId != null) { Task = lookups.Tasks.FirstOrDefault(t => t.TaskId == Entry.TaskId); } lookups.Users.ForEach(u => Users.Add(u)); if (Entry.UserId != null) { User = lookups.Users.FirstOrDefault(u => u.UserId == Entry.UserId); } if (Entry.EnteredById == null) { var usr = AuthService.UserToken.User; Entry.EnteredBy = usr; Entry.EnteredById = usr.UserId; } } catch (Exception ex) { IsBusy = false; ExceptionHelper.ShowException(ex); } finally { IsBusy = false; } } RefreshEntrySubtasks(); OnPropertyChanged("Entry"); }
/// <summary> /// Create a shift /// </summary> /// <param name="name">Name</param> /// <param name="description">Description</param> /// <param name="start">Start of shift</param> /// <param name="duration">Duration of shift</param> /// <returns>Shift</returns> public Shift CreateShift(string name, string description, LocalTime start, Duration duration) { Shift shift = new Shift(name, description, start, duration); if (Shifts.Contains(shift)) { string msg = String.Format(WorkSchedule.GetMessage("shift.already.exists"), name); throw new Exception(msg); } Shifts.Add(shift); shift.WorkSchedule = this; return(shift); }
public void SetEmployeeDroppedHandler() { Mediator.GetInstance().EmployeeDropped += (e, tod, dow) => { if (IsVisible) { Clear(); Shifts.Add(new TemplateShift() { Employee = e, StartTime = tod, WeekDay = dow, WeekNumber = WeekNumber, Hours = DEFAULTSHIFTLENGTH }); LoadShiftsIntoCalendar(); } }; }
public void AddShift(DateTime start, DateTime end, Employee emp, Branch branch, string comment = "No comments.") { if (start > end) // shift starts after it ends? { Console.WriteLine($"Shift cannot start after it ends. Start: {start} - End: {end}"); return; } if (end - start > TimeSpan.FromHours(MaxShiftLengthInHours)) //shift is more than allowed hours? { Console.WriteLine($"Not allowed to work more than {MaxShiftLengthInHours} hours. Shift length: {end - start}"); return; } Shifts.Add(new Shift { StartTime = start, EndTime = end, Employee = emp, Branch = branch, Comment = comment }); }
public void SetEmployeeDroppedHandler() { Mediator.GetInstance().EmployeeDropped += (e, tod, dow) => { if (IsVisible) { Clear(); ScheduleShift ss = new ScheduleShift(); DateBox db = DateBoxes[(int)dow - 1]; DateTime dt = new DateTime(db.Date.Year, db.Date.Month, db.Date.Day, tod.Hours, tod.Minutes, 0); ss.StartTime = dt; ss.Employee = e; ss.Hours = DEFAULTSHIFTLENGTH; Shifts.Add(ss); LoadShiftsIntoCalendar(); } }; }
public async Task <Shifts> GetDCShifts(int id, int group, string creator, string set, int up) { try { var dc = _context.Daycares[id]; var dtoWishes = await _mongo.GetWishes(set, creator); var wishes = ConvertDTOToWish(dtoWishes, dc); await _calc.DaycareShiftsOfThreeWeeks(dc, group, wishes, up); var dcShifts = new Shifts(); foreach (var team in dc.Teams) { List <Employee> sorted = team.TeamEmp.OrderBy(e => e.Id).ToList(); foreach (var emp in sorted) { var shifts = emp.Status == StatusEnum.Nurse ? $"{emp.Id} {emp.Status}: " : $"{emp.Id} {emp.Status}: "; foreach (var shift in emp.Shifts) { var num = Convert.ToInt32(shift.Shift) + 1; shifts += num + ((num > 9) ? " " : " "); } dcShifts.Add(shifts.Trim()); } } return(dcShifts); } catch (Exception ex) { var fail = new Shifts(); fail.AllShifts.Add(ex.Message); return(fail); } }
public void AddShift(Position cursor_position, Point shift) { var indices = GetClosestShiftIndexes(cursor_position, 2); if (indices != null && indices[0].Item2 < Options.Instance.calibration_mode.zone_size) { Shifts[indices[0].Item1] = new ShiftItem(cursor_position, shift); if (indices.Count > 1 && indices[1].Item2 < Options.Instance.calibration_mode.zone_size) { Shifts.RemoveAt(indices[1].Item1); } } else if (Shifts.Count() < Options.Instance.calibration_mode.max_zones_count) { Shifts.Add(new ShiftItem(cursor_position, shift)); } else { Shifts[GetClosestPointOfHihestDensity(cursor_position)] = new ShiftItem(cursor_position, shift); } AsyncSaver.Save(Filepath, GetDeepCopy); NotifyOnChange(); }
public void AddShift(Shift shift) { Shifts.Add(shift); }
public void AddShift(TemplateShift shift) { Shifts.Add(shift); }
private void AddShifts(List <TemplateShift> list) { list.ForEach(x => Shifts.Add(x)); }
public override async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand() { await runTask(async() => { if (!Users.Any()) { Users.Add(new User() { FirstName = "(All)", UserId = _allGuid }); Users.Add(new User() { FirstName = "(Unassigned)", UserId = _unassignedGuid }); Users.Add(new User() { FirstName = "(Assigned)", UserId = _assignedGuid }); var lookups = await DataService.GetLookups(4); lookups.Users.ForEach(u => Users.Add(u)); Shifts.Add(new Shift() { ShiftName = "(All)", ShiftId = _allGuid }); lookups.Shifts.ForEach(s => Shifts.Add(s)); Tasks.Add(new Task() { TaskName = "(All)", TaskId = _allGuid }); lookups.Tasks.ForEach(t => Tasks.Add(t)); } Schedules.Clear(); var items = await DataService.GetItemsAsync <Schedule>($"schedules?start={ScheduleDate.ToString("MM-dd-yyyy")}&end={ScheduleDate.AddDays(6).ToString("MM-dd-yyyy")}"); NoSchedules = !items.Data.Any(); this.WeekUnpublished = false; foreach (var item in items.Data.OrderBy(d => d.ScheduleDateValue).ThenBy(d => d.StartTimeValue).ThenBy(d => d.User == null ? "aaaaaaa" : d.User.FirstName)) { if (item.UserId != null && !item.PublishedValue) { this.WeekUnpublished = true; } _weekSchedules = items.Data; if (SelectedUser != null && SelectedUser.UserIdValue != _allGuid) { if (SelectedUser.UserIdValue == _unassignedGuid && item.User != null) { continue; } if (SelectedUser.UserIdValue == _assignedGuid && item.User == null) { continue; } if (SelectedUser.UserIdValue != _assignedGuid && SelectedUser.UserIdValue != _unassignedGuid && SelectedUser.UserIdValue != item.UserIdValue) { continue; } } if (SelectedShift != null && SelectedShift.ShiftIdValue != _allGuid && SelectedShift.ShiftIdValue != item.ShiftIdValue) { continue; } if (SelectedTask != null && SelectedTask.TaskIdValue != _allGuid && SelectedTask.TaskIdValue != item.TaskIdValue) { continue; } var displayItem = new DisplayItem(); scheduleToDisplayItem(displayItem, item); Schedules.Add(displayItem); } OnPropertyChanged("WeekUnpublished"); return(items); }); OnPropertyChanged("NoSchedules"); }
public GameBoardUpdate(Shift singleShift) { Shifts.Add(singleShift); }