public IActionResult Get([FromQuery] RetrieveEntityModel model) { FilterContainer <Schema.Domain.Entity> filter = FilterContainerBuilder.Build <Schema.Domain.Entity>(); filter.And(x => x.OrganizationId == CurrentUser.OrganizationId); if (model.Name.NotEmpty()) { filter.And(x => x.Name.In(model.Name)); } if (model.IsAuthorization.HasValue) { filter.And(x => x.AuthorizationEnabled == model.IsAuthorization.Value); } if (model.IsCustomizable.HasValue) { filter.And(x => x.IsCustomizable == model.IsCustomizable.Value); } if (model.IsLoged.HasValue) { filter.And(x => x.LogEnabled == model.IsLoged.Value); } if (model.DuplicateEnabled.HasValue) { filter.And(x => x.DuplicateEnabled == model.DuplicateEnabled.Value); } if (model.WorkFlowEnabled.HasValue) { filter.And(x => x.WorkFlowEnabled == model.WorkFlowEnabled.Value); } if (model.BusinessFlowEnabled.HasValue) { filter.And(x => x.BusinessFlowEnabled == model.BusinessFlowEnabled.Value); } if (model.GetAll) { model.PageSize = 25000; } else if (!model.PageSizeBySeted && CurrentUser.UserSettings.PagingLimit > 0) { model.PageSize = CurrentUser.UserSettings.PagingLimit; } model.PageSize = model.PageSize > WebContext.PlatformSettings.MaxFetchRecords ? WebContext.PlatformSettings.MaxFetchRecords : model.PageSize; List <Schema.Domain.Entity> result; if (model.SolutionId.HasValue) { var pagedResult = _entityFinder.QueryPaged(x => x .Page(1, model.PageSize) .Where(filter), model.SolutionId.Value, true); result = pagedResult.Items; } else { result = _entityFinder.Query(x => x .Where(filter)); } return(JOk(result)); }
public IActionResult Get(Guid?solutionId) { var entities = _entityFinder.QueryPaged(x => x .Page(1, 25000) .Where(f => f.OrganizationId == CurrentUser.OrganizationId) .Select(n => new { n.EntityId, n.Name, n.LocalizedName, n.EntityGroups }) .Sort(n => n.SortAscending(f => f.LocalizedName)), solutionId.Value, true); var groups = _dataFinder.RetrieveAll("entitygroup", new List <string> { "name" }, new OrderExpression("name", OrderType.Ascending)); if (entities.Items.Count(x => x.EntityGroups.IsEmpty()) > 0) { var nullGroup = new Xms.Core.Data.Entity("entitygroup"); nullGroup.SetIdValue(Guid.Empty); nullGroup["name"] = "未分组"; groups.Insert(0, nullGroup); foreach (var item in entities.Items.Where(x => x.EntityGroups.IsEmpty())) { item.EntityGroups = Guid.Empty.ToString(); } } List <dynamic> result = new List <dynamic>(); foreach (var group in groups) { dynamic g = new ExpandoObject(); g.label = group["name"]; g.id = group.Id; g.children = entities.Items.Where(x => x.EntityGroups.IsNotEmpty() && x.EntityGroups.IndexOf(group.Id.ToString(), StringComparison.InvariantCultureIgnoreCase) >= 0)?.Select(x => new { id = x.EntityId, label = x.LocalizedName }).ToList(); result.Add(g);; } return(JOk(result)); }
public IActionResult Get([FromQuery] RetrieveEntityModel model) { FilterContainer <Schema.Domain.Entity> filter = FilterContainerBuilder.Build <Schema.Domain.Entity>(); filter.And(x => x.OrganizationId == CurrentUser.OrganizationId); if (model.Name.NotEmpty()) { filter.And(x => x.Name.In(model.Name)); } if (model.AuthorizationEnabled.HasValue) { filter.And(x => x.AuthorizationEnabled == model.AuthorizationEnabled.Value); } if (model.IsCustomizable.HasValue) { filter.And(x => x.IsCustomizable == model.IsCustomizable.Value); } if (model.LogEnabled.HasValue) { filter.And(x => x.LogEnabled == model.LogEnabled.Value); } if (model.DuplicateEnabled.HasValue) { filter.And(x => x.DuplicateEnabled == model.DuplicateEnabled.Value); } if (model.WorkFlowEnabled.HasValue) { filter.And(x => x.WorkFlowEnabled == model.WorkFlowEnabled.Value); } if (model.BusinessFlowEnabled.HasValue) { filter.And(x => x.BusinessFlowEnabled == model.BusinessFlowEnabled.Value); } List <Schema.Domain.Entity> result; if (model.SolutionId.HasValue) { var pagedResult = _entityFinder.QueryPaged(x => x .Page(1, 250000) .Where(filter), model.SolutionId.Value, true); result = pagedResult.Items; } else { result = _entityFinder.Query(x => x .Where(filter)); } return(JOk(result)); }
public IActionResult Index(EntityModel model) { if (!model.LoadData) { return(DynamicResult(model)); } FilterContainer <Schema.Domain.Entity> filter = FilterContainerBuilder.Build <Schema.Domain.Entity>(); filter.And(n => n.OrganizationId == CurrentUser.OrganizationId); if (model.Name.IsNotEmpty()) { filter.And(n => n.Name == model.Name); } if (!model.IsSortBySeted) { model.SortBy = "Name"; model.SortDirection = (int)SortDirection.Asc; } if (model.GetAll) { model.Page = 1; model.PageSize = WebContext.PlatformSettings.MaxFetchRecords; } else if (!model.PageSizeBySeted && CurrentUser.UserSettings.PagingLimit > 0) { model.PageSize = CurrentUser.UserSettings.PagingLimit; } if (!model.EntityGroupId.IsEmpty()) { filter.And(n => n.EntityGroups.Like(model.EntityGroupId.ToString())); } model.PageSize = model.PageSize > WebContext.PlatformSettings.MaxFetchRecords ? WebContext.PlatformSettings.MaxFetchRecords : model.PageSize; PagedList <Schema.Domain.Entity> result = _entityFinder.QueryPaged(x => x .Page(model.Page, model.PageSize) .Where(filter) .Sort(n => n.OnFile(model.SortBy).ByDirection(model.SortDirection)) , SolutionId.Value, true); model.Items = result.Items; model.TotalItems = result.TotalItems; model.SolutionId = SolutionId.Value; return(DynamicResult(model)); }
public string GetXml(Guid solutionId) { StringBuilder result = new StringBuilder(); var pageSize = 100; var page = 1; long totalItems = pageSize; while (totalItems == pageSize) { var data = _entityFinder.QueryPaged(x => x.Page(page, pageSize), solutionId, true); totalItems = data.TotalItems; if (totalItems > 0) { result.Append(data.Items.SerializeToXml()); } page++; } return(result.ToString()); }