Example #1
0
 public void Bind()
 {
     if (id != 0)
     {
         if (Tools.TryParseMethod(id.ToString()) != 0)
         {
             BannerInfo info = bBLL.GetDataById(id);
             ddrBannerCategory.SelectedValue = info.bc_id.ToString();
             ddrBannerLocation.SelectedValue = info.bl_id.ToString();
             ddrBannerCustomer.SelectedValue = info.bcs_id.ToString();
             txtName.Text            = info.b_title;
             txtWebUrl.Text          = info.b_url;
             hfImageIndex.Value      = info.b_imagename;
             txtPrice.Text           = info.b_price.ToString();
             txtProb.Text            = info.b_prob.ToString();
             ddlTarget.SelectedValue = info.b_target;
             txtStartDate.Text       = info.b_startDate.ToString("yyyy/MM/dd");
             txtEndDate.Text         = info.b_endDate.ToString("yyyy/MM/dd");
             txtCreatedate.Text      = info.b_ts.ToString("yyyy/MM/dd");
             txtEditDate.Text        = info.b_editDate.ToString("yyyy/MM/dd");
             rpImage.DataSource      = bpBLL.GetAllImgWithFriendLink(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
             rpImage.DataBind();
         }
     }
 }
Example #2
0
    public void EditorUpdateFetchInfo()
    {
        UnityWebRequestAsyncOperation www = (UnityWebRequestAsyncOperation)coroutine.Current;

        if (!coroutine.MoveNext())
        {
            if (!www.isDone)
            {
                coroutine.MoveNext();
            }
            else
            {
#if UNITY_2020_1_OR_NEWER
                if (m_webRequest.result == UnityWebRequest.Result.Success)
#else
                if (!m_webRequest.isNetworkError && !m_webRequest.isHttpError)
#endif
                {
                    m_info = BannerInfo.CreateFromJSON(m_webRequest.downloadHandler.text);
                    m_materialEditor.Repaint();

                    EditorApplication.update += EditorUpdateFetchImage;
                    coroutine = StartImageRequest(m_info.imageURL);
                }
                EditorApplication.update -= EditorUpdateFetchInfo;
            }
        }
    }
Example #3
0
    protected void InsertData()
    {
        BannerInfo info = new BannerInfo();

        info.bc_id       = Tools.TryParseMethod(ddrBannerCategory.SelectedValue);
        info.bcs_id      = Tools.TryParseMethod(ddrBannerCustomer.SelectedValue);
        info.bl_id       = Tools.TryParseMethod(ddrBannerLocation.SelectedValue);
        info.b_title     = txtName.Text;
        info.b_url       = txtWebUrl.Text;
        info.b_imagename = hfNewsImage.Value;
        info.b_price     = Tools.TryParseMethod(txtPrice.Text);
        info.b_prob      = Tools.TryParseMethod(txtProb.Text);
        info.b_target    = ddlTarget.SelectedValue;
        info.b_hits      = 0;
        info.b_ts        = DateTime.Now;
        info.b_editDate  = DateTime.Now;
        info.b_startDate = DateTime.Parse(txtStartDate.Text);
        info.b_endDate   = DateTime.Parse(txtEndDate.Text);
        if (bBLL.Insert(info) > 0)
        {
            //加入BannerPic資料表
            BannerInfo bpinfos = bBLL.GetLastBanner();
            InsertBannerImage(bpinfos.b_id);
            Response.Redirect("List.aspx?header=" + Getmessage("30009"));
        }
    }
Example #4
0
    protected void Bind()
    {
        BannerInfo                info    = bBLL.GetDataById(id);
        BannerLocationInfo        blinfo  = blBLL.GetDataById(info.bl_id);
        List <BannerLocationInfo> blinfos = blBLL.GetAllUpSortData(blinfo.bl_father_id);

        blinfo.bl_title = " → " + blinfo.bl_title;
        blinfos.Add(blinfo);
        lbCategory.Text = bcBLL.GetDataById(info.bc_id).bc_title;
        foreach (BannerLocationInfo Fblinfo in blinfos)
        {
            lbLocation.Text += Fblinfo.bl_title;
        }
        lbCustomer.Text = bcsBLL.GetDataById(info.bcs_id).bcs_company_name;
        lbTitle.Text    = info.b_title;
        lbWebUrl.Text   = info.b_url;
        lbPrice.Text    = info.b_price.ToString();
        lbProb.Text     = info.b_prob.ToString();
        if (info.b_target == "_blank")
        {
            lbTarget.Text = "開新頁顯示";
        }
        else
        {
            lbTarget.Text = "本頁顯示";
        }
        lbHits.Text        = info.b_hits.ToString();
        lbCreateDate.Text  = info.b_ts.ToString("yyyy/MM/dd");
        lbEditDate.Text    = info.b_editDate.ToString("yyyy/MM/dd");
        lbStartDate.Text   = info.b_startDate.ToString("yyyy/MM/dd");
        lbEndDate.Text     = info.b_endDate.ToString("yyyy/MM/dd");
        rpImage.DataSource = bpBLL.GetDataByBid(id);
        rpImage.DataBind();
    }
Example #5
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                if ((Request.QueryString["vendorid"] != null) && (Request.QueryString["bannerid"] != null))
                {
                    int intVendorId = int.Parse(Request.QueryString["vendorid"]);
                    int intBannerId = int.Parse(Request.QueryString["bannerid"]);

                    string strURL = "~/" + Globals.glbDefaultPage;

                    BannerController objBanners = new BannerController();
                    BannerInfo       objBanner  = objBanners.GetBanner(intBannerId, intVendorId, PortalSettings.PortalId);
                    if (objBanner == null)
                    {
                        //Try a Host Banner
                        objBanner = objBanners.GetBanner(intBannerId, intVendorId, Null.NullInteger);
                    }
                    if (objBanner != null)
                    {
                        if (!Null.IsNull(objBanner.URL))
                        {
                            strURL = Globals.LinkClick(objBanner.URL, -1, -1, false);
                        }
                        else
                        {
                            VendorController objVendors = new VendorController();
                            VendorInfo       objVendor  = objVendors.GetVendor(objBanner.VendorId, PortalSettings.PortalId);
                            if (objVendor == null)
                            {
                                //Try a Host Vendor
                                objVendor = objVendors.GetVendor(objBanner.VendorId, Null.NullInteger);
                            }
                            if (objVendor != null)
                            {
                                if (!String.IsNullOrEmpty(objVendor.Website))
                                {
                                    strURL = Globals.AddHTTP(objVendor.Website);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (Request.UrlReferrer != null)
                        {
                            strURL = Request.UrlReferrer.ToString();
                        }
                    }

                    objBanners.UpdateBannerClickThrough(intBannerId, intVendorId);

                    Response.Redirect(strURL, true);
                }
            }
            catch (Exception exc)  //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
Example #6
0
        public ActionResult Edit(BannerModel model, int id = -1)
        {
            BannerInfo bannerInfo = AdminBanners.AdminGetBannerById(id);

            if (bannerInfo == null)
            {
                return(PromptView("Banner不存在"));
            }

            if (ModelState.IsValid)
            {
                //bannerInfo.Type = model.BannerType;
                bannerInfo.StartTime    = model.StartTime;
                bannerInfo.EndTime      = model.EndTime;
                bannerInfo.IsShow       = model.IsShow;
                bannerInfo.Title        = model.BannerTitle == null ? "" : model.BannerTitle;
                bannerInfo.Img          = model.Img;
                bannerInfo.Url          = model.Url;
                bannerInfo.DisplayOrder = model.DisplayOrder;

                AdminBanners.UpdateBanner(bannerInfo);
                AddMallAdminLog("修改banner", "修改banner,bannerID为:" + id);
                return(PromptView("banner修改成功"));
            }

            Load();
            return(View(model));
        }
Example #7
0
        void AddNavigation(BannerInfo model)
        {
            model.Position = 0;
            //long max = Context.BannerInfo.Where(item => item.ShopId == model.ShopId).Count();
            long max = DbFactory.Default.Get <BannerInfo>().Where(item => item.ShopId == model.ShopId).Count();

            if (max > 0)
            {
                //max = Context.BannerInfo.Where(item => item.ShopId == model.ShopId).Max(item => item.DisplaySequence);
                max = DbFactory.Default.Get <BannerInfo>().Where(item => item.ShopId == model.ShopId).Max <long>(item => item.DisplaySequence);
            }

            model.DisplaySequence = max + 1;
            if (string.IsNullOrWhiteSpace(model.Name))
            {
                throw new HimallException("请输入导航的名称");
            }
            if (System.Text.Encoding.Default.GetByteCount(model.Name) > 20)
            {
                throw new HimallException("导航名称只能为20字符(中文10字符)");
            }
            //Context.BannerInfo.Add(model);
            //Context.SaveChanges();
            DbFactory.Default.Add(model);
        }
Example #8
0
        protected void btnAddBanner_Click(object sender, System.EventArgs e)
        {
            TplCfgInfo info = new BannerInfo
            {
                IsDisable    = false,
                ImageUrl     = this.fmSrc.Value,
                ShortDesc    = this.txtBannerDesc.Text,
                LocationType = (LocationType)System.Enum.Parse(typeof(LocationType), this.ddlType.SelectedValue),
                Url          = this.locationUrl.Value
            };

            //非空判断
            if (string.IsNullOrEmpty(info.ImageUrl) || string.IsNullOrEmpty(info.ShortDesc) || string.IsNullOrEmpty(info.Url))
            {
                Response.Write("<script> alert('请填好所有信息!'); </script>");
                return;
            }
            if (VShopHelper.SaveImgCfg(info))
            {
                this.CloseWindow();
            }
            else
            {
                this.ShowMsg("添加错误!", false);
            }
        }
Example #9
0
 protected void btnAddBanner_Click(object sender, EventArgs e)
 {
     if (VShopHelper.GetCountBanner() < 4)
     {
         TplCfgInfo info = new BannerInfo {
             IsDisable    = false,
             ImageUrl     = this.fmSrc.Value,
             ShortDesc    = this.txtBannerDesc.Text,
             LocationType = (LocationType)Enum.Parse(typeof(LocationType), this.ddlType.SelectedValue),
             Url          = this.locationUrl.Value
         };
         if (VShopHelper.SaveTplCfg(info))
         {
             this.CloseWindow();
         }
         else
         {
             this.ShowMsg("添加错误!", false);
         }
     }
     else
     {
         this.ShowMsg("最多只能添加4条记录!", false);
     }
 }
Example #10
0
        public ActionResult AddBanner(BannerModel model)
        {
            if (Banners.GetBannerPositionById(model.BanPosId) == null)
            {
                ModelState.AddModelError("BanPosId", "Banner位置不存在");
            }

            if (ModelState.IsValid)
            {
                BannerInfo bannerInfo = new BannerInfo()
                {
                    BanPosId     = model.BanPosId,
                    StartTime    = model.StartTime,
                    EndTime      = model.EndTime,
                    IsShow       = model.IsShow,
                    Title        = model.BannerTitle == null ? "" : model.BannerTitle,
                    Img          = model.Img,
                    Url          = model.Url,
                    DisplayOrder = model.DisplayOrder
                };

                Banners.CreateBanner(bannerInfo);
                AddAdminOperateLog("添加banner", "添加banner,banner为:" + model.BannerTitle);
                return(PromptView("banner添加成功"));
            }
            Load();
            return(View(model));
        }
Example #11
0
        public static string BannerLink(BannerInfo banner)
        {
            var url =
                "http://direct.yandex.ru/registered/main.pl?cmd=editBanner&bid={0}&cid={1}"
                .FormatWith(banner.BannerID, banner.CampaignID);

            return(H.Anchor(url, banner.Title).ToString());
        }
Example #12
0
 public void UpdateSellerNavigation(BannerInfo model)
 {
     if (model.ShopId == 0)
     {
         throw new HimallException("供应商id必须大于0");
     }
     UpdateNavigation(model);
 }
Example #13
0
        public void UpdateBannerInfo(BannerInfo entity)
        {
            DataCommand dc = DataCommandManager.GetDataCommand("Banner_UpdateBannerInfo");

            dc.SetParameterValue(entity);

            dc.ExecuteNonQuery();
        }
Example #14
0
 private static string GetNewHref(BannerInfo banner, string href, bool isAdditionalLink = false)
 {
     if (href.IsEmpty())
     {
         return(href);
     }
     return(Remove(href, QueryStringText) + GetQueryString(banner, isAdditionalLink));
 }
 public long Add(BannerInfo model)
 {
     model.Id = IdHelper.GetNewId();
     if (AutofacConfig.Resolve <BannerInfoRepository>().Add(model) > 0)
     {
         return(model.Id);
     }
     return(0);
 }
Example #16
0
        public BannerInfo GetLastBanner()
        {
            BannerInfo  info   = new BannerInfo();
            IDataReader reader = db.GetDataByDesc().CreateDataReader();

            reader.Read();
            info = BannerInfo.Populate(reader);
            return(info);
        }
Example #17
0
        public void CreateBannerInfo(BannerInfo entity)
        {
            DataCommand dc = DataCommandManager.GetDataCommand("Banner_InsertBannerInfo");

            dc.SetParameterValue(entity);

            dc.ExecuteNonQuery();
            entity.SysNo = Convert.ToInt32(dc.GetParameterValue("@SysNo"));
        }
Example #18
0
    //Get one Banner info from the supplied bannerId
    public BannerInfo ViewPhoto1(int BannerID)
    {
        NZEduEntities data = new NZEduEntities();

        BannerInfo bt = new BannerInfo();

        bt = data.BannerInfoes.Single(c => c.BannerID == BannerID); // lamda expression
        return(bt);
    }
Example #19
0
        /// <summary>
        /// 删除Banner
        /// </summary>
        /// <param name="banId">Bannerid</param>
        public static void DeleteBannerById(int Id)
        {
            BannerInfo bannerInfo = AdminGetBannerById(Id);

            if (bannerInfo != null)
            {
                BonSite.Data.Banners.DeleteBannerById(Id);
                BonSite.Core.BSCache.Remove(CacheKeys.SITE_BANNER_LIST + bannerInfo.BanPosId);
            }
        }
Example #20
0
        public JsonResult GetVShopBanner(long?id)
        {
            BannerInfo banner = new BannerInfo();

            if (id.HasValue)
            {
                banner = _iNavigationService.GetSellerNavigation(id.Value);
            }
            return(Json(new { success = true, item = banner }));
        }
Example #21
0
        public JsonResult GetVShopBanner(long?id)
        {
            BannerInfo bannerInfo = new BannerInfo();

            if (id.HasValue)
            {
                bannerInfo = ServiceHelper.Create <INavigationService>().GetSellerNavigation(id.Value);
            }
            return(Json(new { success = true, item = bannerInfo }));
        }
Example #22
0
    protected void rptrBanner_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            NZEduEntities data = new NZEduEntities();
            if (e.CommandName.Equals("del")) // to delete any banner image
            {
                int BannerID = int.Parse(e.CommandArgument.ToString());

                BannerInfo bt = new BannerInfoAction().ViewPhoto1(BannerID); // retrive the info for the banner
                if (bt != null)
                {
                    data.BannerInfoes.Attach(bt);
                    data.BannerInfoes.Remove(bt); // remove banner info from db
                    data.SaveChanges();

                    string path = Server.MapPath("~/Image/Banner/" + bt.BannerSize.ToString() + bt.BannerName);
                    if (File.Exists(path))
                    {
                        File.Delete(path); //delete the image from path
                        ViewBanner();      // bind the banners again
                        lblmsg.Text = "Banner Deleted!";
                    }
                }
            }
            if (e.CommandName.Equals("delall"))                                 // to delete all the banners at once
            {
                var dbBannerId = from b in data.BannerInfoes select b.BannerID; // Get all Banner Id(s)

                string path;
                foreach (var bid in dbBannerId)
                {
                    BannerInfo bt = new BannerInfo();
                    bt = data.BannerInfoes.Single(c => c.BannerID == bid); // lamda expression


                    path = Server.MapPath("~/Image/Banner/" + bt.BannerSize.ToString() + bt.BannerName);
                    if (File.Exists(path))
                    {
                        File.Delete(path); // remove images from the path
                    }

                    data.BannerInfoes.Attach(bt);
                    data.BannerInfoes.Remove(bt); // remove banners info
                }

                data.SaveChanges();
                ViewBanner(); // method calling
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Example #23
0
        private void DeleteNavigation(long shopId, long id)
        {
            BannerInfo bannerInfo = context.BannerInfo.FindBy((BannerInfo item) => item.Id == id && item.ShopId == shopId).FirstOrDefault();

            if (bannerInfo == null)
            {
                throw new HimallException("该导航不存在,或者已被删除!");
            }
            context.BannerInfo.Remove(bannerInfo);
            context.SaveChanges();
        }
Example #24
0
        public List <BannerInfo> GetDataByLocation(int bl_id)
        {
            List <BannerInfo> infos  = new List <BannerInfo>();
            IDataReader       reader = db.GetDataByLocationOrderBcAndTitle(bl_id).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(BannerInfo.Populate(reader));
            }
            return(infos);
        }
Example #25
0
        public List <BannerInfo> GetDataByCustomer(int bcs_id)
        {
            List <BannerInfo> infos  = new List <BannerInfo>();
            IDataReader       reader = db.GetDataByCustomer(bcs_id).CreateDataReader();

            while (reader.Read())
            {
                infos.Add(BannerInfo.Populate(reader));
            }
            return(infos);
        }
Example #26
0
        public BannerInfo GetDataById(int id)
        {
            BannerInfo  info   = new BannerInfo();
            IDataReader reader = db.GetDataById(id).CreateDataReader();

            if (reader.Read())
            {
                info = BannerInfo.Populate(reader);
            }
            return(info);
        }
Example #27
0
        public List <BannerInfo> getAll()
        {
            List <BannerInfo> infos  = new List <BannerInfo>();
            IDataReader       reader = db.GetData().CreateDataReader();

            while (reader.Read())
            {
                infos.Add(BannerInfo.Populate(reader));
            }
            return(infos);
        }
Example #28
0
 public static int getIDFromBanner(BannerInfo targetBanner)
 {
     for (int i = 0; i < Banners.Length; i++)
     {
         if (Banners[i] == targetBanner)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #29
0
        /// <summary>
        /// 后台获得banner
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public static BannerInfo AdminGetBannerById(int id)
        {
            BannerInfo  bannerInfo = null;
            IDataReader reader     = BonSite.Core.BSData.RDBS.AdminGetBannerById(id);

            if (reader.Read())
            {
                bannerInfo = BuildBannerFromReader(reader);
            }
            reader.Close();
            return(bannerInfo);
        }
Example #30
0
        public static string GetQueryString(BannerInfo banner, bool isAdditionalLink = false)
        {
            var result = "?utm_source=yandex&utm_medium=cpc&utm_campaign=" + banner.CampaignID;

            if (isAdditionalLink)
            {
                return(result + AddParam(result, "utm_content", "yd_doplink"));
            }
            result += AddParam(result, "utm_content", banner.BannerID.ToString());
//			result += AddParam(result, "utm_term", Linguistics.UrlTranslite(banner.Title));
            return(result);
        }
 public static void CreateThumbnailArt(BannerInfo bannerInfo, string folderPath, string fileName)
 {
     ConsoleLogger.LogStart("Downloading missing season thumbnail...");
     if (!string.IsNullOrWhiteSpace(bannerInfo.Path))
     {
         DownloadManager.DownloadAndWriteFile(bannerInfo.Path, folderPath + "\\" + fileName);
     }
     else
     {
         ConsoleLogger.Warning("not found!");
     }
     ConsoleLogger.LogEnd("done.");
 }
        // GET: Client
        public ActionResult Index()
        {
            BannerInfo info = new BannerInfo();

            using (db0 = getDB0())
            {
                var all_Banner = db0.Banner.Where(x => x.i_Hide == false && x.i_Lang == System.Globalization.CultureInfo.CurrentCulture.Name & x.type == (int)BannerType.client).OrderByDescending(x => x.sort).ToList();
                foreach (var item in all_Banner)
                {
                    item.imgsrc = GetImg(item.banner_id, "Photo", "Banner", "Banner");//顯示列表圖
                }

                info.photo = all_Banner.Where(x => x.category == (int)BannerCategory.Photo).ToList();
                info.video = all_Banner.Where(x => x.category == (int)BannerCategory.Video).ToList();

                return View("Client", info);
            };
        }
		protected void Page_Load(object sender, EventArgs e)
		{
			Query q = Bobs.BannerServer.Server.GetQueryForBannersActiveBetweenTwoTimes(DateTime.Today, DateTime.Now);
			q.OrderBy = new OrderBy(new OrderBy(Banner.Columns.Position), new OrderBy(Banner.Columns.K));
			BannerSet bannerSet = new BannerSet(q);
			List<Banner> banners = bannerSet.ToList();

			Timeslot timeslotMinus0 = Timeslots.GetCurrentTimeslot();
			Timeslot timeslotMinus1 = timeslotMinus0.GetPreviousTimeslot();

			if (!IsPostBack){
				this.TimeslotStart.Items.Add(timeslotMinus0.StartTime.ToString());
				this.TimeslotEnd.Items.Add(timeslotMinus0.StartTime.ToString());
				DateTime date = timeslotMinus0.StartTime.Date.AddDays(-7);
				while (date < timeslotMinus0.StartTime)
				{
					this.TimeslotStart.Items.Insert(1, date.ToString());
					this.TimeslotEnd.Items.Insert(1, date.ToString());
					date = date.AddHours(8);
				}
				this.TimeslotStart.SelectedIndex = (int) global::Caching.Instances.MainCounterStore.GetCounter("BannerHitViewer.TimeslotStart.SelectedValue for Usr " + Usr.Current.K, () => 0u);
				this.TimeslotEnd.SelectedIndex = (int)global::Caching.Instances.MainCounterStore.GetCounter("BannerHitViewer.TimeslotEnd.SelectedValue for Usr " + Usr.Current.K, () => 1u);
			}

			global::Caching.Instances.MainCounterStore.SetCounter("BannerHitViewer.TimeslotStart.SelectedValue for Usr " + Usr.Current.K, (uint) this.TimeslotStart.SelectedIndex);
			global::Caching.Instances.MainCounterStore.SetCounter("BannerHitViewer.TimeslotEnd.SelectedValue for Usr " + Usr.Current.K, (uint) this.TimeslotEnd.SelectedIndex);


			List<BannerInfo> bannerData = new List<BannerInfo>();
			List<BannerTotalStat> bannerTotalStat = BannerStat.GetBannerStatTotals(banners.ConvertAll(b=>b.K).ToArray());
			

			for (int i=0;i<banners.Count;i++)
			{
				Banner banner = banners[i];
				BannerTimeslotInfoWithDesiredHits bannerTimeslotInfo = new BannerTimeslotInfoWithDesiredHits(banner, timeslotMinus0);
				BannerTimeslotInfoWithDesiredHits previousBannerTimeslotInfo = new BannerTimeslotInfoWithDesiredHits(banner, timeslotMinus1);
				long actualHitsPreviousTimeslot = previousBannerTimeslotInfo.ActualHits.Value;
				long hitsRequiredPreviousTimeslot = previousBannerTimeslotInfo.RequiredHits;
				long hitsDesiredPreviousTimeslot = previousBannerTimeslotInfo.DesiredHits;
				long actualHitsCurrentTimeslot = bannerTimeslotInfo.ActualHits.Value;
				long hitsRequiredCurrentTimeslot = bannerTimeslotInfo.RequiredHits;
				long hitsDesiredCurrentTimeslot = bannerTimeslotInfo.DesiredHits;

				float elapsedLifespan = (float) (Time.Now - banner.FirstDay).TotalDays;
				float lifespan = (float) (banner.LastDay - banner.FirstDay).TotalDays + 1;

				BannerInfo bannerInfo = new BannerInfo()
					{
						K = banner.K,
						Name = banner.Name,
						Position = banner.Position,
						Url = banner.Url(),
						IsMusicTargetted = banner.IsMusicTargetted,
						IsPlaceTargetted = banner.IsPlaceTargetted,
						HitsRequired = banner.TotalRequiredImpressions,
						HitsSoFar = banner.TotalHits,
						UniqueHitsSoFar = bannerTotalStat[i].UniqueVisitors,
						HitsSoFarDb = bannerTotalStat[i].Hits,
						ClicksSoFar = (int)banner.TotalClicks,
						ClicksSoFarDb = bannerTotalStat[i].Clicks,
						ElapsedLifespan = elapsedLifespan,
						Lifespan = lifespan,
						IsTotalHitRateBad = elapsedLifespan / lifespan > 0.5 && ((float)banner.TotalHits / (float)banner.TotalRequiredImpressions) < (0.9 * elapsedLifespan / lifespan),
						ActualHitsCurrentTimeslot = actualHitsCurrentTimeslot,
						HitsRequiredCurrentTimeslot = hitsRequiredCurrentTimeslot,
						HitsDesiredCurrentTimeslot = hitsDesiredCurrentTimeslot,
						ActualHitsPreviousTimeslot = actualHitsPreviousTimeslot,
						HitsRequiredPreviousTimeslot = hitsRequiredPreviousTimeslot,
						HitsDesiredPreviousTimeslot = hitsDesiredPreviousTimeslot,
						IsPreviousTimeslotBad = actualHitsPreviousTimeslot < 0.9 * hitsDesiredPreviousTimeslot,
						IsCurrentTimeslotBad = actualHitsCurrentTimeslot < 0.9 * (Timeslot.ElapsedTimeSinceStartOfCurrentTimeInterval(Time.Now, Timeslot.Duration).TotalMinutes / Timeslot.Duration.TotalMinutes) * hitsDesiredCurrentTimeslot,
						TimesConsidered = bannerTimeslotInfo.Considerations.Value,
						TimesConsideredPrev = previousBannerTimeslotInfo.Considerations.Value,
						Rate = bannerTimeslotInfo.ProportionToBeServed,
						RatePrev = previousBannerTimeslotInfo.ProportionToBeServed,
						RemainingSecondsWhenPreviousBannerCompleted = bannerTimeslotInfo.NumberOfSecondsLeftWhenAllHitsWereServed.Value,
						CreditsPerClick =  ((double)banner.PriceCredits * ((double)banner.TotalHits / (double)banner.TotalRequiredImpressions)) / (double)banner.TotalClicks
					};
				bannerData.Add(bannerInfo);
			}

			this.BannerInfoRepeater.DataSource = bannerData;
			this.BannerInfoRepeater.DataBind();

			

			List<TimeslotInfo> timeslotInfos = new List<TimeslotInfo>();
			Timeslot first;
			try
			{
				first = new Timeslot(DateTime.Parse(TimeslotStart.SelectedValue));
			}
			catch
			{
				first = timeslotMinus0;
			}
			Timeslot last;
			try
			{
				last = new Timeslot(DateTime.Parse(TimeslotStart.SelectedValue));
			}
			catch
			{
				last = timeslotMinus1;
			}
			
			if (first.StartTime < last.StartTime)
			{
				Timeslot temp = first;
				first = last;
				last = temp;
			}

			List<Timeslot> timeslots = new List<Timeslot>();
			while(first.StartTime >= last.StartTime)
			{
				timeslots.Add(first);
				first = first.GetPreviousTimeslot();
			}
			foreach (Timeslot ts in timeslots)
			{
				long actualHits = 0;
				long requiredHits = 0;

				if (ts.StartTime != timeslotMinus0.StartTime)
				{
					actualHits = global::Caching.Instances.Main.Get(ts.GetCacheKey() + "actualHitsForBannerHitViewer", () =>
						{
							long hits = 0;
							banners.ForEach(b =>
							{
								BannerTimeslotInfo info = new BannerTimeslotInfo(b.K, ts);
								hits += info.ActualHits.Value; 
							});
							return hits;
						}
					);
					requiredHits = global::Caching.Instances.Main.Get(ts.GetCacheKey() + "requiredHitsForBannerHitViewer", () =>
						{
							long hits = 0;
							banners.ForEach(b => {
								BannerTimeslotInfoWithDesiredHits info = new BannerTimeslotInfoWithDesiredHits(b, ts);
								hits += info.DesiredHits; 
							});
							return hits;
						}
					);
				}
				else
				{

					banners.ForEach(b => {
						BannerTimeslotInfo info = new BannerTimeslotInfo(b.K, ts); 
						actualHits += info.ActualHits.Value; 
					});
					banners.ForEach(b => {
						BannerTimeslotInfoWithDesiredHits info = new BannerTimeslotInfoWithDesiredHits(b, ts); 
						requiredHits += info.DesiredHits;
					});
				}
				

				
				
				TimeslotInfo ti = new TimeslotInfo()
								  {
									  TimeslotStart = ts.StartTime,
									  NotShown = ts.TotalNotShown().Value,
									  Actual = actualHits,
									  Required = requiredHits,
									  Timeouts = ts.BannerTimeouts().Value,
									  CallsToBannerServer = ts.CallsToBannerServer().Value

								  };

				
				timeslotInfos.Add(ti);
			}


			this.TimeslotInfoRepeater.DataSource = timeslotInfos;
			this.TimeslotInfoRepeater.DataBind();
			
			
		}
Example #34
0
 private void GetInfoFromBannersXml(string bannersMirrorUrl)
 {
     Banners = new List<BannerInfo>();
     XElement dataElement = BannersXml.Element("Banners");
     if (dataElement == null) throw new Exception("Could not find banners element in Banners XML");
     foreach (var bannerElement in dataElement.Elements("Banner"))
     {
         BannerInfo bannerInfo = new BannerInfo(bannerElement, bannersMirrorUrl);
         Banners.Add(bannerInfo);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        string bannerCategoryCodeName = ValidationHelper.GetString(GetValue("BannerCategoryCodeName"), "");

        BannerCategoryInfo bannerCategory = BannerCategoryInfoProvider.GetBannerCategoryInfoFromSiteOrGlobal(bannerCategoryCodeName, SiteContext.CurrentSiteID);

        if ((bannerCategory == null) || (bannerCategory.BannerCategoryEnabled == false))
        {
            Visible = !HideIfBannerNotFound;
            return;
        }

        if (URLHelper.IsPostback() && KeepPreviousBannerOnPostBack && BannerIDViewState.HasValue)
        {
            bannerReused = true;
            banner = BannerInfoProvider.GetBannerInfo(BannerIDViewState.Value);
        }

        // If random banner should be picked or banner from viewstate was not found
        if (banner == null)
        {
            bannerReused = false;
            // Get random banner from selected category. Decrement hits left for this banner only if page is displayed on the live site.
            banner = BannerInfoProvider.GetRandomValidBanner(bannerCategory.BannerCategoryID, (currentViewMode.IsLiveSite()));
        }

        // Exits if no banner was found
        if (banner == null)
        {
            Visible = !HideIfBannerNotFound;
            return;
        }

        // Store banner id in the viewstate if the same banner should be used if request is postback
        if (KeepPreviousBannerOnPostBack)
        {
            BannerIDViewState = banner.BannerID;
        }

        string width = ValidationHelper.GetString(GetValue("Width"), "");
        string height = ValidationHelper.GetString(GetValue("Height"), "");
        string anchorClass = ValidationHelper.GetString(GetValue("AnchorClass"), "");
        bool fakeLink = ValidationHelper.GetBoolean(GetValue("FakeLink"), true);

        if (width != "")
        {
            lnkBanner.Style["width"] = width;
        }
        if (height != "")
        {
            lnkBanner.Style["height"] = height;
        }

        lnkBanner.CssClass = string.Format("CMSBanner {0}", anchorClass).Trim();

        lnkBanner.Visible = true;

        // Do not set link if we are not on the live site.
        if (currentViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview))
        {
            // Link pointing to our custom handler which logs click and redirects
            string bannerRedirectURL = URLHelper.ResolveUrl("~/CMSModules/BannerManagement/CMSPages/BannerRedirect.ashx?bannerID=" + banner.BannerID);

            if (fakeLink)
            {
                // By default href attribute will be set to 'nice' URL
                lnkBanner.Attributes.Add("href", URLHelper.ResolveUrl(banner.BannerURL));

                // After clicking href will be set to URL pointing to custom handler which counts clicks
                lnkBanner.Attributes.Add("onclick", string.Format("this.href='{0}';", bannerRedirectURL));

                // GECKO doesn't count middle mouse click as click, so onmouseup (or down) needs to be added
                lnkBanner.Attributes.Add("onmouseup", string.Format("this.href='{0}';", bannerRedirectURL));
            }
            else
            {
                // If faking links is disabled, set href to redirect url
                lnkBanner.Attributes.Add("href", bannerRedirectURL);
            }

            // Add target="_blank" attribute if link should be opened in new window
            if (banner.BannerBlank)
            {
                lnkBanner.Target = "_blank";
            }
        }

        if (banner.BannerType == BannerTypeEnum.Image)
        {
            BannerImageAttributes bannerImageAttributes = BannerManagementHelper.DeserializeBannerImageAttributes(banner.BannerContent);

            imgBanner.AlternateText = bannerImageAttributes.Alt;
            imgBanner.ToolTip = bannerImageAttributes.Title;
            imgBanner.CssClass = bannerImageAttributes.Class;
            imgBanner.Style.Value = HTMLHelper.HTMLEncode(bannerImageAttributes.Style);

            imgBanner.ImageUrl = URLHelper.ResolveUrl(bannerImageAttributes.Src);

            imgBanner.Visible = true;
            ltrBanner.Visible = false;
        }
        else
        {
            string text = MacroResolver.Resolve(banner.BannerContent);

            ltrBanner.Text = HTMLHelper.ResolveUrls(text, null, false);
            imgBanner.Visible = false;
            ltrBanner.Visible = true;

            if (banner.BannerType == BannerTypeEnum.HTML)
            {
                ControlsHelper.ResolveDynamicControls(this);
            }
        }
    }