Open Closed

Oragainzation unit Custmiztion #6365


User avatar
0
mina created
  • ABP Framework version: v7.4.4
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server,)
  • Tiered (for MVC) or Auth Server Separated (for Angular): /no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Dear All,

1- Is there a way to Customize the Organization unit, such as to change the coding Mechanism? 2- Can we have several organization Units in the same application for example for Location and Category?

Thanks, Mina.


11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Is there a way to Customize the Organization unit, such as to change the coding Mechanism

    You can replace the OrganizationUnitManager to override the GetNextChildCodeAsync method

    Can we have several organization Units in the same application for example for Location and Category?

    1 : You can use organization Units as Location and Category, you need to differentiate between them in business

    Organization Units
    
    Location A
        Location A-a
        Location A-b
    
    Location B
        Location A-a
        Location A-b
    
    Category A
        Category A-a
    

    2: You can create new organization tree entities for Location and Category.

    Here is a library that can help you simplify the development process: https://github.com/maliming/Owl.GeneralTree

  • User Avatar
    0
    mina created

    For Question Number 1: 1- For Example, if we need to change the CodeUnitLength, as it is a static class, we can't Override, so what is the right way to do it?

    namespace Volo.Abp.Identity;
    public static class OrganizationUnitConsts
    {
    
    
        /// <summary>
        /// Length of a code unit between dots.
        /// </summary>
       ** public const int CodeUnitLength = 5;**
    
     }
    

    2- For Question 2 , will check the option and revert back to you.

    Thanks, Mina.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    For Example, if we need to change the CodeUnitLength, as it is a static class, we can't Override, so what is the right way to do it?

    It's not a big problem.

    You can change the length of the OrganizationUnit entity:

    protected override void OnModelCreating(ModelBuilder builder)
    {
        .....
        
        // Update the code length
        builder.Entity<OrganizationUnit>(b => 
        {
            b.Property(x => x.Code).HasMaxLength(10);
        });
    }
    

    dotnet ef migratons add change_code_length dotnet ef database update

  • User Avatar
    0
    mina created

    That is not what we meant, we need to create the code for Example with 3 digit such as 000.000.000 not with the default 5-digits 00000.00000.00000

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Ok, I think I explained it above: You can replace the OrganizationUnitManager to override the GetNextChildCodeAsync method

    For example:

    [ExposeServices(typeof(OrganizationUnitManager))]
    public class MyOrganizationUnitManager : OrganizationUnitManager
    {
        public override async Task<string> GetNextChildCodeAsync(Guid? parentId)
        {
            var code = await base.GetNextChildCodeAsync(parentId);
            return code.SubString(2);
        }
    }
    
  • User Avatar
    0
    mina created

    For the below provided Solution: Organization Units

    Location A Location A-a Location A-b

    Location B Location A-a Location A-b

    Category A Category A-a

    if we have one Entity such as Book that should has Location and Category and both will be implemented by Organization Unit as above , how we could add the property in the Book Entity

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The organizational units provided by ABP are used to organize users and roles.

    I suggest that you create Category and Location entities instead of using organizational units.

  • User Avatar
    0
    mina created

    Do you mean to use this "Here is a library that can help you simplify the development process: https://github.com/maliming/Owl.GeneralTree"

    is there a guide on how to integrate it into our ABP application?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Here is a simple project: https://github.com/maliming/Owl.GeneralTree/tree/dev/app

  • User Avatar
    0
    mina created

    I mean, is there a way or guide to add an existing Module(this app) to My existing APP?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    No such guide, and the app is not a module. This is a sample project using this library.

    You can refer to it.

    And the Owl.GeneralTree is a library to help you develop tree entities. It provides some practical methods, such as adding deletions and moving tree nodes.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11