Skip to content

Commit

Permalink
Merge pull request #602 from Orckestra/dev
Browse files Browse the repository at this point in the history
C1 CMS 6.5
  • Loading branch information
Marcus Wendt authored Jun 29, 2018
2 parents 0b2a13a + 0947337 commit c5bfaf0
Show file tree
Hide file tree
Showing 68 changed files with 778 additions and 705 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public sealed partial class AddDataFolderExWorkflow : Composite.C1Console.Workfl
private string HasLocalizationBindingName { get { return "HasLocalization"; } }


private static readonly object _lock = new object();

public AddDataFolderExWorkflow()
{
InitializeComponent();
Expand Down Expand Up @@ -228,7 +230,16 @@ private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs

IPage page = (IPage)dataEntityToken.Data;

page.AddFolderDefinition(type.GetImmutableTypeId());
Guid dataTypeId = type.GetImmutableTypeId();

lock (_lock)
{
if (page.GetFolderDefinitionId(dataTypeId) == Guid.Empty)
{
page.AddFolderDefinition(dataTypeId);
}
}


SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
specificTreeRefresher.PostRefreshMesseges(this.EntityToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, Ev
Dictionary<string, string> selectableTreeIds = new Dictionary<string, string>();
foreach (Tree tree in TreeFacade.AllTrees)
{
if (tree.HasAttachmentPoints(this.EntityToken) == false) continue;
if (!tree.HasAttachmentPoints(this.EntityToken)) continue;
if (!tree.HasPossibleAttachmentPoints(this.EntityToken)) continue;

selectableTreeIds.Add(tree.TreeId, tree.AllowedAttachmentApplicationName);
}
Expand Down
6 changes: 4 additions & 2 deletions Composite.Workflows/Composite.Workflows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,10 @@
<GitBranchFile>$(ProjectDir)git_branch.txt</GitBranchFile>
<GitCommitHashFile>$(ProjectDir)git_commithash.txt</GitCommitHashFile>
</PropertyGroup>
<Exec Command="git -C $(ProjectDir) rev-parse --abbrev-ref HEAD&gt; &quot;$(GitBranchFile)&quot;" />
<Exec Command="git -C $(ProjectDir) rev-parse HEAD&gt; &quot;$(GitCommitHashFile)&quot;" />
<Exec Condition="Exists('$(SolutionDir)\.git')" Command="git -C $(ProjectDir) rev-parse --abbrev-ref HEAD&gt; &quot;$(GitBranchFile)&quot;" />
<Exec Condition="Exists('$(SolutionDir)\.git')" Command="git -C $(ProjectDir) rev-parse HEAD&gt; &quot;$(GitCommitHashFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown branch > &quot;$(GitBranchFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown commit > &quot;$(GitCommitHashFile)&quot;" />
<PropertyGroup>
<GitBranch>$([System.IO.File]::ReadAllText("$(GitBranchFile)").Trim())</GitBranch>
<GitCommitHash>$([System.IO.File]::ReadAllText("$(GitCommitHashFile)").Trim())</GitCommitHash>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs
DataEntityToken dataEntityToken = piggybag.GetParentEntityTokens().FindDataEntityToken(typeof(IPageType));
IPageType parentPageType = (IPageType)dataEntityToken.Data;

defaultPageContent.PageTypeId = parentPageType.Id;
defaultPageContent.Content = " ";
var duplicate = DataFacade.GetData<IPageTypeDefaultPageContent>(f => f.PageTypeId == parentPageType.Id && f.PlaceHolderId == defaultPageContent.PlaceHolderId).FirstOrDefault();

defaultPageContent = DataFacade.AddNew<IPageTypeDefaultPageContent>(defaultPageContent);
if (duplicate == null)
{
defaultPageContent.PageTypeId = parentPageType.Id;
defaultPageContent.Content = " ";

defaultPageContent = DataFacade.AddNew<IPageTypeDefaultPageContent>(defaultPageContent);
}
else
{
defaultPageContent = duplicate;
}

this.CloseCurrentView();
this.RefreshCurrentEntityToken();
Expand Down
32 changes: 16 additions & 16 deletions Composite/C1Console/Actions/FlowControllerServicesContainer.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
using System;
using System.Collections.Generic;
using Composite.Core.Extensions;


namespace Composite.C1Console.Actions
{
/// <summary>
/// <summary>
/// </summary>
/// <exclude />
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public sealed class FlowControllerServicesContainer
{
private Dictionary<Type, List<object>> _services = new Dictionary<Type, List<object>>();
private readonly Dictionary<Type, List<object>> _services = new Dictionary<Type, List<object>>();


/// <exclude />
public FlowControllerServicesContainer()
{ }


/// <exclude />
public FlowControllerServicesContainer(params IFlowControllerService[] services)
{
foreach (var service in services)
{
AddService(service);
}
}

// Creates a new service container and initialized it with the services from servicesContainerToClone.
/// <exclude />
public FlowControllerServicesContainer(FlowControllerServicesContainer servicesContainerToClone)
Expand All @@ -34,14 +44,7 @@ public void AddService(IFlowControllerService flowControllerService)

foreach (Type interfaceType in type.GetInterfaces())
{
List<object> list;

if (_services.TryGetValue(interfaceType, out list) == false)
{
list = new List<object>();

_services.Add(interfaceType, list);
}
List<object> list = _services.GetOrAdd(interfaceType, () => new List<object>());

list.Add(flowControllerService);
}
Expand All @@ -56,8 +59,7 @@ public void RemoveService(IFlowControllerService flowControllerService)

foreach (Type interfaceType in type.GetInterfaces())
{
List<object> list;
if (_services.TryGetValue(interfaceType, out list) == false) throw new InvalidOperationException();
if (!_services.TryGetValue(interfaceType, out var list)) throw new InvalidOperationException();

list.Remove(flowControllerService);
}
Expand All @@ -83,16 +85,14 @@ public T GetService<T>() where T : IFlowControllerService
/// <exclude />
public IFlowControllerService GetService(Type serviceType)
{
List<object> list;

if (_services.TryGetValue(serviceType, out list) == false)
if (!_services.TryGetValue(serviceType, out var list))
{
return null;
}

if (list.Count > 1)
{
throw new InvalidOperationException(string.Format("More than one services of type '{0}' is added", serviceType));
throw new InvalidOperationException($"More than one service of type '{serviceType}' was added");
}

return (IFlowControllerService)list[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -270,9 +270,9 @@ private IEnumerable<Element> GetRootGroupFolders(Type interfaceType, EntityToken
var expressionBuilder = new ExpressionBuilder(interfaceType, queryable);

IQueryable resultQueryable = expressionBuilder.
Distinct().
OrderBy(propertyInfo, true, firstDataFieldDescriptor.TreeOrderingProfile.OrderDescending).
Select(propertyInfo, true).
Distinct().
CreateQuery();

var propertyInfoValueCollection = new PropertyInfoValueCollection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Composite.Core.Caching;

Expand Down Expand Up @@ -116,31 +116,14 @@ private static void SetToCache(UserToken userToken, EntityToken entityToken, IRe

private static IReadOnlyCollection<PermissionType> GetFromCache(UserToken userToken, EntityToken entityToken, object cachingKey)
{
// Using RequestLifetimeCache and there for no thread locking /MRJ

Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>> permissionTypeCache;
var permissionTypeCache = RequestLifetimeCache.TryGet<Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>>>(cachingKey);

if (RequestLifetimeCache.HasKey(cachingKey))
if (permissionTypeCache == null || !permissionTypeCache.TryGetValue(userToken, out var entityTokenPermissionTypes))
{
permissionTypeCache = RequestLifetimeCache.TryGet<Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>>>(cachingKey);
return null;
}
else
{
permissionTypeCache = new Dictionary<UserToken, Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>>();

RequestLifetimeCache.Add(cachingKey, permissionTypeCache);
}

Dictionary<EntityToken, IReadOnlyCollection<PermissionType>> entityTokenPermissionTypes;
if (!permissionTypeCache.TryGetValue(userToken, out entityTokenPermissionTypes))
{
entityTokenPermissionTypes = new Dictionary<EntityToken, IReadOnlyCollection<PermissionType>>();
permissionTypeCache.Add(userToken, entityTokenPermissionTypes);
}

IReadOnlyCollection<PermissionType> permissionTypes;

entityTokenPermissionTypes.TryGetValue(entityToken, out permissionTypes);
entityTokenPermissionTypes.TryGetValue(entityToken, out var permissionTypes);

return permissionTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Castle.Core.Internal;
using Composite.Core.Extensions;

namespace Composite.C1Console.Security.Plugins.LoginSessionStore.Runtime
{
Expand Down
2 changes: 1 addition & 1 deletion Composite/C1Console/Trees/TreeElementAttachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public IEnumerable<ElementAttachingProviderResult> GetAlternateElementLists(Enti
}
catch (Exception ex)
{
LoggingService.LogError("TreeFacade", string.Format("Getting elements from the three '{0}' failed", tree.TreeId));
LoggingService.LogError("TreeFacade", string.Format("Getting elements from the tree '{0}' failed", tree.TreeId));
LoggingService.LogError("TreeFacade", ex);

Element errorElement = ShowErrorElementHelper.CreateErrorElement(
Expand Down
Loading

0 comments on commit c5bfaf0

Please sign in to comment.