Error Log Watcher in Lombiq Orchard Visual Studio Extension, Disable and Enable Tasks - This week in Orchard (03/04/2020)
New tasks when working tenants in your workflows, a best practice about how to validate your ViewModel using a service and a spectacular and fun demo about a nice addition to our Orchard Visual Studio Extension! Read our current post for more!
Orchard Core updates
Tenant Workflows: Disable and Enable Tasks
Now you have workflow tasks to Disable or Enable tenants to support tenant management using with Forms or any external services. With these you have four events to manipulate tenants:
- Create Tenant
- Enable Tenant
- Disable Tenant
- Setup Tenant
From now, you can use the workflows to create, setup and then enable the tenants, because we have tasks to cover the whole process. In our case, we created a workflow called Add tenant and used these activities to fire up a tenant from scratch by the values provided by the users in a form.
Antoine Griffard updated all the search inputs in admin to use
type="search". This is a way to let the browser display these inputs with better hints. You can even predefine a list of common search inputs if you want. It's not used here, but we could also extend these to do that or show a list of historical data that you put in that textbox.
We would like to mention this because by reading this solution you could get a nice best practice about how to validate something with a service if you are in a ViewModel. In this current issue, we would like to validate the value of an email address by using the
RegisterExternalLoginViewModel. If you would like to validate an object using a ViewModel, you have to implement the
IValidatableObject interface which will give you a
Validate method. And in this method, you can use whatever service you want.
When you create a new instance of your ViewModel, you can pass your service to it in a parameter by using constructor dependency injection. In this current example, we could see the passing of the
IEmailAddressValidator to the
RegisterExternalLoginViewModel. And in the
RegisterExternalLoginViewModel you can use the service in the
Validate method injected using the constructor. But, if you see the changes below, you could notice that by using the
ValidationContext, you can get your service from the
IServiceProvider by calling
validationContext.GetService<T>(). In this case, you don't have to pass anything using the constructor when creating a new instance of your ViewModel, just simply resolve your service using the
A new section in the Orchard Core documentation: Resources
Now when you open the documentation of Orchard Core, you will find a new item on the menu, called Resources. The goal of the Resources page is to collect any external resources that are available to teach you how to develop with Orchard Core. Our Orchard Core Training Demo module has been added as the first demo project for this page. And you can also found some lines about our newsletter here and the URL where you can sign up for our newsletter!
New favicon for the Orchard Core documentation
If you check the previous screen again, you will see that the snip contains the title bar of the window too. That's because when you visit the documentation page of Orchard Core, you will face a new blueish favicon, that looks nicer in a browser that uses a darker theme too.
Adding BlinkStick support to Lombiq Orchard Visual Studio Extension Orchard Error Log Watcher feature
Lombiq Orchard Visual Studio Extension is a Visual Studio extension with many features and templates frequently used by Lombiq developers. It contains Orchard-related (including Orchard Core) as well as generic goodies.
This extension has an Orchard Log Watcher feature, that alerts you when you have any new entry in the log file. When you install this extension, you will see a new button on the Orchard Log Watcher toolbar. The button of this toolbar will be enabled when you have unread entries in the error log files. If you click on this button, the log file will be opened with the editor assigned to open .log files.
When you navigate to Tools -> Options -> Lombiq Orchard Visual Studio Extension -> Orchard Log Watcher you can enable or disable this feature. You can also set the log file folder path. The path can be anything, so, you can set custom paths as well. The default path here supports the default path of the log files in the case of an Orchard Core and an Orchard 1.x solution too.
And here comes the fun part: you can also set to blink or light up continuously a BlinkStick LED stick when a new entry is detected. BlinkStick brings colorful notifications to your computer and wide range programming language implementations give you the power to control LEDs without the need to program a microcontroller and you can choose from different kinds of products. Furthermore, you can also set the color for the LED by providing a hex value or the name of the color. You can find the list of the supported colors here. You just need to plug this device into your USB port and the extension will recognize it!
Here you can download this free, open-source extension. In GitHub, you can find the extension's Readme with release notes too. Also, if you encountered bugs or have a feature request please add it on the GitHub page as well. And don't forget to watch the full demo on YouTube!
News from the community
Training Demo updated: how to add an ASP.NET Core middleware to your Orchard Core application?
Orchard Core Training Demo module is a demo Orchard Core module for training purposes guiding you to become an Orchard developer. You can use this module as part of a vanilla Orchard Core source that including the full source code - which is the recommended way.
You can use it as part of a solution the uses Orchard Core NuGet packages, however, it's harder to look under the hood of Orchard Core features.
The module assumes that you have a good understanding of basic Orchard concepts and that you can get around the Orchard admin area (the official documentation may help you with that). You should also be familiar with how to use Visual Studio and write C#, as well as the concepts of ASP.NET Core MVC.
We have just added a new section to our module about how to implement an ASP.NET Core middleware in your Orchard Core application. Take a look at the RequestLoggingMiddleware.cs file!
Orchard Dojo Newsletter
Now we have 130 subscribers of the Lombiq's Orchard Dojo Newsletter! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!