Esempio n. 1
0
        public IList <SeatBox> Preparing(Entity campaign, Entity[] areas, DateTime start, DateTime end)
        {
            _organizationSeatingAreaSet = new Dictionary <Entity, OrganizationSeatingArea[]>();
            _seatsMap = new Dictionary <Entity, IEnumerable <ISeat> >();

            foreach (var area in areas)
            {
                _organizationSeatingAreaSet[area] =
                    _areaRepository.GetOrganizationSeatingArea(area.Id).Where(o => o.IsSelected == true && o.TargetSeat != null).OrderBy(o => o.Index).ToArray();
                _seatsMap[area] = ((IArea)area).Seats;
            }

            _priorityEmployeeSet = _areaRepository.GetPriorityEmployees(areas).ToUsefulDictionary();

            var seatBoxList = _seatBoxRepository.Search(areas, start, end, false);

            var seatIds = new string[seatBoxList.Count];
            var counter = 0;

            _seatBoxSet = seatBoxList.ToDictionary(o =>
            {
                o.Initial();
                var key          = o.Seat.Id.ToString();
                seatIds[counter] = key;
                counter++;
                return(key);
            });

            //TODO: need filter with OccupyStatus ? do not load labourRule only timebox object
            _participaters = _timeBoxRepository.GetTimeBoxesFrom(campaign, start, end);
            _agentsOnSeat  = _timeBoxRepository.GetTimeBoxes(seatIds, _participaters.Select(o => o.Id).ToArray(), start, end);

            return(seatBoxList);
        }
        public void Announce(Schedule schedule)
        {
            var timeboxes = _timeBoxRepository.GetTimeBoxesFrom(schedule.Campaign, schedule.Start, schedule.End);

            foreach (var timeBox in timeboxes)
            {
                foreach (var term in timeBox.TermSet)
                {
                    var hrDate = term.GetLowestTerm().SaftyGetProperty <DateTime, IAssignment>(o => o.SaftyGetHrDate());

                    if (!hrDate.IsInTheRange(schedule))
                    {
                        continue;
                    }

                    //backupTerm
                    var backup = new BackupTerm(term.Id, timeBox.Agent.Id, term.Start, term.End, term.Text, term.Background, term.Level)
                    {
                        HrDate = hrDate
                    };
                    if (term.ParentTerm != null)
                    {
                        backup.ParentTermId = term.ParentTerm.Id;
                    }
                    term.SaftyInvoke <AssignmentBase>(o => backup.WorkingTotals = o.WorkingTotals);

                    _timeBoxRepository.SaveOrUpdate(backup);
                }
            }
        }