How to integrate hangfire into the DotnetNuke backend - dotnetnuke

I have a long process method that needs to be handled by a background process. I am thinking of using a HangFire. It is a free and open-source framework that will allow you to easily perform background processing in .NET application. The catch is I am new to DNN and I don't know how to start. I am searching in Google on how to integrate it, but I can't find a reference for that. Anyone has an idea on how to integrate HangFire to DNN?

You have to create a .NET project and install Owin and Hangfire packages in the project.
In that project,
create an Owin startup class and put your Hangfire initialization code in the Configuration method like this:
using Hangfire;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(DnnHangfireIntegration.Startup))]
namespace DnnHangfireIntegration
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnection");
app.UseHangfireServer();
app.UseHangfireDashboard("/desktopmodules/hangfire");
}
}
}
You must configure the hangfire dashboard to use '/desktopmodules/hangfire' URL so it won't be intercepted by DNN.
Compile your project and copy your project DLL, Hangfire DLL's and Owin DLL's to your DNN bin-folder.
Lastly, you'll have to update the web.config to tell Hangfire how to find your startup class. You can do this by using this appsetting:
<add key="owin:AutomaticAppStartup" value="true"/>
Also don't forget to add the connectionstring, you could also just reuse the existing connectionstring.
For a more detailed walkthrough, check out my blog post: https://swimburger.net/blog/dotnet/how-to-add-hangfire-to-dnn

Related

EJB:011224 Unable to bind the interface. Another EJB has already bound an interface to that name

I am having a subject line issue with my ADF application. It works OK on WLS 10.3.6 env, but fails on WLS 12c (12.2.1.3).
Some background. I have model, reusable and ADF UI projects. The model has services part, which is deployed from the application menu. The same model project is a dependency for reusable and ADF UI project. The services part deploys OK, but when I deploy the ADF UI project, it fails with EJB:011224.
Per Oracle Note
javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface - JNDI naming collision occurs when two separate applications, EAR and WAR, have the same exact EJB (Doc ID 1642388.1)
Removing the bean class from the WAR file is the correct way to fix this issue. The war gets successfully deployed after ear deployment
OR
Setting metadata-complete="true" flag in web.xml will not process any annotations, and deployment succeeds.
But these workarounds did not help.
As I indicated this is a "feature" of WLS 12c version, the project works OK with WLS 11g.
The application itself is divided into several projects, one is an ADF Model project, which is deployed as an ADF Library (JAR) and as an ADF Application (EAR), which contains the web services.
As ADF Library does not allow customizations, to avoid the mentioned project you have to create a usual JAR deployment profile and remove all the classes which are related to the services part, to do so go to Deployment profile->Project output -> Filters and uncheck the classes

Which Nuget package for Active Directory should I use?

I built an Azure WebAPI. I did not create the project with Authentication at the time it was first created. I added Active directory Authentication based on a code sample from Microsoft. It utilizes Microsoft.IdentityModel.Clients.ActiveDirectory which I got from NuGet. It works just fine.
I then created a WebAPI from VS 2017 and selected Authentication (using AD) at the time of project creation. It included Microsoft.AspNetCore.Authentication.AzureAD.UI.
I am not sure of the difference between these two NuGet modules nor which is better suited for my Azure WebAPI.
Then comes the modules to use in a .NET WPF client. There is no AuthorizationContext class (and others) in Microsoft.AspNetCore.Authentication.AzureAD.UI. Should I stick with Microsoft.IdentityModel.Clients.ActiveDirectory in the .NET WPF client or are there equivalents in Microsoft.AspNetCore.Authentication.AzureAD.UI?
For your web api project, answer is it depends on what you're trying to do from within the web api. For most simple scenarios where you just need to read/validate tokens, you should be good with the added Microsoft.AspNetCore.Aurthentication.JwtBearer nuget pacakges. More detailed question/answer available in this SO post
In case of your WPF client application although, you won't have much choice. You will need to work with ADAL or MSAL based on which AD version/endpoints you want to use. Also, in case of WPF client more probably than not you will need to acquire a token from Azure AD so internal operations (which library will take care of under the hood e.g. authenticationContext.AcquireTokenAsync) will be a little more involved than just reading the provided token from a header and hence the package.

ServiceStack as a ServiceLayer for MVC, WPF, WP7-8

after bumping into ServiceStack i would like to explore the option to have ServiceStack as a ServiceLayer for my existing MVC4 Project. The goal is to create a servicelayer for all other platform options like wpf, windows phone...
My main issue is the existing mvc project and the need to continue to use the SimpleMembershipProvider. Is it possible to move all code of the default AccountController to the ServiceStack ServiceLayer and call it from the AccountControler (WebSecurity Class)? Has someone tried something like this or should i dump this code and start a ServiceStack specific Security Class?
Regards,
S. Mantziaris
The first part on service layer is in http://nuget.org/packages/ServiceStack.Host.Mvc/ (adding it to your MVC4 project via NuGet almost instantly gives your a working service layer, just run and check yourhost.com/api/metadata).
https://github.com/ServiceStack/SocialBootstrapApi gives you a detailed example how to do authentication and authorization the ServiceStack way.
Check these two answers on how to integrate ASP Membeship and ServiceStack:
https://stackoverflow.com/a/8715958/801189 and https://stackoverflow.com/a/15078308/801189

RIA Services domain service factory in web.config

I have created a WCF RIA Services Class Library project which has a custom IDomainServiceFactory. Normally I would hook this up in Application_Start or something in a ASPNET project but this service will also be used by third parties via a SOAP endpoint so I need a way to create it automatically.
Only way I can think of is via web.config. Is this possible? I can't seem to find any documentation on domain services configuration settings.
You could do this programmatically in this fashion:
public void SomeConfigurationMethod()
{
DomainService.Factory = new YourDomainServiceFactory();
}

How to manually install the EPiServer Scheduling Service

I'm trying to manually install the EPiServer scheduler service on a web server using installutil.
I run this at the command promp:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\installutil D:\EPiServerSchedulerService\EPiServer.SchedulerSvc.exe
And get an error:
No public installers with the RunInstallerAttribute.Yes attribute could be found in the D:\EPiServerSchedulerService\EPiServer.SchedulerSvc.exe assembly.
It turns out it's not possible to do this with installutil, the service doesn't support it. I used the installer EPiServerShared.msi which is included with the EPiServer CMS downloads.
I wrote a quick blog post about it.

Resources