أنشطة "moinahmed"

Hi,

I checked that the source code is not available to us on our license tier; is there any other way to accomplish this without buying the source code?

Thanks

Hi Mahmut,

I'm talking about here extending an existing with new functionality, precisely in this case, adding another tab to User update modal. Can you provide some more concrete example how to do it without the source code?

Thanks

إجابة

Yes, already added; as I said it was working like a charm and then suddenly stopped working.

إجابة

إجابة

I think you must be interested in the two files:

public class Auth0UsersManagementModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var configuration = context.Services.GetConfiguration();

            Configure<Auth0ConnectionOptions>(
                configuration.GetSection("Auth0"));
        }

        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var service = context
                .ServiceProvider
                .GetRequiredService<Auth0UsersManagementInit>();
            service.Initialize();
        }
    }
public class Auth0UsersManagementModuleAutoMapperProfile : Profile
    {
        public Auth0UsersManagementModuleAutoMapperProfile()
        {
            CreateMap<UserDto, UserCreateRequest>()                
              //.ForMember(dest => dest.Prop, opt => opt.Ignore())
              //.ForMember(dest => dest.Prop, opt => opt.MapFrom(src => src.Prop))
                .AfterMap((src, dest) => {
                    dest.Connection = "Username-Password-Authentication";
                });

            CreateMap<UserDto, UserUpdateRequest>()
                .ForMember(dest => dest.Password, opt => opt.Ignore())
                .AfterMap((src, dest) => {
                    dest.Connection = "Username-Password-Authentication";
                });

            CreateMap<User, UserDto>()
                .ForMember(dest => dest.Password, opt => opt.Ignore())
                .ForMember(dest => dest.Id,       opt => opt.MapFrom(src => src.UserId));
            
            CreateMap<User, UserUpdateRequest>();
        }
    }

Mapping is called as: var request = ObjectMapper.Map<UserDto, UserCreateRequest>(user);

إجابة

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;		
	}
}
إجابة

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

إجابة

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

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.

$(function () {
    var l = abp.localization.getResource("IosIdentity");
	
    var agencyCustomerService = window.iosIdentity.pS3.agencyCustomers;
	
        var lastNpIdId = '';
        var lastNpDisplayNameId = '';

        var _lookupModal = new abp.ModalManager({
            viewUrl: abp.appPath + "Shared/LookupModal",
            scriptUrl: "/Pages/Shared/lookupModal.js",
            modalClass: "navigationPropertyLookup"
        });

        $('.lookupCleanButton').on('click', '', function () {
            $(this).parent().find('input').val('');
        });

        _lookupModal.onClose(function () {
            var modal = $(_lookupModal.getModal());
            $('#' + lastNpIdId).val(modal.find('#CurrentLookupId').val());
            $('#' + lastNpDisplayNameId).val(modal.find('#CurrentLookupDisplayName').val());
        });
	
    var createModal = new abp.ModalManager({
        viewUrl: abp.appPath + "AgencyCustomers/CreateModal",
        scriptUrl: "/Pages/AgencyCustomers/createModal.js",
        modalClass: "agencyCustomerCreate"
    });

	var editModal = new abp.ModalManager({
        viewUrl: abp.appPath + "AgencyCustomers/EditModal",
        scriptUrl: "/Pages/AgencyCustomers/editModal.js",
        modalClass: "agencyCustomerEdit"
    });

	var getFilter = function() {
        return {
            filterText: $("#FilterText").val(),
            name: $("#NameFilter").val(),
			brandId: $("#BrandIdFilter").val(),			
			answerDataUploadOptionId: $("#AnswerDataUploadOptionIdFilter").val(),			
			subAccountInventoryControlTypeId: $("#SubAccountInventoryControlTypeIdFilter").val(),			
            allowSubAccounts: (function () {
                var value = $("#AllowSubAccountsFilter").val();
                if (value === undefined || value === null || value === '') {
                    return '';
                }
                return value === 'true';
            })(),
			organizationUnitId: $("#OrganizationUnitIdFilter").val()
        };
    };

    var dataTable = $("#AgencyCustomersTable").DataTable(abp.libs.datatables.normalizeConfiguration({
        processing: true,
        serverSide: true,
        paging: true,
        searching: false,
        scrollX: true,
        autoWidth: true,
        scrollCollapse: true,
        order: [[1, "asc"]],
        ajax: abp.libs.datatables.createAjax(agencyCustomerService.getList, getFilter),
        columnDefs: [
            {
                rowAction: {
                    items:
                        [
                            {
                                text: l("Edit"),
                                visible: abp.auth.isGranted('IosIdentity.AgencyCustomers.Edit'),
                                action: function (data) {
                                    editModal.open({
                                     id: data.record.agencyCustomer.id
                                     });
                                }
                            },
                            {
                                text: l("Delete"),                                
                                visible: false, // abp.auth.isGranted('IosIdentity.AgencyCustomers.Delete'),
                                confirmMessage: function () {
                                    return l("DeleteConfirmationMessage");
                                },
                                action: function (data) {
                                    return false;
                                    //agencyCustomerService.delete(data.record.agencyCustomer.id)
                                    //    .then(function () {
                                    //        abp.notify.info(l("SuccessfullyDeleted"));
                                    //        dataTable.ajax.reload();
                                    //    });
                                }
                            }
                        ]
                }
            },
			{ data: "agencyCustomer.name" },
			{ data: "agencyCustomer.brandId" },
            {
                data: "agencyCustomer.answerDataUploadOptionId",
                render: function (data) {
                    return l('Enum:UploadOption.' + data);
                }
            },
            {
                data: "agencyCustomer.subAccountInventoryControlTypeId",
                render: function (data) {
                    return l('Enum:ControlType.' + data);
                }
            },
            {
                data: "agencyCustomer.allowSubAccounts",
                render: function (allowSubAccounts) {
                    return allowSubAccounts ? 'Yes' : 'No';
                    //return allowSubAccounts ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>';
                }
            },
            {
                data: "organizationUnit.displayName",
                defaultContent : ""
            }
        ]
    }));

    createModal.onResult(function () {
        dataTable.ajax.reload();
    });

    editModal.onResult(function () {
        dataTable.ajax.reload();
    });

    $("#NewAgencyCustomerButton").click(function (e) {
        e.preventDefault();
        createModal.open();
    });

	$("#SearchForm").submit(function (e) {
        e.preventDefault();
        dataTable.ajax.reload();
    });

    $('#AdvancedFilterSectionToggler').on('click', function (e) {
        $('#AdvancedFilterSection').toggle();
    });

    $('#AdvancedFilterSection').on('keypress', function (e) {
        if (e.which === 13) {
            dataTable.ajax.reload();
        }
    });

    $('#AdvancedFilterSection select').change(function() {
        dataTable.ajax.reload();
    });
    
    
});
عرض 1 الي 10 من 18 إدخالات
Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11