Example #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;
        }
Example #2
0
        protected internal virtual List<OutDoorIndexEntity> GetOutDoors(EntitiesContext context, DateTime? lastIndexTime)
        {
            if (context == null)
            {
                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);

            if (lastIndexTime.HasValue)
            {
                query = query.Where(x => x.LastTime > lastIndexTime.Value);
            }

            foreach (var x in query.ToList())
            {
                OutDoorIndexEntity item = new OutDoorIndexEntity();

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

                result.Add(item);

            }
            return result;
        }
Example #3
0
        /// <summary>
        /// 添加索引
        /// </summary>
        /// <param name="OutDoors"></param>
        /// <param name="creatingIndex"></param>
        private static void AddOutDoor(OutDoorIndexEntity OutDoor)
        {
            var document = new Document();

            var field = new Field(OutDoorIndexFields.Title, OutDoor.Title, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 2.5f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.Description, OutDoor.Description, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 2.1f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.CompanyName, OutDoor.CompanyName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 2.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.AreaAtt, OutDoor.AreaAtt, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 1.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.CityName, OutDoor.CityName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 1.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.ProvinceName, OutDoor.ProvinceName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 1.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.MediaCateName, OutDoor.MediaCateName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 1.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.PMediaCateName, OutDoor.PMediaCateName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 1.0f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.FormatName, OutDoor.FormatName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 0.2f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.PeriodName, OutDoor.PeriodName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 0.2f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.OwnerCateName, OutDoor.OwnerCateName, Field.Store.YES, Field.Index.ANALYZED);
            field.Boost = 0.2f;
            document.Add(field);

            field = new Field(OutDoorIndexFields.ImgUrl, OutDoor.ImgUrl, Field.Store.YES, Field.Index.NOT_ANALYZED);
            document.Add(field);

            field = new Field(OutDoorIndexFields.VideoUrl, string.IsNullOrEmpty(OutDoor.VideoUrl) ? string.Empty : OutDoor.VideoUrl, Field.Store.YES, Field.Index.NOT_ANALYZED);
            document.Add(field);

            document.Add(new NumericField(OutDoorIndexFields.Price, Field.Store.YES, true).SetDoubleValue(Convert.ToDouble(OutDoor.Price)));
            document.Add(new NumericField(OutDoorIndexFields.Width, Field.Store.YES, true).SetDoubleValue(Convert.ToDouble(OutDoor.Width)));
            document.Add(new NumericField(OutDoorIndexFields.Height, Field.Store.YES, true).SetDoubleValue(Convert.ToDouble(OutDoor.Height)));
            document.Add(new NumericField(OutDoorIndexFields.TotalFaces, Field.Store.YES, true).SetIntValue(OutDoor.TotalFaces));
            document.Add(new NumericField(OutDoorIndexFields.Province, Field.Store.YES, true).SetIntValue(OutDoor.Province));
            document.Add(new NumericField(OutDoorIndexFields.City, Field.Store.YES, true).SetIntValue(OutDoor.City));
            document.Add(new NumericField(OutDoorIndexFields.MediaCode, Field.Store.YES, true).SetIntValue(OutDoor.MediaCode));
            document.Add(new NumericField(OutDoorIndexFields.PMediaCode, Field.Store.YES, true).SetIntValue(OutDoor.PMediaCode));
            document.Add(new NumericField(OutDoorIndexFields.FormatCode, Field.Store.YES, true).SetIntValue(OutDoor.FormatCode));
            document.Add(new NumericField(OutDoorIndexFields.PeriodCode, Field.Store.YES, true).SetIntValue(OutDoor.PeriodCode));
            document.Add(new NumericField(OutDoorIndexFields.OwnerCode, Field.Store.YES, true).SetIntValue(OutDoor.OwnerCode));
            document.Add(new NumericField(OutDoorIndexFields.Status, Field.Store.YES, true).SetIntValue(OutDoor.Status));
            document.Add(new NumericField(OutDoorIndexFields.AuthStatus, Field.Store.YES, true).SetIntValue(OutDoor.AuthStatus));
            document.Add(new NumericField(OutDoorIndexFields.MediaID, Field.Store.YES, true).SetIntValue(OutDoor.MediaID));
            document.Add(new NumericField(OutDoorIndexFields.Hit, Field.Store.YES, true).SetIntValue(OutDoor.Hit));
            document.Add(new NumericField(OutDoorIndexFields.Published, Field.Store.YES, true).SetLongValue(OutDoor.Published.Ticks));

            document.Add(new NumericField(OutDoorIndexFields.MemberStatus, Field.Store.YES, true).SetIntValue(OutDoor.MemberStatus));

            document.Add(new NumericField(OutDoorIndexFields.Lat, Field.Store.YES, true).SetDoubleValue(OutDoor.Lat));

            document.Add(new NumericField(OutDoorIndexFields.Lng, Field.Store.YES, true).SetDoubleValue(OutDoor.Lng));

            document.Add(new NumericField(OutDoorIndexFields.MemberCreditIndex, Field.Store.YES, true).SetIntValue(OutDoor.MemberCreditIndex));

            document.Add(new NumericField(OutDoorIndexFields.MemberID, Field.Store.YES, true).SetIntValue(OutDoor.MemberID));

            _indexWriter.AddDocument(document);
        }
Example #4
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);
        }