コード例 #1
0
        private void ProcessLinearityParameters(VAST vast, IDictionary <string, string> parameters)
        {
            if (IsWrapper(vast))
            {
                return;
            }

            var creatives = ((VASTADInLine)vast.Ad[0].Item).Creatives;

            if (creatives == null || creatives.Length == 0)
            {
                return;
            }

            if (creatives.Any(x => x.Item is VASTADInLineCreativeLinear))
            {
                parameters["LINEARITY"] = "Linear";
                return;
            }

            if (creatives.Any(x => x.Item is VASTADInLineCreativeNonLinearAds))
            {
                parameters["LINEARITY"] = "NonLinear";
                return;
            }

            throw new BrandscreenException("Vast tag must contain linearity info.");
        }
コード例 #2
0
        private void ProcessCompanionParamers(VAST vast, IDictionary <string, string> parameters)
        {
            var companions = new List <Companion_type>();

            if (IsWrapper(vast))
            {
                var creatives = ((VASTADWrapper)vast.Ad[0].Item).Creatives;
                foreach (var companionTypes in creatives.Select(vastadWrapperCreative => vastadWrapperCreative.Item)
                         .OfType <VASTADWrapperCreativeCompanionAds>()
                         .Where(companionAds => companionAds.Companion != null)
                         .Select(companionAds => companionAds.Companion))
                {
                    companions.AddRange(companionTypes);
                }
            }
            else
            {
                var creatives = ((VASTADInLine)vast.Ad[0].Item).Creatives;
                foreach (var companionTypes in creatives.Select(vastadInLineCreative => vastadInLineCreative.Item)
                         .OfType <VASTADInLineCreativeCompanionAds>()
                         .Where(companionAds => companionAds.Companion != null)
                         .Select(companionAds => companionAds.Companion))
                {
                    companions.AddRange(companionTypes);
                }
            }

            if (companions.Count == 0)
            {
                return;
            }

            foreach (var companionType in companions)
            {
                if (companionType.ItemElementName != ItemChoiceType.StaticResource)
                {
                    continue;
                }

                var staticResource = (Companion_typeStaticResource)companionType.Item;
                if (!staticResource.creativeType.Contains("flash") && !staticResource.creativeType.Contains("image"))
                {
                    continue;
                }

                var type   = staticResource.creativeType.Replace("application/x-shockwave-flash", "FLASH").Replace("image/jpeg", "IMAGE").Replace("image/gif", "IMAGE");
                var prefix = $"COMPANION_{companionType.width}x{companionType.height}_{type}";
                parameters[$"{prefix}_URL"]             = companionType.CompanionClickThrough;
                parameters[$"{prefix}_APIFRAMEWORK"]    = companionType.apiFramework ?? string.Empty;
                parameters[$"{prefix}_EXPANDED_WIDTH"]  = companionType.expandedWidth ?? string.Empty;
                parameters[$"{prefix}_EXPANDED_HEIGHT"] = companionType.expandedHeight ?? string.Empty;
                parameters[$"{prefix}_CLICK_URL"]       = staticResource.Value;
                parameters[$"{prefix}_MIME_TYPE"]       = staticResource.creativeType;
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //Generar Elementos
                VASTADInLineCreativeLinearMediaFile[] media_files = GenerarMediaFileArray();
                VideoClicks_type video_clicks;
                if (chkIncluirClickthrough.Checked == true || chkIncluirClickTracker.Checked == true)
                {
                    video_clicks = GenerarVideoClicks_Type();
                }
                else
                {
                    video_clicks = null;
                }
                var linear_ad_item_creative_linear = GenerarCreativeLinear(video_clicks, media_files);
                var linear_ad_item_creative_array  = GenerarAdInlineCreativeArray(linear_ad_item_creative_linear);
                var impression_tracker_array       = GenerarImpressionTrackerArray();
                var inline_ad_item = GenerarInlineAd(linear_ad_item_creative_array, impression_tracker_array);
                var vast_ad_array  = Generar_VAST_AD_array(inline_ad_item);

                var vast_tag = new VAST
                {
                    Ad      = vast_ad_array,
                    version = "2.0"
                };

                //Write
                string time_stamp = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
                                    DateTime.Now.Day.ToString() + "-" + DateTime.Now.Hour.ToString() +
                                    DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                var    serializer = new XmlSerializer(typeof(VAST));
                string path       = @"C:\VASTARD\";
                if (!Directory.Exists(path))
                {
                    //Crear Directorio
                    Directory.CreateDirectory(path);
                }

                using (var stream = new StreamWriter(path + time_stamp + ".xml"))
                    serializer.Serialize(stream, vast_tag);
                MessageBox.Show("Listo!");
            }
            catch (Exception exc)
            {
                //Mostrar mensaje
                MessageBox.Show(exc.Message);
            }
        }
コード例 #4
0
        private async Task <Tuple <string, VAST> > Unwrap(string url, VAST vast)
        {
            var wrapperUrl = ((VASTADWrapper)vast.Ad[0].Item).VASTAdTagURI;
            var xml        = await _vastService.Download(wrapperUrl).ConfigureAwait(false);

            var vastValidationResult = await _vastService.Validate(xml).ConfigureAwait(false);

            if (!vastValidationResult.Success)
            {
                Logger.Warn($"{url} contains invalid wrapped vast content at {wrapperUrl} with error {vastValidationResult.Error} with content {xml}.");
                throw new BrandscreenException($"Wrapped vast content is invalid at {wrapperUrl} with error {vastValidationResult.Error}.");
            }
            vast = await Deserialize(xml).ConfigureAwait(false);

            return(new Tuple <string, VAST>(wrapperUrl, vast));
        }
コード例 #5
0
ファイル: OutboundService.cs プロジェクト: tcns/impulse
        VAST GetVastFromAdState(Models.AdModels.AdState AdState)
        {
            VAST   v  = new VAST();
            VASTAD ad = new VASTAD();

            ad.id = AdState.Id.ToString();
            VASTADInLine inline = new VASTADInLine();

            v.version          = "1.0";
            inline.AdTitle     = AdState.Name;
            inline.Description = "Impulse ad";
            inline.Creatives   = new VASTADInLineCreative[AdState.UserElements.Count];
            List <VASTADInLineCreative> creativeList = new List <VASTADInLineCreative>();

            foreach (var elem in AdState.UserElements)
            {
                VASTADInLineCreative creative = new VASTADInLineCreative();
                creative.sequence = "1";
                creative.AdID     = AdState.AdId.ToString();
                NonLinear_type nonlinearAd            = new NonLinear_type();
                NonLinear_typeStaticResource resource = new NonLinear_typeStaticResource();
                nonlinearAd.height       = elem.Height;
                nonlinearAd.width        = elem.Width;
                nonlinearAd.apiFramework = "mpls-framework";
                resource.creativeType    = "image/png";
                resource.Value           = elem.Text;
                //resource.Value = "<![CDATA[<div style='"+elem.HtmlStyle+"'>" + elem.Text + "</div>]]>";
                creativeList.Add(creative);
            }
            inline.Creatives = creativeList.ToArray();
            Impression_type impression = new Impression_type();

            impression.id    = AdState.VideoUnitId.ToString();
            impression.Value = AdState.VideoUnit.FullPath;
            //impression.Value = "<![CDATA[" + AdState.VideoUnit.FullPath + "]]>";
            inline.Impression    = new Impression_type[1];
            inline.Impression[0] = impression;
            ad.Item = inline;
            v.Ad    = new VASTAD[1];
            v.Ad[0] = ad;
            return(v);
        }
コード例 #6
0
        private void ProcessDurationParamers(VAST vast, IDictionary <string, string> parameters)
        {
            if (IsWrapper(vast))
            {
                return;
            }

            var creatives = ((VASTADInLine)vast.Ad[0].Item).Creatives;

            if (creatives == null || creatives.Length == 0)
            {
                return;
            }

            foreach (var creativeLinear in creatives.Select(x => x.Item).OfType <VASTADInLineCreativeLinear>())
            {
                var duration = creativeLinear.Duration - new DateTime();
                parameters["DURATION"] = duration.TotalSeconds.ToString("00");
            }
        }
コード例 #7
0
        private void ProcessMediaFileParamers(VAST vast, IDictionary <string, string> parameters)
        {
            if (IsWrapper(vast))
            {
                return;
            }

            var creatives = ((VASTADInLine)vast.Ad[0].Item).Creatives;

            if (creatives == null || creatives.Length == 0)
            {
                return;
            }

            var i = 1;

            foreach (var mediaFile in creatives.Select(x => x.Item).OfType <VASTADInLineCreativeLinear>().SelectMany(x => x.MediaFiles))
            {
                var type     = mediaFile.type.ToLower();
                var width    = Convert.ToInt32(mediaFile.width);
                var height   = Convert.ToInt32(mediaFile.height);
                var bitrate  = Convert.ToInt32(mediaFile.bitrate);
                var delivery = mediaFile.delivery.ToString();
                var url      = mediaFile.Value.Trim();

                parameters.Add("MEDIA_FILE_DELIVERY_" + i, delivery);
                parameters.Add("MEDIA_FILE_MIME_TYPE_" + i, type);
                parameters.Add("MEDIA_FILE_BITRATE_" + i, bitrate.ToString());
                parameters.Add("MEDIA_FILE_HEIGHT_" + i, height.ToString());
                parameters.Add("MEDIA_FILE_WIDTH_" + i, width.ToString());
                parameters.Add("MEDIA_FILE_URL_" + i, url);
                if (!string.IsNullOrEmpty(mediaFile.apiFramework))
                {
                    parameters.Add("MEDIA_FILE_APIFRAMEWORK_" + i, mediaFile.apiFramework);
                }

                i++;
            }
        }
コード例 #8
0
 private bool IsWrapper(VAST vast)
 {
     return(vast.Ad[0].Item is VASTADWrapper);
 }