/// <summary> /// This is for developing new features /// </summary> /// <returns></returns> public ActionResult FindOutdate2() { FindSite e = new FindSite(); e.CampaignID = 0; return(View(e)); }
public JsonResult FindJson4Quote(FindSite e, int quoteID) { var l = Find(e); CodeMasterRepository codeMasterRepo = new CodeMasterRepository(); return(Json(l.Select(r => new { r.ID, r.SiteID, r.Name, r.Site.Lat, r.Site.Lng, AddressLine1 = r.Site.AddressLine1 ?? "", AddressLine2 = r.Site.AddressLine2 ?? "", Code = r.Site.Code ?? "", r.Format, Type = string.IsNullOrEmpty(r.Type) ? "" : codeMasterRepo.GetNote(CodeMasterType.Type, r.Type), CodeType = r.Type, r.Site.GeoFullName, Address = r.Site.AddressLine1 + " " + r.Site.AddressLine2, Orientation = r.Width >= r.Height ? "Horizontal" : "Vertical", Size = string.Format("{0}m x {1}m", r.Height.ToString(), r.Width.ToString()), Lighting = r.Site.FrontlitNumerOfLamps > 0 ? "Fontlit" : "Backlit", Contractor = r.Site.Contractor != null ? r.Site.Contractor.Name : "", CurrentProduct = r.ToStringProduct, CurrentClient = r.ToStringClient, r.Site.Score, AlbumID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('/')[9].Split('?')[0], AuthID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('?')[1].Split('=')[1], Added = r.Site.QuoteDetails.Where(r1 => r1.QuoteID == quoteID && r1.SiteDetailName == r.Name).Count() > 0 ? true : false, }))); }
public ActionResult Find(int campaignID = 0) { FindSite e = new FindSite(); //e.From = DateTime.Now.Date; e.CampaignID = campaignID; return(View(e)); }
public JsonResult FindJsonOutdate(FindSite e) { List <SiteDetail> l = Find(e); CodeMasterRepository codeMasterRepo = new CodeMasterRepository(); Func <Site, List <string> > f = r => { var v = r.SiteDetails.SelectMany(r1 => r1.SiteDetailPhotoes).Select(r1 => r1.Url.ToUrlPicasaPhotoResize()).ToList(); if (v.Count == 0) { v = r.SitePhotoes.Select(r1 => r1.Url.ToUrlPicasaPhotoResize()).ToList(); } return(v); }; return(Json(l.Distinct().Select(r => new { r.Site.ID, SiteDetailID = r.ID, r.Site.Lat, r.Site.Lng, Geo2 = r.Site.Geo2 != null ? r.Site.Geo2.Name : "", Geo3 = r.Site.Geo3 != null ? r.Site.Geo3.Name : "", AddressLine1 = r.Site.AddressLine1 ?? "", AddressLine2 = r.Site.AddressLine2 ?? "", Code = r.Site.Code ?? "", Type = string.IsNullOrEmpty(r.Type) ? "" : codeMasterRepo.GetNote(CodeMasterType.Type, r.Type), Contractor = r.Site.Contractor != null ? r.Site.Contractor.Name : "", LastUpdatedDate = r.Site.LastUpdatedDate.ToShortDateString(), r.Format, CodeType = r.Type, r.Site.GeoFullName, Address = r.Site.AddressLine1 + " " + r.Site.AddressLine2, Orientation = r.Width >= r.Height ? "Horizontal" : "Vertical", Size = string.Format("{0}m x {1}m", r.Height.ToString(), r.Width.ToString()), Lighting = r.Site.FrontlitNumerOfLamps > 0 ? "Fontlit" : "Backlit", CurrentProduct = r.ToStringProduct, CurrentClient = r.ToStringClient, r.Site.Score, Rating = r.Site.Score.ToRating(), AlbumID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('/')[9].Split('?')[0], AuthID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('?')[1].Split('=')[1], PhotoUrlList = new List <string>(), CategoryLevel1 = r.ToStringCategoryLevel1, CategoryLevel2 = r.ToStringCategoryLevel2, }))); }
private static List <SiteDetail> Find(FindSite e) { OAMSEntities DB = new OAMSEntities(); DB.CommandTimeout = 300; //var geo1 = DB.Geos.FirstOrDefault(r => r.Level == 1 && r.FullName == e.Geo1FullName); //Guid? geo1ID = null; //if (geo1 != null) geo1ID = geo1.ID; var l = DB.SiteDetails .Where(r => true //Find on its own properties && e.StyleList.Contains(r.Type) && (string.IsNullOrEmpty(e.Format) || r.Format == e.Format) //Find on 1 level relationship properties //&& (!e.ViewingDistance.HasValue || r.Site.ViewingDistance == e.ViewingDistance) && (string.IsNullOrEmpty(e.ViewingDistance) || r.Site.ViewingDistance == e.ViewingDistance) && (!e.InstallationPosition2.HasValue || r.Site.InstallationPosition2 == e.InstallationPosition2) && // Angle to Road (!e.RoadType2.HasValue || r.Site.RoadType2 == e.RoadType2) && //Traffic (e.ContractorList.Count == 0 || e.ContractorList.Contains(r.Site.ContractorID)) && (!e.ScoreFrom.HasValue || !e.ScoreTo.HasValue || (r.Site.Score >= e.ScoreFrom && r.Site.Score <= e.ScoreTo)) && (e.InstallationPosition1MarkList.Count == 0 || e.InstallationPosition1MarkList.Contains(r.Site.InstallationPosition1.HasValue ? r.Site.InstallationPosition1.Value : 0)) && ( (!e.NoPhotoFrom.HasValue && !e.NoPhotoTo.HasValue) || r.SiteDetailPhotoes.FirstOrDefault(r1 => r1.TakenDate.HasValue && (!e.NoPhotoFrom.HasValue || r1.TakenDate >= e.NoPhotoFrom) && (!e.NoPhotoTo.HasValue || r1.TakenDate <= e.NoPhotoTo) ) == null ) && ( (!e.HasPhotoFrom.HasValue && !e.HasPhotoTo.HasValue) || r.SiteDetailPhotoes.FirstOrDefault(r1 => r1.TakenDate.HasValue && (!e.HasPhotoFrom.HasValue || r1.TakenDate >= e.HasPhotoFrom) && (!e.HasPhotoTo.HasValue || r1.TakenDate <= e.HasPhotoTo) ) != null ) //&& (!e.HasPhotoFrom.HasValue || r.SiteDetailPhotoes.FirstOrDefault(r1 => r1.TakenDate.HasValue && r1.TakenDate >= e.HasPhotoFrom) != null) //&& (!e.HasPhotoTo.HasValue || r.SiteDetailPhotoes.FirstOrDefault(r1 => r1.TakenDate.HasValue && r1.TakenDate <= e.HasPhotoTo) != null) //&& (string.IsNullOrEmpty(e.Geo1FullName) || (r.Site.Geo1ID == geo1ID)) //Find on 2 level relationship properties && (string.IsNullOrEmpty(e.Geo1FullName) || (r.Site.Geo1 != null && r.Site.Geo1.FullName == e.Geo1FullName)) && (e.Geo2List.Count == 0 || (r.Site.Geo2 != null && e.Geo2List.Contains(r.Site.Geo2.FullName))) //Find on 3 level relationship properties && (e.ProductIDList.Count == 0 || e.ProductIDList.Intersect(r.SiteDetailMores.Select(r2 => r2.ProductID)).Count() > 0) && (e.ClientList.Count == 0 || e.ClientList.Intersect(r.SiteDetailMores.Select(r1 => r1.Product == null ? 0 : r1.Product.ClientID)).Count() > 0) && (e.CatList.Count == 0 || (e.CatList.Intersect(r.SiteDetailMores.Select(r1 => r1.Product.CategoryID1)).Count() > 0 || e.CatList.Intersect(r.SiteDetailMores.Select(r1 => r1.Product.CategoryID2)).Count() > 0 || e.CatList.Intersect(r.SiteDetailMores.Select(r1 => r1.Product.CategoryID3)).Count() > 0 ) ) ) .ToList() .Where(r => true && (!e.IsWithinCircle || Helper.DistanceBetweenPoints(r.Site.Lat, r.Site.Lng, e.Lat, e.Long) <= e.Distance) ).ToList(); return(l); }
public JsonResult FindJson(FindSite e) { //SiteRepository siteRepo = new SiteRepository(); //List<Site> l = siteRepo.GetAll().ToList() // .Where(r => // e.StyleList.Contains(r.Type) // && (e.ContractorList == null || e.ContractorList.Contains(r.ContractorID.ToInt())) // && (e.ClientList == null || e.ClientList.Contains(r.CurrentClientID.ToInt())) // //&& (e.ClientList == null || e.ClientList.Join(r.SiteDetails.Select(r1 => r1.ClientID), r1 => r1, r1 => r1.ToInt(), (r1, r2) => r1).Count() > 0) // && (e.CatList == null || e.CatList.Contains(r.CategoryID1.ToString()) || e.CatList.Contains(r.CategoryID2.ToString()) || e.CatList.Contains(r.CategoryID3.ToString())) // && (string.IsNullOrEmpty(e.Format) || r.Format == e.Format) // && (string.IsNullOrEmpty(e.RoadType1) || r.RoadType1 == e.RoadType1.ToInt()) // && (string.IsNullOrEmpty(e.RoadType2) || r.RoadType2 == e.RoadType2.ToInt()) // && (string.IsNullOrEmpty(e.InstallationPosition1) || r.InstallationPosition1 == e.InstallationPosition1.ToInt()) // && (string.IsNullOrEmpty(e.InstallationPosition2) || r.InstallationPosition2 == e.InstallationPosition2.ToInt()) // && (string.IsNullOrEmpty(e.ViewingDistance) || r.ViewingDistance == e.ViewingDistance.ToInt()) // && (string.IsNullOrEmpty(e.ViewingSpeed) || r.ViewingSpeed == e.ViewingSpeed.ToInt()) // && (string.IsNullOrEmpty(e.Height) || r.Height == e.Height.ToInt()) // && (string.IsNullOrEmpty(e.DirectionalTrafficPublicTransport) || r.DirectionalTrafficPublicTransport == e.DirectionalTrafficPublicTransport.ToInt()) // && (string.IsNullOrEmpty(e.ShopSignsBillboards) || r.ShopSignsBillboards == e.ShopSignsBillboards.ToInt()) // && (string.IsNullOrEmpty(e.FlagsTemporaryBannersPromotionalItems) || r.FlagsTemporaryBannersPromotionalItems == e.FlagsTemporaryBannersPromotionalItems.ToInt()) // && (string.IsNullOrEmpty(e.CompetitiveProductSigns) || r.CompetitiveProductSigns == e.CompetitiveProductSigns.ToInt()) // && (e.ProductList == null || e.ProductList.Match(r.CurrentProduct)) // && (string.IsNullOrEmpty(e.Geo1FullName) || (r.Geo1 != null && r.Geo1.FullName == e.Geo1FullName)) // && ((string.IsNullOrEmpty(e.Geo1FullName) && e.Geo2List == null) // || (e.Geo2List != null && (e.Geo2List.FirstOrDefault() == null || (r.Geo2 != null && e.Geo2List.Contains(r.Geo2.FullName))))) // ).ToList() // .Where(r => !e.IsWithinCircle || Helper.DistanceBetweenPoints(r.Lat, r.Lng, e.Lat, e.Long) <= e.Distance) // .ToList(); var siteDetailRepo = new SiteDetailRepository(); List <SiteDetail> l = siteDetailRepo.DB.SiteDetails.Include("Site").ToList() .Where(r => e.StyleList.Contains(r.Site.Type) && (e.ContractorList == null || e.ContractorList.Contains(r.Site.ContractorID.ToInt())) && (e.ClientList == null || e.ClientList.Contains(r.Product == null ? 0 : r.Product.ClientID.ToInt())) //&& (e.CatList == null || e.CatList.Contains(r.CategoryID1.ToString()) || e.CatList.Contains(r.CategoryID2.ToString()) || e.CatList.Contains(r.CategoryID3.ToString())) && (e.CatList == null || (r.Product != null && (e.CatList.Contains(r.Product.CategoryID1.ToString()) || e.CatList.Contains(r.Product.CategoryID2.ToString()) || e.CatList.Contains(r.Product.CategoryID3.ToString())) ) ) && (string.IsNullOrEmpty(e.Format) || r.Format == e.Format) && (string.IsNullOrEmpty(e.RoadType1) || r.Site.RoadType1 == e.RoadType1.ToInt()) && (string.IsNullOrEmpty(e.RoadType2) || r.Site.RoadType2 == e.RoadType2.ToInt()) && (string.IsNullOrEmpty(e.InstallationPosition1) || r.Site.InstallationPosition1 == e.InstallationPosition1.ToInt()) && (string.IsNullOrEmpty(e.InstallationPosition2) || r.Site.InstallationPosition2 == e.InstallationPosition2.ToInt()) && (string.IsNullOrEmpty(e.ViewingDistance) || r.Site.ViewingDistance == e.ViewingDistance.ToInt()) && (string.IsNullOrEmpty(e.ViewingSpeed) || r.Site.ViewingSpeed == e.ViewingSpeed.ToInt()) && (string.IsNullOrEmpty(e.Height) || r.Site.Height == e.Height.ToInt()) && (string.IsNullOrEmpty(e.DirectionalTrafficPublicTransport) || r.Site.DirectionalTrafficPublicTransport == e.DirectionalTrafficPublicTransport.ToInt()) && (string.IsNullOrEmpty(e.ShopSignsBillboards) || r.Site.ShopSignsBillboards == e.ShopSignsBillboards.ToInt()) && (string.IsNullOrEmpty(e.FlagsTemporaryBannersPromotionalItems) || r.Site.FlagsTemporaryBannersPromotionalItems == e.FlagsTemporaryBannersPromotionalItems.ToInt()) && (string.IsNullOrEmpty(e.CompetitiveProductSigns) || r.Site.CompetitiveProductSigns == e.CompetitiveProductSigns.ToInt()) //&& (e.ProductList == null || e.ProductList.Match(r.Product)) && (e.ProductList == null || e.ProductList.Match(r.Product == null ? "" : r.Product.Name)) && (r.Site.Score.ToInt() >= e.ScoreFrom.ToInt() && r.Site.Score.ToInt() <= e.ScoreTo.ToInt()) && (string.IsNullOrEmpty(e.Geo1FullName) || (r.Site.Geo1 != null && r.Site.Geo1.FullName == e.Geo1FullName)) && ((string.IsNullOrEmpty(e.Geo1FullName) && e.Geo2List == null) || (e.Geo2List != null && (e.Geo2List.FirstOrDefault() == null || (r.Site.Geo2 != null && e.Geo2List.Contains(r.Site.Geo2.FullName))))) ).ToList() .Where(r => !e.IsWithinCircle || Helper.DistanceBetweenPoints(r.Site.Lat, r.Site.Lng, e.Lat, e.Long) <= e.Distance) .ToList(); CodeMasterType cmt = new CodeMasterType(); CodeMasterRepository codeMasterRepo = new CodeMasterRepository(); return(Json(l.Distinct().Select(r => new { r.Site.ID, r.Site.Lat, r.Site.Lng, AddressLine1 = r.Site.AddressLine1 ?? "", AddressLine2 = r.Site.AddressLine2 ?? "", Code = r.Site.Code ?? "", r.Format, Type = string.IsNullOrEmpty(r.Site.Type) ? "" : codeMasterRepo.GetNote(cmt.Type, r.Site.Type), CodeType = r.Site.Type, r.Site.GeoFullName, Address = r.Site.AddressLine1 + " " + r.Site.AddressLine2, Orientation = r.Site.Width >= r.Site.Height ? "Horizontal" : "Vertical", Size = string.Format("{0}m x {1}m", r.Site.Height.ToString(), r.Site.Width.ToString()), Lighting = r.Site.FrontlitNumerOfLamps > 0 ? "Fontlit" : "Backlit", Contractor = r.Site.Contractor != null ? r.Site.Contractor.Name : "", CurrentProduct = r.Product == null ? "" : (r.Product.Name ?? ""), CurrentClient = r.Product == null ? "" : (r.Product.Client == null ? "" : (r.Product.Client.Name ?? "")), r.Site.Score, Rating = r.Site.Score.ToRating(), AlbumID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('/')[9].Split('?')[0], AuthID = string.IsNullOrEmpty(r.Site.AlbumUrl) ? "" : r.Site.AlbumUrl.Split('?')[1].Split('=')[1], CategoryLevel1 = r.Product == null ? "" : (r.Product.Category1 != null ? r.Product.Category1.Name : ""), CategoryLevel2 = r.Product == null ? "" : (r.Product.Category2 != null ? r.Product.Category2.Name : ""), Geo2 = r.Site.Geo2 != null ? r.Site.Geo2.Name : "", Geo3 = r.Site.Geo3 != null ? r.Site.Geo3.Name : "" }))); }