Пример #1
0
        //public IList<IPlaylistItem> Build()
        //{
        //    DateTime startTime, stopTime;

        //    if (_beginItem!=null && _endItem != null)
        //    {
        //        startTime = _beginItem.ScheduleInfo.StopTime;
        //        stopTime = _endItem.ScheduleInfo.StartTime;
        //    }
        //    else
        //    {
        //        if (_beginItem != null)
        //        {
        //            startTime = _beginItem.ScheduleInfo.StopTime;
        //            stopTime = DateTime.MaxValue;
        //        }
        //        else // _endItem != null
        //        {
        //            stopTime = _endItem.ScheduleInfo.StartTime;


        //            if(_autoList.Count>0 && _breakList.Count > 0)
        //            {
        //                var autoStartTime = _autoList[0].ScheduleInfo.StartTime;
        //                var breakStartTime = _breakList[0].ScheduleInfo.StartTime;
        //                startTime = autoStartTime < breakStartTime ? autoStartTime : breakStartTime;
        //            }
        //            else if (_autoList.Count > 0)
        //            {
        //                startTime = _autoList[0].ScheduleInfo.StartTime;
        //            }
        //            else if (_breakList.Count > 0)
        //            {
        //                startTime = _breakList[0].ScheduleInfo.StartTime;
        //            }
        //            else
        //            {
        //                startTime = stopTime;
        //            }

        //            startTime = startTime > stopTime ? stopTime : startTime;
        //        }
        //    }

        //    var result = new List<IPlaylistItem>();
        //    Build(startTime, stopTime, result);
        //    return result;
        //}


        //private void Build(DateTime startTime, DateTime stopTime, IList<PlaybillItem> result)
        //{
        //    PlaybillItem autoItem = null;
        //    PlaybillItem breakItem = null;

        //    while (startTime < stopTime)
        //    {
        //        if (autoItem == null && _autoList.Count > 0)
        //        {
        //            autoItem = _autoList[0];
        //            _autoList.RemoveAt(0);
        //        }

        //        if (breakItem==null && _breakList.Count > 0)
        //        {
        //            autoItem = _breakList[0];
        //            _breakList.RemoveAt(0);
        //        }

        //        if(autoItem!=null && breakItem != null)
        //        {
        //            if (startTime < breakItem.ScheduleInfo.StartTime)
        //            {
        //                var duration = breakItem.ScheduleInfo.StartTime.Subtract(startTime);
        //                if (duration >= autoItem.PlaySource.PlayRange.Duration)
        //                {
        //                    duration = autoItem.PlaySource.PlayRange.Duration;
        //                    var info = autoItem.ScheduleInfo;
        //                    info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
        //                    autoItem.ScheduleInfo = info;

        //                    result.Add(autoItem);
        //                    autoItem = null;
        //                    startTime = info.StopTime;
        //                }
        //                else
        //                {
        //                    PlaybillItem first = null, second = null;
        //                    // 注:autoItem可能本身是个片断。
        //                    Split(autoItem, duration, out first, out second);

        //                    var info = autoItem.ScheduleInfo;
        //                    info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
        //                    first.ScheduleInfo = info;

        //                    result.Add(first);
        //                    autoItem = second;
        //                    startTime = info.StopTime;
        //                }
        //            }
        //            else
        //            {
        //                Debug.Assert(startTime == breakItem.ScheduleInfo.StartTime);

        //                result.Add(breakItem);
        //                breakItem = null;
        //                startTime = breakItem.ScheduleInfo.StopTime;
        //            }
        //        }
        //        else if (autoItem != null) // breakItem == null
        //        {
        //            var duration = stopTime.Subtract(startTime);
        //            if (duration >= autoItem.PlaySource.PlayRange.Duration)
        //            {
        //                duration = autoItem.PlaySource.PlayRange.Duration;
        //                var info = autoItem.ScheduleInfo;
        //                info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
        //                autoItem.ScheduleInfo = info;

        //                result.Add(autoItem);
        //                autoItem = null;
        //                startTime = info.StopTime;
        //            }
        //            else
        //            {
        //                var info = autoItem.ScheduleInfo;
        //                info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
        //                autoItem.ScheduleInfo = info;

        //                result.Add(autoItem);
        //                autoItem = null;
        //                startTime = info.StopTime;
        //            }
        //        }
        //        else if (breakItem != null) // autoItem == null
        //        {
        //            if (startTime < breakItem.ScheduleInfo.StartTime)
        //            {
        //                var duration = breakItem.ScheduleInfo.StartTime.Subtract(startTime);
        //                PlaybillItem autoPaddingItem = CreateAutoPaddingItem(startTime, duration);
        //                result.Add(autoPaddingItem);

        //                startTime = autoPaddingItem.ScheduleInfo.StopTime; // breakItem.ScheduleInfo.StartTime;
        //            }
        //            else
        //            {
        //                Debug.Assert(startTime == breakItem.ScheduleInfo.StartTime);

        //                result.Add(breakItem);
        //                startTime = breakItem.ScheduleInfo.StopTime;
        //                breakItem = null;
        //            }
        //        }
        //        else
        //        {
        //            if (stopTime != DateTime.MaxValue)
        //            {
        //                PlaybillItem autoPaddingItem = CreateAutoPaddingItem(startTime, stopTime.Subtract(startTime));
        //                result.Add(autoPaddingItem);
        //            }


        //            startTime = stopTime;
        //        }
        //    }

        //    Debug.Assert(_breakList.Count == 0);
        //    while (_autoList.Count > 0)
        //    {
        //        autoItem = _autoList[0];
        //        _autoList.RemoveAt(0);

        //        var info = autoItem.ScheduleInfo;
        //        info = new ScheduleInfo(startTime, TimeSpan.Zero, info.ScheduleMode);
        //        autoItem.ScheduleInfo = info;

        //        result.Add(autoItem);
        //    }
        //}

        private PlaybillItem CreateAutoPaddingItem(DateTime startTime, TimeSpan duration)
        {
            var result = PlaybillItem.CreateAutoPadding(duration);

            result.ScheduleInfo = new ScheduleInfo(startTime, duration, ScheduleMode.Auto);
            return(result);
        }
Пример #2
0
 public void Dispose()
 {
     _autoList.Clear();
     _breakList.Clear();
     _resultList.Clear();
     _timingItem = null;
     _beginTime  = null;
     _endTime    = null;
 }
Пример #3
0
        public override PlaybillItem Merge(PlaybillItem nextItem)
        {
            if (!CanMerge(nextItem))
            {
                throw new InvalidOperationException();
            }

            // Note: 是否在自动垫片上操作?

            PlaySource mergedSource = ((PlaySourceSegment)this.PlaySource).Merge(nextItem.PlaySource);

            return(CreateInternal(mergedSource));
        }
Пример #4
0
        public override bool CanMerge(PlaybillItem nextItem)
        {
            if (nextItem == null)
            {
                throw new ArgumentNullException("nextItem");
            }

            // Note: 是否在自动垫片上操作?

            var segment = this.PlaySource as PlaySourceSegment;

            return(segment != null?segment.CanMerge(nextItem.PlaySource) : false);
        }
Пример #5
0
 private void AddAuto(PlaybillItem playbillItem)
 {
     if (!playbillItem.IsAutoPadding()) // 移除自动垫片。
     {
         PlaybillItem prevItem = _autoList.Count > 0 ? _autoList[_autoList.Count - 1] : null;
         if (prevItem != null && prevItem.CanMerge(playbillItem))
         {
             _autoList[_autoList.Count - 1] = prevItem.Merge(playbillItem);
         }
         else
         {
             _autoList.Add(playbillItem);
         }
     }
 }
Пример #6
0
        internal void Set(DateTime beginTime, DateTime endTime, PlaybillItem timingItem)
        {
            Debug.Assert(beginTime < endTime);

            if (timingItem != null)
            {
                if (timingItem.ScheduleMode != ScheduleMode.Timing)
                {
                    throw new ArgumentException("必须是定时播。", "timingItem");
                }

                Debug.Assert(beginTime <= timingItem.ScheduleInfo.StartTime && endTime >= timingItem.ScheduleInfo.StopTime);
            }

            _beginTime = beginTime;
            _endTime   = endTime;

            _timingItem = timingItem;
        }
Пример #7
0
        public PlaybillItem TakeTiming()
        {
            PlaybillItem breakItem = null;
            PlaybillItem result    = null;

            if (_breakList.Count > 0)
            {
                breakItem = _breakList[0];
            }

            if (_timingItem != null && breakItem != null)
            {
                if (_timingItem.ScheduleInfo.StartTime < breakItem.ScheduleInfo.StartTime)
                {
                    result      = _timingItem;
                    _timingItem = null;
                }
                else
                {
                    _breakList.RemoveAt(0);
                    result = breakItem;
                }
            }
            else
            {
                if (_timingItem != null)
                {
                    result      = _timingItem;
                    _timingItem = null;
                }
                else if (breakItem != null)
                {
                    _breakList.RemoveAt(0);
                    result = breakItem;
                }
            }
            return(result);
        }
Пример #8
0
        public void Add(PlaybillItem playbillItem)
        {
            if (playbillItem == null)
            {
                throw new ArgumentNullException("playbillItem");
            }

            var scheduleMode = playbillItem.ScheduleMode;

            if (scheduleMode != ScheduleMode.Auto && scheduleMode != ScheduleMode.TimingBreak)
            {
                throw new ArgumentException("必须是顺播或定时插播。", "playbillItem");
            }

            if (scheduleMode == ScheduleMode.Auto)
            {
                AddAuto(playbillItem);
            }
            else
            {
                AddBreak(playbillItem);
            }
        }
Пример #9
0
        public override void Split(TimeSpan duration, out PlaybillItem first, out PlaybillItem second)
        {
            if (duration <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("duration", string.Format("<{0}>无效,必须大于TimeSpan.Zero。", duration));
            }

            // Note: 是否在自动垫片上操作?

            PlayRange firstRange, secondRange;

            this.PlaySource.Break(duration, out firstRange, out secondRange);

            var segment             = this.PlaySource as PlaySourceSegment;
            NormalPlaySource source = segment != null ? segment.PlaySource : (NormalPlaySource)this.PlaySource;

            var firstSource = PlaySourceSegment.Create(source, firstRange);

            first = CreateInternal(firstSource);

            var secondSource = PlaySourceSegment.Create(source, secondRange);

            second = CreateInternal(secondSource);
        }
Пример #10
0
 public static bool IsTimingBreak(this PlaybillItem playbillItem)
 {
     return(playbillItem.ScheduleMode == ScheduleMode.TimingBreak);
 }
Пример #11
0
 public abstract PlaybillItem Merge(PlaybillItem nextItem);
Пример #12
0
 public static bool IsTruncated(this PlaybillItem playbillItem)
 {
     // Note: 定时播和定时插播应该总是返回false。
     return(playbillItem.ScheduleInfo.Duration < playbillItem.PlaySource.PlayRange.Duration);
 }
Пример #13
0
 internal PlaylistSegmentBuildData GetBuidData(DateTime beginTime, DateTime endTime, PlaybillItem timingItem)
 {
     // ensure _buildData has no data.
     _buildData.Set(beginTime, endTime, timingItem);
     return(_buildData);
 }
Пример #14
0
 public override void Split(TimeSpan duration, out PlaybillItem first, out PlaybillItem second)
 {
     throw new InvalidOperationException();
 }
Пример #15
0
 private void AddBreak(PlaybillItem breakItem)
 {
     Debug.Assert(_beginTime <= breakItem.ScheduleInfo.StartTime && _endTime >= breakItem.ScheduleInfo.StopTime);
     _breakList.Add(breakItem);
 }
Пример #16
0
        private void AddTiming2(DateTime startTime, IPlaySource playSource)
        {
            // 验证操作的合法性。
            ValidatePlayDuration(playSource.PlayRange.Duration);
            ValidateStartTime(startTime, false);
            EnsureNoTimingConflict(startTime, playSource.PlayRange.Duration);

            // 触发事件前置事件。



            List <PlaybillItem> tempList = new List <PlaybillItem>();

            // 重新计算调度信息。
            DateTime beginTime;


            var prevIndex = _playlist.FindLastIndex(i => !i.IsSkipped() && i.ScheduleInfo.StopTime <= startTime);

            if (prevIndex == -1)
            {
                if (_playlist.Count == 0)
                {
                    if (_playlist.HasMinStartTime() && _playlist.MinStartTime.Value < startTime)
                    {
                        beginTime = _playlist.MinStartTime.Value;
                    }
                    else
                    {
                        beginTime = startTime;
                    }
                }
                else
                {
                    beginTime = _playlist[0].ScheduleInfo.StartTime; // startTime;
                    beginTime = beginTime > startTime ? startTime : beginTime;
                }

                // [prevIndex+1, index-1], 注:index-prevIndex+1
                // 替换范围:[prevIndex+1, index-1] (删除的起始索引0==prevIndex+1,数量index==index-prevIndex-1)
            }
            else
            {
                beginTime = _playlist[prevIndex].ScheduleInfo.StopTime;
                // 注:prevIndex可能等于index-1。
                // 当prevIndex小于index-1时。
                // 替换范围:[prevIndex + 1, index-1] (删除的起始索引prevIndex + 1,数量index-prevIndex-1 )

                // 当prevIndex等于index-1时。(删除的起始索引prevIndex + 1==index,数量index-prevIndex-1==0 )
                // 在index处插入0个或1个。
            }

            DateTime endTime;
            var      nextIndex = _playlist.FindFirstIndex(prevIndex + 1, i => !i.IsSkipped() && i.ScheduleInfo.ScheduleMode == ScheduleMode.Timing && i.ScheduleInfo.StartTime > startTime);

            //beginTime = playItem.ScheduleInfo.StopTime;
            if (nextIndex == -1)
            {
                endTime   = DateTime.MaxValue;
                nextIndex = _playlist.Count;

                // [index + 1, _playlist.Count - 1], 注:index + 1可能等于_playlist.Count - 1
                // 替换范围:[index + 1, _playlist.Count - 1] (删除的起始索引index + 1, 数量nextIndex-index-1==_playlist.Count-index-1)
            }
            else
            {
                endTime = _playlist[nextIndex].ScheduleInfo.StartTime;

                // 注:nextIndex可能等于index+1。
                // 当nextIndex大于index+1时。
                // 替换范围:[index+1, nextIndex-1] (删除的起始索引index+1,数量nextIndex-index-1 )

                // 当nextIndex等于index+1时。(删除的起始索引index+1, 数量nextIndex-index-1==0 )
                // 在index+1处插入0个或1个。
            }

            PlaybillItem playItem = PlaybillItem.CreateTiming(startTime, new NormalPlaySource(playSource), false);

            Debug.Assert(beginTime <= endTime);
            Debug.Assert(beginTime <= startTime && endTime > playItem.ScheduleInfo.StopTime);

            for (int i = prevIndex + 1; i < nextIndex; i++)
            {
                tempList.Add(_playlist[i].PlaybillItem);
                //builder.Add(_playlist[i].PlaybillItem);
            }

            // case 1: prevIndex + 1==nextIndex-1,替换起始位置prevIndex + 1,删除数量1 (nextIndex-1-prevIndex)
            // case 2: prevIndex + 1<nextIndex-1,替换起始位置prevIndex + 1,删除数量1 (nextIndex-1-prevIndex)
            // case 3: prevIndex + 1>nextIndex-1
            // 替换范围为[prevIndex + 1, nextIndex-1]
            // 触发事件(表示操作完成)。
        }
Пример #17
0
        private void AddTiming(DateTime startTime, IPlaySource playSource)
        {
            // 验证操作的合法性。
            ValidatePlayDuration(playSource.PlayRange.Duration);
            ValidateStartTime(startTime, false);
            EnsureNoTimingConflict(startTime, playSource.PlayRange.Duration);


            // 获取插入位置。
            // 第一个开始时间大于等于startTime的索引(-1表示列表为空或开始时间全部小于startTime)
            int index = FindTimingInsertIndex(startTime);
            //_playlist.FindFirstIndex((i)=>!i.IsSkipped() && i.ScheduleInfo.StartTime>=startTime);
            //index = index < 0 ? _playlist.Count : index;

            // 下面的处理代码确保顺播片断不会被定时播分隔。
            var tempIndex = index;

            while (tempIndex < _playlist.Count)
            {
                var item = _playlist[tempIndex];
                if (item.ScheduleInfo.ScheduleMode == ScheduleMode.Timing)
                {
                    break;
                }
                else if (item.ScheduleInfo.ScheduleMode == ScheduleMode.TimingBreak)
                {
                    continue;
                }
                else if (!item.IsSegment() || item.IsFirstSegment())
                {
                    break;
                }
                else
                {
                    if (tempIndex != index)
                    {
                        var temp = _playlist[tempIndex];
                        _playlist.RemoveAt(tempIndex);

                        _playlist.Insert(index, temp);
                    }
                    index++;
                }
                tempIndex++;
            }

            // 触发事件前置事件。

            PlaybillItem playItem = PlaybillItem.CreateTiming(startTime, new NormalPlaySource(playSource), false);

            Insert(index, playItem);

            // 重新计算调度信息。
            DateTime beginTime;
            DateTime endTime;

            if (index == 0)
            {
                if (_playlist.HasMinStartTime() && _playlist.MinStartTime.Value < startTime)
                {
                    beginTime = _playlist.MinStartTime.Value;
                    endTime   = startTime;

                    using (var builder = Build())
                    {
                        Replace(0, 0, builder.Build(beginTime, endTime));
                    }
                }
            }
            else if (index > 0) // 有前部片断
            {
                var prevIndex = _playlist.FindLastIndex(index - 1, i => !i.IsSkipped() && i.ScheduleInfo.StopTime <= startTime);
                endTime = startTime;
                if (prevIndex == -1)
                {
                    beginTime = _playlist[0].ScheduleInfo.StartTime; // startTime;
                    beginTime = beginTime > endTime ? endTime : beginTime;


                    // [prevIndex+1, index-1], 注:index-prevIndex+1
                    // 替换范围:[prevIndex+1, index-1] (删除的起始索引0==prevIndex+1,数量index==index-prevIndex-1)
                }
                else
                {
                    beginTime = _playlist[prevIndex].ScheduleInfo.StopTime;
                    // 注:prevIndex可能等于index-1。
                    // 当prevIndex小于index-1时。
                    // 替换范围:[prevIndex + 1, index-1] (删除的起始索引prevIndex + 1,数量index-prevIndex-1 )

                    // 当prevIndex等于index-1时。(删除的起始索引prevIndex + 1==index,数量index-prevIndex-1==0 )
                    // 在index处插入0个或1个。
                }

                using (var builder = Build())
                {
                    for (int i = prevIndex + 1; i < index; i++)
                    {
                        builder.Add(_playlist[i].PlaybillItem);
                    }

                    Replace(prevIndex + 1, index - prevIndex - 1, builder.Build(beginTime, endTime));
                }
            }

            if (index < _playlist.Count - 1) // 有后部片断
            {
                var nextIndex = _playlist.FindFirstIndex(index + 1, i => !i.IsSkipped() && i.ScheduleInfo.ScheduleMode == ScheduleMode.Timing);
                beginTime = playItem.ScheduleInfo.StopTime;
                if (nextIndex == -1)
                {
                    endTime   = DateTime.MaxValue;
                    nextIndex = _playlist.Count;

                    // [index + 1, _playlist.Count - 1], 注:index + 1可能等于_playlist.Count - 1
                    // 替换范围:[index + 1, _playlist.Count - 1] (删除的起始索引index + 1, 数量nextIndex-index-1==_playlist.Count-index-1)
                }
                else
                {
                    endTime = _playlist[nextIndex].ScheduleInfo.StartTime;

                    // 注:nextIndex可能等于index+1。
                    // 当nextIndex大于index+1时。
                    // 替换范围:[index+1, nextIndex-1] (删除的起始索引index+1,数量nextIndex-index-1 )

                    // 当nextIndex等于index+1时。(删除的起始索引index+1, 数量nextIndex-index-1==0 )
                    // 在index+1处插入0个或1个。
                }

                using (var builder = Build())
                {
                    for (int i = index + 1; i < nextIndex; i++)
                    {
                        builder.Add(_playlist[i].PlaybillItem);
                    }
                    Replace(index + 1, nextIndex - index - 1, builder.Build(beginTime, endTime));
                }
            }

            // 触发事件(表示操作完成)。
        }
Пример #18
0
 public abstract void Split(TimeSpan duration, out PlaybillItem first, out PlaybillItem second);
Пример #19
0
 public static bool IsAutoPadding(this PlaybillItem playbillItem)
 {
     return(playbillItem.ScheduleMode == ScheduleMode.Auto);
 }
Пример #20
0
 public static bool IsSkipped(this PlaybillItem playbillItem)
 {
     // Note: 定时播和定时插播应该总是返回false。
     return(playbillItem.ScheduleInfo.Duration == TimeSpan.Zero);
 }
Пример #21
0
 public override PlaybillItem Merge(PlaybillItem nextItem)
 {
     throw new InvalidOperationException();
 }
Пример #22
0
 private void Split(PlaybillItem autoItem, TimeSpan duration,
                    out PlaybillItem first, out PlaybillItem second)
 {
     autoItem.Split(duration, out first, out second);
 }
Пример #23
0
        private void Build2(PlaylistSegmentBuildData buildData)
        {
            DateTime             startTime = buildData.BeginTime;
            DateTime             stopTime  = buildData.EndTime;
            IList <PlaybillItem> result    = buildData.Result;

            PlaybillItem autoItem   = null;
            PlaybillItem timingItem = null;

            while (startTime < stopTime)
            {
                if (autoItem == null)
                {
                    autoItem = buildData.TakeAuto(); // _autoList[0];
                }

                if (timingItem == null)
                {
                    autoItem = buildData.TakeTiming(); // _breakList[0];
                }

                if (autoItem != null && timingItem != null)
                {
                    if (startTime < timingItem.ScheduleInfo.StartTime)
                    {
                        var duration = timingItem.ScheduleInfo.StartTime.Subtract(startTime);
                        if (duration >= autoItem.PlaySource.PlayRange.Duration)
                        {
                            duration = autoItem.PlaySource.PlayRange.Duration;
                            var info = autoItem.ScheduleInfo;
                            info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
                            autoItem.ScheduleInfo = info;

                            result.Add(autoItem);
                            autoItem  = null;
                            startTime = info.StopTime;
                        }
                        else
                        {
                            if (timingItem.ScheduleMode == ScheduleMode.TimingBreak)
                            {
                                PlaybillItem first = null, second = null;
                                // 注:autoItem可能本身是个片断。
                                Split(autoItem, duration, out first, out second);

                                var info = autoItem.ScheduleInfo;
                                info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
                                first.ScheduleInfo = info;

                                result.Add(first);
                                autoItem  = second;
                                startTime = info.StopTime;
                            }
                            else
                            {
                                // 截短。
                                var info = autoItem.ScheduleInfo;
                                info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
                                autoItem.ScheduleInfo = info;

                                result.Add(autoItem);
                                autoItem  = null;
                                startTime = info.StopTime;
                            }
                        }
                    }
                    else
                    {
                        Debug.Assert(startTime == timingItem.ScheduleInfo.StartTime);

                        if (timingItem.ScheduleMode == ScheduleMode.TimingBreak || !autoItem.IsSegment)
                        {
                            result.Add(timingItem);
                            timingItem = null;
                            startTime  = timingItem.ScheduleInfo.StopTime;
                        }
                        else
                        {
                            Debug.Assert(!autoItem.IsFirstSegment);
                            // 完全截掉。
                            var info = autoItem.ScheduleInfo;
                            info = new ScheduleInfo(startTime, TimeSpan.Zero, info.ScheduleMode);
                            autoItem.ScheduleInfo = info;

                            result.Add(autoItem);
                            autoItem  = null;
                            startTime = info.StopTime;
                        }
                    }
                }
                else if (autoItem != null) // timingItem == null
                {
                    var duration = stopTime.Subtract(startTime);
                    if (duration >= autoItem.PlaySource.PlayRange.Duration)
                    {
                        duration = autoItem.PlaySource.PlayRange.Duration;
                        var info = autoItem.ScheduleInfo;
                        info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
                        autoItem.ScheduleInfo = info;

                        result.Add(autoItem);
                        autoItem  = null;
                        startTime = info.StopTime;
                    }
                    else
                    {
                        var info = autoItem.ScheduleInfo;
                        info = new ScheduleInfo(startTime, duration, info.ScheduleMode);
                        autoItem.ScheduleInfo = info;

                        result.Add(autoItem);
                        autoItem  = null;
                        startTime = info.StopTime;
                    }
                }
                else if (timingItem != null) // autoItem == null
                {
                    if (startTime < timingItem.ScheduleInfo.StartTime)
                    {
                        var          duration        = timingItem.ScheduleInfo.StartTime.Subtract(startTime);
                        PlaybillItem autoPaddingItem = CreateAutoPaddingItem(startTime, duration);
                        result.Add(autoPaddingItem);

                        startTime = autoPaddingItem.ScheduleInfo.StopTime; // breakItem.ScheduleInfo.StartTime;
                    }
                    else
                    {
                        Debug.Assert(startTime == timingItem.ScheduleInfo.StartTime);

                        result.Add(timingItem);
                        startTime  = timingItem.ScheduleInfo.StopTime;
                        timingItem = null;
                    }
                }
                else
                {
                    if (stopTime != DateTime.MaxValue)
                    {
                        PlaybillItem autoPaddingItem = CreateAutoPaddingItem(startTime, stopTime.Subtract(startTime));
                        result.Add(autoPaddingItem);
                    }


                    startTime = stopTime;
                }
            }

            Debug.Assert(buildData.TakeTiming() == null);

            autoItem = buildData.TakeAuto();
            while (autoItem != null)
            {
                var info = autoItem.ScheduleInfo;
                info = new ScheduleInfo(startTime, TimeSpan.Zero, info.ScheduleMode);
                autoItem.ScheduleInfo = info;

                result.Add(autoItem);

                autoItem = buildData.TakeAuto();
            }
        }
Пример #24
0
 public override bool CanMerge(PlaybillItem nextItem)
 {
     return(false);
 }
Пример #25
0
 public abstract bool CanMerge(PlaybillItem nextItem);