Skip to content

Instantly share code, notes, and snippets.

View jraps20's full-sized avatar

John Rappel jraps20

View GitHub Profile
namespace MyClient.Foundation.Services
{
using Sitecore.Data.Items;
using Sitecore.ExperienceEdge.Connector.Abstraction.DirectPublishing;
public class EdgeService : IEdgeService
{
private const string EdgePublishingTargetId = "{3013BEED-71CA-4DE3-A1D2-17DD871597F1}";
/// <summary>
namespace Foundation.Search.Crawlers
{
using System;
using Microsoft.Extensions.DependencyInjection;
using Sitecore;
using Sitecore.Abstractions;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Events;
using Sitecore.Data.Items;
@jraps20
jraps20 / build.yml
Created August 12, 2019 17:57
Cache NuGet Packages with Cache Task in Azure DevOps YAML
- powershell: | # generates a hash of all packages.config and saves each on a single line on 'hash.txt'
Get-FileHash -Algorithm MD5 -Path (Get-ChildItem packages.config -Recurse) >> hash.txt
Write-Host "Hash File saved to $pwd\hash.txt"
workingDirectory: src
displayName: 'Calculate and save packages.config hash'
- task: CacheBeta@0 # speed up builds by caching packages folder
inputs:
key: nuget|1|$(Agent.OS)|$(Build.SourcesDirectory)\src\hash.txt # hash map generated in previous step
path: $(Build.SourcesDirectory)\src\packages
var localCopyrightSettingsItem = Context.Items.Get(MultisiteConstants.LocalCopyrightSettingsItem);
namespace MyProject.Pipelines
{
public class ItemsLookup : HttpRequestProcessor
{
public override void Process(HttpRequestArgs args)
{
// Shared Data Folder
Context.Items.SetLazy(MultisiteConstants.SharedDataFolderItem, () =>
Context.Database.GetItem(new ID(MultisiteConstants.SharedDataFolderId))
);
namespace MyProject.Extensions
{
public static class ItemsContextExtensions
{
public static Item Get(this ItemsContext source, string identifier)
{
if (string.IsNullOrWhiteSpace(identifier))
throw new Exception("Must set identifier for getting global property");
var dictionary = source as IDictionary;
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<httpRequestBegin>
<processor type="MyProject.Pipelines.ItemsLookup, MyProject" resolve="true" patch:after="*[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" />
</httpRequestBegin>
</pipelines>
</sitecore>
</configuration>
@jraps20
jraps20 / RemoteDelete.config
Created July 3, 2018 20:39
Delete Sitecore items from remote databases when delete occurs in master.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="item:deleting">
<handler type="MyProject.MyNamespace.RemoteDeleteHandler, MyProject" method="OnItemDeleting" />
</event>
</events>
</sitecore>
</configuration>
using Quartz;
public class TestJob : SiteCronBase
{
protected override void Run(IJobExecutionContext context)
{
WriteLogLine(context, "Starting SiteCron job");
// core functionality lives here
// obtain databases with Factory.GetDatabase("master"); for example
using Quartz;
using Sitecron.SitecronSettings;
public abstract class SiteCronBase : IJob
{
private DateTime _lastLogEntry;
protected abstract void Run(IJobExecutionContext args);
public void Execute(IJobExecutionContext context)
{