Sitecore Precision Scheduling with SiteCron 3.0.6 released with Commerce goodies and cleanup agent!

SiteCron

WHAT’S NEW?

Lets look at what was added and modified. Please remember to Merge – Append when installing the package if you are upgrading.

>> Quartz.Net was upgraded from 2.5.0 to 2.6.2, please verify your deployment processes appropriately.

>> Ability to run a Sitecore Commerce Minion on a SiteCron schedule! Yeap, here it is. In order for you to do this please include Konabos.Minions.RunMinion.dll in your Commerce engine deployment. This will exposes methods in the Proxy which will let you execute a Commerce Minion. An example of a RunMinionNow job is in Sitecron.Jobs.Commerce.RunMinionNow.

Minion

>> SiteCron.aspx page in the admin part of Sitecore. I have a basic page which shows you all the jobs that are recognized by SiteCron. Navigate to /sitecore/admin/sitecron.aspx to see the new page.

SiteCron ASPX

>> Modified the Database Job Provider to use the content search rather than Axes.GetDescendants.

>> Added a restriction to show Execute Now only on the Publishing instance, if one is configured.

>> Added a setting to specify the TemplateId’s of valid SiteCron job templates in the SiteCron.config file.

>> Added a setting to specify the index name to be used for loading SiteCron jobs.


    <!-- In order to load all SiteCron scheduled items from the search index, we need a list of valid templates. We could have done this by writing custom content search code that might come later. Comma separated my friend! -->
    <setting name="SiteCron.ValidTemplates" value="{7F2C8881-6AE4-48CF-A499-7745CC4B2EB2},{49A27DC8-2A6A-48A2-A8EF-02A3DD0D3274},{B9B437B2-789C-48F6-AAE2-B49C4AA2A4BB},{40F6016F-C38D-4024-8B48-7DE2655E6007}" />

    <!-- Index used to perform Content Search that returns all SiteCron items based on the templates defined in the SiteCron.ValidTemplates setting-->
    <setting name="SiteCron.GetItemIndex" value="sitecore_master_index" />

>> Modified SiteCronJobs.config to add extra parameters to include Commerce Minion job attributes.

>> Added a clean up agent schedule job which runs at 1AM on the first Sunday of the month. Currently the deletion is taking about 90 seconds for 3000 items. The Bucket Sync takes quite a bit of time depending on the size of your Execution report item bucket.

Cleanup Agent

The script is disabled by default. Please turn it on if you need it. The script is shown below. It deletes all Execution reports older than 200 days.


    $noOfDays = -200
    $dateOlder = (Get-date).AddDays($noOfDays)
    $sitecronExecutionLog = "Scheduled Job to delete older SiteCron Execution Reports - Older than $dateOlder - Older than $noOfDays days! `n"

    #Gather SiteCron Execution report items which meet the criteria
    $items = Get-ChildItem -Recurse -Path "master:sitecoresystemModulesSitecronOOTBSiteCron Execution Reports" | Where { $_.__Created -le $dateOlder -and $_.TemplateName -eq "SiteCron Execution Report"}

    #Store the information to save as part of this items Execution report
    $itemsToBeDeleted = $items |Format-Table DisplayName, Id, __Created -AutoSize | Out-String

    #Disable Events
    New-UsingBlock(New-Object Sitecore.Data.Events.EventDisabler) {
    #Delete the Execution Reports without having to go to the recycling bin
    $items | Remove-Item -Recurse -Permanently -Force
    }
    $sitecronExecutionLog += $itemsToBeDeleted

    $sitecronExecutionLog += (Get-date).ToString() + "Syncing item bucket"

    #Sync Item Bucket to remove empty folders
    $bucketItem = Get-Item -Path "master:sitecoresystemModulesSitecronOOTBSiteCron Execution Reports"
    [Sitecore.Buckets.Managers.BucketManager]::Sync($bucketItem)
    $sitecronExecutionLog += (Get-date).ToString() + "Done!"

Credit to Ben for suggesting the cleanup agent. Credit to Michael for helping me with the cleanup agent Powershell script.

Credits:

Ben Golden
Michael West
Tyler Ortiz (pull request for parameter bug)

If you have any questions or concerns, please get in touch with me. (@akshaysura13 on twitter or on Slack).