Esempio n. 1
0
        private void PutItem(ProgramItem programItem, List <ProgramItemSlot> slots)
        {
            if (!slots.Any())
            {
                NotScheduled.Add(programItem);
                return;
            }

            var conflicts = (from slot in slots
                             where slot.ProgramItem != null
                             select slot.ProgramItem).Distinct().ToList();

            if (conflicts.Any())
            {
                Conflicted.Add(programItem);
                foreach (var conflict in conflicts)
                {
                    Conflicted.Add(conflict);
                }
            }
            else
            {
                foreach (var slot in slots)
                {
                    slot.ProgramItem = programItem;
                }
            }
        }
Esempio n. 2
0
        private List <ProgramItemSlot> SelectSlots(ProgramItem programItem, Character character)
        {
            var fields = character.GetFields();

            List <int> GetSlotIndexes(ProjectField field, IEnumerable <ScheduleItemAttribute> items)
            {
                var variantIds = fields
                                 .Single(f => f.Field.ProjectFieldId == field.ProjectFieldId)
                                 .GetDropdownValues()
                                 .Select(variant => variant.ProjectFieldDropdownValueId)
                                 .ToList();
                var indexes = (from item in items where variantIds.Contains(item.Id) select item.SeqId).ToList();

                if (indexes.Count < variantIds.Count) // Some variants not found, probably deleted
                {
                    NotScheduled.Add(programItem);
                }

                return(indexes);
            }

            var slots = from timeSeqId in GetSlotIndexes(TimeSlotField, TimeSlots)
                        from roomSeqId in GetSlotIndexes(RoomField, Rooms)
                        select Slots[timeSeqId][roomSeqId];

            return(slots.ToList());
        }
 private ProgramItemPlaced(ProgramItem item,
                           IReadOnlyCollection <ScheduleRoom> rooms,
                           IReadOnlyCollection <TimeSlot> timeSlots)
 {
     ProgramItem = item;
     Rooms       = rooms;
     StartTime   = timeSlots.Min(x => x.Options.StartTime);
     EndTime     = timeSlots.Max(x => x.Options.EndTime);
 }
 public ProgramItemPlaced(ProgramItem programItem, List <ScheduleBuilder.ProgramItemSlot> slots)
     : this(programItem, slots.Select(x => x.Room).ToList(), slots.Select(x => x.TimeSlot).ToList())
 {
 }