Пример #1
0
        public static EventStatus Map(IEnumerable <EventRunStatus> runStatus, EventEventIdPair @event)
        {
            if (runStatus == null || @event == null)
            {
                throw new ArgumentNullException(runStatus == null ? "runStatus" : "event");
            }

            if (runStatus.Any())
            {
                switch (runStatus.First())
                {
                case EventRunStatus.Done:
                    //case EventRunStatus.NotPlayed:
                    //case EventRunStatus.Skipped:
                    return(EventStatus.Done);

                case EventRunStatus.PlayedNextVideo:
                case EventRunStatus.Prepared:
                case EventRunStatus.Prerolled:
                case EventRunStatus.RollingNext:
                case EventRunStatus.StandbyOn:      //<--
                    return(EventStatus.Cued);

                case EventRunStatus.Running:
                    return(EventStatus.Running);

                default:
                    return(@event.ADCEvent.EmsIndex > 0 ? EventStatus.Unknown : EventStatus.Error);
                }
            }

            return(@event.ADCEvent.EmsIndex <= 0 ? EventStatus.Error : EventStatus.Unknown);
        }
Пример #2
0
        public EventEventIdPair InsertEvent(String server, Int32 list, EventEventIdPair ev, InsertPlaceType place, Guid position)
        {
            ADCListHelper           lc = GetListHelper(server, list);
            List <EventEventIdPair> el = new List <EventEventIdPair> {
                ev
            };
            var res = lc.InsertEvents(position, el, place);

            return(res.FirstOrDefault());
        }
Пример #3
0
        public IEnumerable <EventEventIdPair> GetListByPeriod(String server, Int32 list, String from, String to)
        {
            List <EventEventIdPair> all = GetListHelper(server, list).GetList().ToList();
            var adapter = _servers.First(srv => srv.ServerName == server);
            List <EventEventIdPair> result = new List <EventEventIdPair>();
            TimeCode fromTC;
            TimeCode toTC;

            try
            {
                fromTC = new TimeCode(adapter.FrameRate, adapter.DropFrame, from);
                toTC   = new TimeCode(adapter.FrameRate, adapter.DropFrame, to);
            }
            catch (TimeCodeException ex)
            {
                Logger.ServiceLogger.Error(ex.Message, ex.StackTrace);
                throw new ServiceParametersValidationException(ex.Message);
            }

            EventEventIdPair currentPrimary      = null;
            TimeCode         currentPrimaryStart = default(TimeCode);
            TimeCode         currentPrimaryEnd   = default(TimeCode);

            all.ForEach(e =>
            {
                if (e.IsPrimary)
                {
                    currentPrimary      = e;
                    currentPrimaryStart = new TimeCode(adapter.FrameRate, adapter.DropFrame, currentPrimary.ADCEvent.OnAirTime);
                    currentPrimaryEnd   = currentPrimaryStart + new TimeCode(adapter.FrameRate, adapter.DropFrame, currentPrimary.ADCEvent.Duration);
                }

                TimeCode
                start = new TimeCode(adapter.FrameRate, adapter.DropFrame, e.ADCEvent.OnAirTime);
                TimeCode
                end = start + new TimeCode(adapter.FrameRate, adapter.DropFrame, e.ADCEvent.OnAirTime);
                if ((e.IsPrimary &&
                     start != TimeCode.Default &&
                     !start.IsEmpty &&
                     ((fromTC <= start && start < toTC) || (fromTC < end && end < toTC))) ||
                    (!e.IsPrimary &&
                     !currentPrimaryStart.IsEmpty &&
                     ((fromTC <= currentPrimaryStart && currentPrimaryStart < toTC) || (fromTC < currentPrimaryEnd && currentPrimaryEnd < toTC))))
                {
                    e.RelatedPrimary = currentPrimary == null ? default(Guid) : currentPrimary.ADCEventId;
                    result.Add(e);
                }
            });

            return(result);
        }
Пример #4
0
        public string GetContentFromDBResultAdc(List <MediaInfo> list, EventEventIdPair ev)
        {
            var records = list.Where(info => info.Identifier == ev.ADCEvent.ID).ToList();

            if (!records.Any())
            {
                return(String.Empty);
            }

            if (records.Count() == 1)
            {
                return(records.First().ContentTable.Content ?? String.Empty);
            }

            // collision
            if (records.Count() >= 2)
            {
                MediaInfo record;
                if (ev.ADCEvent.SegmentNumber != 255)
                {
                    record = records.FirstOrDefault(info => info.SegmentInfos.Count > 0);
                    if (record != null)
                    {
                        return(record.ContentTable.Content ?? String.Empty);
                    }
                }

                // resolve collision
                record = records.FirstOrDefault(
                    info =>
                    info.Title == ev.ADCEvent.Title && info.Duration == TimeCode.BCDToInt32(ev.ADCEvent.Duration) &&
                    info.StartOfMedia == TimeCode.BCDToInt32(ev.ADCEvent.SOM));

                if (record != null)
                {
                    return(record.ContentTable.Content ?? String.Empty);
                }

                record = records.FirstOrDefault(info => info.SegmentInfos.Count == 0);
                if (record != null)
                {
                    return(record.ContentTable.Content ?? String.Empty);
                }

                return(records.First().ContentTable.Content ?? String.Empty);
            }

            return(String.Empty);
        }
Пример #5
0
        public string GetContentFromDBResultAsdb(List <ASDB> list, EventEventIdPair ev)
        {
            var records = list.Where(info => info.Identifier == ev.ADCEvent.ID).ToList();

            if (!records.Any())
            {
                return(String.Empty);
            }

            if (records.Count() == 1)
            {
                return(records.First().Content ?? String.Empty);
            }

            // collision
            if (records.Count() >= 2)
            {
                ASDB record;
                if (ev.ADCEvent.SegmentNumber != 255)
                {
                    record = records.FirstOrDefault(info => info.Type == "m" || info.Type == "M");
                    if (record != null)
                    {
                        return(record.Content ?? String.Empty);
                    }
                }

                // resolve collision
                record = records.FirstOrDefault(
                    info =>
                    info.Title == ev.ADCEvent.Title && info.Duration == TimeCode.BCDToInt32(ev.ADCEvent.Duration) &&
                    info.StartOfMessage == TimeCode.BCDToInt32(ev.ADCEvent.SOM));
                if (record != null)
                {
                    return(record.Content ?? String.Empty);
                }

                record = records.FirstOrDefault(info => info.Type == "s" || info.Type == "S");
                if (record != null)
                {
                    return(record.Content ?? String.Empty);
                }

                return(records.First().Content ?? String.Empty);
            }

            return(String.Empty);
        }
Пример #6
0
 public void CreateTaskOnModifyEvent(String server, Int32 list, EventEventIdPair _event)
 {
     _dbTasks.Enqueue(new DataServiceManagerTask(server, list, new List <EventEventIdPair> {
         _event
     }, TaskType.Modify));
 }
Пример #7
0
 public Boolean ModifyEvent(String server, Int32 list, EventEventIdPair ev, Guid position)
 {
     return(GetListHelper(server, list).ModifyEvent(position, ev.ADCEvent));
 }
Пример #8
0
        private Boolean RippleEvent(ref EventEventIdPair evPair, ref TimeCode holdtime)
        {
            Boolean result = true;

            if (evPair.ADCEvent.EventType == ADCEventType.Primary && !evPair.ADCEvent.EventControl.Contains(EventControlType.AutoRecord))
            {
                var evPairOnAir    = new TimeCode(holdtime.FrameRate, holdtime.DropFrame, evPair.ADCEvent.OnAirTime);
                var evPairDuration = new TimeCode(holdtime.FrameRate, holdtime.DropFrame, evPair.ADCEvent.Duration);
                if (holdtime == TimeCode.Default) // First iteration
                {
                    result   = false;
                    holdtime = TimeCode.Empty;
                    if (evPairOnAir != TimeCode.Default)
                    {
                        holdtime = evPairOnAir + evPairDuration;
                    }
                }
                else // Second and all next iterations
                {
                    if (evPair.ADCEvent.TransitionEffect == Transition.Mix ||
                        evPair.ADCEvent.TransitionEffect == Transition.MixedAV ||
                        evPair.ADCEvent.TransitionEffect == Transition.Wipe)
                    {
                        TimeCode subSeed     = TimeCode.Empty;
                        byte     frameCount  = 30;
                        int      effectSpeed = 60;
                        if (evPairOnAir.FrameRate == FrameRateEnum.PAL)
                        {
                            frameCount = 25;
                        }

                        switch (evPair.ADCEvent.TransitionEffectRate)
                        {
                        case SwitchRate.Slow:
                            effectSpeed = 60;
                            break;

                        case SwitchRate.Medium:
                            effectSpeed = 30;
                            break;

                        case SwitchRate.Fast:
                            effectSpeed = 15;
                            break;
                        }

                        subSeed.InitTime(0, 0, TimeCode.ToBCD((byte)(effectSpeed / frameCount)), TimeCode.ToBCD((byte)(effectSpeed % frameCount)));
                        holdtime -= subSeed;
                    }

                    if (evPairOnAir != TimeCode.Default)
                    {
                        evPair.ADCEvent.OnAirTime = TimeCode.Int32ToBCD(holdtime.ToInt32());
                    }

                    if (evPairDuration != TimeCode.Default)
                    {
                        holdtime += evPairDuration;
                    }
                }
            }
            else
            {
                result = false;
            }

            return(result);
        }