private DataSourceLoadOptionsBase DxLoad(Func <string, string> valueSource) { var loadOptions = new DataSourceLoadOptionsBase(); DataSourceLoadOptionsParser.Parse(loadOptions, valueSource); return(loadOptions); }
private async Task ExportResult(string format, DataSourceLoadOptionsBase dataOptions, HttpContext context) { XtraReport report = new XtraReport(); dataOptions.Skip = 0; dataOptions.Take = 0; var loadedData = DataSourceLoader.Load(await weatherForecastService.GetForecastAsync(), dataOptions); report.DataSource = loadedData.data.Cast <WeatherForecast>(); ReportHelper.CreateReport(report, new string[] { "TemperatureC", "TemperatureF", "Summary", "Date" }); await new TaskFactory().StartNew(() => { report.CreateDocument(); using (MemoryStream fs = new MemoryStream()) { if (format == pdf) { report.ExportToPdf(fs); } else if (format == xlsx) { report.ExportToXlsx(fs); } else if (format == docx) { report.ExportToDocx(fs); } context.Response.Clear(); context.Response.Headers.Append("Content-Type", "application/" + format); context.Response.Headers.Append("Content-Transfer-Encoding", "binary"); context.Response.Headers.Append("Content-Disposition", "attachment; filename=ExportedDocument." + format); context.Response.Body.WriteAsync(fs.ToArray(), 0, fs.ToArray().Length); return(context.Response.CompleteAsync()); } }); }
//NOTIFICACIONES public async Task <ActionResult> BusquedaNotificaciones_Bandeja(DataSourceLoadOptionsBase loadOptions) { try { string baseUrl = configuration.GetSection("AppSettings").GetSection("Servicio").Value; var listadoResponseMessage = await new NotificacionBus().ListaNotificacionB(baseUrl); if (listadoResponseMessage != null) { if (listadoResponseMessage.IsSuccessStatusCode) { ICollection <NotificacionBanResponse> listadoNot = JsonConvert.DeserializeObject <ICollection <NotificacionBanResponse> >(listadoResponseMessage.Content.ReadAsStringAsync().Result); //return Json(new { data = listadoPT }); //return NewtonsoftJson(await DataSourceLoader.LoadAsync(listadoPT, loadOptions)); return(NewtonsoftJson(listadoNot)); } } } catch (Exception ex) { Console.Write("Error" + ex.Message); } return(Content("Ups! Un error ocurrio")); }
public object load([FromRoute] string dvoFullName, [FromQuery] DataSourceLoadOptionsBase options) { var type = Assembly.GetEntryAssembly().GetType(dvoFullName); var viewAttr = (ViewAttribute)type.GetCustomAttribute(typeof(ViewAttribute)); var dbSet = this.getEntityByName(viewAttr.entity); return(DataSourceLoader.Load(dbSet, options)); }
public async Task <LoadResult> GetRoles(DataSourceLoadOptionsBase loadOptions) { using var unitOfWork = UnitOfWorkFactory(); _roleRepository = unitOfWork.Repository <Role>(); var owners = await _roleRepository.GetRoles(); return(LoadCustom(owners, loadOptions)); }
public async Task <LoadResult> GetAccessControls(DataSourceLoadOptionsBase loadOptions) { using var unitOfWork = UnitOfWorkFactory(); _accessControlRepository = unitOfWork.Repository <AccessControl>(); var source = (await _accessControlRepository.GetAllAsync()).ToList(); return(LoadCustom(source, loadOptions)); }
public async Task <LoadResult> GetAllLeaguers(DataSourceLoadOptionsBase loadOptions) { using var unitOfWork = UnitOfWorkFactory(); _leaguerRepository = unitOfWork.Repository <Leaguer>(); var source = await _leaguerRepository.GetAllLeaguers(unitOfWork.CurrentUser.UnitId); return(LoadCustom(source, loadOptions)); }
public async Task <LoadResult> GetChangeOfficialDocuments(DataSourceLoadOptionsBase loadOptions) { using var unitOfWork = UnitOfWorkFactory(); _changeOfficialDocument = unitOfWork.Repository <ChangeOfficialDocument>(); var source = (await _changeOfficialDocument.GetAllAsync()).ToList(); return(LoadCustom(source, loadOptions)); }
public async Task <LoadResult> DataSourceLoadAsync(DataSourceLoadOptionsBase loadOptions) { using (var uow = _uowFactory.CreateUnitOfWork()) { return(await DataSourceLoader.LoadAsync( uow.CreateRepository <IWordRepository>().GetContext().Words, loadOptions)); } }
public async Task <IActionResult> ListadoCabecera(DataSourceLoadOptionsBase loadOptions) { try { var maeCargaActividadBus = new McmaeCargaForDosBus(); string baseUrl = this.configuration.GetSection("AppSettings").GetSection("Servicio").Value; var maeCargaActividadRequest = new McmaeCargaForDosListadoRequest { Activo = true }; var maeCargaActividadListadoResponse = await maeCargaActividadBus.BusquedaCabecera(maeCargaActividadRequest, baseUrl); if (maeCargaActividadListadoResponse != null) { if (maeCargaActividadListadoResponse.IsSuccessStatusCode) { //var maeCargaActividadListado = JsonConvert.DeserializeObject<MCMaeCargaForDosListadoResponse>(jsonResponse); //ICollection<PedidoTrabajoBResponse> listadoPT = JsonConvert.DeserializeObject<ICollection<PedidoTrabajoBResponse>>(listadoResponseMessage.Content.ReadAsStringAsync().Result); ICollection <MCMaeCargaForDosListadoResponse> maeCargaActividadListado = JsonConvert.DeserializeObject <ICollection <MCMaeCargaForDosListadoResponse> >(maeCargaActividadListadoResponse.Content.ReadAsStringAsync().Result); return(NewtonsoftJson(maeCargaActividadListado)); } else { switch (maeCargaActividadListadoResponse.StatusCode) { case HttpStatusCode.InternalServerError: var mensajeErrorInterno = JsonConvert.DeserializeObject <ErrorInternoResponse>(maeCargaActividadListadoResponse.Content.ReadAsStringAsync().Result); Console.Write("Error"); break; case HttpStatusCode.UnprocessableEntity: var mensajeEntidadImprosesable = JsonConvert.DeserializeObject <ErrorInternoResponse>(maeCargaActividadListadoResponse.Content.ReadAsStringAsync().Result); Console.Write("Error"); break; default: Console.Write("Error"); break; } } } else { Console.Write("Error"); } } catch (Exception ex) { Console.Write("Error"); } return(Content("Ups! Un error ocurrio")); }
public object GetUsersLookup(DataSourceLoadOptionsBase loadOptions) { IQueryable <SelectModelBinder <int> > query = _dbset.Select(x => new SelectModelBinder <int>() { Value = x.Id, Text = x.LastName + " " + x.FirstName }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result.data); }
public object load([FromRoute] string dvoFullName, [FromQuery] DataSourceLoadOptionsBase options) { var type = Assembly.GetEntryAssembly().GetType(dvoFullName); var dbSetMethodInfo = typeof(DbContext).GetMethod("Set"); dynamic dbSet = dbSetMethodInfo.MakeGenericMethod(type).Invoke(hk, null); dynamic Rec = Activator.CreateInstance(type); var data = DataSourceLoader.Load(((Microsoft.EntityFrameworkCore.Internal.InternalDbSet <Wings.Projects.Hk.DVO.Rbac.OrgManage>)dbSet), options); return(data); }
public object GetUserRoles(DataSourceLoadOptionsBase loadOptions, int userId) { IQueryable <UserRoleListDTO> query = _dbset.Where(x => x.AppUserId == userId).Select(x => new UserRoleListDTO() { UserRoleId = x.Id, RoleName = x.AppRole.Name }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
public object GetRolesToList(DataSourceLoadOptionsBase loadOptions) { IQueryable <RolerListDTO> query = _dbset.Select(x => new RolerListDTO() { Id = x.Id, Name = x.Name, Description = x.Description }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
public object GetRoleFunctionality(DataSourceLoadOptionsBase loadOptions, int roleId) { IQueryable <RoleFunctionalityListDTO> query = _dbset.Where(x => x.AppRoleId == roleId).Select(x => new RoleFunctionalityListDTO() { FunctionalityRoleId = x.Id, Description = x.Functionality.Description, Name = x.Functionality.Name }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
public object GetRoleUsers(DataSourceLoadOptionsBase loadOptions, int roleId) { IQueryable <RoleUserListDTO> query = _dbset.Where(x => x.AppRoleId == roleId).Select(x => new RoleUserListDTO() { UserRoleId = x.Id, FirstName = x.AppUser.FirstName, LastName = x.AppUser.LastName, FullName = x.AppUser.LastName + " " + x.AppUser.FirstName }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
private DataSourceLoadOptionsBase GetOptionsFromQuery(string query) { DataSourceLoadOptionsBase options = new DataSourceLoadOptionsBase(); IDictionary <string, StringValues> myQUeryString = QueryHelpers.ParseQuery(query); DataSourceLoadOptionsParser.Parse(options, key => { if (myQUeryString.ContainsKey(key)) { return(myQUeryString[key]); } return(null); }); return(options); }
public ArangoTransform(DataSourceLoadOptionsBase loadOption, ArangoTransformSettings settings) { _loadOption = loadOption; _settings = settings; HasGrouping = loadOption.Group?.Any() == true; if (loadOption.Take <= 0) { loadOption.Take = settings.DefaultTake; } if (loadOption.Take > settings.MaxTake) { loadOption.Take = settings.MaxTake; } }
public async Task <LoadResult> GetUsers(DataSourceLoadOptionsBase loadOptions) { using var unitOfWork = UnitOfWorkFactory(); try { _userRepository = unitOfWork.Repository <User>(); var source = _userRepository.GetUsers(); return(await LoadAsync(source, loadOptions)); } catch (Exception e) { _logger.Error(e, e.Message); throw new AppException(e.Message); } }
public object GetUsersToList(DataSourceLoadOptionsBase loadOptions) { var query = _dbset.Select(x => new { x.Id, x.FirstName, x.LastName, x.IsActive, x.Email, x.Login, Role = x.AppUserRoles.Select(r => r.AppRole.AppRoleType) }); LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
public object GetFunctionalitiesToAdd(DataSourceLoadOptionsBase loadOptions, int roleId) { IQueryable <RoleFunctionalityToAddListDTO> query = from functionality in Context.Functionalities join functionalityRole in Context.FunctionalityAppRoles.Where(x => x.AppRoleId == roleId) on functionality.Id equals functionalityRole.FunctionalityId into joinedFunctionalityRoles from data in joinedFunctionalityRoles.DefaultIfEmpty() select new RoleFunctionalityToAddListDTO() { Id = functionality.Id, Description = functionality.Description, Name = functionality.Name, IsAdded = data != null }; LoadResult result = DataSourceLoader.Load(query, loadOptions); return(result); }
public static void Parse(DataSourceLoadOptionsBase loadOptions, Func<string, string> valueSource) { var requireTotalCount = valueSource(KEY_REQUIRE_TOTAL_COUNT); var requireGroupCount = valueSource(KEY_REQUIRE_GROUP_COUNT); var isCountQuery = valueSource(KEY_IS_COUNT_QUERY); var skip = valueSource(KEY_SKIP); var take = valueSource(KEY_TAKE); var sort = valueSource(KEY_SORT); var group = valueSource(KEY_GROUP); var filter = valueSource(KEY_FILTER); var totalSummary = valueSource(KEY_TOTAL_SUMMARY); var groupSummary = valueSource(KEY_GROUP_SUMMARY); if(!String.IsNullOrEmpty(requireTotalCount)) loadOptions.RequireTotalCount = Convert.ToBoolean(requireTotalCount); if(!String.IsNullOrEmpty(requireGroupCount)) loadOptions.RequireGroupCount = Convert.ToBoolean(requireGroupCount); if (!String.IsNullOrEmpty(isCountQuery)) loadOptions.IsCountQuery = Convert.ToBoolean(isCountQuery); if(!String.IsNullOrEmpty(skip)) loadOptions.Skip = Convert.ToInt32(skip); if(!String.IsNullOrEmpty(take)) loadOptions.Take = Convert.ToInt32(take); if(!String.IsNullOrEmpty(sort)) loadOptions.Sort = JsonConvert.DeserializeObject<SortingInfo[]>(sort); if(!String.IsNullOrEmpty(group)) loadOptions.Group = JsonConvert.DeserializeObject<GroupingInfo[]>(group); if(!String.IsNullOrEmpty(filter)) { loadOptions.Filter = JsonConvert.DeserializeObject<IList>(filter, new JsonSerializerSettings { DateParseHandling = DateParseHandling.None }); } if(!String.IsNullOrEmpty(totalSummary)) loadOptions.TotalSummary = JsonConvert.DeserializeObject<SummaryInfo[]>(totalSummary); if(!String.IsNullOrEmpty(groupSummary)) loadOptions.GroupSummary = JsonConvert.DeserializeObject<SummaryInfo[]>(groupSummary); }
protected async Task <LoadResult> LoadEvents(DataSourceLoadOptionsBase options, CancellationToken cancellationToken) { try { var query = options.ToApiQuery <GetEventsQuery>(); query.From = DateRangePicker.FromDate; query.To = DateRangePicker.ToDate; var result = await EventLogService.GetEvents(query, !AutoUpdateCheckBox); Events = result; return(result.ToDxLoadResult()); } catch (Exception ex) { Logger.LogWarning(ex, "Failed to load events data"); } return(new LoadResult()); }
public static T ToApiQuery <T>(this DataSourceLoadOptionsBase dxDataSourceOptions) where T : PageRequest, new() { var query = new T { PageNumber = (dxDataSourceOptions.Skip / dxDataSourceOptions.Take) + 1, PageSize = dxDataSourceOptions.Take }; var queryProperties = query.GetType().GetProperties(); if (dxDataSourceOptions.Filter == null) { return(query); } foreach (var filter in dxDataSourceOptions.Filter) { if (filter is string) { continue; } var filterExpression = filter as IList <object>; if (filterExpression == null) { continue; } (string?parameterName, object parameterValue) = (filterExpression.First() as string, filterExpression.Last()); Logger.LogWarning($"{parameterName} {parameterValue}"); var queryProperty = queryProperties.FirstOrDefault(x => string.Equals(parameterName, x.Name, StringComparison.InvariantCultureIgnoreCase)); if (queryProperty == null) { continue; } queryProperty.SetValue(query, parameterValue); } return(query); }
public async void GivenLoadOptions_ControllerReturnsLoadResult() { // Arrange var loadOptions = new DataSourceLoadOptionsBase(); var words = Helper.FakeEnumerable(() => new Word().Fake()).ToList(); var loadResult = new LoadResult { data = words }; // Act _wordManager.Setup(m => m.DataSourceLoadAsync(loadOptions)) .ReturnsAsync(loadResult) .Verifiable(); var result = await _wordsController.GetWords(loadOptions).ConfigureAwait(false); // Assert _wordManager.Verify(m => m.DataSourceLoadAsync(loadOptions), Times.Once); Assert.Equal(typeof(ActionResult <LoadResponse <WordModel> >), result.GetType()); }
public LoadResult GetOrders(DataSourceLoadOptionsBase loadOptions) { using (OrdersDbContext dbContext = new OrdersDbContext() { ConnectionString = _connectionString }) { var queryable = dbContext.Orders .Select(t => new GetOrdersOutputDto() { OrderId = t.OrderID, CustomerName = t.CustomerName, ShipperCity = t.ShipperCity, IsShipped = t.IsShipped }); // Enumerate now to avoid the 'context disposed' error var loadResult = DataSourceLoader.Load(queryable, loadOptions); loadResult.data = loadResult.data.Cast <object>().ToList(); return(loadResult); } }
/// <summary> /// Get all users /// </summary> /// <param name="loadOptionsBase"></param> /// <returns></returns> public IActionResult OnGetGetUsers(DataSourceLoadOptionsBase loadOptionsBase) { List <User> usuarios = new List <User>(); try { var response = _user.GetUsers(); if (response.StatusCode == HttpStatusCode.OK) { usuarios = JsonConvert.DeserializeObject <UsersResponse>(response.Content).Usuarios; return(new JsonResult(DataSourceLoader.Load(usuarios, loadOptionsBase))); } else { return(BadRequest(JsonConvert.DeserializeObject <BaseResponse>(response.Content).ErrorMessage)); } } catch (Exception e) { _logger.LogError(e, $"Failed to get user"); return(BadRequest("Ocurrió un error inesperado al listar los usuarios")); } }
static DataSourceExpressionBuilder <T> CreateBuilder <T>(DataSourceLoadOptionsBase loadOptions, bool guardNulls = false) { return(new DataSourceExpressionBuilder <T>(loadOptions, guardNulls)); }
public async Task <LoadResult> GetChangeOfficialDocuments(DataSourceLoadOptionsBase loadOptions) { return(await _settingService.GetChangeOfficialDocuments(loadOptions)); }
public object GetFunctionalitiesToAdd(DataSourceLoadOptionsBase loadOptions, int roleId) { return(FunctionalityAppRoleRepository.GetFunctionalitiesToAdd(loadOptions, roleId)); }
public async Task <LoadResult> GetUsers(DataSourceLoadOptionsBase loadOptions) { return(await _settingService.GetUsers(loadOptions)); }