public Task <IActionResult> GetAllSortedFiltered([FromBody] FilterInput input) { return(Task.Run <IActionResult>(() => { var roles = _db.All <Role>(); var count = _db.All <User>() .ToList() .Count; var data = _db.All <User>() .Skip(input.Size * (input.Start - 1)) .Take(input.Size) .ToArray() .Select(x => new FilteredUser { Id = x.Id, Role = roles.Single(y => y.Id == x.RoleId).Name, Username = x.Username, Active = x.IsActive, Validated = x.Validated }) .ToArray(); return Ok(new { success = true, result = new FilteredData <FilteredUser> { Total = count, Data = data } }); })); }
/// <summary> /// Returns <see cref="PhpArray"/> containing required input. /// </summary> /// <param name="context">CUrrent <see cref="ScriptContext"/>.</param> /// <param name="type"><see cref="FilterInput"/> value.</param> /// <returns>An instance of <see cref="PhpArray"/> or <c>null</c> if there is no such input.</returns> private static PhpArray GetArrayByInput(Context /*!*/ context, FilterInput type) { PhpArray arrayobj = null; switch (type) { case FilterInput.Get: arrayobj = context.Get; break; case FilterInput.Post: arrayobj = context.Post; break; case FilterInput.Server: arrayobj = context.Server; break; case FilterInput.Request: arrayobj = context.Request; break; case FilterInput.Env: arrayobj = context.Env; break; case FilterInput.Cookie: arrayobj = context.Cookie; break; case FilterInput.Session: arrayobj = context.Session; break; default: return(null); } // cast arrayobj to PhpArray if possible: return(arrayobj); }
public HttpResponseMessage LoadUserDataByFilter(FilterInput filterInput) { string json = Newtonsoft.Json.JsonConvert.SerializeObject(filterInput); string hash = GetMd5Hash(json); return(Request.CreateResponse <string>(HttpStatusCode.OK, hash)); }
public void Filter_WhenSingleFilterInputIsNull_ShouldReturnPrimaryQueryable() { FilterInput filterInput = null; var queryable = Mock.QueryableItems.Filter(filterInput); Assert.Equal(queryable, Mock.QueryableItems); }
private static Expression MultipleValueHandleExpression <T>(FilterInput filterInput, ParameterExpression parameter) { var timer = Stopwatch.StartNew(); Expression valueArrayExpression = null; var isJarray = JArrayUtil.IsJArray(filterInput.Value); var values = filterInput.Value as IEnumerable <object>; if (values == null) { return(Expression.Empty()); } foreach (var value in values) { filterInput.Value = isJarray ? ((JValue)value).Value : value; if (valueArrayExpression == null) { valueArrayExpression = FilterExpression <T>(filterInput, parameter); continue; } if (filterInput.Operation == OperationTypeEnum.NotEqual) { valueArrayExpression = Expression.AndAlso(valueArrayExpression, FilterExpression <T>(filterInput, parameter)); } else { valueArrayExpression = Expression.OrElse(valueArrayExpression, FilterExpression <T>(filterInput, parameter)); } } timer.Stop(); Trace.Write(timer.ElapsedTicks); return(valueArrayExpression); }
public Task <IActionResult> Filter([FromBody] FilterInput input) { return(Task.Run <IActionResult>(() => { var count = _db.All <Role>() .ToList() .Count; var data = _db.All <Role>() .Skip(input.Size * (input.Start - 1)) .Take(input.Size) .Select(x => new FilteredRole { Id = x.Id, Name = x.Name, Permissions = x.Permissions.Length }) .ToArray(); return Ok(new { success = true, result = new FilteredData <FilteredRole> { Total = count, Data = data } }); })); }
/// <summary> /// Returns <see cref="PhpArray"/> containing required input. /// </summary> /// <param name="context">CUrrent <see cref="ScriptContext"/>.</param> /// <param name="type"><see cref="FilterInput"/> value.</param> /// <returns>An instance of <see cref="PhpArray"/> or <c>null</c> if there is no such input.</returns> private static PhpArray GetArrayByInput(ScriptContext /*!*/ context, FilterInput type) { object arrayobj = null; switch (type) { case FilterInput.Get: arrayobj = context.AutoGlobals.Get.Value; break; case FilterInput.Post: arrayobj = context.AutoGlobals.Post.Value; break; case FilterInput.Server: arrayobj = context.AutoGlobals.Server.Value; break; case FilterInput.Request: arrayobj = context.AutoGlobals.Request.Value; break; case FilterInput.Env: arrayobj = context.AutoGlobals.Env.Value; break; case FilterInput.Cookie: arrayobj = context.AutoGlobals.Cookie.Value; break; case FilterInput.Session: arrayobj = context.AutoGlobals.Session.Value; break; default: return(null); } // cast arrayobj to PhpArray if possible: return(PhpArray.AsPhpArray(arrayobj)); }
protected void PopulateReports(FilterInput filterInput) { DBContext db = null; try { db = new DBContext(); // Get the collection Reports = (from bank in db.Banks join card in db.MoneyCards on bank.MoneyCardId equals card.MoneyCardId join user in db.Users on card.UserId equals user.UserId join company in db.Companies on card.CompanyId equals company.CompanyId where (company.CompanyId == filterInput.CompanyId && bank.OrderTime >= filterInput.StartDate && bank.OrderTime <= filterInput.EndDate) group bank by new { user.UserId, user.UserFullName, card.LastFourDigits } into report select new Report { UserId = report.Key.UserId, UserFullName = report.Key.UserFullName, Pan = report.Key.LastFourDigits, TotalVolume = report.Sum(b => b.TxValue) }).ToList(); } catch (Exception ex) { Publish(ex, "Error while loading entries."); } }
public List <BuildEntity> Execute(FilterInput input) { var all = _buildsProvider.GetBuilds(); var toRemoveBuilds = _buildsProvider.GetBuilds(); var whitelisted = _whitelistProvider.Get(); bool daysSelected = input.BeforeDays != null; bool countSelected = input.ExcludeNLast != null; if (input.UseWhiteList) { var whitelistBuilds = FilterBy.GetBuildsToRemoveByWhiteList(toRemoveBuilds, whitelisted); toRemoveBuilds = toRemoveBuilds.Intersect(whitelistBuilds, BuildEntityComparer.Instance); } if (daysSelected) { var daysBuilds = FilterBy.GetBuildsToRemoveOlderThan(all, input.BeforeDays.GetValueOrDefault()); toRemoveBuilds = toRemoveBuilds.Intersect(daysBuilds, BuildEntityComparer.Instance); } if (countSelected) { var numberBuilds = FilterBy.GetBuildsToRemoveExceptNLast(all, input.ExcludeNLast.GetValueOrDefault()); toRemoveBuilds = toRemoveBuilds.Intersect(numberBuilds, BuildEntityComparer.Instance); } return(toRemoveBuilds.ToList()); }
public Task <IActionResult> Filter([FromBody] FilterInput input) { return(Task.Run <IActionResult>(() => { var count = _db.All <ApiResource>() .ToList() .Count; var data = _db.All <ApiResource>() .Skip(input.Size * (input.Start - 1)) .Take(input.Size) .Select(x => new FilteredResource { Name = x.Name, DisplayName = x.DisplayName }) .ToArray(); return Ok(new { success = true, result = new FilteredData <FilteredResource> { Total = count, Data = data } }); })); }
private void LoadManifestations(string filterTarget) { AvailableMaifs = new ObservableCollection <Manifestation>(); ManifsOnMap = new ObservableCollection <Manifestation>(); bool manifOnMap; foreach (Manifestation manif in Repository.GetInstance().Manifestations) { if (manif.MapCoordinates == null) { continue; } if (!manif.Id.Contains(filterTarget) && !manif.Name.Contains(filterTarget)) { continue; } manifOnMap = false; foreach (Coordinates coords in manif.MapCoordinates) { if (coords.ParentMap.Id == MapToShow.Id) { ManifsOnMap.Add(manif); manifOnMap = true; break; } } if (!manifOnMap) { AvailableMaifs.Add(manif); } } drawManifPointers(); FilterInput.Focus(); }
public async Task <IActionResult> BuscarVagasFiltro(FilterInput input, long usuarioId) { if (string.IsNullOrEmpty(input.Filter)) { return(StatusCode(400, "O filtro não pode estar vázio.")); } else { var usuarioDb = _usuarioRepository.GetById(usuarioId); if (usuarioDb == null) { return(StatusCode(400, $"Este Id de usuário [{usuarioId}] não existe")); } var usuarioCandidatoDb = _usuarioCandidatoAlunoRepository.GetByUsuarioId(usuarioDb.Id); if (usuarioCandidatoDb == null) { return(StatusCode(401, "Este usuário não tem um perfil de candidato.")); } var vagas = _vagaQueries.BuscarVagasPorFiltro(input.Filter, usuarioCandidatoDb.Id); // Busca statusVaga encerrado no BD var statusVagaEncerradaDb = _statusVagaRepository.GetByDescricao(StatusVagaDefaultValuesAcess.GetValue(StatusVagaDefaultValues.VagaEncerrada)); // ForEach para verificar a data de encerramento da vaga foreach (var vaga in vagas.ToList()) { if (DateTime.Now.ToUniversalTime() > vaga.DataEncerramento.ToUniversalTime()) { try { // Busca a vaga DOMAIN na DB, pois as vagas buscadas são ViewModels var vagaDomainDb = _vagaRepository.GetById(vaga.Id); // Altera Status da vaga para encerrada vagaDomainDb.AlterarStatusVaga(statusVagaEncerradaDb.Id); // Altera vaga no DB _vagaRepository.UpdateVaga(vagaDomainDb); } catch (Exception) { return(StatusCode(500, "Houve um erro interno ao alterar o Status da Vaga.")); } // Remove vagas encerradas da lista vagas.Remove(vaga); } } // Salva qualquer alteração na DB caso houver await _vagaRepository.UnitOfWork.SaveDbChanges(); return(StatusCode(200, vagas)); } }
public void Init() { // Initialize properties in this class Companies = new List <Company>(); Reports = new List <Report>(); ChartJson = string.Empty; FilterInput = new FilterInput(); }
public MapView() { InitializeComponent(); DataContext = this; AvailableMaifs = new ObservableCollection <Manifestation>(); ManifsOnMap = new ObservableCollection <Manifestation>(); FilterInput.Focus(); }
public async Task <IEnumerable <Log> > GetFiltered(FilterInput input) { var log = await _context.Log .Where(x => string.IsNullOrEmpty(input.Ip)?true : x.IP == input.Ip) .Where(x => string.IsNullOrEmpty(input.User) ? true : x.UserId.ToString() == input.User) .ToListAsync(); return(log); }
public LabelsView() { InitializeComponent(); SelectedLabel = null; DataContext = this; Labels = Repository.GetInstance().Labels; FilterInput.Focus(); }
public ManifestationTypesView() { InitializeComponent(); SelectedManifestationType = null; DataContext = this; Types = Repository.GetInstance().ManifestationTypes; FilterInput.Focus(); }
public ManifestationsView(MainWindow parent) { InitializeComponent(); SelectedManifestation = null; DataContext = this; Manifestations = Repository.GetInstance().Manifestations; mainWindow = parent; FilterInput.Focus(); }
public static object filter_input(ScriptContext /*!*/ context, FilterInput type, string variable_name, int filter /*= FILTER_DEFAULT*/, object options) { var arrayobj = GetArrayByInput(context, type); object value; if (arrayobj == null || !arrayobj.TryGetValue(variable_name, out value)) { return(null); } return(filter_var(value, filter, options)); }
public async Task <ActionResult <IEnumerable <Log> > > GetLog(string ip, string user) { var filter = new FilterInput(); if (ip != "0") { filter.Ip = ip; } filter.User = user; return(Ok(await _service.GetFiltered(filter))); }
/// <summary> /// Checks if variable of specified type exists /// </summary> public static bool filter_has_var(Context /*!*/ context, FilterInput type, string variable_name) { var arrayobj = GetArrayByInput(context, type); if (arrayobj != null) { return(arrayobj.ContainsKey(variable_name)); } else { return(false); } }
public static IQueryable <T> Filter <T>(IQueryable <T> dataInput, FilterInput filterInput) { var parameter = Expression.Parameter(typeof(T), "p"); if (filterInput.Value is IEnumerable <object> ) { var valueArrayExpression = MultipleValueHandleExpression <T>(filterInput, parameter); if (valueArrayExpression != null) { return(dataInput.Where(Expression.Lambda <Func <T, bool> >(valueArrayExpression, parameter))); } } return(dataInput.Where(Expression.Lambda <Func <T, bool> >(FilterExpression <T>(filterInput, parameter), parameter))); }
/// <summary> /// Gets a specific external variable by name and optionally filters it. /// </summary> public static PhpValue filter_input(Context /*!*/ context, FilterInput type, string variable_name, int filter, PhpValue options) { var arrayobj = GetArrayByInput(context, type); PhpValue value; if (arrayobj == null || !arrayobj.TryGetValue(variable_name, out value)) { return(PhpValue.Null); } else { return(filter_var(context, value, filter, options)); } }
// Public Methods public static void PhpMain() { int compression = FilterInput.ValidateInt(FilterInput.Type.Get, "compression", IntFlags.AllowHex, new IntOptions() { Default = 90 }).Value; if (Script.Get.ContainsKey("format") && Script.Get["format"] == "jpg") { CreateImage(true, compression); } else { CreateImage(false, compression); } }
public void Filter_WhenSingleFilterWithSingleInputIsPassed_ShouldReturnFilteredQueryable() { FilterInput filterInput = new FilterInput() { Operation = OperationTypeEnum.NotEqual, Property = "Date", Value = "2017/04/07", Type = InputTypeEnum.String }; var filteredResult = Mock.QueryableItems.Filter(filterInput); var normalResult = Mock.QueryableItems.Where(p => string.Compare(p.Date, "2017/04/07") != 0); AssertUtil.EnumarableAreEqual(filteredResult, normalResult); }
public static void Filters() { var a = FilterVar.ValidateIp(Script.Get["ipAddress"]); var b = FilterVar.ValidateIp(Script.Get["ipAddress"], IpFlags.IpV4 | IpFlags.IpV6); var defaultValue = new IpOptions() { Default = "1.2.3.4" }; //defaultValue.Default = "255.255.255.255"; var c1 = FilterVar.ValidateIp(Script.Get["ipAddress"], IpFlags.IpV4 | IpFlags.IpV6, defaultValue); var c = FilterVar.ValidateIp(Script.Get["ipAddress"], IpFlags.IpV4 | IpFlags.IpV6, new IpOptions { Default = "1.2.3.4" }); var d = FilterVar.ValidateBoolean(Script.Post["aaa"]); var e = FilterVar.ValidateBoolean(Script.Post["aaa"], false); var clientIp = FilterInputServer.ValidateIp(ServerVariables.HttpClientIp); var other = FilterInput.ValidateIp(FilterInput.Type.Get, "Somename", IpFlags.IpV4); }
public async Task <Result> FilteredList([FromBody] FilterInput filters) { Result rslt = new Result(); try { rslt.Data = await _postRepository.GetFilteredList(filters); rslt.Status = 1; rslt.Message = "Success"; } catch (Exception ex) { rslt.Status = 0; rslt.Message = ex.Message; Log.Error(ex, "FilteredList"); } return(rslt); }
public static List <FilterInput> getFilterInputs(List <FieldSchema> fieldDefs) { List <FilterInput> ret = new List <FilterInput>(); foreach (FieldSchema col in fieldDefs) { if (col.DataType == DbType.Binary) { continue; } //if (col.DataType.Equals(typeof(System.String))) continue; FilterInput fi = new FilterInput(); fi.field = col.Id; fi.options = new FilterOption(); fi.op = FilterInput.BigTextOP; ret.Add(fi); } return(ret); }
private static List <FilterInput> getFilterInputs(string connName, List <FieldDef> fields) { List <FilterInput> ret = new List <FilterInput>(); foreach (FieldDef col in fields) { if (DatabaseAdmin.getInstance(connName).getDbType(col.Type) == DbType.Binary) { continue; } //if (col.DataType.Equals(typeof(System.String))) continue; FilterInput fi = new FilterInput(); fi.field = col.Name; fi.options = new FilterOption(); fi.op = FilterInput.BigTextOP; ret.Add(fi); } return(ret); }
public Task <IActionResult> Filter([FromBody] FilterInput input) { return(Task.Run <IActionResult>(() => { var count = _db.All <Client>() .ToList() .Count; var data = _db.All <Client>() .Skip(input.Size * (input.Start - 1)) .Take(input.Size) .ToArray() .Select(x => { x.Properties.TryGetValue("permissions", out var permissions); var permissionsData = JsonConvert.DeserializeObject <List <string> >(permissions ?? "[]").ToArray(); return new FilteredClient { ClientId = x.ClientId, ClientName = x.ClientName, Permissions = permissionsData.Length, AllowedScopes = string.Join(", ", x.AllowedScopes), AllowedGrantTypes = string.Join(", ", x.AllowedGrantTypes), AllowOfflineAccess = x.AllowOfflineAccess }; }) .ToArray(); return Ok(new { success = true, result = new FilteredData <FilteredClient> { Total = count, Data = data } }); })); }
public FubuContinuation Filter(FilterInput input) { return FubuContinuation.NextBehavior(); }
public static object filter_input(ScriptContext/*!*/context, FilterInput type, string variable_name) { return filter_input(context, type, variable_name, (int)FilterSanitize.FILTER_DEFAULT, null); }
public static object filter_input(ScriptContext/*!*/context, FilterInput type, string variable_name, int filter) { return filter_input(context, type, variable_name, filter, null); }
public static object filter_input(ScriptContext/*!*/context, FilterInput type, string variable_name, int filter /*= FILTER_DEFAULT*/ , object options) { var arrayobj = GetArrayByInput(context, type); object value; if (arrayobj == null || !arrayobj.TryGetValue(variable_name, out value)) return null; return filter_var(value, filter, options); }
public static bool filter_has_var(ScriptContext/*!*/context, FilterInput type, string variable_name) { var arrayobj = GetArrayByInput(context, type); if (arrayobj != null) return arrayobj.ContainsKey(variable_name); else return false; }
/// <summary> /// Returns <see cref="PhpArray"/> containing required input. /// </summary> /// <param name="context">CUrrent <see cref="ScriptContext"/>.</param> /// <param name="type"><see cref="FilterInput"/> value.</param> /// <returns>An instance of <see cref="PhpArray"/> or <c>null</c> if there is no such input.</returns> private static PhpArray GetArrayByInput(ScriptContext/*!*/context, FilterInput type) { object arrayobj = null; switch (type) { case FilterInput.Get: arrayobj = context.AutoGlobals.Get.Value; break; case FilterInput.Post: arrayobj = context.AutoGlobals.Post.Value; break; case FilterInput.Server: arrayobj = context.AutoGlobals.Server.Value; break; case FilterInput.Request: arrayobj = context.AutoGlobals.Request.Value; break; case FilterInput.Env: arrayobj = context.AutoGlobals.Env.Value; break; case FilterInput.Cookie: arrayobj = context.AutoGlobals.Cookie.Value; break; case FilterInput.Session: arrayobj = context.AutoGlobals.Session.Value; break; default: return null; } // cast arrayobj to PhpArray if possible: return PhpArray.AsPhpArray(arrayobj); }