Atividades de "moinahmed"

Responder

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;		
	}
}
Responder

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

Responder

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

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

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 need to add a new Menu item in Administration > Identity Management. How can I do that?

Thanks, Moin

Pergunta

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?

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?

I have created a new entity and it's respective page, models, and app service in a separate project and then manually moved every artifact into my project. The entity listing and crud operations were working perfectly fine in the separate project where I actually generated it, however, the issue started arising when I moved all the artifacts into my main project. All looks good, except I cannot locate app service in my entity-page's index.js file. My entity name is agencyCustomer and when I go in index.js file, the code fails at: var agencyCustomerService = window.iosIdentity.pS3.agencyCustomers; The error says iosIdentity.pS3 is undefined or null, while I can see the namespace is there with the app service. I'm unsure about why the error is coming. I have made sure all the code files are moved properly with every change carefully checked, but stuck on the above error. Any idea what could have gone wrong here?

Thanks, Moin

$(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();
    });
    
    
});
Mostrando 11 até 20 de 28 registros
Made with ❤️ on ABP v8.2.0-preview Updated on março 25, 2024, 15:11