Beispiel #1
0
        //public PlayItemEntity ToEntity(PlaybillEntity billEntity, IPlayItem playItem)
        //{
        //    var dtoItem = new PlayItemEntity();
        //    dtoItem.Id = playItem.Id;

        //    dtoItem.StartTime = playItem.StartTime;
        //    dtoItem.PlayDuration = playItem.CalculatedPlayDuration.TotalSeconds;
        //    dtoItem.MarkerIn = playItem.PlayRange.StartPosition.TotalSeconds;
        //    dtoItem.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds;

        //    dtoItem.PlaybillItem = ToEntity(billEntity, playItem.PlaybillItem);
        //    return dtoItem;
        //}

        //public PlaybillItemEntity ToEntity(PlaybillEntity billEntity, IPlaybillItem billItem)
        //{
        //    var dtoItem = new PlaybillItemEntity();
        //    dtoItem.Id = billItem.Id;

        //    dtoItem.Playbill = billEntity;

        //    dtoItem.StartTime = billItem.StartTime;
        //    dtoItem.MarkerIn = billItem.PlayRange.StartPosition.TotalSeconds;
        //    dtoItem.ScheduleMode = billItem.ScheduleMode;
        //    dtoItem.MarkerDuration = billItem.PlayRange.Duration.TotalSeconds;

        //    if (billItem.MediaSource.Category!=MediaSourceCategory.Null)
        //    {
        //        dtoItem.MediaSourceId = billItem.MediaSource.Id;
        //    }
        //    else
        //    {
        //        dtoItem.MediaSourceTitle = billItem.MediaSource.Title;
        //        dtoItem.MediaSourceDuration = billItem.MediaSource.Duration.Value.TotalSeconds;
        //    }

        //    var autoBillItem = billItem as AutoPlaybillItem;
        //    if (autoBillItem != null)
        //    {
        //        dtoItem.IsAutoPadding = autoBillItem.IsAutoPadding;
        //    }


        //    var fileMediaSource = billItem.MediaSource as IFileMediaSource;
        //    if (fileMediaSource != null)
        //    {
        //        dtoItem.AudioGain = fileMediaSource.AudioGain;
        //    }

        //    if (billItem.CGItems != null)
        //    {
        //        dtoItem.CGContents = CGItemCollection.ToXml(billItem.CGItems);
        //    }

        //    return dtoItem;
        //}

        public static Playbill Load(Guid id, IList <IPlayItem> playItemList)
        {
            PlaybillEntity billEntity = PlayoutRepository.GetPlaybill(id); // GetEntity(id);
            Playbill       playbill   = null;
            Dictionary <Guid, IPlaybillItem> playbillItemDict = new Dictionary <Guid, IPlaybillItem>();

            if (billEntity != null)
            {
                playbill = new Playbill(billEntity);
                for (int i = 0; i < billEntity.PlayItems.Count; i++)
                {
                    PlayItemEntity playItemEntity = billEntity.PlayItems[i];
                    IPlaybillItem  playbillItem   = null;
                    if (!playbillItemDict.ContainsKey(playItemEntity.PlaybillItemId))
                    {
                        playbillItem = playItemEntity.PlaybillItem.ToPlaybillItem();
                        // FromEntity(playItemEntity.PlaybillItem);
                        playbillItemDict.Add(playItemEntity.PlaybillItemId, playbillItem);
                    }
                    else
                    {
                        playbillItem = playbillItemDict[playItemEntity.PlaybillItemId];
                    }

                    IPlayItem playItem = playItemEntity.ToPlayItem(playbillItem); // FromEntity(playItemEntity,playbillItem);
                    playItemList.Add(playItem);
                }
            }
            return(playbill);
        }
        public static PlayItemEntity ToEntity(this IPlayItem playItem, PlaybillEntity billEntity, IMediaSource replaceAutoPadding)
        {
            var dtoItem = new PlayItemEntity();

            dtoItem.Id = playItem.Id;

            dtoItem.StartTime      = playItem.StartTime;
            dtoItem.PlayDuration   = playItem.CalculatedPlayDuration.TotalSeconds;
            dtoItem.MarkerIn       = playItem.PlayRange.StartPosition.TotalSeconds;
            dtoItem.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds;

            dtoItem.PlaybillItem = ToEntity(billEntity, playItem.PlaybillItem, replaceAutoPadding); //.ToEntity();
            return(dtoItem);
        }
        public static PlayItemEntity ToEntity(this IPlayItem playItem)
        {
            var entity = new PlayItemEntity();

            entity.Id = playItem.Id;

            entity.StartTime      = playItem.StartTime;
            entity.PlayDuration   = playItem.CalculatedPlayDuration.TotalSeconds;
            entity.MarkerIn       = playItem.PlayRange.StartPosition.TotalSeconds;
            entity.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds;

            entity.PlaybillItemId = playItem.PlaybillItem.Id;
            entity.PlaybillItem   = new PlaybillItemEntity(playItem.PlaybillItem, (i) => i.ToEntity());

            return(entity);
        }
 public static IPlayItem ToPlayItem(this PlayItemEntity entity, IPlaybillItem playbillItem)
 {
     if (playbillItem.ScheduleMode == PlayScheduleMode.Auto)
     {
         var autoPlayItem = new AutoPlayItem(playbillItem);
         autoPlayItem.StartTime = entity.StartTime;
         autoPlayItem.CalculatedPlayDuration = TimeSpan.FromSeconds(entity.PlayDuration);
         autoPlayItem.PlayRange = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration));
         //autoPlayItem.PlaybillItem = playbillItem;
         autoPlayItem.Id = entity.Id;
         return(autoPlayItem);
     }
     else
     {
         return((TimingPlaybillItem)playbillItem);
     }
     //throw new NotImplementedException();
 }
        public static IPlayItem ToPlayItem(this PlayItemEntity entity)
        {
            IPlaybillItem playbillItem = entity.PlaybillItem.ToPlaybillItem(); // FromEntity(entity.PlaybillItem);

            if (playbillItem.ScheduleMode == PlayScheduleMode.Auto)
            {
                var autoPlayItem = new AutoPlayItem(playbillItem);
                autoPlayItem.StartTime = entity.StartTime;
                autoPlayItem.CalculatedPlayDuration = TimeSpan.FromSeconds(entity.PlayDuration);
                autoPlayItem.PlayRange = new PlayRange(TimeSpan.FromSeconds(entity.MarkerIn), TimeSpan.FromSeconds(entity.MarkerDuration));
                autoPlayItem.Id        = entity.Id;
                return(autoPlayItem);
            }
            else
            {
                return((TimingPlaybillItem)playbillItem);
            }
        }