Any update please.
Any update on this please.
Hi,
I haveused Abp Suite 2.7.0 to create a new solution to Demo my team. I see below error from Identity server project.
2020-05-20 15:16:04.889 -04:00 [ERR] An unhandled exception has occurred while executing the request.
System.NullReferenceException: Object reference not set to an instance of an object.
at AspNetCore._Themes_Lepton_Components_Toolbar_LanguageSwitch_Default.ExecuteAsync() in /Themes/Lepton/Components/Toolbar/LanguageSwitch/Default.cshtml:line 6
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult.ExecuteAsync(ViewComponentContext context)
at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context)
at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments)
at Volo.Abp.AspNetCore.Mvc.UI.Widgets.AbpViewComponentHelper.InvokeAsync(Type componentType, Object arguments)
at AspNetCore._Themes_Lepton_Layouts_Account_Default.<>c__DisplayClass17_0.<<ExecuteAsync>b__7>d.MoveNext() in /Themes/Lepton/Layouts/Account/Default.cshtml:line 93
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
at AspNetCore._Themes_Lepton_Layouts_Account_Default.<>c__DisplayClass17_0.<<ExecuteAsync>b__3>d.MoveNext() in /Themes/Lepton/Layouts/Account/Default.cshtml:line 80
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
at AspNetCore._Themes_Lepton_Layouts_Account_Default.<>c__DisplayClass17_0.<<ExecuteAsync>b__1>d.MoveNext() in /Themes/Lepton/Layouts/Account/Default.cshtml:line 78
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
at AspNetCore._Themes_Lepton_Layouts_Account_Default.ExecuteAsync() in /Themes/Lepton/Layouts/Account/Default.cshtml:line 36
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass5_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Hi,
I don't see Add() method in the _alertSubEventTypeRepository If you are referring to use Add() method instead of InsertAsync().
Hi,
public class Alert : FullAuditedEntity<long>
{
[NotNull]
public virtual string FlightRegistrationNumber { get; set; }
[NotNull]
public virtual string Subject { get; set; }
public ICollection<AlertSubEventType> SubEvents { get; set; }
public Alert()
{
}
public Alert(long id, string flightRegistrationNumber, string subject, string details)
{
Id = id;
Check.NotNull(flightRegistrationNumber, nameof(flightRegistrationNumber));
Check.Length(flightRegistrationNumber, nameof(flightRegistrationNumber), AlertConsts.FlightRegistrationNumberMaxLength, 0);
Check.NotNull(subject, nameof(subject));
Check.Length(subject, nameof(subject), AlertConsts.SubjectMaxLength, 0);
FlightRegistrationNumber = flightRegistrationNumber;
Subject = subject;
Details = details;
SubEvents = new Collection<AlertSubEventType>();
}
public virtual void AddSubEvent(int eventId)
{
Check.NotNull(eventId, nameof(eventId));
if (IsInSubEvents(eventId))
{
return;
}
SubEvents.Add(new AlertSubEventType(Id, eventId));
}
public virtual void RemoveSubEvent(int eventId)
{
Check.NotNull(eventId, nameof(eventId));
if (!IsInSubEvents(eventId))
{
return;
}
SubEvents.RemoveAll(s => s.EventTypeId == eventId);
}
public bool IsInSubEvents(int eventId)
{
Check.NotNull(eventId, nameof(eventId));
return SubEvents.Any(s => s.EventTypeId == eventId);
}
}
public class AlertSubEventType : FullAuditedEntity
{
public long AlertId { get; set; }
public int EventTypeId { get; set; }
public AlertSubEventType()
{
}
public AlertSubEventType(long alertId, int eventTypeId)
{
AlertId = alertId;
EventTypeId = eventTypeId;
}
public override object[] GetKeys()
{
return new object[] { AlertId, EventTypeId };
}
}
public class EventType : FullAuditedEntity<int>
{
[NotNull]
public virtual string Name { get; set; }
public AlertEventType()
{
}
public EventType(int id, string name)
{
Id = id;
Check.NotNull(name, nameof(name));
Check.Length(name, nameof(name), EventTypeConsts.NameMaxLength, 0);
Name = name;
}
}
builder.Entity<Alert>(b =>
{
b.ToTable(VgccConsts.DbTablePrefix + "Alerts", VgccConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.FlightRegistrationNumber).HasColumnName(nameof(Alert.FlightRegistrationNumber)).IsRequired().HasMaxLength(AlertConsts.FlightRegistrationNumberMaxLength);
b.Property(x => x.Subject).HasColumnName(nameof(Alert.Subject)).IsRequired().HasMaxLength(AlertConsts.SubjectMaxLength);
b.Property(x => x.Details).HasColumnName(nameof(Alert.Details)).HasMaxLength(AlertConsts.DetailsMaxLength);
b.HasMany(a => a.SubEvents).WithOne().HasForeignKey(ae => ae.AlertId).IsRequired();
});
builder.Entity<AlertSubEventType>(b =>
{
b.ToTable(VgccConsts.DbTablePrefix + "AlertSubEventTypes", VgccConsts.DbSchema);
b.ConfigureByConvention();
b.HasKey(ae => new { ae.AlertId, ae.EventTypeId });
b.HasOne<EventType>().WithMany().HasForeignKey(ae => ae.EventTypeId).IsRequired();
b.HasOne<Alert>().WithMany(a => a.SubEvents).HasForeignKey(ae => ae.AlertId).IsRequired();
b.HasIndex(ae => new { ae.EventTypeId, ae.AlertId });
});
builder.Entity<EventType>(b =>
{
b.ToTable(VgccConsts.DbTablePrefix + "EventType", VgccConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name).HasColumnName(nameof(EventType.Name)).IsRequired().HasMaxLength(EventTypeConsts.NameMaxLength);
});
private readonly IAlertRepository _alertRepository;
private readonly IRepository<AlertSubEventType> _alertSubEventTypeRepository;
public virtual async Task<AlertDto> CreateAsync(AlertCreateDto input)
{
var newAlert = ObjectMapper.Map<AlertCreateDto, Alert>(input);
var alert = await _alertRepository.InsertAsync(newAlert);
await UpdateAlertByInput(alert, input); // inserting subevents here
await CurrentUnitOfWork.SaveChangesAsync(); //Error occured here
return ObjectMapper.Map<Alert, AlertDto>(alert);
}
protected virtual async Task UpdateAlertByInput(Alert alert, AlertCreateOrUpdateDtoBase input)
{
alert.Subject = input.Subject;
alert.FlightRegistrationNumber = input.FlightRegistrationNumber;
alert.PrimaryEventTypeId = input.PrimaryEventTypeId;
alert.ScopeId = input.ScopeId;
alert.SeverityId = input.SeverityId;
if (input.SubEventNames != null)
{
await SetSubEventsAsync(alert, input.SubEventNames);
}
}
private async Task SetSubEventsAsync([NotNull] Alert alert, [NotNull] IEnumerable<string> subEventNames)
{
Check.NotNull(alert, nameof(alert));
Check.NotNull(subEventNames, nameof(subEventNames));
var currentSubEventNames = await _alertRepository.GetSubEventTypes(alert);
var result = await RemoveFromSubEventsAsync(alert, currentSubEventNames.Except(subEventNames).Distinct());
result = await AddToSubEventsAsync(alert, subEventNames.Except(currentSubEventNames).Distinct());
}
private async Task<bool> RemoveFromSubEventsAsync(Alert alert, IEnumerable<string> subEvents)
{
Check.NotNull(alert, nameof(alert));
Check.NotNull(subEvents, nameof(subEvents));
var EventTypesMasterList = await _alertEventTypeRepository.GetListAsync();
foreach (var subEvent in subEvents)
{
var eventId = EventTypesMasterList.FirstOrDefault(e => e.Name == subEvent);
await _alertSubEventTypeRepository.DeleteAsync(new AlertSubEventType(alert.Id, eventId.Id));
}
return true;
}
private async Task<bool> AddToSubEventsAsync(Alert alert, IEnumerable<string> subEvents)
{
Check.NotNull(alert, nameof(alert));
Check.NotNull(subEvents, nameof(subEvents));
var EventTypesMasterList = await _alertEventTypeRepository.GetListAsync();
foreach (var subEvent in subEvents)
{
var eventId = EventTypesMasterList.FirstOrDefault(e => e.Name == subEvent);
await _alertSubEventTypeRepository.InsertAsync(new AlertSubEventType(alert.Id, eventId.Id));
}
return true;
}
ERROR Details:
2020-05-19 11:43:44.874 -04:00 [ERR] An error occurred while updating the entries. See the inner exception for details.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_AppAlertSubEventTypes_AppAlerts_AlertId". The conflict occurred in database "Vgcc", table "dbo.AppAlerts", column 'Id'.
The statement has been terminated.
at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__164_0(Task`1 result)
NOTE: I have followed ABP Identity module IdentityUser, IdentityRole & IdentityUserRole implementation. Let me know if any additionall details required.
please ignore.
Hi,
can you please provide a sample to adjust the dropdown & lable sizing while using abp-select.
I went through the docs, https://bootstrap-taghelpers.abp.io/Components/FormElements couldn't find an option.