private IEnumerable <BindablePlaybill> LoadPlaybills()
        {
            DateTime minStopTime = DateTime.Now.AddMinutes(5);

            if (_bindablePlaybill == null)
            {
                return(Playbill.LoadPlaybills(minStopTime).Select(i => new BindablePlaybill(i)).ToArray());
            }
            else
            {
                return(Playbill.LoadPlaybills(minStopTime, _bindablePlaybill.StartTime).Select(i => new BindablePlaybill(i)).ToArray());
            }
        }
        private void LoadFirstPlaybill()
        {
            var bill = this.LoadPlaybills().FirstOrDefault();

            if (bill != null)
            {
                List <IPlayItem> playItems = new List <IPlayItem>();
                var playbill = Playbill.Load(bill.Id, playItems);

                if (playItems.Count > 0)
                {
                    //this.Clear();

                    _playbill = playbill;

                    _bindablePlaybill = bill;

                    foreach (var item in playItems)
                    {
                        _playItemCollection.Add(_playItemCollection.CreateBindablePlayItem(item));
                    }
                }
            }
        }
        private void SavePlaybill()
        {
            if (CanSavePlaybill())
            {
                // TODO: 更新数据库之前提示?
                if (ValidateBeforeSave())
                {
                    if (_playbill == null)
                    {
                        _playbill = new Playbill();
                    }

                    _playbill.PlayItemCollection = _playItemCollection;
                    try
                    {
                        _playbill.Save(_playoutConfig.AutoPaddingMediaSource, _userService.CurrentUser);
                    }
                    catch (Exception ex)
                    {
                        OnError(ex);
                    }
                }
            }
        }
        private void LoadPlaybill()
        {
            if (CanLoadPlaybill())
            {
                // TODO: 提示保存

                this.LoadPlaybillInteractionRequest.Raise(new LoadPlaybillConfirmation {
                    Title = "选择节目单", Playbills = LoadPlaybills()
                },
                                                          c =>
                {
                    if (c.Confirmed)
                    {
                        BindablePlaybill bill = c.SelectedPlaybill;

                        if (bill != null)
                        {
                            List <IPlayItem> playItems = new List <IPlayItem>();
                            var playbill = Playbill.Load(bill.Id, playItems);

                            if (playItems.Count > 0)
                            {
                                this.Clear();

                                _playbill = playbill;

                                foreach (var item in playItems)
                                {
                                    _playItemCollection.Add(_playItemCollection.CreateBindablePlayItem(item));
                                }
                            }
                        }
                    }
                });
            }
        }
        private void LoadPlaybill()
        {
            if (CanLoadPlaybill())
            {
                this.LoadPlaybillInteractionRequest.Raise(new LoadPlaybillConfirmation {
                    Title = "选择节目单", Playbills = LoadPlaybills()
                },
                                                          c =>
                {
                    if (c.Confirmed)
                    {
                        BindablePlaybill bill = c.SelectedPlaybill;

                        if (bill != null)
                        {
                            List <IPlayItem> playItems = new List <IPlayItem>();
                            var playbill = Playbill.Load(bill.Id, playItems);

                            if (playItems.Count == 0)
                            {
                                return;
                            }

                            if (_playItemCollection.Count > 0)
                            {
                                var maxStopTime = playItems[0].StartTime;
                                if (maxStopTime > _playItemCollection.Last().StopTime)
                                {
                                    int conflictCount = 0;
                                    // TODO: 提示截短。

                                    for (int i = _playItemCollection.Count - 1; i >= 0; i--)
                                    {
                                        var temp = _playItemCollection[i];
                                        if (temp.StopTime <= maxStopTime)
                                        {
                                            break;
                                        }

                                        if (temp.ScheduleMode != PlayScheduleMode.Auto)
                                        {
                                            conflictCount++;
                                        }
                                    }

                                    if (conflictCount > 0)
                                    {
                                        this.RaiseDisplayMessageInteractionRequest("错误", "新加载的节目单的开始时间为" + maxStopTime.ToString("yyyy-MM--dd HH:mm:ss") + ",在这个时间段内与现有定时播或定时插播存在时间冲突。");
                                        return;
                                    }
                                }
                            }

                            //this.Clear();

                            _playbill         = playbill;
                            _bindablePlaybill = bill;

                            _playItemCollection.Append(playItems);
                            //foreach (var item in playItems)
                            //{
                            //    _playItemCollection.Add(_playItemCollection.CreateBindablePlayItem(item));
                            //}
                        }
                    }
                });
            }
        }
 private void Clear()
 {
     // TODO: 提示保存。
     _playbill = null;
     _playItemCollection.Clear();
 }
        private IEnumerable <BindablePlaybill> LoadPlaybills()
        {
            DateTime minStopTime = DateTime.Now.AddMinutes(5);

            return(Playbill.LoadPlaybills(minStopTime).Select(i => new BindablePlaybill(i)).ToArray());
        }