Skip to content

Instantly share code, notes, and snippets.

Robin Hermanussen hermanussen

Block or report user

Report or block hermanussen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TailScLog.ps1
# Tail Sitecore log files, even when using rolling log files
# ==========================================================
# 1) Copy this file into your App_Data folder or set the logFolder parameter to point to the Sitecore logs folder.
# 2) Run it in Powershell
# 3) View the log messages as they appear (even if the worker process recycles)
param (
[string]$logFolder = ".\\logs\\",
[string]$filter = "log.*",
[int]$tailAmount = 20
)
View Blog: Monitor your Sitecore server's health - 3.cs
if (Tags.Contains("fail", StringComparer.InvariantCultureIgnoreCase))
{
ChecksRun.Checks.Add(new AlwaysFailCheck());
}
View Blog: Monitor your Sitecore server's health - 2.cs
// Add your checks here
ChecksRun.Checks.Add(new ItemExistsCheck("Folder template", "{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}", new[] { "master", "web" }, null, false));
ChecksRun.Checks.Add(new ItemExistsCheck("Launchpad has layout", "{6B846FBD-8549-4C91-AE6B-18286EFE82D2}", new[] { "core" }, new string[] { "en" }, true));
ChecksRun.Checks.Add(new SearchIndexSizeCheck("Master index", "sitecore_master_index", 1000, null));
ChecksRun.Checks.Add(new UrlCheck("Google is reachable", "http://www.google.com/"));
ChecksRun.Checks.Add(new ConfigCheck("Check if master database is available", "/sitecore/databases/database[@id='master']", 1));
View Blog: Monitor your Sitecore server's health - 1.cs
// Optional: uncomment whichever ways you feel are appropriate for security
// Ensure that your monitoring tool matches these
if (!(true
//&& Request.IsSecureConnection // Checks if using HTTPS
//&& Request.QueryString["authkey"] == @"secret"
&& Request.UserHostAddress == "127.0.0.1"
//&& Sitecore.Context.IsLoggedIn
//&& Sitecore.Context.IsAdministrator
//&& Sitecore.Context.User.IsInRole(@"sitecore\Developer")
))
View Blog: Validating your code references to serialized data - 4.cs
[Test(Description = "Checks if all Glass mapper template and field IDs can be found in serialized data")]
public void ShouldAllTemplatesAndFieldsBeFoundInSerializedData(
[Values(
typeof(SomeType), // From assembly MyProject
)]
Type typeFromAssembyUnderTest)
{
Assembly assemblyUnderTest = Assembly.GetAssembly(typeFromAssembyUnderTest);
// Find all templates and fields that need to be checked in the serialized data
View Blog: Validating your code references to serialized data - 3.cs
[SitecoreType(TemplateId = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}")]
public interface ISampleItem
{
[SitecoreField(FieldId = "{75577384-3C97-45DA-A847-81B00500E250}")]
string Title { get; set; }
}
View Blog: Validating your code references to serialized data - 2.cs
[Test(Description = "Checks if Sitecore IDs in a class with constants can be found in the serialized data")]
public void ShouldIdsBeFoundInSerializedData(
[Values(typeof(Constants))]
Type typeWithIdConstants)
{
foreach (FieldInfo field in typeWithIdConstants
.GetFields(BindingFlags.Public | BindingFlags.Static)
.Where(f => f.FieldType == typeof (ID)))
{
ID constantValue = field.GetValue(null) as ID;
View Blog: Validating your code references to serialized data - 1.cs
public static class Constants
{
public static readonly ID SampleTemplateId
= new ID("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}");
}
View Blog: Unit testing with Sitecore.FakeDb and deserialized data - 2.xml
<szfolders>
<folder name="core" value="c:\somefolder\data\serialization\core\" />
<folder name="master" value="c:\somefolder\data\serialization\master\" />
<folder name="web" value="c:\somefolder\data\serialization\web\" />
</szfolders>
View Blog: Unit testing with Sitecore.FakeDb and deserialized data - 1.cs
[TestCase]
public void TestCombined()
{
using (Db db = new Db()
{
new DsDbTemplate(
"/sitecore/templates/Sample/Sample Item"),
new DsDbItem("/sitecore/content/home", true)
{
new DbItem("Child")
You can’t perform that action at this time.