private static LinkItem GetMediaItem(Document doc) { int MemberStatus = Int32.Parse(doc.Get(OutDoorIndexFields.MemberStatus), CultureInfo.InvariantCulture); int MemberID = Int32.Parse(doc.Get(OutDoorIndexFields.MemberID), CultureInfo.InvariantCulture); int Hit = Int32.Parse(doc.Get(OutDoorIndexFields.Hit), CultureInfo.InvariantCulture); int SuggestStatus = Int32.Parse(doc.Get(OutDoorIndexFields.SuggestStatus), CultureInfo.InvariantCulture); int ID = Int32.Parse(doc.Get(OutDoorIndexFields.ID), CultureInfo.InvariantCulture); int CityCode = Int32.Parse(doc.Get(OutDoorIndexFields.CityCode), CultureInfo.InvariantCulture); int FormatCode = Int32.Parse(doc.Get(OutDoorIndexFields.FormatCode), CultureInfo.InvariantCulture); int AuthStatus = Int32.Parse(doc.Get(OutDoorIndexFields.AuthStatus), CultureInfo.InvariantCulture); int MediaCode = Int32.Parse(doc.Get(OutDoorIndexFields.MediaCode), CultureInfo.InvariantCulture); int TrafficAuto = Int32.Parse(doc.Get(OutDoorIndexFields.TrafficAuto), CultureInfo.InvariantCulture); int TrafficPerson = Int32.Parse(doc.Get(OutDoorIndexFields.TrafficPerson), CultureInfo.InvariantCulture); decimal Price = Decimal.Parse(doc.Get(OutDoorIndexFields.Price), CultureInfo.InvariantCulture); decimal RealPrice = Decimal.Parse(doc.Get(OutDoorIndexFields.RealPrice), CultureInfo.InvariantCulture); double Lng = double.Parse(doc.Get(OutDoorIndexFields.Lng), CultureInfo.InvariantCulture); double Lat = double.Parse(doc.Get(OutDoorIndexFields.Lat), CultureInfo.InvariantCulture); DateTime Published = new DateTime(Int64.Parse(doc.Get(OutDoorIndexFields.Published), CultureInfo.InvariantCulture)); DateTime DeadLine = new DateTime(Int64.Parse(doc.Get(OutDoorIndexFields.DeadLine), CultureInfo.InvariantCulture)); int IsRegularValue = Int32.Parse(doc.Get(OutDoorIndexFields.IsRegular), CultureInfo.InvariantCulture); int HasLightValue = Int32.Parse(doc.Get(OutDoorIndexFields.HasLight), CultureInfo.InvariantCulture); int CityCateCode = Int32.Parse(doc.Get(OutDoorIndexFields.CityCateCode), CultureInfo.InvariantCulture); int MediaCateCode = Int32.Parse(doc.Get(OutDoorIndexFields.MediaCateCode), CultureInfo.InvariantCulture); int Status = Int32.Parse(doc.Get(OutDoorIndexFields.Status), CultureInfo.InvariantCulture); bool IsRegular = IsRegularValue == 1; bool HasLight = HasLightValue == 1; LinkItem item = new LinkItem(); item.ID = ID; item.MemberID = MemberID; item.Status = Status; item.SuggestStatus = SuggestStatus; item.Hit = Hit; item.FocusImgUrl = doc.Get(OutDoorIndexFields.FocusImgUrl); item.CredentialsImg = doc.Get(OutDoorIndexFields.CredentialsImg); item.ImgUrl = doc.Get(OutDoorIndexFields.ImgUrl); item.CityCode = CityCode; item.CityCateName = doc.Get(OutDoorIndexFields.CityCateName); item.CityCateValue = doc.Get(OutDoorIndexFields.CityCateValue); item.CityCateCode = CityCateCode; item.MediaCode = MediaCode; item.MediaCateName = doc.Get(OutDoorIndexFields.MediaCateName); item.MediaCateValue = doc.Get(OutDoorIndexFields.MediaCateValue); item.MediaCateCode = MediaCateCode; item.Name = doc.Get(OutDoorIndexFields.Title); item.Description = doc.Get(OutDoorIndexFields.Description); item.Price = Price; item.RealPrice = RealPrice; item.PeriodName = doc.Get(OutDoorIndexFields.PeriodName); item.FormatName = doc.Get(OutDoorIndexFields.FormatName); //item.OwnerName = doc.Get(OutDoorIndexFields.OwnerName); item.AuthStatus = AuthStatus; item.MemberStatus = MemberStatus; item.CompanyName = doc.Get(OutDoorIndexFields.CompanyName); //item.AreaCate = doc.Get(OutDoorIndexFields.AreaCate); //item.IndustryCate = doc.Get(OutDoorIndexFields.IndustryCate); //item.CrowdCate = doc.Get(OutDoorIndexFields.CrowdCate); //item.PurposeCate = doc.Get(OutDoorIndexFields.PurposeCate); item.AddTime = Published; item.DeadLine = DeadLine; item.TrafficAuto = TrafficAuto; item.TrafficPerson = TrafficPerson; item.Location = doc.Get(OutDoorIndexFields.Location); decimal TotalArea = Decimal.Parse(doc.Get(OutDoorIndexFields.TotalArea), CultureInfo.InvariantCulture); if (IsRegular) { decimal Width = Decimal.Parse(doc.Get(OutDoorIndexFields.Width), CultureInfo.InvariantCulture); decimal Height = Decimal.Parse(doc.Get(OutDoorIndexFields.Height), CultureInfo.InvariantCulture); int TotalFaces = Int32.Parse(doc.Get(OutDoorIndexFields.TotalFaces), CultureInfo.InvariantCulture); item.IsRegular = IsRegular; item.Width = Width; item.Height = Height; item.TotalFaces = TotalFaces; item.TotalArea = TotalArea; } else { item.IsRegular = IsRegular; item.IrRegularArea = doc.Get(OutDoorIndexFields.IrRegularArea); item.TotalArea = TotalArea; } if (HasLight) { item.HasLight = HasLight; int LightStart = Int32.Parse(doc.Get(OutDoorIndexFields.LightStart), CultureInfo.InvariantCulture); int LightEnd = Int32.Parse(doc.Get(OutDoorIndexFields.LightEnd), CultureInfo.InvariantCulture); item.LightStart = LightStart; item.LightEnd = LightEnd; } item.Lat = Lat; item.Lng = Lng; item.VideoUrl = doc.Get(OutDoorIndexFields.VideoUrl); return item; }
public LinkItem Search(int MediaID) { var model = new LinkItem(); using (var directory = new SimpleFSDirectory(new DirectoryInfo(LuceneCommon.IndexOutDoorDirectory))) { var searcher = new IndexSearcher(directory, readOnly: true); var term = new Term(OutDoorIndexFields.ID, MediaID.ToString()); var result = searcher.Search(new TermQuery(term), 1); var doc = searcher.Doc(result.ScoreDocs[0].Doc); model = GetMediaItem(doc); searcher.Dispose(); } return model; }