eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
222 stars 115 forks source link

Hangfire :Execute Action Job did not appear in Workers and Dashboard access did not work #990

Closed qwertybba closed 8 months ago

qwertybba commented 1 year ago

Hello; My configuration

Devexpress XAF Blazor 22.2.5 (XPO,Postgres) with two projects [XpandTest.Blazor.Server, XpandTest.Module] <PackageReference Include="Xpand.XAF.Web.All" Version="4.222.6" /> <PackageReference Include="Hangfire.PostgreSql" Version="1.19.12" />

RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.Blazor.BlazorModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.JobScheduler.Hangfire.JobSchedulerModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.Email.EmailModule));

In startup class I added


[assembly: HostingStartup(typeof(HostingStartup))]
[assembly: HostingStartup(typeof(HangfireStartup))]
[assembly: HostingStartup(typeof(Xpand.XAF.Modules.Blazor.BlazorStartup))]
namespace XpandTest.Blazor.Server;
    services.AddHangfire(configuration => configuration
    .UsePostgreSqlStorage(Configuration.GetConnectionString("HangfireConnection")));
    services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => {
        options.LoginPath = "/LoginPage";
    });

01-After creating an Execute Action Job and triggering it the job works fine but it is not appearing in the Workers list view (The view has been refreshed) I tried several jobs all with the same result.
![Execute Action Job-Workers](https://user-images.githubusercontent.com/20028775/232322672-a612f939-29df-48d0-bcba-e171dfa21ca9.jpg)

02-The Hangfire dashboard can still be accessed from the URL although I have restricted access to the user using the Security system.
![HangFireDashboardDeniedAction](https://user-images.githubusercontent.com/20028775/232322682-eb087532-aa34-4bc7-b124-f00839eab172.jpg)

[github simple](https://github.com/qwertybba/XpandTest)
Or zip file
[XpandTest-master.zip](https://github.com/eXpandFramework/eXpand/files/11242644/XpandTest-master.zip)
apobekiaris commented 1 year ago

I did my test with an inmem storage, as it easier to setup. Please verify it as well and post the problematic sample

qwertybba commented 1 year ago

I did my test with an inmem storage, as it easier to setup. Please verify it as well and post the problematic sample

Unfortunately, I got the same result github simple InMemoryStorage.zip

apobekiaris commented 1 year ago

it should be easier to repro if in mem though

qwertybba commented 1 year ago

it should be easier to repro if in mem though

I'm sorry, but I don't understand. I have already provided the simples with InMemoryStorage

qwertybba commented 1 year ago

It also appears that two servers have been created with the same name and port, but different GUIDs HangfireServers

apobekiaris commented 1 year ago

After creating an Execute Action Job and triggering it the job works fine but it is not appearing in the Workers list view (The view has been refreshed) I tried several jobs all with the same result.

looks same https://github.com/eXpandFramework/eXpand/issues/992#issuecomment-1519961370

It also appears that two servers have been created with the same name and port

posible u used the AddHangfire twice the module is calling the method use GlobalConfiguration.Configuration instead

The Hangfire dashboard can still be accessed

fixed in next minor

qwertybba commented 1 year ago

First of all, I really appreciate the time and effort you put into this project.

It also appears that two servers have been created with the same name and port

posible u used the AddHangfire twice the module is calling the method use GlobalConfiguration.Configuration instead

Regarding getting two servers, I've tried different methods without success Method 01: I installed InMemory package <PackageReference Include="Hangfire.InMemory" Version="0.3.7" /> in Startup class I added this code GlobalConfiguration.Configuration.UseInMemoryStorage();

Method 02: I installed MemoryStorage package <PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" /> in Startup class I added this code GlobalConfiguration.Configuration.UseMemoryStorage();

Method 03: I installed PostgreSql package <PackageReference Include="Hangfire.PostgreSql" Version="1.19.12" /> in Startup class I added this code

 var hangFireConnection = Configuration.GetConnectionString("HangfireConnection");
 GlobalConfiguration.Configuration.UsePostgreSqlStorage(hangFireConnection);
apobekiaris commented 1 year ago

do you have the AddHangfire call in your startup? remove it

qwertybba commented 1 year ago

do you have the AddHangfire call in your startup? remove it

I don't have any AddHangfire call in my startup class

using DevExpress.ExpressApp.Security;
using DevExpress.ExpressApp.ApplicationBuilder;
using DevExpress.ExpressApp.Blazor.ApplicationBuilder;
using DevExpress.ExpressApp.Blazor.Services;
using DevExpress.Persistent.Base;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Server.Circuits;
using DevExpress.ExpressApp.Xpo;
using XpandTest.Blazor.Server.Services;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
using DevExpress.ExpressApp.Core;
using Hangfire;
using Hangfire.PostgreSql;
using Hangfire.MemoryStorage;
using Xpand.Extensions.Blazor;
using Xpand.XAF.Modules.JobScheduler.Hangfire.Hangfire;

[assembly: HostingStartup(typeof(HostingStartup))]
[assembly: HostingStartup(typeof(HangfireStartup))]
[assembly: HostingStartup(typeof(Xpand.XAF.Modules.Blazor.BlazorStartup))]
namespace XpandTest.Blazor.Server;

public class Startup {
    public Startup(IConfiguration configuration) {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }
    public void ConfigureServices(IServiceCollection services) {
        services.AddSingleton(typeof(Microsoft.AspNetCore.SignalR.HubConnectionHandler<>), typeof(ProxyHubConnectionHandler<>));

        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddHttpContextAccessor();
        services.AddScoped<CircuitHandler, CircuitHandlerProxy>();      
        services.AddXaf(Configuration, builder => {
            builder.UseApplication<XpandTestBlazorApplication>();
            builder.Modules
                .AddAuditTrailXpo()
                .AddCloningXpo()
                .AddConditionalAppearance()
                .AddDashboards(options => {
                    options.DashboardDataType = typeof(DevExpress.Persistent.BaseImpl.DashboardData);
                })
                .AddFileAttachments()
                .AddOffice()
                .AddReports(options => {
                    options.EnableInplaceReports = true;
                    options.ReportDataType = typeof(DevExpress.Persistent.BaseImpl.ReportDataV2);
                    options.ReportStoreMode = DevExpress.ExpressApp.ReportsV2.ReportStoreModes.XML;
                    options.ShowAdditionalNavigation = true;
                })
                .AddStateMachine(options => {
                    options.StateMachineStorageType = typeof(DevExpress.ExpressApp.StateMachine.Xpo.XpoStateMachine);
                })
                .AddValidation()
                .AddViewVariants(options => {
                    options.ShowAdditionalNavigation = true;
                })
                .Add<XpandTest.Module.XpandTestModule>()
                .Add<XpandTestBlazorModule>();
            builder.ObjectSpaceProviders

                .AddSecuredXpo((serviceProvider, options) =>
                {
                    string connectionString = null;
                    if (Configuration.GetConnectionString("ConnectionString") != null)
                    {
                        connectionString = Configuration.GetConnectionString("ConnectionString");
                    }
                    ArgumentNullException.ThrowIfNull(connectionString);
                    options.ConnectionString = connectionString;
                    options.ThreadSafe = true;
                    options.UseSharedDataStoreProvider = true;
                })
                .AddNonPersistent();
            builder.Security
                .UseIntegratedMode(options => {
                    options.RoleType = typeof(PermissionPolicyRole);
                    options.UserType = typeof(XpandTest.Module.BusinessObjects.ApplicationUser);
                    options.UserLoginInfoType = typeof(XpandTest.Module.BusinessObjects.ApplicationUserLoginInfo);
                    options.UseXpoPermissionsCaching();
                })
                .AddPasswordAuthentication(options => {
                    options.IsSupportChangePassword = true;
                });
        });

        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => {
            options.LoginPath = "/LoginPage";
        });

        GlobalConfiguration.Configuration.UseInMemoryStorage();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
        if(env.IsDevelopment()) {
            app.UseDeveloperExceptionPage();
        }
        else {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. To change this for production scenarios, see: https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }
        app.UseHttpsRedirection();
        app.UseRequestLocalization();
        app.UseStaticFiles();
        app.UseRouting();
        app.UseAuthentication();
        app.UseAuthorization();
        app.UseXaf();
        app.UseEndpoints(endpoints => {
            endpoints.MapXafEndpoints();
            endpoints.MapBlazorHub();
            endpoints.MapFallbackToPage("/_Host");
            endpoints.MapControllers();
        });
    }
}
apobekiaris commented 1 year ago

in this project i see 1 server DXApplication4.zip

qwertybba commented 1 year ago

in this project i see 1 server DXApplication4.zip

Even with this project I have 2 servers, I have no clue where the problem is?

qwertybba commented 1 year ago

Hello; Now that I have upgraded to the latest version, all my problems have been resolved, and I only have one server. I appreciate your help a lot

<ItemGroup>
  <PackageReference Include="Hangfire.InMemory" Version="0.4.0" />
  <PackageReference Include="Xpand.XAF.Modules.JobScheduler.Hangfire" Version="4.222.10" />
</ItemGroup>

I would appreciate it if you could provide a link to the project that you used for creating Chain Jobs

ChainJobs I the next screencast:

1.We create a new ExecuteActionJob that will schedule the Email action for a Product. 2.We create a new ObjectStateNotificationJob for new Products. 3.We add a new ChainedJob to run te Email ExecuteActionJob after a successful with new Products execution of the ObjectStateNotification job. 4.We check the recipient email to verify that emails send for the new Products found.

expand commented 1 year ago

The pre-release 4.222.11.0 in the Reactive.XAF lab branch includes commits that relate to this task:

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.222.13
Xpand.Extensions.Blazor v.4.222.13
Xpand.Extensions.Mono.Cecil v.4.222.13
Xpand.Extensions.Office.Cloud v.4.222.13
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.222.13
Xpand.Extensions.Reactive v.4.222.13
Xpand.Extensions.XAF v.4.222.13
Xpand.Extensions.XAF.Xpo v.4.222.13
Xpand.TestsLib v.4.222.13
Xpand.TestsLib.Blazor v.4.222.13
Xpand.TestsLib.Common v.4.222.13
Xpand.TestsLib.EasyTest v.4.222.13
Xpand.VersionConverter v.4.222.13
Xpand.XAF.Core.All v.4.222.13
Xpand.XAF.Modules.AutoCommit v.4.222.13
Xpand.XAF.Modules.Blazor v.4.222.13
Xpand.XAF.Modules.BulkObjectUpdate v.4.222.13
Xpand.XAF.Modules.CloneMemberValue v.4.222.13
Xpand.XAF.Modules.CloneModelView v.4.222.13
Xpand.XAF.Modules.Email v.4.222.13
Xpand.XAF.Modules.GridListEditor v.4.222.13
Xpand.XAF.Modules.HideToolBar v.4.222.13
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.222.13
Xpand.XAF.Modules.JobScheduler.Notification v.4.222.13
Xpand.XAF.Modules.MasterDetail v.4.222.13
Xpand.XAF.Modules.ModelMapper v.4.222.13
Xpand.XAF.Modules.ModelViewInheritance v.4.222.13
Xpand.XAF.Modules.Office.Cloud.Google v.4.222.13
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.222.13
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.222.13
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.222.13
Xpand.XAF.Modules.OneView v.4.222.13
Xpand.XAF.Modules.PositionInListView v.4.222.13
Xpand.XAF.Modules.ProgressBarViewItem v.4.222.13
Xpand.XAF.Modules.RazorView v.4.222.13
Xpand.XAF.Modules.Reactive v.4.222.13
Xpand.XAF.Modules.Reactive.Logger v.4.222.13
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.222.13
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.222.13
Xpand.XAF.Modules.Reactive.Rest v.4.222.13
Xpand.XAF.Modules.RefreshView v.4.222.13
Xpand.XAF.Modules.SequenceGenerator v.4.222.13
Xpand.XAF.Modules.Speech v.4.222.13
Xpand.XAF.Modules.SpellChecker v.4.222.13
Xpand.XAF.Modules.StoreToDisk v.4.222.13
Xpand.XAF.Modules.SuppressConfirmation v.4.222.13
Xpand.XAF.Modules.TenantManager v.4.222.13
Xpand.XAF.Modules.ViewEditMode v.4.222.13
Xpand.XAF.Modules.ViewItemValue v.4.222.13
Xpand.XAF.Modules.ViewWizard v.4.222.13
Xpand.XAF.Modules.Windows v.4.222.13
Xpand.XAF.Web.All v.4.222.13
Xpand.XAF.Win.All v.4.222.13

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

expand commented 8 months ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.