Exemplo n.º 1
0
        /// <include file='doc\AdRotatorDesigner.uex' path='docs/doc[@for="AdRotatorDesigner.GetDesignTimeHtml"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Returns the design-time HTML of the <see cref='System.Web.UI.WebControls.AdRotator'/>
        ///       web control
        ///    </para>
        /// </devdoc>

        public override string GetDesignTimeHtml()
        {
            AdRotator adRotator = (AdRotator)Component;

            StringWriter   sw = new StringWriter();
            HtmlTextWriter tw = new HtmlTextWriter(sw);

            // we want to put some properties on the link, and some on the image, so we
            // create temporary objects for rendinger and distribute the properties.
            HyperLink bannerLink = new HyperLink();

            bannerLink.ID          = adRotator.ID;
            bannerLink.NavigateUrl = "";
            bannerLink.Target      = adRotator.Target;
            bannerLink.AccessKey   = adRotator.AccessKey;
            bannerLink.Enabled     = adRotator.Enabled;
            bannerLink.TabIndex    = adRotator.TabIndex;
            bannerLink.RenderBeginTag(tw);

            Image bannerImage = new Image();

            // apply style copies most style-related properties
            bannerImage.ApplyStyle(adRotator.ControlStyle);
            bannerImage.ImageUrl      = "";
            bannerImage.AlternateText = adRotator.ID;
            bannerImage.ToolTip       = adRotator.ToolTip;
            bannerImage.RenderControl(tw);

            bannerLink.RenderEndTag(tw);

            return(sw.ToString());
        }
        public override string GetDesignTimeHtml()
        {
            AdRotator                viewControl = (AdRotator)base.ViewControl;
            StringWriter             writer      = new StringWriter(CultureInfo.CurrentCulture);
            DesignTimeHtmlTextWriter writer2     = new DesignTimeHtmlTextWriter(writer);
            HyperLink                link        = new HyperLink {
                ID          = viewControl.ID,
                NavigateUrl = "",
                Target      = viewControl.Target,
                AccessKey   = viewControl.AccessKey,
                Enabled     = viewControl.Enabled,
                TabIndex    = viewControl.TabIndex
            };

            link.Style.Value = viewControl.Style.Value;
            link.RenderBeginTag(writer2);
            Image image = new Image();

            image.ApplyStyle(viewControl.ControlStyle);
            image.ImageUrl      = "";
            image.AlternateText = viewControl.ID;
            image.ToolTip       = viewControl.ToolTip;
            image.RenderControl(writer2);
            link.RenderEndTag(writer2);
            return(writer.ToString());
        }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AdRotator rotator = new AdRotator();

        // Set the control's properties.
        rotator.AdvertisementFile = "AdRotatorFiles.xml";

        // Add the control to the Controls collection of a
        // PlaceHolder control.
        PlaceHolder1.Controls.Add(rotator);
    }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create an AdRotator control.
            AdRotator AdRotator1 = new AdRotator();

            // Set the control's properties.
            // AdRotator1.AdvertisementFile = "HeaderImages.xml";

            // Add the control to the Controls collection of a
            // PlaceHolder control.
            PlaceHolder1.Controls.Add(AdRotator1);
        }
Exemplo n.º 5
0
        public ActionResult ClickAd(string redirectGuid)
        {
            var url = AdRotator.GetOriginalUrlByRedirectGuid(redirectGuid);

            if (url != null)
            {
                StoredProcs.AdRedirectUrls_IncrementClickCount(Guid.Parse(redirectGuid), 1).Execute();
                return(Redirect(url));
            }

            Logger.Error("Invalid Ad URL redirect GUID: {0}", redirectGuid);
            return(HttpNotFound());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Builds the ad column and add the html in to the HTML Buffer
        /// </summary>
        protected void BuildAdColum()
        {
            Page pageHolder = new Page();

            outputHTML.Append(BuildOpeningColumHTML());
            AdRotator ad = (AdRotator)LoadControl("AdRotator.ascx");

            ad.MaxWidth  = 295;
            ad.MaxHeight = 100;
            pageHolder.Controls.Add(ad);
            StringWriter result = new StringWriter();

            HttpContext.Current.Server.Execute(pageHolder, result, false);
            outputHTML.Append(result.ToString());
            outputHTML.Append(BuildClosingColumHTML());
        }
Exemplo n.º 7
0
        public ActionResult ViewAd(string id)
        {
            var ad = AdRotator.GetAdById(id);

            if (ad != null)
            {
                bool addImpression = this.Request.QueryString["noimpression"] == null;
                if (addImpression)
                {
                    StoredProcs.AdImpressions_IncrementCount(ad.FileName, DateTime.Now.Date, 1).Execute();
                }
                return(File(ad.DiskPath, MimeMapping.GetMimeMapping(ad.DiskPath)));
            }

            Logger.Error("Invalid Ad attempted to be loaded from: /fblast/{0}", id);
            return(HttpNotFound());
        }
Exemplo n.º 8
0
    void Awake()
    {
        if (current == null)
        {
            current = this;

            gameObject.name = "TwimlerAdRotator";

            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            DontDestroyOnLoad(this);

            AmazonAds.current.Init();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 9
0
            public override string GetDesignTimeHtml()
            {
                // Component is the instance of the component or control that
                // this designer object is associated with. This property is
                // inherited from System.ComponentModel.ComponentDesigner.
                string tmpS = string.Empty;

                try
                {
                    AdRotator DesignAdRotator = (AdRotator)Component;

                    // Capture the default output of the AdRotator control
                    StringWriter   writer = new StringWriter();
                    HtmlTextWriter buffer = new HtmlTextWriter(writer);
                    DesignAdRotator.RenderControl(buffer);
                    tmpS = writer.ToString();
                }
                catch (Exception ex)
                {
                    tmpS = this.GetErrorDesignTimeHtml(ex);
                }
                return(tmpS);
            }
Exemplo n.º 10
0
        // ReSharper restore FunctionNeverReturns

        private void AdHelper()
        {
            var tmp = AdRotator.RotateAd();

            picBanner.ImageLocation = @tmp[0];
            picBanner.Tag           = tmp[1];
            //Lets cheat and use this thread for our heartbeat too :-)
            var serverName = GameInfo.ServerName();
            var mapName    = GameInfo.MapName();

            if (string.IsNullOrEmpty(serverName) || string.IsNullOrEmpty(mapName))
            {
                return;
            }

            Commands.QueryEx(string.Format(Commands.PingServer, Lobby.Player.GetUnixDate(),
                                           GameInfo.ServerName(), GameInfo.MapName(), Lobby.Player.GetMyIp(),
                                           Hardware.GetPcId()));
            PokeUpdate();
            var tmp3 = Commands.QueryGet("SELECT mto FROM messages WHERE mto='" + _dets.Name + "' AND mnew ='1'");

            toolStripStatusLabel2.Text = @"Mail (" + tmp3.Count + @")";
        }
Exemplo n.º 11
0
 public Ad GetNextAd(Dimensions dimensions)
 {
     return(AdRotator.GetNextAd(dimensions));
 }
Exemplo n.º 12
0
        public ActionResult ViewAd(string id)
        {
            var ad = AdRotator.GetAdById(id);

            return(File(ad.DiskPath, MimeMapping.GetMimeMapping(ad.DiskPath)));
        }
Exemplo n.º 13
0
        internal object GetProviderFrameworkElement(AdRotator.AdProviderConfig.SupportedPlatforms platform, AdProvider adProvider)
        {
            var provider = adProvider.AdProviderConfigValues[platform];
            Type providerType = null;
            object instance;
            try
            {
                if (PlatformAdProviderComponents.ContainsKey(adProvider.AdProviderType))
                {
                    providerType = PlatformAdProviderComponents[adProvider.AdProviderType];
                }
                else
                {
                    providerType = reflectionHelper.TryGetType(provider.AssemblyName, provider.ElementName);
                }
            }
            catch (PlatformNotSupportedException)
            {
                AdFailed(adProvider.AdProviderType);
            }
            if (providerType == null)
            {
                return null;
            }
            try
            {
                instance = Activator.CreateInstance(providerType);

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AppId))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AppId], adProvider.AppId.ToString());
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.SecondaryId))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.SecondaryId], adProvider.SecondaryId.ToString());
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdType))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdType], "IaAdType_Banner");
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.IsTest))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.IsTest], adProvider.IsTest.ToString());
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdWidth))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdWidth], AdWidth.ToString());
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdHeight))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdHeight], AdHeight.ToString());
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.Size))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.Size], AdWidth.ToString() + "x" + AdHeight.ToString());
                }

#if DEBUG
                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.ShowErrors))
                {
                    reflectionHelper.TrySetProperty(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.ShowErrors], "true");
                }
#endif
                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdSuccessEvent))
                {
                    WireUpDelegateEvent(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdSuccessEvent], string.Format("Ads served for: {0}", _settings.CurrentAdType.ToString()));
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdFailedEvent))
                {
                    WireUpDelegateEvent(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdFailedEvent], string.Format("Ad failed request for: {0}", _settings.CurrentAdType.ToString()));
                }

                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.AdClickedEvent))
                {
                    WireUpDelegateEvent(instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.AdClickedEvent], string.Format("Ad clicked for: {0}", _settings.CurrentAdType.ToString()));
                } 
                
                if (provider.ConfigurationOptions.ContainsKey(AdProviderConfig.AdProviderConfigOptions.StartMethod))
                {
                    reflectionHelper.TryInvokeMethod(providerType, instance, provider.ConfigurationOptions[AdProviderConfig.AdProviderConfigOptions.StartMethod]);
                }

            }
            catch (PlatformNotSupportedException)
            {
                OnLog(string.Format("Configured provider {0} not found in this installation", adProvider.AdProviderType.ToString()));
                AdFailed(adProvider.AdProviderType);
                return null;
            }
            catch (NotImplementedException)
            {
                OnLog(string.Format("Configured provider {0} is not fully implemented yet", adProvider.AdProviderType.ToString()));
                AdFailed(adProvider.AdProviderType);
                return null;
            }
            catch (Exception e)
            {
                OnLog(string.Format("General exception [{0}] occured, continuing", e.InnerException.ToString()));
                AdFailed(adProvider.AdProviderType);
                return null;
            }

            OnLog(string.Format("Ad created for provider {0}", adProvider.AdProviderType.ToString()));

            return instance;
        }