예제 #1
0
        public void UpdateVisibilityMetric()
        {
            long newTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - startTime;

            if ((newTime - lastTime) > timeResolution)
            {
                lastTime = newTime;
                ao.Update();
                AppParams param = AdConfigurer.GetAppParams();
                InstanceParamsUpdateLog dtoObj = new InstanceParamsUpdateLog(param.userId, this.adUnitId, this.adServingId, this.instanceId, newTime, ao.CameraLA_X(), ao.CameraLA_Y(), ao.CameraLA_Z(), ao.CameraX(), ao.CameraY(), ao.CameraZ(), ao.AdObjectX(), ao.AdObjectY(), ao.AdObjectZ());
                AnalyticsManager.Push(dtoObj, AnalyticsManager.TYPE.VISIBILITY_METRIC, AnalyticsManager.PRIORITY.LOW);
            }
        }
        /*************************************************************************
         *
         * Instnance handling methods
         *
         ************************************************************************/
        public ImageTextureAdInstance CreateInstance(String instanceId, IAdObject adObject)
        {
            if (ads.Count == 0)
            {
                return(null);
            }
            ImageTextureAdInstance instance = new ImageTextureAdInstance(instanceId, ads[adIndex], adObject);

            instances.Add(instance.GetInstanceId(), instance);
            adIndex = (adIndex + 1) % ads.Count;
            AppParams param = AdConfigurer.GetAppParams();

            AnalyticsManager.Push(new AdServedLog(param.userId, this.adUnitId, instance.GetAdServingId(), instanceId), AnalyticsManager.TYPE.AD_DISPLAYED, AnalyticsManager.PRIORITY.MEDIUM);
            return(instance);
        }
        public void LoadAds(int nDistinctAds)
        {
            Logger.Log(this, "LoadAd: Entered");
            this.nDistinctAds = nDistinctAds;

            AdRequest adRequest = new AdRequest(AdType.IMAGE_TEXTURE, this.adUnitId, this.nDistinctAds, AdConfigurer.GetAppParams());

            WebClient webClient = new WebClient();

            webClient.Headers.Add("Content-Type", "application/json");
            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(OnAdResponseReceived);
            try
            {
                webClient.UploadStringAsync(new Uri(AdConfigurer.GetServerConfigedParams().imageTextureAdUnitUrl), "POST", JsonConvert.SerializeObject(adRequest));
            }
            catch (System.Net.WebException e)
            {
                Console.WriteLine("Exception caught: {0}", e);
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("Exception caught: {0}", e);
            }
        }