Base solution for your next web application

Activities of "inovatech"

How did I not see it !!! ?? It was to test the length of the ParentId Code, not the ParentId itself. :oops: :geek: Thank you very much!!! Now everything is working.

Hi,

I sent my project via email as you requested. Please help me and thanks for your attention.

I fill in the value of the field inside the CreateOrganizationUnit routine.

<span style="color:#BF0000">String lFlgTipoOU = "";

If (input.ParentId.ToString (). Length == 0) {lFlgTipoOU = "P"; }; If (input.ParentId.ToString (). Length == 5) {lFlgTipoOU = "A"; }; If (input.ParentId.ToString (). Length == 11) {lFlgTipoOU = "D"; }; ... FlgTipoOrganizationUnit = lFlgTipoOU,</span>

Creating a root OrganizationUnit is working correctly. Only the sub-OrganizationUnit is experiencing a problem. I think it's something in relation to the Code field, because only when I pass the ParentId field does the error occur.

I made an extension of the OrganizationUnit entity, including new fields in the AbpOrganizationUnit table, and it is working very well except for the inclusion of the Sub-Units. The root Organization Unit´s are being added normally. If I do not pass the parentId parameter, the inclusion occurs, but as root Organization Unit.

My extension class is (Cad_Deposito): <span style="color:#BF0000"> public class Cad_Deposito : OrganizationUnit, IEndereco, IFlgInativo, IFullAudited { public const int MaxLengthDescr = 500; public const int MaxLengthCEP = 9; public const int MaxCodIBGE = 9999999; public const int MaxNumEndereco = 99999; public const int MaxSglUFEndereco = 2; public const int MaxCodCNPJ = 18;

    [Required]
    [MaxLength(MaxCodCNPJ)]
    public virtual string CodCNPJ { get; set; }

    [Required]
    [MaxLength(MaxLengthDescr)]
    public virtual string BairroEndereco { get; set; }

    [Required]
    [MaxLength(MaxLengthCEP)]
    public virtual string CEPEndereco { get; set; }

    [Required]
    [MaxLength(MaxLengthDescr)]
    public virtual string CidadeEndereco { get; set; }

    [Required]
    public virtual int CodIBGEEndereco { get; set; }

    [MaxLength(MaxLengthDescr)]
    public virtual string ComplEndereco { get; set; }

    [Required]
    [Range(0, MaxNumEndereco)]
    public virtual int NumEndereco { get; set; }

    [Required]
    [MaxLength(MaxLengthDescr)]
    public virtual string RuaEndereco { get; set; }

    [Required]
    [MaxLength(MaxSglUFEndereco)]
    public virtual string SiglaUFEndereco { get; set; }

    [Required]
    public virtual bool FlgInativo { get; set; }

    public long? FlgInativoUserId { get; set; }

    public DateTime? FlgInativoTime { get; set; }

    [Required]
    public virtual bool FlgMatriz { get; set; }

    public virtual ICollection&lt;Cad_DepositoContato&gt; Contatos { get; set; }

    /// &lt;summary&gt;
    /// Indica se a Organization Unit é P = Planta, A = Armazém, D = Depositante
    /// &lt;/summary&gt;
    [Required]
    public string FlgTipoOrganizationUnit { get; set; }

    [Required]
    public virtual int TipoDocumentacaoId { get; set; }
    [ForeignKey("TipoDocumentacaoId")]
    public virtual Cad_Tipo_Documentacao Cad_Tipo_Documentacao { get; set; }
}&lt;/span&gt;

In OrganizationUnitAppService I changed the "CreateOrganizationUnit":

<span style="color:#BF0000"> public async Task<OrganizationUnitDto> CreateOrganizationUnit(CreateOrganizationUnitInput input) {

        string lFlgTipoOU = "";

        if (input.ParentId.ToString().Length == 0) { lFlgTipoOU = "P"; };
        if (input.ParentId.ToString().Length == 5) { lFlgTipoOU = "A"; };
        if (input.ParentId.ToString().Length == 11) { lFlgTipoOU = "D"; };
        

        var organizationUnit = new Cad_Deposito()
        {
            TenantId = AbpSession.TenantId,
            DisplayName = input.DisplayName,
            ParentId = input.ParentId,
            CodCNPJ = input.CodCNPJ,
            BairroEndereco = input.BairroEndereco,
            CEPEndereco = input.CEPEndereco,
            CidadeEndereco = input.CidadeEndereco,
            CodIBGEEndereco = input.CodIBGEEndereco,
            ComplEndereco = input.ComplEndereco,
            NumEndereco = input.NumEndereco,
            RuaEndereco = input.RuaEndereco,
            SiglaUFEndereco = input.SiglaUFEndereco,
            FlgInativo = input.FlgInativo,
            FlgMatriz = input.FlgMatriz,
            FlgTipoOrganizationUnit = lFlgTipoOU,
            TipoDocumentacaoId = input.TipoDocumentacaoId

        };

        await _organizationUnitManager.CreateAsync(organizationUnit);
        await CurrentUnitOfWork.SaveChangesAsync();

        return organizationUnit.MapTo&lt;OrganizationUnitDto&gt;();
    }&lt;/span&gt;

But, the error in the Audit Log is: <span style="color:#BF0000"> System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. em System.Data.Entity.Internal.InternalContext.SaveChangesAsync(CancellationToken cancellationToken) em System.Data.Entity.Internal.LazyInternalContext.SaveChangesAsync(CancellationToken cancellationToken) em Abp.EntityFramework.AbpDbContext.<SaveChangesAsync>d__34.MoveNext() na D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\AbpDbContext.cs:linha 204 --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) em Abp.EntityFramework.Uow.EfUnitOfWork.<SaveChangesInDbContextAsync>d__23.MoveNext() na D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\EfUnitOfWork.cs:linha 209 --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) em Abp.EntityFramework.Uow.EfUnitOfWork.<SaveChangesAsync>d__14.MoveNext() na D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Uow\EfUnitOfWork.cs:linha 80 --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada --- em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) em System.Runtime.CompilerServices.TaskAwaiter.GetResult() em Inovatech.INVTC.Organizations.OrganizationUnitAppService.<CreateOrganizationUnit>d__10.MoveNext() na C:\INVTC_aspnetzero_v1_12 - Copia\Inovatech.INVTC.Application\Organizations\OrganizationUnitAppSer... </span> This is the input: <span style="color:#BF0000">{ "input": { "parentId": 64, "displayName": "Santos", "codCNPJ": "95.959.595/9595-95", "bairroEndereco": "Alto da Mooca", "cepEndereco": "03178-120", "cidadeEndereco": "São Paulo", "codIBGEEndereco": 3550308, "complEndereco": null, "numEndereco": 0, "ruaEndereco": "Rua Vladimir Jorge", "siglaUFEndereco": "SP", "flgInativo": false, "flgMatriz": false, "flgTipoOrganizationUnit": null, "tipoDocumentacaoId": 1 } }</span>

Please, help me !!!

Answer

Yes, I solved the problem. It was my mistake. Tks.

Question

I'm creating an OrganizationUnit-dependent table, with contact information (Name, Phone, etc.). However I am having an error in the command to delete a contact and I am not understanding the reason. Could you help me, please?

The error message is (obtained by the Audit log): <span style="color:#FF0000"> System.Reflection.AmbiguousMatchException: Equivalência ambígua encontrada. em System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) em System.Type.GetProperty(String name, BindingFlags bindingAttr) em System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName) em Abp.Domain.Repositories.AbpRepositoryBase2.CreateEqualityExpressionForId(TPrimaryKey id) na D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Repositories\AbpRepositoryBase.cs:linha 262 em Abp.Domain.Repositories.AbpRepositoryBase2.FirstOrDefault(TPrimaryKey id) na D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Repositories\AbpRepositoryBase.cs:linha 104 em Castle.Proxies.EfRepositoryBase3Proxy_22.FirstOrDefault_callback(Int64 id) em Castle.Proxies.Invocations.AbpRepositoryBase2_FirstOrDefault_52.InvokeMethodOnTarget() em Castle.DynamicProxy.AbstractInvocation.Proceed() em Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) na D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:linha 53 em Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) na D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:linha 45 em Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) na D:\Halil\GitHub\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:linha 35 em Castle.DynamicProxy.AbstractInvocation.Proceed() em Castle.Proxies.EfRepositoryBase3Proxy_22.FirstOrDefault(Int64 id) em Abp.EntityFramework.Repositories.EfRepositoryBase3.Delete(TPrimaryKey id) na D:\Halil\GitHub\aspnetboilerplate\src\Abp.EntityFramework\EntityFramework\Repositories\EfRepositoryBaseOfTEntityAndTPrimaryKey.cs:linha 174 em Castle.Proxies.EfRepositoryBase`3Proxy_22.Delete_call...

The call of the Angular command is: vm.deleteContato = function (contato) { abp.message.confirm( app.localize('ContatoDeleteWarningMessage', contato.nome), function (isConfirmed) { if (isConfirmed) { organizationUnitService.deleteContato({ id: contato.depositoContatoId }).then(function () { vm.getOrganizationUnits(); abp.notify.success(app.localize('SuccessfullyDeleted')); }); } } ); };

In the ApplicationService I'm doing this:

public async Task DeleteContato(EntityDto input) { await _contatoRepository.DeleteAsync(input.Id); }

Declaration of _contatoRepository is:

private readonly IRepository<Cad_DepositoContato, long> _contatoRepository;

And my class Cad_DepositoContato is:

public class Cad_DepositoContato : FullAuditedEntity

    public long DepositoContatoId { get; set; }
    public virtual string Nome { get; set; }
    public virtual int CodDDI { get; set; }
    public virtual int CodDDD { get; set; }
    public virtual string Fone { get; set; }
    public virtual string Email { get; set; }
    public bool FlgAtivo { get; set; }
    public bool FlgResponsavel { get; set; }

    [ForeignKey("Id")]
    public virtual Cad_Deposito Cad_Deposito { get; set; }
    [Column("OrganizationUnitId")]
    public virtual long Id { get; set; }</span>

Hi for all!!!! I figured out how to do it!!! Tks for all!!!!

In the file CreateOrUpdateUnitModal.js add $uibModalInstance, $uibModal:

appModule.controller('common.views.organizationUnits.createOrEditUnitModal', [
    '$scope', '$uibModalInstance', '$uibModal', 'abp.services.app.organizationUnit', 'organizationUnit',
    function ($scope, $uibModalInstance, $uibModal, organizationUnitService, organizationUnit) {
        var vm = this;

        vm.createContato = function (organizationUnit) {
            openCreateOrEditOUContatoModal(organizationUnit, null);
        };


        vm.editContato = function (organizationUnit, contato) {
            openCreateOrEditOUContatoModal(organizationUnit, contato);
        };


        function openCreateOrEditOUContatoModal(organizationUnit, contato) {
            var modalInstance = $uibModal.open({
                templateUrl: '~/App/common/views/organizationUnits/createOrEditOUContatoModal.cshtml',
                controller: 'common.views.organizationUnits.createOrEditOUContatoModal as vm',
                backdrop: 'static',
                resolve: {
                    param: function () {
                        return { 'organizationUnit': organizationUnit, 'contato': contato };
                    }
                }
            });

            modalInstance.result.then(function (result) {
                vm.getOrganizationUnits();
            });
        }

And add the function openCreateOrEditOUContatoModal:

(function () { appModule.controller('common.views.organizationUnits.createOrEditOUContatoModal', [ '$scope', '$uibModalInstance', 'abp.services.app.organizationUnit', 'param', function ($scope, $uibModalInstance, organizationUnitService, param) { var vm = this;

    vm.organizationUnit = param.organizationUnit;
    vm.contato = param.contato;

    vm.cancel = function () {
        $uibModalInstance.dismiss();
    };


    vm.save = function () {
        vm.contato.organizationUnitId = param.organizationUnit.id;
        if (vm.contato.depositoContatoId) {
            organizationUnitService
                .updateContato(vm.contato)
                .then(function (result) {
                    abp.notify.info(app.localize('SavedSuccessfully'));
                    $uibModalInstance.close(result.data);
                });
        } else {
            organizationUnitService
                .createContato(vm.contato)
                .then(function (result) {
                    abp.notify.info(app.localize('SavedSuccessfully'));
                    $uibModalInstance.close(result.data);
                });
        }


    };


    }
]);

})();

I'm trying to open a new modal form from CreateOrUpdateUnitModal, but I'm not getting. I did the same procedure in the sample PhoneBook project , and it worked. Please, help me!!!!

I'm doing the following:

In the file CreateOrUpdateUnitModal.cshtml, i have a button:

<span style="color:#FF0000"><button ng-if="vm.permissions.createOUContato" class="btn btn-primary blue" ng-disabled="!vm.organizationUnit.id" ng-click="vm.createContato(vm.organizationUnit)"><i class="fa fa-plus"></i> @L("CreateNewOUContato")</button></span>

In then file CreateOrUpdateUnitModal.js, i added "$uibModal, $uibModalInstance"

<span style="color:#FF0000">appModule.controller('common.views.organizationUnits.createOrEditUnitModal', [ '$scope', '$uibModal', '$uibModalInstance', 'abp.services.app.organizationUnit', 'organizationUnit', function ($scope, $uibModal, $uibModalInstance, organizationUnitService, organizationUnit) {</span>

And add the function openCreateOrEditOUContatoModal:

             &lt;span style=&quot;color:#FF0000&quot;&gt;      **vm.createContato = function (OU) {
            openCreateOrEditOUContatoModal(OU);
        };**&lt;/span&gt;

 &lt;span style=&quot;color:#FF0000&quot;&gt;      **function openCreateOrEditOUContatoModal(OU) {
            var modalInstance2 = $uibModal.open({
                templateUrl: '~/App/common/views/organizationUnits/createOrEditOUContatoModal.cshtml',
                controller: 'common.views.organizationUnits.createOrEditOUContatoModal as vm',
                backdrop: 'static',
                resolve: {
                    OU: function () {
                        return OU;
                    }
                }
            });

            modalInstance2.result.then(function (result) {
                vm.getOrganizationUnits();
            });
        }**&lt;/span&gt;

I would like to hear from you on what the best approach to have to develop a single application using multiple databases (SQL Server or Oracle (one at a time)). It would be better to use Entity Framework with Code First or Model First? I browsed the available documentation aspnetboilerplate and Oracle, but had problems with the Migrations. Please help me this question.

I would like to centralize the contents of a grid cell, but I can't. In SurName column on columnDefs, I tried to use cellClass, but did not work (file \App\common\views\users\index.js). Could help me, please?

Showing 1 to 10 of 13 entries