private async Task LoadDynamicPropertyDictionaryItems(ICollection <DynamicObjectProperty> dynamicProperties, CustomContext context, CancellationToken cancellationToken) { var dynamicPropertyDictionaryItems = new List <DynamicPropertyDictionaryItem>(); if (dynamicProperties != null) { foreach (var dynamicProperty in dynamicProperties.Where(dynamicProperty => dynamicProperty.IsDictionary)) { var dynamicPropertyDictionaryItemsSearchResult = await _dynamicPropertyDictionaryItemsSearchService.SearchDictionaryItemsAsync(new DynamicPropertyDictionaryItemSearchCriteria { PropertyId = dynamicProperty.Id }); dynamicPropertyDictionaryItems.AddRange(dynamicPropertyDictionaryItemsSearchResult.Results); } } context.ParentContext.RootContextData[ImportDynamicPropertyValidator <T> .DynamicPropertyDictionaryItems] = dynamicPropertyDictionaryItems; }
public virtual async Task <SearchDynamicPropertyDictionaryItemResponse> Handle(SearchDynamicPropertyDictionaryItemQuery request, CancellationToken cancellationToken) { var searchCriteria = new DynamicPropertyDictionaryItemSearchCriteriaBuilder(_searchPhraseParser, _mapper) .ParseFilters(request.Filter) .WithPropertyId(request.PropertyId) .WithLanguage(request.CultureName) .WithPaging(request.Skip, request.Take) .WithSorting(request.Sort) .Build(); var searchResult = await _dynamicPropertyDictionaryItemsSearchService.SearchDictionaryItemsAsync(searchCriteria); return(new SearchDynamicPropertyDictionaryItemResponse { Results = searchResult.Results, TotalCount = searchResult.TotalCount }); }
private async Task ExportPlatformEntriesInternalAsync(ZipArchive zipArchive, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback, ICancellationToken cancellationToken) { var progressInfo = new ExportImportProgressInfo(); var serializer = GetJsonSerializer(); //Create part for platform entries var platformEntiriesPart = zipArchive.CreateEntry(PlatformZipEntryName, CompressionLevel.Optimal); using (var partStream = platformEntiriesPart.Open()) { using (var sw = new StreamWriter(partStream, Encoding.UTF8)) using (var writer = new JsonTextWriter(sw)) { await writer.WriteStartObjectAsync(); if (manifest.HandleSecurity) { #region Roles progressInfo.Description = "Roles exporting..."; progressCallback(progressInfo); cancellationToken.ThrowIfCancellationRequested(); await writer.WritePropertyNameAsync("Roles"); await writer.WriteStartArrayAsync(); var roles = _roleManager.Roles.ToList(); if (_roleManager.SupportsRoleClaims) { foreach (var role in roles) { var fullyLoadedRole = await _roleManager.FindByIdAsync(role.Id); serializer.Serialize(writer, fullyLoadedRole); } writer.Flush(); progressInfo.Description = $"{ roles.Count } roles exported"; progressCallback(progressInfo); } await writer.WriteEndArrayAsync(); #endregion Roles cancellationToken.ThrowIfCancellationRequested(); #region Users await writer.WritePropertyNameAsync("Users"); await writer.WriteStartArrayAsync(); var usersResult = _userManager.Users.ToArray(); progressInfo.Description = $"Security: {usersResult.Length} users exporting..."; progressCallback(progressInfo); var userExported = 0; foreach (var user in usersResult) { var userExt = await _userManager.FindByIdAsync(user.Id); if (userExt != null) { serializer.Serialize(writer, userExt); userExported++; } } await writer.FlushAsync(); progressInfo.Description = $"{ userExported } of { usersResult.Length } users exported"; progressCallback(progressInfo); await writer.WriteEndArrayAsync(); #endregion Users cancellationToken.ThrowIfCancellationRequested(); #region UserApiKeys await writer.WritePropertyNameAsync("UserApiKeys"); await writer.WriteStartArrayAsync(); progressInfo.Description = "User Api keys: load keys..."; progressCallback(progressInfo); var apiKeys = (await _userApiKeySearchService.SearchUserApiKeysAsync(new UserApiKeySearchCriteria { Take = int.MaxValue })).Results; foreach (var apiKey in apiKeys) { serializer.Serialize(writer, apiKey); } progressInfo.Description = $"User Api keys have been exported"; progressCallback(progressInfo); await writer.WriteEndArrayAsync(); #endregion UserApiKeys } if (manifest.HandleSettings) { cancellationToken.ThrowIfCancellationRequested(); await writer.WritePropertyNameAsync("Settings"); await writer.WriteStartArrayAsync(); progressInfo.Description = "Settings: selected modules settings exporting..."; progressCallback(progressInfo); foreach (var module in manifest.Modules) { var moduleSettings = await _settingsManager.GetObjectSettingsAsync(_settingsManager.AllRegisteredSettings.Where(x => x.ModuleId == module.Id).Select(x => x.Name)); //Export only settings with set values foreach (var setting in moduleSettings.Where(x => x.ItHasValues)) { serializer.Serialize(writer, setting); } await writer.FlushAsync(); } progressInfo.Description = $"Settings of modules exported"; progressCallback(progressInfo); await writer.WriteEndArrayAsync(); } cancellationToken.ThrowIfCancellationRequested(); await writer.WritePropertyNameAsync("DynamicProperties"); await writer.WriteStartArrayAsync(); progressInfo.Description = "Dynamic properties: load properties..."; progressCallback(progressInfo); var dynamicProperties = (await _dynamicPropertySearchService.SearchDynamicPropertiesAsync(new DynamicPropertySearchCriteria { Take = int.MaxValue })).Results; foreach (var dynamicProperty in dynamicProperties) { serializer.Serialize(writer, dynamicProperty); } progressInfo.Description = $"Dynamic properties exported"; progressCallback(progressInfo); await writer.WriteEndArrayAsync(); cancellationToken.ThrowIfCancellationRequested(); await writer.WritePropertyNameAsync("DynamicPropertyDictionaryItems"); await writer.WriteStartArrayAsync(); progressInfo.Description = "Dynamic properties Dictionary Items: load properties..."; progressCallback(progressInfo); var dynamicPropertyDictionaryItems = (await _dynamicPropertyDictionaryItemsSearchService.SearchDictionaryItemsAsync(new DynamicPropertyDictionaryItemSearchCriteria { Take = int.MaxValue })).Results; foreach (var dynamicPropertyDictionaryItem in dynamicPropertyDictionaryItems) { serializer.Serialize(writer, dynamicPropertyDictionaryItem); } progressInfo.Description = $"Dynamic properties dictionary items exported"; progressCallback(progressInfo); await writer.WriteEndArrayAsync(); await writer.WriteEndObjectAsync(); await writer.FlushAsync(); } } }
public async Task <ActionResult <DynamicPropertyDictionaryItemSearchResult> > SearchDictionaryItems([FromBody] DynamicPropertyDictionaryItemSearchCriteria criteria) { var result = await _dynamicPropertyDictionaryItemsSearchService.SearchDictionaryItemsAsync(criteria); return(Ok(result)); }