-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*.{cs,sln,csproj,config,xml}] | ||
indent_size = 2 | ||
indent_style = space |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{ED1EE91E-47D7-4209-AE86-27C112FDA016}") = "Sitecore.Support.201408", "Sitecore.Support.201408\Sitecore.Support.201408.csproj", "{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
4 changes: 4 additions & 0 deletions
4
src/Sitecore.Support.201408/App_Config/Include/zzz/Sitecore.Support.201408.config
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/"> | ||
<sitecore role:require="Standalone OR ContentManagement OR ContentDelivery OR Processing OR Reporting"> | ||
</sitecore> | ||
</configuration> |
96 changes: 96 additions & 0 deletions
96
src/Sitecore.Support.201408/CES/DeviceDetection/Rules/RuleDeviceInformationManager.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
| ||
|
||
using System; | ||
using Sitecore.Analytics; | ||
using Sitecore.CES.DeviceDetection; | ||
using Sitecore.CES.DeviceDetection.Exceptions; | ||
using Sitecore.CES.DeviceDetection.Rules; | ||
using Sitecore.Diagnostics; | ||
using Sitecore.Rules; | ||
using Sitecore.Rules.Devices; | ||
using Sitecore.Xdb.Configuration; | ||
|
||
namespace Sitecore.Support.CES.DeviceDetection.Rules | ||
{ | ||
internal class RuleDeviceInformationManager : IRuleDeviceInformationManager | ||
{ | ||
public DeviceInformation GetDeviceInformation(RuleContext ruleContext) | ||
{ | ||
if (!DeviceDetectionManager.IsReady) | ||
{ | ||
return null; | ||
} | ||
return this.ResolveObject<DeviceInformation>(ruleContext, "DeviceInfo", new Func<string, DeviceInformation>(DeviceDetectionManager.GetDeviceInformation), "Tracking is disabled. Device rules can't be evaluated", "Can't get the device info", Array.Empty<object>()); | ||
} | ||
|
||
public string GetExtendedProperty(RuleContext ruleContext, string propertyName) | ||
{ | ||
Assert.ArgumentNotNull(propertyName, "propertyName"); | ||
if (!DeviceDetectionManager.IsReady) | ||
{ | ||
return null; | ||
} | ||
object[] formatArgs = new object[] { propertyName }; | ||
return this.ResolveObject<string>(ruleContext, "DeviceInfo" + propertyName, x => DeviceDetectionManager.GetExtendedProperty(x, propertyName), "Tracking is disabled. Device rules can't be evaluated", "Can't get the extended property '{0}'", formatArgs); | ||
} | ||
|
||
private string GetUserAgentFromDeviceRuleContext(DeviceRuleContext deviceRuleContext) | ||
{ | ||
Assert.ArgumentNotNull(deviceRuleContext, "deviceRuleContext"); | ||
Assert.IsNotNull(deviceRuleContext.HttpContext, "deviceRuleContext.HttpContext is null"); | ||
Assert.IsNotNull(deviceRuleContext.HttpContext.Request, "deviceRuleContext.HttpContext.Request is null"); | ||
return deviceRuleContext.HttpContext.Request.UserAgent; | ||
} | ||
|
||
private string GetUserAgentFromTracker() | ||
{ | ||
Assert.IsNotNull(Tracker.Current, "Tracker.Current is not initialized"); | ||
Assert.IsNotNull(Tracker.Current.Session, "Tracker.Current.Session is not initialized"); | ||
Assert.IsNotNull(Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized"); | ||
return Tracker.Current.Session.Interaction.UserAgent; | ||
} | ||
|
||
private T ResolveObject<T>(RuleContext ruleContext, string key, Func<string, T> objectFactory, string trackerDisabledMessageFormat, string deviceDetectionExceptionMessageFormat, params object[] formatArgs) | ||
{ | ||
Assert.ArgumentNotNull(key, "key"); | ||
Assert.ArgumentNotNull(objectFactory, "objectFactory"); | ||
Assert.ArgumentNotNull(trackerDisabledMessageFormat, "trackerDisabledMessageFormat"); | ||
Assert.ArgumentNotNull(deviceDetectionExceptionMessageFormat, "deviceDetectionExceptionMessageFormat"); | ||
Assert.ArgumentNotNull(formatArgs, "formatArgs"); | ||
try | ||
{ | ||
DeviceRuleContext deviceRuleContext = ruleContext as DeviceRuleContext; | ||
if (deviceRuleContext != null) | ||
{ | ||
object obj2; | ||
if (!deviceRuleContext.CustomData.TryGetValue(key, out obj2)) | ||
{ | ||
string userAgentFromDeviceRuleContext = this.GetUserAgentFromDeviceRuleContext(deviceRuleContext); | ||
if (userAgentFromDeviceRuleContext == null) | ||
{ | ||
return default(T); | ||
} | ||
obj2 = objectFactory(userAgentFromDeviceRuleContext); | ||
deviceRuleContext.CustomData[key] = obj2; | ||
} | ||
return (T)obj2; | ||
} | ||
if (XdbSettings.Tracking.Enabled) | ||
{ | ||
string userAgentFromTracker = this.GetUserAgentFromTracker(); | ||
if (userAgentFromTracker == null) | ||
{ | ||
return default(T); | ||
} | ||
return objectFactory(userAgentFromTracker); | ||
} | ||
Log.Warn(string.Format(trackerDisabledMessageFormat, formatArgs), this); | ||
} | ||
catch (DeviceDetectionException exception) | ||
{ | ||
Log.Error(string.Format(deviceDetectionExceptionMessageFormat, formatArgs), exception, ruleContext); | ||
} | ||
return default(T); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("Sitecore.Support.201408")] | ||
[assembly: AssemblyProduct("Sitecore.Support.201408")] | ||
[assembly: ComVisible(false)] |
71 changes: 71 additions & 0 deletions
71
src/Sitecore.Support.201408/Sitecore.Support.201408.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion> | ||
</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{0802B730-B6F1-445F-9A5E-7FE2A7EEB36E}</ProjectGuid> | ||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Sitecore.Support</RootNamespace> | ||
<AssemblyName>Sitecore.Support.201408</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | ||
<UseIISExpress>true</UseIISExpress> | ||
<IISExpressSSLPort /> | ||
<IISExpressAnonymousAuthentication /> | ||
<IISExpressWindowsAuthentication /> | ||
<IISExpressUseClassicPipelineMode /> | ||
<UseGlobalApplicationHostFile /> | ||
<TargetFrameworkProfile /> | ||
<LangVersion>6</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Sitecore.Kernel"> | ||
<HintPath>..\packages\SC.Sitecore.Kernel.9.0.0\lib\Sitecore.Kernel.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Configuration" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="App_Config\Include\zzz\Sitecore.Support.201408.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<None Include="web.config" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> | ||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="SC.Sitecore.Analytics" version="9.0.0" targetFramework="net462" /> | ||
<package id="SC.Sitecore.CES.DeviceDetection" version="9.0.0" targetFramework="net462" /> | ||
<package id="SC.Sitecore.CES.DeviceDetection.Rules" version="9.0.0" targetFramework="net462" /> | ||
<package id="SC.Sitecore.Kernel" version="9.0.0" targetFramework="net462" /> | ||
<package id="SC.Sitecore.Xdb.Configuration" version="9.0.0" targetFramework="net462" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<!-- Do not change this file - it must be empty, see https://github.com/SitecoreSupport/PatchCreator/issues/13 --> | ||
</configuration> |