Activities of "moinahmed"

Is there a way to extend existing system entities (IdentityUser, OrganizationUnit, IdentityRole) with an interface? I'm trying to add customer data filters through ABP EF Core's Global Query Filters system. I can easily extend my custom entities but how to do existing system entities. I read about ObjectExtensionManager to add new properties but don't know how to use (if there's a possibility) to extend with an interface?

Question

Is there a way to override the current dbcontext and call another for an specific App Service?

I have extended the AbdDbContext and overriding CreateFilterExpression method to inject additional database filtering only for the case of IdentityUserAppService. All looks good, but I'm unsure how to route the database calls through this new Extended dbcontext, any idea?

I need to add a new Menu item in Administration > Identity Management. How can I do that?

Thanks, Moin

The actual ask is I'd like to extend IdentiyUser model to add departments functionality just as we have for roles in the same table. I need a collection out there with all CRUD methods.

I'm trying to create a new entity (Department) as follows: Entity name: Department

| Name | DataType | Remarks | | ---- | -------- | ------- | | Id | Uniqueidentifier | Primary Key | | Name | NVarchar(255) | Department name | | OrganizationUnitId (FK) | UniqueIdentifier | Foreign key from OrganizationUnit entity |

How can I achieve this? Also, how to add Collection property (Departments) in OrganizationUnity entity?

Thanks, Moin

It didn't work; I tried a new project too. Were you able to reproduce at your end?

Our cache needs are very limited and in-memory/in-process is sufficient for it; that's why do not want to try Redis.

I'm sharing the code below; removing/obfuscating many things for privacy but have included bare-minimum set that give you a clear idea.

Here's module code:

[DependsOn(
	typeof(AbpAutoMapperModule),        
	typeof(AbpCachingModule)
	)]
public class CustomModule : AbpModule
{
	public override void ConfigureServices(ServiceConfigurationContext context)
	{
		var configuration = context.Services.GetConfiguration();
		Configure<AbpAutoMapperOptions>(options => {
			options.AddMaps<CustomModule>();
		});
	}

	public override void OnApplicationInitialization(ApplicationInitializationContext context)
	{
		var service = context
			.ServiceProvider
			.GetRequiredService<CustomInit>();
		service.Initialize();
	}
}

Init class:

public class CustomInit : ISingletonDependency
{
	private IDistributedCache<CacheItem> _cache;	

	public CustomInit(
		IDistributedCache<CacheItem> cache)
	{
		_cache = cache;
	}

	public void Initialize()
	{
		// load records from API
		var records = client.Records.GetAllAsync(request).Result;

		// initialize abp cache
		foreach (var rec in records) {
			_cache.SetAsync(
				rec.Id, // Cache key
				new CacheItem { Id = rec.Id, Name = rec.Name }, // Cache value
				new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromDays(1000) } // Cache options
			);
		}
	}
}

Service class where I'm accessing cache:

public class CustomService : ApplicationService, ICustomService, ITransientDependency
{        
	private IDistributedCache<CacheItem> _cache;
	
	public CustomService(
		IDistributedCache<CacheItem> cache)
	{
		_cache = cache;
	}

	public async Task<CacheItem> GetAsync(string id)
	{            
		var rec = await _cache.GetAsync(id); // rec is always null
		return rec;		
	}
}

Hi,

Can we share/access cache across services? I have a service that initializes the cache upon module load, but when I access the same cache into another service I always get a cache miss. I have thoroughly verified that the cache is getting initialized but items not accessible from the other service. Is this a default behavior or am I missing something? If it is something by design how can we overcome this?

Thanks, Moin

Hi,

I'm new to ABP framework and need some help regarding best practices to make changes in ABP modules code. We need to extend one of the methods (specifically CreateAsync) to publish another event to Distributed event bus service, upon new user creation. We have the module (Identity.pro) source code; however, I'm not sure if it is a good idea to include the whole module source code into our project, instead I'm looking for the best practices on how to do that. Is there any better way to make such changes without making the whole module source code part of your project?

Thanks, Moin

Showing 11 to 20 of 28 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11