private void ExportPlatformEntriesInternal(Package package, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback) { var progressInfo = new ExportImportProgressInfo(); var platformExportObj = new PlatformExportEntries(); if (manifest.HandleSecurity) { //Roles platformExportObj.Roles = _roleManagementService.SearchRoles(new RoleSearchRequest { SkipCount = 0, TakeCount = int.MaxValue }).Roles; //users var usersResult = Task.Run(() => _securityService.SearchUsersAsync(new UserSearchRequest { TakeCount = int.MaxValue })).Result; progressInfo.Description = String.Format("Security: {0} users exporting...", usersResult.Users.Count()); progressCallback(progressInfo); foreach (var user in usersResult.Users) { var userExt = Task.Run(() => _securityService.FindByIdAsync(user.Id, UserDetails.Export)).Result; if (userExt != null) { platformExportObj.Users.Add(userExt); } } } //Export setting for selected modules if (manifest.HandleSettings) { progressInfo.Description = String.Format("Settings: selected modules settings exporting..."); progressCallback(progressInfo); platformExportObj.Settings = manifest.Modules.SelectMany(x => _settingsManager.GetModuleSettings(x.Id)).ToList(); } //Dynamic properties var allTypes = _dynamicPropertyService.GetAvailableObjectTypeNames(); progressInfo.Description = String.Format("Dynamic properties: load properties..."); progressCallback(progressInfo); platformExportObj.DynamicProperties = allTypes.SelectMany(x => _dynamicPropertyService.GetProperties(x)).ToList(); platformExportObj.DynamicPropertyDictionaryItems = platformExportObj.DynamicProperties.Where(x => x.IsDictionary).SelectMany(x => _dynamicPropertyService.GetDictionaryItems(x.Id)).ToList(); //Notification templates progressInfo.Description = String.Format("Notifications: load templates..."); progressCallback(progressInfo); platformExportObj.NotificationTemplates = _notificationTemplateService.GetAllTemplates().ToList(); //Create part for platform entries var platformEntiriesPart = package.CreatePart(_platformEntriesPartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal); using (var partStream = platformEntiriesPart.GetStream()) { platformExportObj.SerializeJson <PlatformExportEntries>(partStream); } }
private void ExportPlatformEntriesInternal(Package package, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback) { var progressInfo = new ExportImportProgressInfo(); var platformExportObj = new PlatformExportEntries(); if (manifest.HandleSecurity) { //Roles platformExportObj.Roles = _roleManagementService.SearchRoles(new RoleSearchRequest { SkipCount = 0, TakeCount = int.MaxValue }).Roles; //users var usersResult = Task.Run(() => _securityService.SearchUsersAsync(new UserSearchRequest { TakeCount = int.MaxValue })).Result; progressInfo.Description = $"Security: {usersResult.Users.Count()} users exporting..."; progressCallback(progressInfo); foreach (var user in usersResult.Users) { var userExt = Task.Run(() => _securityService.FindByIdAsync(user.Id, UserDetails.Export)).Result; if (userExt != null) { platformExportObj.Users.Add(userExt); } } } //Export setting for selected modules if (manifest.HandleSettings) { progressInfo.Description = "Settings: selected modules settings exporting..."; progressCallback(progressInfo); platformExportObj.Settings = manifest.Modules.SelectMany(x => _settingsManager.GetModuleSettings(x.Id)).ToList(); } //Dynamic properties var allTypes = _dynamicPropertyService.GetAvailableObjectTypeNames(); progressInfo.Description = "Dynamic properties: load properties..."; progressCallback(progressInfo); platformExportObj.DynamicProperties = allTypes.SelectMany(x => _dynamicPropertyService.GetProperties(x)).ToList(); platformExportObj.DynamicPropertyDictionaryItems = platformExportObj.DynamicProperties.Where(x => x.IsDictionary).SelectMany(x => _dynamicPropertyService.GetDictionaryItems(x.Id)).ToList(); //Notification templates progressInfo.Description = "Notifications: load templates..."; progressCallback(progressInfo); platformExportObj.NotificationTemplates = _notificationTemplateService.GetAllTemplates().ToList(); //Asset entries progressInfo.Description = "Asset: Evaluate asset entries count..."; progressCallback(progressInfo); const int batchSize = 50; var totalAssetsEntriesCount = _assetEntrySearchService.SearchAssetEntries(new AssetEntrySearchCriteria { Skip = 0, Take = 0 }).TotalCount; for (var i = 0; i <= totalAssetsEntriesCount; i += batchSize) { progressInfo.Description = $"Asset: {Math.Min(totalAssetsEntriesCount, i + batchSize) } of {totalAssetsEntriesCount} asset entries have been loaded..."; progressCallback(progressInfo); platformExportObj.AssetEntries.AddRange(_assetEntrySearchService.SearchAssetEntries(new AssetEntrySearchCriteria { Skip = i, Take = batchSize }).Results); } //Create part for platform entries var platformEntiriesPart = package.CreatePart(_platformEntriesPartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal); using (var partStream = platformEntiriesPart.GetStream()) { platformExportObj.SerializeJson(partStream); } }
public IHttpActionResult GetProperties(string typeName) { var properties = _service.GetProperties(typeName); return(Ok(properties)); }
private async Task ExportPlatformEntriesInternalAsync(ZipArchive zipArchive, PlatformExportManifest manifest, Action <ExportImportProgressInfo> progressCallback, CancellationToken cancellationToken) { var progressInfo = new ExportImportProgressInfo(); var platformExportObj = new PlatformExportEntries(); if (manifest.HandleSecurity) { //Roles platformExportObj.Roles = _roleManager.Roles.ToList(); if (_roleManager.SupportsRoleClaims) { var permissions = _permissionsProvider.GetAllPermissions(); foreach (var role in platformExportObj.Roles) { role.Permissions = (await _roleManager.GetClaimsAsync(role)).Join(permissions, c => c.Value, p => p.Name, (c, p) => p).ToArray(); } } //users var usersResult = _userManager.Users.ToArray(); progressInfo.Description = $"Security: {usersResult.Count()} users exporting..."; progressCallback(progressInfo); foreach (var user in usersResult) { var userExt = await _userManager.FindByIdAsync(user.Id); if (userExt != null) { platformExportObj.Users.Add(userExt); } } } //Export setting for selected modules if (manifest.HandleSettings) { progressInfo.Description = "Settings: selected modules settings exporting..."; progressCallback(progressInfo); platformExportObj.Settings = manifest.Modules.SelectMany(x => _settingsManager.GetModuleSettings(x.Id)).ToList(); } //Dynamic properties var allTypes = _dynamicPropertyService.GetAvailableObjectTypeNames(); progressInfo.Description = "Dynamic properties: load properties..."; progressCallback(progressInfo); platformExportObj.DynamicProperties = allTypes.SelectMany(x => _dynamicPropertyService.GetProperties(x)).ToList(); platformExportObj.DynamicPropertyDictionaryItems = platformExportObj.DynamicProperties.Where(x => x.IsDictionary).SelectMany(x => _dynamicPropertyService.GetDictionaryItems(x.Id)).ToList(); //Notification templates progressInfo.Description = "Notifications: load templates..."; progressCallback(progressInfo); //Create part for platform entries var platformEntiriesPart = zipArchive.CreateEntry(_platformZipEntryName, CompressionLevel.Optimal); using (var partStream = platformEntiriesPart.Open()) { platformExportObj.SerializeJson(partStream); } }