Orchard Core 1.2 release, Background Jobs - This week in Orchard (14/01/2022)

Gábor Domonkos's avatar
Background task, Localization, This week in Orchard

We are thrilled to announce that Orchard Core 1.2 is now available! Check out this post to know the latest features of this release of Orchard Core and see a demo about an upcoming feature to have a jobs queue for scheduling! Let's get started!

Orchard Core updates

Support data annotations PO localization

This feature is about to be able to localize data annotations. Let's say you have a required field and you would like to save your form without providing any value for that field. In this case, you will get a validation error of course something like: The {fieldname} field is required. And from now you can easily translate the default error messages for data annotations attributes. If you open up the DataAnnotationsDefaultErrorMessages sealed class, you will find the default error messages that you can translate.

The DataAnnotationsDefaultErrorMessages marker class

But how can you translate these? In your PO file, you have to target the DataAnnotationsDefaultErrorMessages marker class, provide the value of the variable that you want to translate (msgid), and provide the translated text after the msgstr keyword, which is the Arabic version in this case.

A PO file that uses the DataAnnotationsDefaultErrorMessages marker class

In the following GIF, Hisham Bin Ateya shows you the given scenario mentioned above by using the Arabic translation for a required field.

Support data annotations PO localization

Code cleanup

For C# code files, Visual Studio 2022 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl+K, Ctrl+E) to apply code styles from an EditorConfig file or the Code Style options page. If a .editorconfig file exists for the project, those are the settings that take precedence. After you've configured code cleanup, you can either click on the broom icon or press Ctrl+K, Ctrl+E to run code cleanup. You can also run code cleanup across your entire project or solution. Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup. For more information about code style, check out this page.

The codebase of Orchard Core got this cleanup, which means 312 file changes in this PR.

Code cleanup in the source of Orchard Core

And if you would like your code to be nicer, check out the Lombiq.NET Analyzers repository. Our Lombiq .NET Analyzers repository contains .NET code analyzers and code convention settings for Lombiq projects. We also had a demo about the analyzers in This week in Orchard post!

Fix index cursors management

When there are hundreds of thousands of rows the results returned by QueryIndex() may not be ordered by Id by default. In that case, services as AutorouteEntries using an index cursor on the Id column are not working properly, the _lastIndexId being not well managed. In this case when first publishing an item having an Autoroute, in place of only adding one Autoroute entry, it was trying to add thousands of them in an unordered way and was taking a very long time. Jean-Thierry Kéchichian also enhances the lookup of Autoroute entries to evict, the ones related to contained items of a given container.

Fix index cursors management

Demos

Background Jobs

Orchard Core has a background task infrastructure that runs tasks on a minute-by-minute schedule on a CRON job. But it doesn't actually allow us to have a queue where we can put jobs into a queue. This demo is about an upcoming feature to have a jobs queue for scheduling.

Background Jobs UI

In this demo (to show you this feature), Dean Marcussen used the Publish Later feature of Orchard Core to keep track of the background jobs, and by running a scheduler, you can run the Publish Later Job immediately without the need of waiting for the given time to be elapsed.

Watch this recording on YouTube to know more about this upcoming feature!

News from the community

Orchard Core 1.2 release

Orchard Core 1.2 is released! If you open up nuget.org and search for the OrchardCore.Application.Cms.Targets package, you will find the newest released version of Orchard Core! Upgrade your solution to 1.2 now! If you head to the repository of Orchard Core and head to releases, you will find the 1.2.0 release with the list of changes and the contributors. Feel free to drop on the dedicated Gitter chat or use the Discussions on GitHub and ask questions!

Orchard Core 1.2 list of changes

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 236 subscribers! 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 is 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!

If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

No Comments

Add a Comment