Beispiel #1
0
        /// <summary>
        /// 获取指定位置的广告信息集合
        /// </summary>
        /// <param name="relationId">城市或单位类型(MQ)编号</param>
        /// <param name="position">广告位置</param>
        /// <returns></returns>
        public IList <EyouSoft.Model.AdvStructure.AdvInfo> GetNotFillAdvs(int relationId, EyouSoft.Model.AdvStructure.AdvPosition position)
        {
            string cachename = string.Format(EyouSoft.CacheTag.Adv.SystemAdv, position.ToString(), relationId);

            EyouSoft.Cache.Facade.EyouSoftCacheTime <List <EyouSoft.Model.AdvStructure.AdvInfo> > list = (EyouSoft.Cache.Facade.EyouSoftCacheTime <List <EyouSoft.Model.AdvStructure.AdvInfo> >)
                                                                                                         EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cachename);

            object UpdateTime = EyouSoft.Cache.Facade.EyouSoftCache.GetCache(string.Format(EyouSoft.CacheTag.Adv.SystemAdvUpdateKey, position.ToString()));

            if (UpdateTime == null)
            {
                EyouSoft.Cache.Facade.EyouSoftCache.Add(string.Format(EyouSoft.CacheTag.Adv.SystemAdvUpdateKey, position.ToString()), DateTime.Now);
            }
            if (list != null && UpdateTime != null && list.UpdateTime > (DateTime)UpdateTime)
            {
                return(list.Data);
            }
            else
            {
                list = new EyouSoft.Cache.Facade.EyouSoftCacheTime <List <EyouSoft.Model.AdvStructure.AdvInfo> >();

                EyouSoft.Model.AdvStructure.AdvPositionInfo positionInfo = this.GetPositionInfo(position);

                IList <EyouSoft.Model.AdvStructure.AdvInfo> advs = dal.GetAdvs(positionInfo.AdvType, relationId, position, DateTime.Today, positionInfo.AdvCount, false);

                int appendItems = positionInfo.AdvCount;

                #region 补平台广告
                if (advs != null && advs.Count > 0)
                {
                    appendItems = positionInfo.AdvCount - advs.Count;
                }
                else
                {
                    advs = new List <EyouSoft.Model.AdvStructure.AdvInfo>();
                }

                if (appendItems > 0)
                {
                    IList <EyouSoft.Model.AdvStructure.AdvInfo> platformAdvs = dal.GetAdvs(positionInfo.AdvType, relationId, position, DateTime.Today, appendItems, true);

                    if (platformAdvs != null && platformAdvs.Count > 0)
                    {
                        //advs = advs.Union(platformAdvs).ToList();
                        foreach (EyouSoft.Model.AdvStructure.AdvInfo advInfo in platformAdvs)
                        {
                            advs.Add(advInfo);
                        }
                    }
                }
                #endregion

                list.Data       = advs.ToList();
                list.UpdateTime = DateTime.Now;

                EyouSoft.Cache.Facade.EyouSoftCache.Add(cachename, list, DateTime.Today.AddDays(1).AddMinutes(10));
            }

            return(list.Data);
        }
Beispiel #2
0
        /// <summary>
        /// 设置广告排序
        /// </summary>
        /// <param name="advId">广告编号</param>
        /// <param name="position">广告位置</param>
        /// <param name="relationId">关联编号</param>
        /// <param name="sortId">排序编号</param>
        /// <returns></returns>
        public bool SetAdvSort(int advId, EyouSoft.Model.AdvStructure.AdvPosition position, int relationId, int sortId)
        {
            string cachename = string.Format(EyouSoft.CacheTag.Adv.SystemAdvUpdateKey, position.ToString());

            EyouSoft.Cache.Facade.EyouSoftCache.Add(cachename, DateTime.Now);

            return(dal.SetAdvSort(advId, this.GetPositionInfo(position).AdvType, relationId, sortId));
        }