This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "PostDeploy" | |
################################################################################## | |
# VARIABLES | |
################################################################################## | |
$excludeItemUpdates = [System.Convert]::ToBoolean($OctopusParameters["ExcludeItemUpdates"]) | |
$internalPort = $OctopusParameters["InternalPort"] | |
$rootPath = $OctopusParameters["Octopus.Action.Package.CustomInstallationDirectory"] | |
$updatePackagesPath = [io.path]::combine($rootPath, 'Website', 'sitecore', 'admin', 'Packages') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ WebService Language="C#" Class="PackageInstaller" %> | |
using System; | |
using System.Configuration; | |
using System.IO; | |
using System.Web.Services; | |
using System.Xml; | |
using Sitecore.Data.Proxies; | |
using Sitecore.Data.Engines; | |
using Sitecore.Install.Files; | |
using Sitecore.Install.Framework; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CompositeRelationshipSavingTask : IObjectSavingTask | |
{ | |
private static readonly ConcurrentDictionary<Type, SitecoreFieldConfiguration[]> _compositeRelationships = new ConcurrentDictionary<Type, SitecoreFieldConfiguration[]>(); | |
private SitecoreFieldConfiguration[] GetCompositeRelationshipFields(ObjectSavingArgs args) | |
{ | |
var type = args.SavingContext.Config.Type; | |
return _compositeRelationships.GetOrAdd(type, x => CompositeRelationshipsValueFactory(args)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CompositeRelationshipSavingTask : IObjectSavingTask | |
{ | |
public void Execute(ObjectSavingArgs args) | |
{ | |
// Only perform processing if composite relationship fields exist | |
var compositeRelationshipFields = GetCompositeRelationshipFields(args); | |
if (!compositeRelationshipFields.Any()) | |
return; | |
// Get access to the SitecoreService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IDependencyResolver CreateResolver(){ | |
var config = new Glass.Mapper.Sc.Config(); | |
var resolver = new DependencyResolver(config); | |
// Add the ability to save composite relationships. This needs to occur before the parent is saved so all IDs are known. | |
resolver.ObjectSavingFactory.Insert(0, () => new CompositeRelationshipSavingTask()); | |
return resolver; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Property)] | |
public class SitecoreCompositeRelationshipAttribute : Attribute | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var service = new SitecoreService("master"); | |
var person = new Person(); | |
person.Name = "Mike Skutta"; | |
person.FirstName = "Mike"; | |
person.LastName = "Skutta"; | |
person.Education = new List<Education> { new Education | |
{ | |
Name = "University of Illinois", | |
School = "University of Illinois", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SitecoreType(TemplateId = "004c9474-1df4-47ab-9414-c372b25cdde6", AutoMap = true)] | |
public partial class Education | |
{ | |
public virtual Guid Id { get; set; } | |
public virtual System.String Name { get; set; } | |
public virtual string Degree { get; set; } | |
public virtual string School { get; set; } | |
public virtual System.Int32 YearOfDegree { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateItemTask : IObjectConstructionTask | |
{ | |
private bool IsValid(ObjectConstructionArgs args) | |
{ | |
var context = (SitecoreTypeCreationContext) args.AbstractTypeCreationContext; | |
var service = (SitecoreService)args.Service; | |
var requiredFields = GetRequiredFields(args); | |
foreach (var requiredField in requiredFields) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateItemTask : IObjectConstructionTask | |
{ | |
private static readonly ConcurrentDictionary<Type, SitecoreFieldConfiguration[]> _requiredFields = new ConcurrentDictionary<Type, SitecoreFieldConfiguration[]>(); | |
private SitecoreFieldConfiguration[] GetRequiredFields(ObjectConstructionArgs args) | |
{ | |
var type = args.Configuration.Type; | |
return _requiredFields.GetOrAdd(type, x => RequiredFieldsValueFactory(args)); | |
} |