Windows server 2016 IIS 10. On winhost. Com.
@aaron - The example document cited by @maliming in his first reply shows that code. I was NOT using that in version 6.3.1. That's what gave me that impression. Plus at this point I am just looking for help/direction to solve my issue. Is that too much to ask?
I did some more testing/debugging.
I applied the code to the UserClaimsPrincipalFactory with two claims.
public override async Task<ClaimsPrincipal> CreateAsync(User user)
{
var claim = await base.CreateAsync(user);
claim.Identities.First().AddClaim(new Claim("CompanyFilter", user.CompanyId.HasValue ? user.CompanyId.Value.ToString() : ""));
claim.Identities.First().AddClaim(new Claim("NurseHomeFilter", user.NurseHomeId.HasValue ? user.NurseHomeId.Value.ToString() : ""));
return claim;
}
In my DB Context, I have added these two methods. In debug, I dont see these methods execute.
protected virtual int? GetCurrentUsersCompanyIdOrNull()
{
var userOuClaim = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "CompanyFilter");
if (string.IsNullOrEmpty(userOuClaim?.Value))
{
return null;
}
return Convert.ToInt32(userOuClaim.Value);
}
protected virtual int? GetCurrentUsersNurseHomeIdOrNull()
{
var userOuClaim = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "NurseHomeFilter");
if (string.IsNullOrEmpty(userOuClaim?.Value))
{
return null;
}
return Convert.ToInt32(userOuClaim.Value);
}
In debug, i then checked the values of the filters when the "GetAll" repository method is called. They both have nothing?
> ? CurrentUnitOfWork.Filters
Count = 5
[0]: {Abp.Domain.Uow.DataFilterConfiguration}
[1]: {Abp.Domain.Uow.DataFilterConfiguration}
[2]: {Abp.Domain.Uow.DataFilterConfiguration}
[3]: {Abp.Domain.Uow.DataFilterConfiguration}
[4]: {Abp.Domain.Uow.DataFilterConfiguration}
> ? CurrentUnitOfWork.Filters[3]
{Abp.Domain.Uow.DataFilterConfiguration}
FilterName: "CompanyFilter"
FilterParameters: Count = 0
IsEnabled: true
> ? CurrentUnitOfWork.Filters[4]
{Abp.Domain.Uow.DataFilterConfiguration}
FilterName: "NurseHomeFilter"
FilterParameters: Count = 0
IsEnabled: true
It's going to take some time and effort for me to recreate in the demo project. I dont have time to do that right now.
Today, I went back to my V631 solution and retested my data filters there and it seems to be broken there too. Its working on one app service and MVC view but not on another. I dont know how this broke, I had tested all of my pages and services after I applied the changes. Now I'm more confused as to what the issue could be!
DB Context code:
protected override bool ShouldFilterEntity<TEntity>(IMutableEntityType entityType)
{
if (typeof(IHasCompany).IsAssignableFrom(typeof(TEntity)))
{
return true;
}
return false;
}
protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
{
Expression<Func<TEntity, bool>> expression = null;
if (typeof(IHasCompany).IsAssignableFrom(typeof(TEntity)))
{
Expression<Func<TEntity, bool>> companyFilter = e => ((IHasCompany)e).CompanyId == CurrentCompanyId || (((IHasCompany)e).CompanyId == CurrentCompanyId) == IsCompanyFilterEnabled;
expression = expression == null ? companyFilter : CombineExpressions(expression, companyFilter);
}
return base.CreateFilterExpression<TEntity>();
}
App service method, where filter is enabled.
public async Task<PagedResultDto<GetHomeForView>> GetAll(GetAllHomesInput input)
{
using (CurrentUnitOfWork.EnableFilter(AppConsts.CompanyFilter))
{
using (CurrentUnitOfWork.SetFilterParameter(AppConsts.CompanyFilter, AppConsts.CompanyFilterParameter_CompanyId, GetCurrentUserCompany()))
{
//code removed
}
}
}
When I run my code in debug (see image below), I can see the filter being applied in the using statement and there is a value as well. Yet once it goes inside the method code block and query executes, its not filtering the data. All rows in the table are being returned. All this code works perfectly in V6.3.1 solution.
@clintoncherry - I tried your suggestion today, when I was deploying an update to my hosted app. It did not make any difference. After publishing both errors that I reported in my original post still happened.
I'm not asking you about a specific tool or plugins. I provided Google maps as an example. My question is a generic one. Where should I place scripts that are to be used in Modals before "show" event and after "show" event. As currently I'm getting different results from placing them in the model cshtml.
@ismcagdas - I have opened new issue # 2104
@ismcagdas - Can you respond to each of my questions and clarify the correct placement?
@ismcagdas - When I tried to enter the issue, it showed me this one. Does that fix apply to my version and do you still want me to enter a new issue?