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<Cad_DepositoContato> Contatos { get; set; }
/// <summary>
/// Indica se a Organization Unit é P = Planta, A = Armazém, D = Depositante
/// </summary>
[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; }
}</span>
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<OrganizationUnitDto>();
}</span>
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 !!!
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.AbpRepositoryBase
2.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.AbpRepositoryBase
2_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.EfRepositoryBase
3.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>
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:
<span style="color:#FF0000"> **vm.createContato = function (OU) {
openCreateOrEditOUContatoModal(OU);
};**</span>
<span style="color:#FF0000"> **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();
});
}**</span>
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?
Hi, It is possible, if so how, get the amount of users logged by tenant ?
You could provide a step by step how to change the theme Metronic Admin4 (default) to the theme Metronic Admin1?
I put all Metronic files in the solution and changed the path files of "\layout4" files for "\layout", but some things have stopped working (eg the display of submenus).
Please at least give me some tips.
Tks.