Skip to content

Instantly share code, notes, and snippets.

@rvsure
rvsure / DeleteOldBearerTickets.ps1
Last active August 24, 2022 07:10
This SPE script queries the Core database's Properties table for old bearer tickets and deletes them
$sql = @"
USE [{0}]
DELETE FROM [dbo].[Properties] WHERE [dbo].[Properties].[Key] like '%SC_TICKET%' AND [dbo].[Properties].[Value] like '%^202112%'
"@
Import-Function Invoke-SqlCommand
Write-Verbose "Cleaning up the History, EventQueue, and PublishQueue tables in the $($db.Name) database."
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("core")
$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $connection
@rvsure
rvsure / QueryOldBearerTickets.ps1
Created August 24, 2022 07:01
This SPE script queries the Core database's Properties table for old bearer tickets
$sql = @"
USE [{0}]
SELECT COUNT(*) FROM [dbo].[Properties] WHERE [dbo].[Properties].[Key] like '%SC_TICKET%' AND [dbo].[Properties].[Value] like '%^202112%'
"@
Import-Function Invoke-SqlCommand
Write-Verbose "Cleaning up the History, EventQueue, and PublishQueue tables in the $($db.Name) database."
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("core")
$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $connection
{
"@odata.context": "https://scm.dev.local/sitecore/api/ssc/aggregate/content/$metadata#Items/$entity",
"Name": " Fact Box",
"DisplayName": "",
"Path": "/sitecore/content/scm/scm-web-app/home/SamplePage/Data/CTAs/Image Fact Box",
"Language": "en",
"Version": 1,
"IsLatestVersion": true,
"TemplateId": "120b86d4-6bc1-4198-9610-6f4452b61efc",
"TemplateName": "ImageCTA",
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Sitecore.Content.Services;
using Sitecore.Content.Services.Items.OData;
using Sitecore.Content.Services.Items.OData.Search;
using Sitecore.ContentSearch.Utilities;
using Sitecore.DependencyInjection;
using Sitecore.Services.Infrastructure.DependencyInjection;
using Sitecore.Services.Infrastructure.Sitecore.Data;
using Sitecore.Services.Infrastructure.Sitecore.Services;
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator type="SCM.Foundation.OData.CustomConfigurator, SCM.Foundation.OData" patch:instead="*[@type='Sitecore.Content.Services.Configurator, Sitecore.Content.Services']" />
<register serviceType="Sitecore.Content.Services.Items.OData.ItemDataModelFactory, Sitecore.Content.Services" implementationType="SCM.Foundation.OData.Services.ItemDataModelFactory, SCM.Foundation.OData" lifetime="Singleton" />
</services>
</sitecore>
</configuration>
using Sitecore.Abstractions;
using Sitecore.Content.Services.Models;
using Sitecore.Diagnostics;
using Sitecore.Data.Items;
using System;
using System.Runtime.CompilerServices;
using Sitecore.Data.Fields;
using Sitecore.Configuration;
using Sitecore.Data.Templates;
using System.Linq;
{
"@odata.context": "https://scm.dev.local/sitecore/api/ssc/aggregate/content/$metadata#Items/$entity",
"Name": " Fact Box",
"DisplayName": "",
"Path": "/sitecore/content/scm/scm-web-app/home/SamplePage/Data/CTAs/Image Fact Box",
"Language": "en",
"Version": 1,
"IsLatestVersion": true,
"TemplateId": "120b86d4-6bc1-4198-9610-6f4452b61efc",
"TemplateName": "ImageCTA",
@rvsure
rvsure / DatasourceItemAndChildrenContentsResolver.cs
Created May 5, 2022 03:32
Datasource Item and Children Contents Resolver is a custom contents resolver for Sitecore JSS that resolved contents of both the datasource items and its direct children.
using Newtonsoft.Json.Linq;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.LayoutService.Configuration;
using System.Collections.Generic;
using System.Linq;
namespace Learning.Foundation.SitecoreExtensions.ContentResolvers
{
public class DatasourceItemAndChildrenContentsResolver : Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver
{
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Web.UI.Sheer;
using Sitecore.XA.Foundation.Multisite.Extensions;
using Sitecore.XA.Foundation.SitecoreExtensions.Extensions;
using System;
namespace Learning.Foundation.SitecoreExtensions.Dialogs
{
public class SelectRenderingDatasourceForm : Sitecore.XA.Foundation.LocalDatasources.Dialogs.SelectRenderingDatasourceForm
<r xmlns:p="p" xmlns:s="s" p:p="1">
<d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}">
<r uid="{1AB520A5-290F-463B-B6EF-E200A5E36844}" p:before="*" s:ds="{075C8FA4-AA94-409B-A86C-878C215B87FC}" s:id="{DB437FBF-6A68-45E1-84B2-CEC78A71D58D}" s:par="Reset Caching Options&amp;GridParameters=%7B7465D855-992E-4DC2-9855-A03250DFA74B%7D&amp;FieldNames=%7BB4AE42C3-7FBF-40E8-8FC6-DB5F6F63E289%7D&amp;Styles&amp;RenderingIdentifier&amp;DynamicPlaceholderId=2" s:ph="/main/scphcontentcards-1-1" s:ccb="Clear on publish" />
<r uid="{604B37B0-91E8-4FA8-BAC8-473718702DB7}" p:after="r[@uid='{1AB520A5-290F-463B-B6EF-E200A5E36844}']" s:ds="{FB095A9B-9955-4BED-8BE6-2C7D108437F5}" s:id="{DB437FBF-6A68-45E1-84B2-CEC78A71D58D}" s:par="Reset Caching Options&amp;GridParameters=%7B7465D855-992E-4DC2-9855-A03250DFA74B%7D&amp;FieldNames=%7BB4AE42C3-7FBF-40E8-8FC6-DB5F6F63E289%7D&amp;Styles&amp;CacheClearingBehavior=Clear%20on%20publish&amp;RenderingIdentifier&amp;DynamicPlaceholderId=3" s:ph="/main/scphcontentcards-1-1" />
<r uid="{B4