Пример #1
0
        /// <summary>
        /// Books the time slots.
        /// </summary>
        /// <param name="EDC">The EDC.</param>
        /// <param name="timeSlot">The time slot.</param>
        /// <param name="isDouble">if set to <c>true</c> [is double].</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException">Time slot has been aleady reserved</exception>
        public static List <TimeSlotTimeSlot> BookTimeSlots(EntitiesDataContext EDC, string timeSlot, bool isDouble)
        {
            TimeSlotTimeSlot _timeSlot = Element.GetAtIndex <TimeSlotTimeSlot>(EDC.TimeSlot, timeSlot);

            if (_timeSlot.Occupied.GetValueOrDefault(Entities.Occupied.None) == Entities.Occupied.Occupied0)
            {
                throw new TimeSlotException("Time slot has been aleady reserved");
            }
            List <TimeSlotTimeSlot> _ret = new List <TimeSlotTimeSlot>();

            _ret.Add(_timeSlot);
            _timeSlot.Occupied = Entities.Occupied.Occupied0;
            if (isDouble)
            {
                Debug.Assert(_timeSlot.StartTime.HasValue, "TimeSlot StartTime has to have Value");
                DateTime _tdy = _timeSlot.StartTime.Value.Date;
                List <TimeSlotTimeSlot> _avlblTmslts = (from _tsidx in EDC.TimeSlot
                                                        let _idx = _tsidx.StartTime.Value.Date
                                                                   where _tsidx.Occupied.GetValueOrDefault(Entities.Occupied.None) == Entities.Occupied.Free &&
                                                                   _idx >= _tdy &&
                                                                   _idx <= _tdy.AddDays(1)
                                                                   orderby _tsidx.StartTime ascending
                                                                   select _tsidx).ToList <TimeSlotTimeSlot>().Where <TimeSlotTimeSlot>(x => x.TimeSlot2ShippingPointLookup == _timeSlot.TimeSlot2ShippingPointLookup).ToList <TimeSlotTimeSlot>();
                TimeSlotTimeSlot _next = FindAdjacent(_avlblTmslts, _timeSlot);
                _ret.Add(_next);
                _next.Occupied = Entities.Occupied.Occupied0;
            }
            return(_ret);
        }
Пример #2
0
        /// <summary>
        /// Makes the booking.
        /// </summary>
        /// <param name="timeSlotsCollection">The time slots collection.</param>
        /// <param name="isDouble">if set to <c>true</c> [_is double].</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException">Time slot has been aleady reserved</exception>
        public List <TimeSlotTimeSlot> MakeBooking(List <TimeSlotTimeSlot> timeSlotsCollection, bool isDouble)
        {
            m_TimeSlots             = null;
            StartTime               = timeSlotsCollection[0].StartTime;
            TSStartTime             = timeSlotsCollection[0].StartTime;
            WarehouseStartTime      = timeSlotsCollection[0].StartTime;
            Shipping2WarehouseTitle = timeSlotsCollection[0].GetWarehouse();
            TimeSlotTimeSlot _next = timeSlotsCollection[0];

            foreach (TimeSlotTimeSlot _tsx in timeSlotsCollection)
            {
                if (isDouble == true)
                {
                    _tsx.IsDouble = true;
                }
                _tsx.TimeSlot2ShippingIndex = this;
                _next = _tsx;
            }
            EndTime          = _next.EndTime;
            TSEndTime        = _next.EndTime;
            WarehouseEndTime = _next.EndTime;
            ShippingDuration = Convert.ToDouble((_next.EndTime.Value - this.StartTime.Value).TotalMinutes);
            LoadingType      = isDouble ? Entities.LoadingType.Manual : Entities.LoadingType.Pallet;
            return(timeSlotsCollection);
        }
Пример #3
0
 private static TimeSlotTimeSlot FindAdjacent(List <TimeSlotTimeSlot> _avlblTmslts, TimeSlotTimeSlot timeSlot)
 {
     for (int _i = 0; _i < _avlblTmslts.Count; _i++)
     {
         if ((_avlblTmslts[_i].StartTime.Value - timeSlot.EndTime.Value).Duration() <= TimeSlotTimeSlot.Span15min)
         {
             return(_avlblTmslts[_i]);
         }
     }
     throw new TimeSlotException("Cannot find the time slot to make the couple.");
 }