static void Main() { Location location1 = GetEnity(22.641766, 113.922681, DateTime.Now); Location location2 = GetEnity(22.641866, 113.922881, DateTime.Now.AddMinutes(1)); Location location3 = GetEnity(22.642866, 113.925881, DateTime.Now.AddMinutes(2)); Location location4 = GetEnity(22.642866, 113.922881, DateTime.Now.AddMinutes(3)); Location location5 = GetEnity(22.641866, 113.922881, DateTime.Now.AddMinutes(4)); Location location6 = GetEnity(22.642866, 113.932881, DateTime.Now.AddMinutes(6)); List <Location> lists = new List <Location>(); lists.Add(location1); lists.Add(location2); lists.Add(location3); lists.Add(location4); lists.Add(location5); lists.Add(location6); Location outLoc = null; List <int> listDistance = new List <int>(); for (int i = 0; i < lists.Count; i++) { FilterLocation.Filter3Point(lists.Skip(i).Take(5).ToList(), out outLoc); } }
/// <summary> /// Заполняет фильтры уникальными значениями свойств. /// </summary> public static void GetFilters() { // Очистить все фильтры. FilterOtv.Clear(); FilterNewOtv.Clear(); FilterUser.Clear(); FilterLocation.Clear(); FilterPodrazdelenie.Clear(); FilterTypeOs.Clear(); FilterSostoyanie.Clear(); FilterDate.Clear(); FilterOtdel.Clear(); FilterTypeInvNumn.Clear(); FilterStatusRec.Clear(); // Добавить во все фильтры пункты Все и Пустые значения. FilterOtv.Add("Все"); FilterOtv.Add("Пустые значения"); FilterNewOtv.Add("Все"); FilterNewOtv.Add("Пустые значения"); FilterUser.Add("Все"); FilterUser.Add("Пустые значения"); FilterLocation.Add("Все"); FilterLocation.Add("Пустые значения"); FilterPodrazdelenie.Add("Все"); FilterPodrazdelenie.Add("Пустые значения"); FilterTypeOs.Add("Все"); FilterTypeOs.Add("Пустые значения"); FilterSostoyanie.Add("Все"); FilterSostoyanie.Add("Пустые значения"); FilterDate.Add("Все"); FilterDate.Add("Пустые значения"); FilterOtdel.Add("Все"); FilterOtdel.Add("Пустые значения"); FilterStatusRec.Add("Все"); FilterStatusRec.Add("Пустые значения"); FilterTypeInvNumn.Add("Все"); foreach (object o in ForWorks.viewSource.View) { if (o is OS obj) { if (!FilterOtv.Contains(obj.Otvetstvenniy) && !string.IsNullOrWhiteSpace(obj.Otvetstvenniy)) { FilterOtv.Add(obj.Otvetstvenniy); } if (!FilterNewOtv.Contains(obj.NewOtv) && !string.IsNullOrWhiteSpace(obj.NewOtv)) { FilterNewOtv.Add(obj.NewOtv); } if (!FilterUser.Contains(obj.User) && !string.IsNullOrWhiteSpace(obj.User)) { FilterUser.Add(obj.User); } if (!FilterLocation.Contains(obj.Location) && !string.IsNullOrWhiteSpace(obj.Location)) { FilterLocation.Add(obj.Location); } if (!FilterPodrazdelenie.Contains(obj.Podrazdelenie) && !string.IsNullOrWhiteSpace(obj.Podrazdelenie)) { FilterPodrazdelenie.Add(obj.Podrazdelenie); } if (!FilterTypeOs.Contains(obj.TypeOs) && !string.IsNullOrWhiteSpace(obj.TypeOs)) { FilterTypeOs.Add(obj.TypeOs); } if (!FilterSostoyanie.Contains(obj.Sostoyanie) && !string.IsNullOrWhiteSpace(obj.Sostoyanie)) { FilterSostoyanie.Add(obj.Sostoyanie); } if (!FilterDate.Contains(obj.DatePostanovki) && !string.IsNullOrWhiteSpace(obj.DatePostanovki)) { FilterDate.Add(obj.DatePostanovki); } if (!FilterOtdel.Contains(obj.Otdel) && !string.IsNullOrWhiteSpace(obj.Otdel)) { FilterOtdel.Add(obj.Otdel); } if (!FilterStatusRec.Contains(obj.StatusRec) && !string.IsNullOrWhiteSpace(obj.StatusRec)) { FilterStatusRec.Add(obj.StatusRec); } if (obj.InvNum.StartsWith("29600") && !FilterTypeInvNumn.Contains("Деловые линии")) { FilterTypeInvNumn.Add("Деловые линии"); } if (obj.InvNum.StartsWith("296CC") && !FilterTypeInvNumn.Contains("КЦ")) { FilterTypeInvNumn.Add("КЦ"); } if (obj.InvNum.StartsWith("6000") && !FilterTypeInvNumn.Contains("ДЛ Транс")) { FilterTypeInvNumn.Add("ДЛ Транс"); } if (obj.InvNum.StartsWith("11100") && !FilterTypeInvNumn.Contains("Гет Карго")) { FilterTypeInvNumn.Add("Гет Карго"); } } } }
public void RemoveFilter(FilterLocation filterLocation, IHttpHandler filterToRemove) { ((filterLocation == FilterLocation.Before) ? _beforeFilters : _afterFilters).Remove(filterToRemove); }
// GET: Burials (filters and sorts) public IActionResult Index(string sortString, string filterId, int pageNum = 1) { int pageSize = 5; //ViewBag.LocationNS = locationNS; var role = wantContext.UserRoles .Where(r => r.UserId == userManager.GetUserId(User)) .FirstOrDefault(); if (!(role is null)) { ViewBag.Role = Int32.Parse(role.RoleId); } //var partialResult = (from b in _context.Burial // join bsquare in _context.BurialSquare // on b.BurialSquareId equals bsquare.BurialSquareId // select new JoinBurialSquareViewModel // { // Burials = b, // BurialSquare = bsquare, // }) // .Where(x => x.BurialSquare.BurialLocationNs == locationNS || locationNS == null) // .Skip((pageNum - 1) * pageSize) // .Take(pageSize) // .ToList(); var queryFilter = (from b in _context.Burial join bsquare in _context.BurialSquare on b.BurialSquareId equals bsquare.BurialSquareId select new JoinBurialSquareViewModel { Burials = b, BurialSquare = bsquare, }); var test = _context.Burial; //Filter var filterLoc = new FilterLocation(filterId); ViewBag.FilterString = filterId; ViewBag.FilterLoc = filterLoc; ViewBag.LocationNStemp = _context.BurialSquare .Select(b => b.BurialLocationNs) .Distinct() .ToList(); ViewBag.LowPairNs = _context.BurialSquare .Select(b => b.LowPairNs) .Distinct() .ToList(); ViewBag.HighPairNs = _context.BurialSquare .Select(b => b.HighPairNs) .Distinct() .ToList(); ViewBag.LocationEw = _context.BurialSquare .Select(b => b.BurialLocationEw) .Distinct() .ToList(); ViewBag.LowPairEw = _context.BurialSquare .Select(b => b.LowPairEw) .Distinct() .ToList(); ViewBag.HighPairEw = _context.BurialSquare .Select(b => b.HighPairEw) .Distinct() .ToList(); ViewBag.SubPlotFilter = _context.BurialQuadrant .Select(b => b.BurialSubplot) .Distinct() .ToList(); ViewBag.Gender = _context.Burial .Select(b => b.GenderGe) .Distinct() .ToList(); ViewBag.HeadDirection = _context.Burial .Where(b => b.HeadDirection != null) .Select(b => b.HeadDirection) .Distinct() .ToList(); ViewBag.AdultChild = _context.Burial .Select(b => b.BurialAdult) .Distinct() .ToList(); if (filterLoc.HasLocationNs) { queryFilter = queryFilter.Where(b => b.BurialSquare.BurialLocationNs == filterLoc.LocationNs); } if (filterLoc.HasLowPairNs) { queryFilter = queryFilter.Where(b => b.BurialSquare.LowPairNs.ToString() == filterLoc.LowPairNs); } if (filterLoc.HasHighPairNs) { queryFilter = queryFilter.Where(b => b.BurialSquare.HighPairNs.ToString() == filterLoc.HighPairNs); } if (filterLoc.HasLocationEw) { queryFilter = queryFilter.Where(b => b.BurialSquare.BurialLocationEw == filterLoc.LocationEw); } if (filterLoc.HasLowPairEw) { queryFilter = queryFilter.Where(b => b.BurialSquare.LowPairEw.ToString() == filterLoc.LowPairEw); } if (filterLoc.HasHighPairEw) { queryFilter = queryFilter.Where(b => b.BurialSquare.HighPairEw.ToString() == filterLoc.HighPairEw); } if (filterLoc.HasSubPlot) { queryFilter = queryFilter.Where(b => b.Burials.BurialSubplot == filterLoc.SubPlotFilter); } if (filterLoc.HasGender) { queryFilter = queryFilter.Where(b => b.Burials.GenderGe == filterLoc.Gender); } if (filterLoc.HasHeadDirection) { if (filterLoc.HeadDirection == "blank") { queryFilter = queryFilter.Where(b => b.Burials.HeadDirection == null); } else { queryFilter = queryFilter.Where(b => b.Burials.HeadDirection == filterLoc.HeadDirection); } } if (filterLoc.HasAdultChild) { queryFilter = queryFilter.Where(b => b.Burials.BurialAdult == bool.Parse(filterLoc.AdultChild)); } //var mummyContext = _context.Burial.Include(b => b.BurialS).Include(b => b.BurialSquare); //ViewBag.mummy = mummyContext // .ToList(); return(View(new BurialsViewModel { JoinBurialSquareViewModel = queryFilter .Skip((pageNum - 1) * pageSize) .Take(pageSize) .ToList(), PageNumberingInfo = new PageNumberingInfo { NumItemsPerPage = pageSize, CurrentPage = pageNum, Query = filterId, TotalNumItems = queryFilter.Count() }, })); }
public void AddFilter(FilterLocation filterLocation, IHttpHandler newFilter) { ((filterLocation == FilterLocation.Before) ? _beforeFilters : _afterFilters).Add(newFilter); }