Пример #1
0
 /// <summary>
 /// Compute the # of content segments for this airing.
 /// Every group of playlist items of type 'segment' between every item of
 /// type 'trigger' constitutes a content segment.
 ///
 /// If there are no item of type 'trigger' in the playlist then whole group
 /// of 'segment' items constitute a content segment
 /// </summary>
 /// <param name="ar">The ar.</param>
 /// <returns></returns>
 int ContentSegmentsCount(BLAiringModel.Airing ar)
 {
     return(ar.PlayList.Select((e, i) => new { Element = e, Index = i })
            .Where(e => e.Element.ItemType == "Segment")
            .GroupBy(e => ar.PlayList.ToList().IndexOf(ar.PlayList.Where(c => c.ItemType == "Trigger" && c.Position > e.Element.Position).FirstOrDefault(), e.Index))
            .Count());
 }
Пример #2
0
        public IList <ValidationResult> Validate(BLModel.Airing airing, string remoteQueueName)
        {
            var results = new List <ValidationResult>();

            foreach (var step in _validatorSteps)
            {
                results.Add(step.Validate(airing, remoteQueueName));
            }

            return(results);
        }
Пример #3
0
        private string FormatHd(Airing airing, string value)
        {
            if (!Regex.IsMatch(value, HdPattern))
            {
                return(value);
            }

            return(airing == null
                ? Regex.Replace(value, HdPattern, "")
                : ReplaceHdTokens(value));
        }
Пример #4
0
        public ValidationResult Validate(BLModel.Airing airing, string remoteQueueName)
        {
            if (string.IsNullOrEmpty(airing.MediaId))
            {
                return(new ValidationResult(false, 11, "MediaId is missing when it was required.", true));
            }

            return(queueService.AnyMessageDeliveredForMediaId(airing.MediaId, remoteQueueName) ?
                   new ValidationResult(false, 11, "MediaId already delivered to the queue.", true)
                : new ValidationResult(true));
        }
Пример #5
0
        /// <summary>
        /// Validates the specified airing.
        /// </summary>
        /// <param name="airing">The airing.</param>
        /// <returns></returns>
        ValidationResult IAiringValidatorStep.Validate(BLModel.Airing airing, string remoteQueueName = "")
        {
            // Verify that version exist
            if (!airing.Versions.Any())
            {
                return(new ValidationResult(false, 11, "Version is missing when it was required.", true));
            }

            // Return true if all validation passes
            return(new ValidationResult(true));
        }
Пример #6
0
        private void ValidateRequest(BLAiringModel.Airing airing, IEnumerable <string> brands)
        {
            if (!brands.Contains(airing.Network))
            {
                throw new SecurityAccessDeniedException(string.Format("Request denied for {0} brand.", airing.Network));
            }

            if (!airing.Flights.Any())
            {
                throw new SecurityAccessDeniedException(string.Format("Request denied for {0} airing.", airing.AssetId));
            }
        }
Пример #7
0
        public QueueAiring Package(BLAiring.Airing airing, Action action, List <BLAiring.ChangeNotification> notifications)
        {
            var queueAiring = new QueueAiring();

            queueAiring.AiringId    = airing.AssetId;
            queueAiring.DeliveredOn = DateTime.UtcNow;
            queueAiring.Action      = action.ToString();

            if (notifications.Any())
            {
                ConsolidateAiringChangeNotification(queueAiring, notifications);
            }

            return(queueAiring);
        }
Пример #8
0
        private string FormatAiringStoryLineShort(Airing airing)
        {
            if (!string.IsNullOrEmpty(Airing.Title.StoryLine.Short))
            {
                return(Airing.Title.StoryLine.Short);
            }

            var primaryTitleId = airing.Title.TitleIds.FirstOrDefault(t => t.Primary);

            if (primaryTitleId != null && Airing.FlowTitleData.Any())
            {
                var primaryTitle = Airing.FlowTitleData.First(t => t.TitleId == int.Parse(primaryTitleId.Value));
                var storyline    = (primaryTitle != null) ? primaryTitle.Storylines.FirstOrDefault(s => s.Type == "Short (245 Characters)"):null;
                return((storyline == null) ? string.Empty : storyline.Description);
            }
            return(string.Empty);
        }
Пример #9
0
        public byte?Calculate(BLQueue.Queue queue, BLAiring.Airing airing)
        {
            if (!queue.IsPriorityQueue)
            {
                return(null);
            }

            if (airing.Flights.All(e => e.End < DateTime.UtcNow))
            {
                return(0);
            }

            var firstAiringStartDate = airing.Flights.Select(e => e.Start).OrderBy(date => date).First();

            var differenceBetweenDates = (int)(firstAiringStartDate.Date - DateTime.UtcNow.Date).TotalDays;

            //Flight window already started
            if (differenceBetweenDates < 0)
            {
                return(7);
            }
            if (differenceBetweenDates == 0) //Flight windows started today
            {
                return(6);
            }
            if (differenceBetweenDates == 1) //Flight Starts tomorrow
            {
                return(5);
            }
            if (differenceBetweenDates <= 3) //Flight starts with in next two days
            {
                return(4);
            }
            if (differenceBetweenDates <= 7) //Flight starts with in a week
            {
                return(3);
            }

            if (differenceBetweenDates <= 14)
            {
                return(2);
            }

            return(1);
        }
Пример #10
0
        private void FilterDestinations(BLAiringModel.Airing airing, List <string> permissableDestinations)
        {
            foreach (var flight in airing.Flights)
            {
                var destinations = flight.Destinations.ToList();

                destinations.RemoveAll(item => !permissableDestinations.Contains(item.Name));

                flight.Destinations = destinations;
            }

            for (var index = airing.Flights.Count - 1; index >= 0; index--)
            {
                if (!airing.Flights[index].Destinations.Any())
                {
                    airing.Flights.RemoveAt(index);
                }
            }
        }
Пример #11
0
        public void AugmentMediaId(ref BLModel.Airing airing)
        {
            var contentIds = new StringBuilder();

            if (appSettings.EnableMediaIdGenrationByPlayList)
            {
                foreach (var playList in airing.PlayList.Where(t => t.Type != "Trigger"))
                {
                    contentIds.Append(playList.Id);
                }
            }

            if (string.IsNullOrEmpty(contentIds.ToString()))
            {
                foreach (var version in airing.Versions)
                {
                    contentIds.Append(version.ContentId);
                }
            }

            airing.MediaId = IdGenerator.Generate(string.Concat(contentIds.ToString(), airing.Network));
        }
Пример #12
0
        private void SendBIMStatus(IList <ValidationResult> results, BLAiring.Airing airing, BLQueue.Queue queue)
        {
            var bimFoundResult    = results.Where(r => r.Valid && r.StatusEnum == BIMFOUND).FirstOrDefault();
            var bimNotFoundResult = results.Where(r => !r.Valid && r.StatusEnum == BIMNOTFOUND).FirstOrDefault();
            var bimisMatch        = results.Where(r => !r.Valid && r.StatusEnum == BIMMISMATCH).FirstOrDefault();

            if (bimFoundResult != null)
            {
                // LogInformation(string.Format("BIM  Found. {0} - {1}", airing.AssetId, bimFoundResult.Message));
                reportStatusCommand.BimReport(queue, airing.AssetId, true, bimFoundResult.Message, bimFoundResult.StatusEnum);
            }
            if (bimNotFoundResult != null)
            {
                //  LogInformation(string.Format("BIM  Not Found. {0} - {1}", airing.AssetId, bimNotFoundResult.Message));
                reportStatusCommand.BimReport(queue, airing.AssetId, true, bimNotFoundResult.Message, bimNotFoundResult.StatusEnum);
            }

            if (bimisMatch != null)
            {
                //  LogInformation(string.Format("BIM  Mismatch. {0} - {1}", airing.AssetId, bimisMatch.Message));
                reportStatusCommand.BimReport(queue, airing.AssetId, true, bimisMatch.Message, bimisMatch.StatusEnum);
            }
        }
Пример #13
0
        public void VerifyDeporterJobTest()
        {
            //Prepare
            IAiringService         airingService         = fixture.Container.GetInstance <IAiringService>();
            IAiringUnitTestService airingUnitTestService = fixture.Container.GetInstance <IAiringUnitTestService>();
            var     dfStatusService = fixture.Container.GetInstance <IDfStatusService>();
            JObject airingJson      = JObject.Parse(Resources.Resources.ResourceManager.GetString("TBSAiringWithSingleFlight"));
            JObject response        = new JObject();
            var     request         = new RestRequest("/v1/airing/TBSE", Method.POST);

            request.AddParameter("application/json", UpdateAiringDates(airingJson), ParameterType.RequestBody);

            Task.Run(async() =>
            {
                response = await _client.RetrieveRecord(request);
            }).Wait();
            string airingId = response.Value <string>(@"airingId");

            airingUnitTestService.UpdateAiringRelasedDateAndFlightEndDate(airingId, DateTime.UtcNow.AddDays(-3));

            //Act
            airingService.Deport(int.Parse(fixture.Configuration["AiringDeportGraceDays"]));

            //Assert
            BLModel.Airing expiredairingModel = airingService.GetBy(airingId, AiringCollection.ExpiredCollection);

            if (expiredairingModel == null)
            {
                Assert.True(false, "Deporter Airing test Failed : Airing is  not returned from Expired Collection : " + expiredairingModel.AssetId);
            }

            if (dfStatusService.HasMessages(airingId, true))
            {
                Assert.True(false, string.Format("Deporter Airing test Failed : Airing {0} DF messages not moved to Expired Collection.", expiredairingModel.AssetId));
            }
        }
Пример #14
0
 public PropertyFormatter(Airing airing) : base(airing)
 {
 }
Пример #15
0
 public Formatter(Airing airing)
 {
     Airing = airing;
 }
Пример #16
0
 public BLModel.Airing Delete(BLModel.Airing airing)
 {
     return
         (airingDeleteCommandHelper.Delete(airing.ToDataModel <BLModel.Airing, DLModel.Airing>())
          .ToBusinessModel <DLModel.Airing, BLModel.Airing>());
 }
Пример #17
0
 public BLModel.Airing Save(BLModel.Airing airing, bool hasImmediateDelivery, bool updateHistorical)
 {
     return
         (airingSaveCommandHelper.Save(airing.ToDataModel <BLModel.Airing, DLModel.Airing>(), hasImmediateDelivery, updateHistorical)
          .ToBusinessModel <DLModel.Airing, BLModel.Airing>());
 }
Пример #18
0
        public ValidationResult Validate(BLModel.Airing airing, string remoteQueueName = "")
        {
            var contentIds = airing.Versions
                             .Select(v => new BimContent(v.ContentId, "Version", v.Source))
                             .Where(v => !string.IsNullOrEmpty(v.Id))
                             .ToList();

            var promoContentIds = airing.PlayList
                                  .Where(l => l.ItemType != "Promo")
                                  .Where(l => !string.IsNullOrEmpty(l.Id))
                                  .Select(l => new BimContent(l.Id, l.ItemType, Sources.MAPS.ToString()));

            var adContentIds = airing.PlayList
                               .Where(l => l.ItemType != "Commercial")
                               .Where(l => !string.IsNullOrEmpty(l.Id))
                               .Select(l => new BimContent(l.Id, l.ItemType, Sources.MTS.ToString()));

            var otherShortformContentIds = airing.PlayList
                                           .Where(l => l.ItemType != "Segment" && l.ItemType != "Promo" && l.ItemType != "Commercial")
                                           .Where(l => !string.IsNullOrEmpty(l.Id))
                                           .Select(l => new BimContent(l.Id, l.ItemType, Sources.NotSpecified.ToString()));

            contentIds.AddRange(promoContentIds);
            contentIds.AddRange(adContentIds);
            contentIds.AddRange(otherShortformContentIds);

            if (!contentIds.Any())
            {
                return(new ValidationResult(true));
            }

            List <string> invalidIds      = new List <string>();
            List <string> validIds        = new List <string>();
            List <string> invalidOrionIds = new List <string>();

            foreach (var contentId in contentIds)
            {
                if (_validContentIds.Contains(contentId.Id))
                {
                    validIds.Add(contentId.Id);
                    continue;
                }
                if (_invalidContentIds.Contains(contentId.Id))
                {
                    invalidIds.Add(contentId.Id);
                    continue;
                }
                if (_invalidOrionIds.Contains(contentId.Id))
                {
                    invalidOrionIds.Add(contentId.Id);
                    continue;
                }

                var bimContent = _bimQuery.Get(contentId.Id);
                if (string.IsNullOrEmpty(bimContent.ContentId))
                {
                    _invalidContentIds.Add(contentId.Id);
                    invalidIds.Add(contentId.Id);
                }
                else
                {
                    if (contentId.Type == "Version" && contentId.Source == Sources.Orion.ToString())
                    {
                        var orionContent = _orionQuery.Get(contentId.Id);
                        if (string.IsNullOrEmpty(orionContent.ContentId))
                        {
                            return(new ValidationResult(false, 4, string.Format("Content not found in Orion. {0}: {1}", contentId.Type, contentId.Id)));
                        }

                        if (!AreMaterialIdsInBim(orionContent, bimContent))
                        {
                            _invalidOrionIds.Add(contentId.Id);
                            invalidOrionIds.Add(contentId.Id);
                            continue;
                        }
                    }
                    validIds.Add(contentId.Id);
                    _validContentIds.Add(contentId.Id);
                }
            }
            if (invalidIds.Any())
            {
                List <string> formattedlist = FormateList(contentIds, invalidIds);
                return(new ValidationResult(false, 18, string.Format("Queue validation error. Content Not found in BIM.  {0} ", string.Join(",", formattedlist.ToArray()))));
            }

            if (invalidOrionIds.Any())
            {
                List <string> formattedlist = FormateList(contentIds, invalidOrionIds);
                return(new ValidationResult(false, 19, string.Format("Queue validation error. (material id mismatch).  {0}", string.Join(",", formattedlist.ToArray()))));
            }

            return(new ValidationResult(true, 17, string.Format("Content found in BIM")));;
        }
Пример #19
0
 public void Report(BLAiringModel.Airing airing, bool isActiveAiringStatus)
 {
     reportStatusCommandSvc.Report(airing.ToDataModel <BLAiringModel.Airing, DLAiringModel.Airing>(), isActiveAiringStatus);
 }
Пример #20
0
 public DeliverableFormatter(Airing airing) : base(airing)
 {
 }
Пример #21
0
 public bool Validate(BLModel.Airing airing, string queueName)
 {
     return(queueService.AnyMessageDeliveredForAiringId(airing.AssetId, queueName));
 }
Пример #22
0
        private Dictionary <string, object> GeneratePostAiringpropertiesForLogzIO(BLAiringModel.Airing savedAiring, UserIdentity user)
        {
            Dictionary <string, object> airingdetails = new Dictionary <string, object>
            {
                { "airingid", savedAiring.AssetId },
                { "mediaid", savedAiring.MediaId },
                { "brand", savedAiring.Network }
            };


            int    i = 0;
            string flightWindow = null, products = null, destinations = null;

            foreach (var flight in savedAiring.Flights)
            {
                flightWindow = string.Concat(flightWindow, string.Format("flightWindow[{0}] : [startDate : {1} , endDate : {2}] \n", i, flight.Start, flight.End));
                int j = 0;
                foreach (var product in flight.Products)
                {
                    products = string.Concat(products, string.Format("products[{0}] : [IsAuth : {1}] \n", j, product.IsAuth));
                    j++;
                }

                foreach (var destination in flight.Destinations)
                {
                    destinations = string.Concat(destinations, string.Format("[Name : {0}, authenticationRequired : {1}, externalId : {2}] \n",
                                                                             destination.Name, destination.AuthenticationRequired, destination.ExternalId));
                }

                i++;
            }
            string titleIds = null;

            i = 0;
            foreach (var element in savedAiring.Title.TitleIds)
            {
                titleIds = string.Concat(titleIds, string.Format("titleIds[{0}] : [type : {1} , value : {2} , authority : {3}] \n",
                                                                 i, element.Type, element.Value, element.Authority));
                i++;
            }

            i = 0;
            string relatedTitleIds = null;

            foreach (var element in savedAiring.Title.RelatedTitleIds)
            {
                relatedTitleIds = string.Concat(relatedTitleIds, string.Format("RelatedTitleIds[{0}] : [type : {1} , value : {2} , authority : {3}] \n",
                                                                               i, element.Type, element.Value, element.Authority));
                i++;
            }

            airingdetails.Add("titleIds", titleIds);
            airingdetails.Add("relatedTitleIds", relatedTitleIds);
            airingdetails.Add("flightwindow", flightWindow);
            airingdetails.Add("products", products);
            airingdetails.Add("flags", string.Format("hd : {0}, cx : {1}, ProgrammerBrandingReq : {2}, FastForwardAllowed : {3}, ManuallyProcess : {4}",
                                                     savedAiring.Flags.Hd, savedAiring.Flags.Cx, savedAiring.Flags.ProgrammerBrandingReq,
                                                     savedAiring.Flags.FastForwardAllowed, savedAiring.Flags.ManuallyProcess));
            airingdetails.Add("destination", destinations);
            airingdetails.Add("apikey", user.ApiKey.ToString().Substring(user.ApiKey.ToString().Length - 4));

            return(airingdetails);
        }