Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "deltavision"

Hi,

using: Core, MVC, jQuery project - v9.0.1

With EF / Net Core 3.0 - it is not possible as before to use extension method - e.g. for filtering.

Specific we have a string extension method - that checks if a string contains any string from a list/array of strings

        public static bool ContainsAny(this string str, params string[] values)
        {
            if (!string.IsNullOrEmpty(str) && values.Length > 0)
            {
                foreach (string value in values)
                {
                    if (str.ToUpper().Contains(value.ToUpper()))
                        return true;
                }
            }

            return false;
        }

used like this (searchWords variable is a string array)

            var query = _customerRepository
                 .GetAll()
                 .WhereIf(
                    ! input.Filter.IsNullOrWhiteSpace(),
                    c => 
                        c.CustomerName.ContainsAny(searchWords) );
                        
                        


as of Core 3.0 (EF) - this can not be converted to SQL. So we have to do a ToList() or equivalent - to get the "entire" result from DB and then start filtering...

any ideas on how to be able to use extension methods directly on the query / where clause ?

Hi @ismcagdas

any news on these issues :-)

NB: also reference to #4115

Hi maliming

thank you - we have done it with the code below. To avoid "breaking" exsisting use of AppServices - we created a "HangfireUser" in each tenant, with the relevant roles/rights.

var tenants = _tenantRepository.GetAll();
foreach(var tenant in tenants)
{
    using (CurrentUnitOfWork.SetTenantId(tenant.Id))
    {
        if (_featureChecker.IsEnabled(tenant.Id, AppFeatures.XYZ))
        {
            var tenantUser = _userManager.Users.FirstOrDefault(u => u.UserName.ToUpper() == "HangfireUser");
            if (tenantUser != null)
            {
                using (_abpSession.Use(tenant.Id, tenantUser.Id))
                {
                    // DO PROCESS...

Hi,

using: Core, MVC, jQuery project - v7.2.2

Reference to #5755 - Specific the last comment.

We have a Hangfire job that is run for each tenant. When in UnitOfWork for the specific tenant - call to methods that are authorized fails (No user logged in)

  • As suggested in #5755 - run a job as a user or role?
  • "Disable" authorized check for hangfire job called through host.

@bobingham,

thank you - works perfectly :-)

Hi ismcagdas

yes we did :-)

but do you have any best-practice for creating the jobs - where to initialize them (PostInitialize or...) and if we should use class based on BackgroundJob<>

Hi,

using: Core, MVC, jQuery project - v7.2.2

We wish to implement Hangfire in a project - but have som questions :-)

Need a background job running for each tenant - on a scheduled basis. (RecurringJob.AddOrUpdate) Should always be running - that is when the web site starts, the job should be "created" and start running. So no "manual" trigger to start job.

In the ....Web.Core project

  • Webconst - HangfireDashboardEnabled set to true
  • In this project should I uncomment "Configureation.BackgroundJobs.UseHangfire() in the ... WebCoreModule?

In the ...Web.Host project

  • Startup.cs - no changes made - it is checking the WebConst HangfireDashboardEnabled - OK?

**In the ...Web.Mvc project **

  • Startup.cs - no changes made - it is checking the WebConst HangfireDashboardEnabled - OK?

Defining / starting the Hangfire job From searching I can see that often jobs are created / started in the PostInitialize - eg. in ...WebMvcModule of the ...Web.Mvc project Is this the correct approach?

Or should we make a new controller? and then how do we trigger the job?

Should we create a class like below - based on BackgroundJob - and make an Execute method?

public class TestStatusService : BackgroundJob&lt;int&gt;, ITransientDependency

hoping for some "best practice" input :-)

Thank you

Hi ismcagdas

this works :-)

Thank you.

Showing 51 to 60 of 148 entries