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