I see some documation here; https://aspnetboilerplate.com/Pages/Documents/Timing I will try setting clock provider and retest.
Hi,
It doesn't look like we've configured Clock.Provider in the API project. I've searched in all .cs files for "Clock.Provider",
Do we need to configure clock provider?
Thanks
What is your product version? 10.2.0
What is your product type (Angular or MVC)?Angular
What is product framework type (.net framework or .net core)? .net core
RAD Power tool version 3.1.1
Hi,
Recreation steps:
I created a new entity with a single property (DateTime) using the RAD Power tool. I then picked 1st Jan 1970 as the date when creating the new entity with the UI generated by the RAD Power tool. The date is saved incorrectly as "1969-12-31 23:00:00.0000000" in the database.
I tried the same with 1st Jan 1971 and it saved incorrectly as "1970-12-31 23:00:00.0000000" in the database.
Then I tried 1st Jan 2022 and it saved correctly as "2022-01-01 00:00:00.0000000"
Are you aware of this bug and how it may be fixed?
Though debugging I can see that the fault lies in the UI , the API is receiving the wrong date through the REST call.
Ok, so I managed to get this working by injecting the UOW manager into the Authorization Handler:
using (var uow = _unitOfWorkManager.Begin())
{
var exampleEntity = await _entityRepository.FirstOrDefaultAsync(entityId);
var teamId = exampleEntity?.TeamId;
........
}
What is your product version? 10.2.0
What is your product type (Angular or MVC)?Angular
What is product framework type (.net framework or .net core)? .net core
Hi,
Looking to add custom policy and requirement based authorization to asp net zero as per: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-6.0#iauthorizationservice
It is working as intended but when i try to access a default repository to check for some values it seems like it hasn't been registered and I get an error:
I'm using constructor parameter injection in the requirement handler.
System.ArgumentNullException: Value cannot be null. (Parameter 'unitOfWork') at Abp.EntityFrameworkCore.Uow.UnitOfWorkExtensions.GetDbContext[TDbContext](IActiveUnitOfWork unitOfWork, Nullable
1 multiTenancySide, String name)
at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetContext() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase
3.<GetQueryableAsync>b__8_0(Type key)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func
2 valueFactory)
at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetQueryableAsync() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase
3.GetAllIncludingAsync(Expression1[] propertySelectors) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase
3.GetAllAsync()
at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.FirstOrDefaultAsync(TPrimaryKey id) at TCM.Web.Startup.Authorization.TeamMemberAuthorizationHandler.HandleRequirementAsync(AuthorizationHandlerContext context, TeamMemberRequirement requirement) in C:\Users\EKeane\source\repos\TCM\aspnet-core\src\TCM.Web.Host\Startup\Authorization\TeamMemberAuthorizationHandler.cs:line 66 at Microsoft.AspNetCore.Authorization.AuthorizationHandler
1.HandleAsync(AuthorizationHandlerContext context)
at Microsoft.AspNetCore.Authorization.DefaultAuthorizationService.AuthorizeAsync(ClaimsPrincipal user, Object resource, IEnumerable1 requirements) at Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator.AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, Object resource) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Any help appreciated
That link is not reachable.
Hi Team,
I figured out the work around by bringing my handlers back into Application project.
It was not working when I had handlers in a new class library, as you can see I did made them ITransientDependency as well which should Ideally register the handlers in dependency container for the event.
My assumption, somehow handlers in different projects dont get recognised/ mapped although after implementing ITransientDependency, thats why even if trigger the event from application project, they dont get picked by handlers.
Please look into it, is there anything extra I need to do to keep the handlers in a separate prooject, its very important as we are planning to divide the whole project into smaller libraries instead of one FAT application or core etc project, which will also help us in upgrading version of aspnetzero as eventually the shipped projects will be untouched.
Regards
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
Im trying to leverage Event Bus to fire Custom Domain Events but looks there is some problem and the subscribed handlers are not receiving the event data. Below is a s sample of code of what I am doing.
https://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events
` /* SAMPLE CODE */
public class InspectionFailedEventData : EventData
{
// Few Properties which will be part of Event Data
}
public interface IInspectionFailedEventManager : IEventHandler<InspectionFailedEventData>, ITransientDependency
{
// Interface for Handlers
}
public class SendEmailOnInspectionStatusChange : IInspectionFailedEventManager
{
// First handler (Subscription) for the event data
private readonly IEmailTemplateProvider _emailTemplateProvider;
private readonly ISiteRepository _siteRepository;
private readonly IEmailSender _emailSender;
private readonly IRepository<Capture, Guid> _captureRepository;
private const string TemplateName = "InspectionCompleteEmailTemplate";
public SendEmailOnInspectionStatusChange(IEmailTemplateProvider emailTemplateProvider,
ISiteRepository siteRepository,
IEmailSender emailSender,
IRepository<Capture, Guid> captureRepository)
{
_emailTemplateProvider = emailTemplateProvider;
_siteRepository = siteRepository;
_emailSender = emailSender;
_captureRepository = captureRepository;
}
public void HandleEvent(InspectionFailedEventData eventData)
{
var captureDetails = _captureRepository.GetAllIncluding(s => s.CaptureTemplate)
.Include(s => s.CaptureTemplate)
.FirstOrDefault(s => s.Id == eventData.InspectionId);
if (captureDetails != null)
{
var templateForStatusChange = _emailTemplateProvider.GetTemplate(eventData.TenantId, TemplateName);
templateForStatusChange = templateForStatusChange.Replace("{Material}", captureDetails.CaptureTemplate.ItemName);
templateForStatusChange = templateForStatusChange.Replace("{ItemNumber}", captureDetails.SMPItemNumber);
templateForStatusChange = templateForStatusChange.Replace("{SMPLotNumber}", captureDetails.SMPLotNumber);
templateForStatusChange = templateForStatusChange.Replace("{CompletedUser}", eventData.UserName);
templateForStatusChange = templateForStatusChange.Replace("{StatusColour}", eventData.InspectionPassed ? "green" : "red");
templateForStatusChange = templateForStatusChange.Replace("{MaterialStatus}", ((CaptureStatusEnum)captureDetails.CaptureStatusId).ToString());
var wareHouseEmail = _siteRepository.Get(eventData.TenantId).WarehouseDistributionEmail;
if (string.IsNullOrEmpty(wareHouseEmail))
{
throw new EntityNotFoundException("No email sent. Warehouse email was not set for this site");
}
_emailSender.SendAsync(new MailMessage
{
To = { wareHouseEmail },
Subject = "Inspection Complete",
Body = templateForStatusChange,
IsBodyHtml = true
});
}
}
}
public class SendStatusToQadOnInspectionStatusChange : IInspectionFailedEventManager
{
// Second handler (Subscription) for the event data
private readonly IQadIntegrationAction _qadIntegrationAction;
public SendStatusToQadOnInspectionStatusChange(IQadIntegrationAction qadIntegrationAction)
{
_qadIntegrationAction = qadIntegrationAction;
}
public void HandleEvent(InspectionFailedEventData eventData)
{
var stockInboundMessage = new QadStockInboundMessage()
{
Id = eventData.Id,
ExpiryDate = eventData.ExpiryDate,
Status = eventData.InspectionPassed ? QadStatus.Available : QadStatus.Quality
};
_qadIntegrationAction.SendStockUpdateToServiceBusAsync(stockInboundMessage);
}
}
// AppService
public async Task<string> SetInspectionStatus(SetInspectionStatusDto input)
{
var user = await GetCurrentUserAsync();
var tenant = await GetCurrentTenantAsync();
var userName = user.FullName;
var hasInspectionPassed = CheckIfCaptureHasPassed(input.CaptureId);
capture.CaptureTypeLockId = null;
capture.ReleasedTime = DateTime.UtcNow;
capture.ReleasedById = (await GetCurrentUserAsync()).Id;
if (!hasInspectionPassed)
{
capture.CaptureStatusId = (int)CaptureStatusEnum.ReleaseFailed;
}
// Event Data Creation
var eventData = new InspectionFailedEventData
{
Id = capture.GRN,
InspectionId = capture.Id,
InspectionPassed = hasInspectionPassed,
ExpiryDate = capture.ExpiryDate,
UserName = userName,
TenantId = tenant.Id
};
// EventData passed to a Domain Service with some extra info
await _inspectionEventManager.TakeActionOnInspectionFailAsync(eventData, user, tenant);
return CaptureStatusEnum.Release.ToString();
}
// DomainService
class InspectionEventManager : PortalDomainServiceBase, IInspectionEventManager
{
public IEventBus EventBus { get; set; }
public InspectionEventManager()
{
EventBus = NullEventBus.Instance;
}
public async Task TakeActionOnInspectionFailAsync(InspectionFailedEventData eventData, User user1, Tenant tenant)
{
await EventBus.TriggerAsync(this, eventData);
}
}
`
Nothing happens when TriggerAsync method is called, and I cant figure out a way to debug or resolve it.
Version9.0.1 Angular .net core
Running an AMD Ryzen 5 3600 with 32gb Ram.
Is there anything I can do to speed it up? npm start takes 3min 52sec
The logs are: Dynamic bundles are being created. [14:18:58] Finished 'buildDev' after 1.57 min Then it does another building where it takes the duration. One file sticks out and takes particularly long 69% building 1139/1140 modules 1 active ...js??ref--13-3!C:\Users\jtallon\source\repos\XYZ\Portal\angular\src\app\shared\layout\themes\kendo\theme.scss
Is this to be expected? We accept it but I wonder if it can be quickened even more. AOT is off for Dev which is handy for rebuilds of simple pages.