Пример #1
0
        public bool IsBannerActive(BannerInfo objBanner)
        {
            bool blnValid = true;

            if (Null.IsNull(objBanner.StartDate) == false && DateTime.Now < objBanner.StartDate)
            {
                blnValid = false;
            }
            if (blnValid)
            {
                switch (objBanner.Criteria)
                {
                case 0:     //AND = cancel the banner when the Impressions expire
                    if (objBanner.Impressions < objBanner.Views && objBanner.Impressions != 0)
                    {
                        blnValid = false;
                    }
                    break;

                case 1:     //OR = cancel the banner if either the EndDate OR Impressions expire
                    if ((objBanner.Impressions < objBanner.Views && objBanner.Impressions != 0) || (DateTime.Now > objBanner.EndDate && Null.IsNull(objBanner.EndDate) == false))
                    {
                        blnValid = false;
                    }
                    break;
                }
            }
            return(blnValid);
        }
Пример #2
0
 public void UpdateBanner(BannerInfo objBannerInfo)
 {
     _dataService.UpdateBanner(objBannerInfo.BannerId,
                               objBannerInfo.BannerName,
                               objBannerInfo.ImageFile,
                               objBannerInfo.URL,
                               objBannerInfo.Impressions,
                               objBannerInfo.CPM,
                               objBannerInfo.StartDate,
                               objBannerInfo.EndDate,
                               objBannerInfo.CreatedByUser,
                               objBannerInfo.BannerTypeId,
                               objBannerInfo.Description,
                               objBannerInfo.GroupName,
                               objBannerInfo.Criteria,
                               objBannerInfo.Width,
                               objBannerInfo.Height);
     ClearBannerCache();
 }
Пример #3
0
        public ArrayList LoadBanners(int PortalId, int ModuleId, int BannerTypeId, string GroupName, int Banners)
        {
            if (GroupName == null)
            {
                GroupName = Null.NullString;
            }

            //set cache key
            string cacheKey = string.Format(DataCache.BannersCacheKey, PortalId, BannerTypeId, GroupName);

            //get list of active banners
            var bannersList = CBO.GetCachedObject <List <BannerInfo> >(new CacheItemArgs(cacheKey, DataCache.BannersCacheTimeOut, DataCache.BannersCachePriority, PortalId, BannerTypeId, GroupName),
                                                                       LoadBannersCallback);

            //create return collection
            var arReturnBanners = new ArrayList(Banners);

            if (bannersList.Count > 0)
            {
                if (Banners > bannersList.Count)
                {
                    Banners = bannersList.Count;
                }

                //set Random start index based on the list of banners
                int intIndex = new Random().Next(0, bannersList.Count);
                //set counter
                int intCounter = 1;

                while (intCounter <= bannersList.Count && arReturnBanners.Count != Banners)
                {
                    //manage the rotation for the circular collection
                    intIndex += 1;
                    if (intIndex > (bannersList.Count - 1))
                    {
                        intIndex = 0;
                    }

                    //get the banner object
                    BannerInfo objBanner = bannersList[intIndex];

                    //add to return collection
                    arReturnBanners.Add(objBanner);

                    //update banner attributes
                    objBanner.Views += 1;
                    if (Null.IsNull(objBanner.StartDate))
                    {
                        objBanner.StartDate = DateTime.Now;
                    }
                    if (Null.IsNull(objBanner.EndDate) && objBanner.Views >= objBanner.Impressions && objBanner.Impressions != 0)
                    {
                        objBanner.EndDate = DateTime.Now;
                    }
                    _dataService.UpdateBannerViews(objBanner.BannerId, objBanner.StartDate, objBanner.EndDate);

                    //expire cached collection of banners if a banner is no longer active
                    if (!IsBannerActive(objBanner))
                    {
                        DataCache.RemoveCache(cacheKey);
                    }
                    intCounter += 1;
                }
            }
            return(arReturnBanners);
        }
Пример #4
0
		public bool IsBannerActive(BannerInfo objBanner)
        {
            bool blnValid = true;

            if (Null.IsNull(objBanner.StartDate) == false && DateTime.Now < objBanner.StartDate)
            {
                blnValid = false;
            }
            if (blnValid)
            {
                switch (objBanner.Criteria)
                {
                    case 0: //AND = cancel the banner when the Impressions expire
                        if (objBanner.Impressions < objBanner.Views && objBanner.Impressions != 0)
                        {
                            blnValid = false;
                        }
                        break;
                    case 1: //OR = cancel the banner if either the EndDate OR Impressions expire
                        if ((objBanner.Impressions < objBanner.Views && objBanner.Impressions != 0) || (DateTime.Now > objBanner.EndDate && Null.IsNull(objBanner.EndDate) == false))
                        {
                            blnValid = false;
                        }
                        break;
                }
            }
            return blnValid;
        }
Пример #5
0
 public void UpdateBanner(BannerInfo objBannerInfo)
 {
     _dataService.UpdateBanner(objBannerInfo.BannerId,
                                          objBannerInfo.BannerName,
                                          objBannerInfo.ImageFile,
                                          objBannerInfo.URL,
                                          objBannerInfo.Impressions,
                                          objBannerInfo.CPM,
                                          objBannerInfo.StartDate,
                                          objBannerInfo.EndDate,
                                          objBannerInfo.CreatedByUser,
                                          objBannerInfo.BannerTypeId,
                                          objBannerInfo.Description,
                                          objBannerInfo.GroupName,
                                          objBannerInfo.Criteria,
                                          objBannerInfo.Width,
                                          objBannerInfo.Height);
     ClearBannerCache();
 }
Пример #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
				//Only Update if the Entered Data is val
                if (Page.IsValid)
                {
                    if (!cmdCopy.Visible)
                    {
                        BannerId = -1;
                    }
                    DateTime startDate = Null.NullDate;
                    if (StartDatePicker.SelectedDate.HasValue)
                    {
                        startDate = StartDatePicker.SelectedDate.Value;
                    }
                    DateTime endDate = Null.NullDate;
                    if (EndDatePicker.SelectedDate.HasValue)
                    {
                        endDate = EndDatePicker.SelectedDate.Value;
                    }
					
                    //Create an instance of the Banner DB component
                    var objBanner = new BannerInfo();
                    objBanner.BannerId = BannerId;
                    objBanner.VendorId = VendorId;
                    objBanner.BannerName = txtBannerName.Text;
                    objBanner.BannerTypeId = Convert.ToInt32(cboBannerType.SelectedItem.Value);
                    objBanner.GroupName = DNNTxtBannerGroup.Text;
                    objBanner.ImageFile = ctlImage.Url;
                    if (!String.IsNullOrEmpty(txtWidth.Text))
                    {
                        objBanner.Width = int.Parse(txtWidth.Text);
                    }
                    else
                    {
                        objBanner.Width = 0;
                    }
                    if (!String.IsNullOrEmpty(txtHeight.Text))
                    {
                        objBanner.Height = int.Parse(txtHeight.Text);
                    }
                    else
                    {
                        objBanner.Height = 0;
                    }
                    objBanner.Description = txtDescription.Text;
                    objBanner.URL = ctlURL.Url;
                    objBanner.Impressions = int.Parse(txtImpressions.Text);
                    objBanner.CPM = double.Parse(txtCPM.Text);
                    objBanner.StartDate = startDate;
                    objBanner.EndDate = endDate;
                    objBanner.Criteria = int.Parse(optCriteria.SelectedItem.Value);
                    objBanner.CreatedByUser = UserInfo.UserID.ToString();

                    var objBanners = new BannerController();
                    if (BannerId == Null.NullInteger)
                    {
						//Add the banner within the Banners table
                        objBanners.AddBanner(objBanner);
                    }
                    else
                    {
						//Update the banner within the Banners table
                        objBanners.UpdateBanner(objBanner);
                    }
					
                    //Redirect back to the portal home page
                    Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }