Ejemplo n.º 1
0
        protected virtual List<OutDoorIndexEntity> GetOutDoors(DateTime? lastIndexTime)
        {
            List<OutDoorIndexEntity> result = new List<OutDoorIndexEntity>();

            var context = new EntitiesContext();
            var OutDoors = context.Set<OutDoor>()
                .Include(x => x.Area)
                .Include(x => x.Area.PCategory)
                .Include(x => x.OutDoorMediaCate)
                .Include(x => x.OutDoorMediaCate.PCategory)
                .Include(x => x.AreaAtt)
                .Include(x => x.PeriodCate)
                .Include(x => x.FormatCate)
                .Include(x => x.MediaImg);

            if (lastIndexTime != null)
            {
                OutDoors = OutDoors.Where(x => x.LastTime > lastIndexTime);
            }
            OutDoors = OutDoors.OrderByDescending(x => x.LastTime);
            foreach (var x in OutDoors.ToList())
            {
                OutDoorIndexEntity item = new OutDoorIndexEntity()
                {
                    City = x.Area.ID,
                    FormatCode = x.FormatCode,
                    ImgUrl = x.MediaImg.FocusImgUrl,
                    MediaCode = x.MeidaCode,
                    OwnerCode = x.OwnerCode,
                    PeriodCode = x.PeriodCode,
                    PMediaCode = x.OutDoorMediaCate.PCategory.ID,
                    Province = x.Area.PCategory.ID,
                    Status = x.Status,
                    MediaID = x.MediaID,
                    ProvinceName = x.Area.PCategory.CateName,
                    CityName = x.Area.CateName,
                    AreaAtt = String.Join(",", x.AreaAtt.Select(y => y.AttName)),
                    Description = x.Description,
                    FormatName = x.FormatCate.CateName,
                    Hit = x.Hit,
                    MediaCateName = x.OutDoorMediaCate.CateName,
                    PMediaCateName = x.OutDoorMediaCate.PCategory.CateName,
                    OwnerCateName = x.OwnerCate.CateName,
                    PeriodName = x.PeriodCate.CateName,
                    Price = Convert.ToInt32(x.Price),
                    Published = x.LastTime,
                    Title = x.Name
                };
                result.Add(item);

            }
            return result;
        }
Ejemplo n.º 2
0
        public void UpdateIndex(List<int> keys)
        {
            EnsureIndexWriter(false);

            var context = new EntitiesContext();

            List<OutDoorIndexEntity> result = new List<OutDoorIndexEntity>();

            var query = context.Set<OutDoor>()
                .Include(x => x.Area)
                .Include(x => x.Area.PCategory)
                .Include(x => x.OutDoorMediaCate)
                .Include(x => x.OutDoorMediaCate.PCategory)
                .Include(x => x.AreaAtt)
                .Include(x => x.PeriodCate)
                .Include(x => x.FormatCate)
                .Include(x => x.MediaImg)
                .Include(x => x.Member)
                .Include(x => x.Member.Member_CreditIndex)
                .Include(x => x.Member.SelfCompany)
                .Where(x => keys.Contains(x.MediaID));

            foreach (var x in query.ToList())
            {
                OutDoorIndexEntity item = new OutDoorIndexEntity()
                {
                    City = x.Area.ID,
                    FormatCode = x.FormatCode,
                    ImgUrl = x.MediaImg == null ? string.Empty : x.MediaImg.FocusImgUrl,
                    MediaCode = x.MeidaCode,
                    OwnerCode = x.OwnerCode,
                    PeriodCode = x.PeriodCode,
                    PMediaCode = x.OutDoorMediaCate.PCategory.ID,
                    Province = x.Area.PCategory.ID,
                    Status = x.Status,
                    AuthStatus = x.AuthStatus,
                    MediaID = x.MediaID,
                    ProvinceName = x.Area.PCategory.CateName,
                    CityName = x.Area.CateName,
                    AreaAtt = String.Join(",", x.AreaAtt.Select(y => y.AttName)),
                    Description = x.Description,
                    FormatName = x.FormatCate.CateName,
                    Hit = x.Hit,
                    MediaCateName = x.OutDoorMediaCate.CateName,
                    PMediaCateName = x.OutDoorMediaCate.PCategory.CateName,
                    OwnerCateName = x.OwnerCate.CateName,
                    PeriodName = x.PeriodCate.CateName,
                    VideoUrl = x.VideoUrl,
                    Price = x.Price,
                    Published = x.LastTime,
                    Title = x.Name,
                    Height = x.Height,
                    TotalFaces = x.TotalFaces,
                    Width = x.Wdith,
                    CompanyName = x.Member.SelfCompany.Name,
                    Lat = x.Lat,
                    Lng = x.Lng,
                    MemberCreditIndex = x.Member.Member_CreditIndex == null ? 0 : x.Member.Member_CreditIndex.TotalCreditIndex,
                    MemberStatus = x.Member.Status,
                    MemberID = x.MemberID

                };

                result.Add(item);

            }

            AddOutDoors(result, false);
        }