Ejemplo n.º 1
0
 public Campaign(
     FileName assetName,
     bool assetFailed,
     DealerManifest.Page page,
     int priority,
     bool required,
     HttpLink link,
     string altText,
     DateTime whenStarts,
     DateTime whenEnds,
     string model,
     string modelYear)
 {
     AssetName   = assetName;
     AssetFailed = assetFailed;
     Page        = page;
     Priority    = priority;
     Required    = required;
     Link        = link;
     AltText     = altText;
     WhenStarts  = whenStarts;
     WhenEnds    = whenEnds;
     Model       = model;
     ModelYear   = modelYear;
 }
Ejemplo n.º 2
0
            bool TryGetEnabledPage(XElement creativeXml, out DealerManifest.Page page)
            {
                var xmlPage = GetPageOrNull(creativeXml);

                var isHome        = _homeEnabled && xmlPage == DealerManifest.Page.Home;
                var isConditional = _conditionalEnabled && xmlPage != null && xmlPage != DealerManifest.Page.Home;

                if (isHome || isConditional)
                {
                    page = xmlPage.Value;

                    return(true);
                }

                page = default;

                return(false);
            }
Ejemplo n.º 3
0
            void BuildCampaign(XElement campaignXml, XElement creativeXml, DealerManifest.Page page)
            {
                var pageWidth  = page == DealerManifest.Page.Home ? _homeWidth : _conditionalWidth;
                var pageHeight = page == DealerManifest.Page.Home ? _homeHeight : _conditionalHeight;

                var assets =
                    from sourceXml in creativeXml.Elements("CAMCreativeSource")
                    from assetXml in sourceXml.Elements("CAMAsset")
                    where (int)assetXml.Attribute("Width") == pageWidth
                    where (int)assetXml.Attribute("Height") == pageHeight
                    let id                                                        = (string)assetXml.Attribute("Id")
                                                   let path                       = FixPercentSigns((string)assetXml.Attribute("Path"))
                                                                         let name = FixPercentSigns((string)assetXml.Attribute("Name"))
                                                                                    let caption = (string)campaignXml.Attribute("name")
                                                                                                  select new DealerManifest.Asset(Id.From(id), FileResource.From(path, name), caption);

                var asset = assets.FirstOrDefault();

                if (asset == null)
                {
                    Log.Warning("Dealer {DealerId} has a campaign missing asset size {Width}x{Height}\n\n{ManifestLink}\n\n{Xml}", _dealer.Id, pageWidth, pageHeight, _dealer.ManifestLink, campaignXml);
                }
                else
                {
                    _assets.Write.Add(asset);

                    _campaigns.Write.Add(new DealerManifest.Campaign(
                                             Id.From((string)campaignXml.Attribute("id")),
                                             asset.Id,
                                             page,
                                             _priority,
                                             (bool)campaignXml.Attribute("required"),
                                             ExpandLink(creativeXml),
                                             TruncateAltText((string)creativeXml.Attribute("ImageAltText")),
                                             (DateTime)campaignXml.Attribute("startDate"),
                                             (DateTime)campaignXml.Attribute("endDate"),
                                             (string)creativeXml.Attribute("Model"),
                                             (string)creativeXml.Attribute("ModelYear")));

                    _priority++;
                }
            }
Ejemplo n.º 4
0
 public static bool IsOnVdp(DealerManifest.Page page) =>
 page == DealerManifest.Page.Vdp || page == DealerManifest.Page.SrpVdp;