//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); }