private void CompareAttributes(int count, IEntity original, IEntity ent) { var wrapLog = Log.Call(); if (original.Attributes.Count != ent.Attributes.Count) { Add($"entity {count} has different amount " + $"of attributes {ent.Attributes.Count} " + $"than the original {original.Attributes.Count}"); } else { foreach (var origAttr in original.Attributes) { var newAttr = ent.Attributes.FirstOrDefault(a => a.Key == origAttr.Key); if (newAttr.Equals(default(KeyValuePair <string, IAttribute>))) { Add($"attribute {origAttr.Key} not found in save"); } else if (origAttr.Value.Type != newAttr.Value.Type) { Add($"found different type on attribute {origAttr.Key} " + $"- '{origAttr.Value.Type}'/'{newAttr.Value.Type}'"); } } } wrapLog("done"); }
public DynamicEntity(IEntity entity, string[] dimensions, int compatibility, IBlock block) { SetEntity(entity); Dimensions = dimensions; CompatibilityLevel = compatibility; Block = block; }
internal bool IfUpdateValidateAndCorrectIds(int count, IEntity newEntity, out HttpResponseException preparedException) { var wrapLog = Log.Call(); var previousEntity = AppRead.Entities.Get(newEntity.EntityId) ?? AppRead.Entities.Get(newEntity.EntityGuid); if (previousEntity != null) { Log.Add("found previous entity, will check types/ids/attributes"); CompareTypes(count, previousEntity, newEntity); // for saving, ensure we are using the DB entity-ID if (newEntity.EntityId == 0) { Log.Add("found existing entity - will set the ID to that to overwrite"); newEntity.ResetEntityId(previousEntity.EntityId); } CompareIdentities(count, previousEntity, newEntity); CompareAttributes(count, previousEntity, newEntity); } else { Log.Add("no previous entity found"); } var ok = BuildExceptionIfHasIssues(out preparedException, "EntityIsOk() done"); wrapLog($"{ok}"); return(ok); }
public DynamicEntity(IEntity entity, string[] dimensions, int compatibility, IBlock block) { SetEntity(entity); Dimensions = dimensions; CompatibilityLevel = compatibility; Block = block; ServiceProviderOrNull = Block?.Context?.ServiceProvider; }
/// <summary> /// Creates a permission checker for an app /// Optionally you can provide a type-name, which will be /// included in the permission check /// </summary> /// <returns></returns> protected IPermissionCheck BuildPermissionChecker(IContentType type = null, IEntity item = null) { Log.Add($"BuildPermissionChecker(type:{type?.Name}, item:{item?.EntityId})"); // user has edit permissions on this app, and it's the same app as the user is coming from return(new DnnPermissionCheck(Log, instance: BlockBuilder?.Container, app: App, portal: PortalForSecurityCheck, targetType: type, targetItem: item)); }
private void InitializeQueryStuff() { if (_queryInitialized) { return; } _queryInitialized = true; _queryRaw = GetBestRelationship(FieldPipeline); if (_queryRaw != null) { _query = new QueryDefinition(_queryRaw, Entity.AppId, Log); } }
internal bool EntityIsOk(int count, IEntity newEntity, out HttpResponseException preparedException) { var wrapLog = Log.Call <bool>(); if (newEntity == null) { Add($"entity {count} couldn't deserialize"); var notOk = BuildExceptionIfHasIssues(out preparedException); return(wrapLog("newEntity is null", notOk)); } if (newEntity.Attributes.Count == 0) { Add($"entity {count} doesn't have attributes (or they are invalid)"); } var ok = BuildExceptionIfHasIssues(out preparedException, "EntityIsOk() done"); return(wrapLog("", ok)); }
public DnnPermissionCheck( ILog parentLog, IContentType targetType = null, IEntity targetItem = null, IContainer instance = null, IApp app = null, IEnumerable <Permission> permissions1 = null, PortalSettings portal = null, IAppIdentity appIdentity = null ) : base(parentLog, targetType, targetItem, app?.Metadata.Permissions, permissions1) { var logWrap = Log.Call($"..., {targetItem?.EntityId}, app: {app?.AppId}, "); AppIdentity = appIdentity ?? app; App = app; Instance = instance; Portal = portal; logWrap(null); }
protected void SetEntity(IEntity entity) { Entity = entity; EntityForEqualityCheck = (Entity as IEntityWrapper)?.EntityForEqualityCheck ?? Entity; }
public View(IEntity templateEntity, ILog parentLog) : base(templateEntity, parentLog, "Sxc.View") { }
/// <inheritdoc /> public dynamic AsDynamic(IEntity entity) => UnwrappedContents?.AsDynamic(entity);
/// <inheritdoc /> public IFolder AsAdam(IEntity entity, string fieldName) => UnwrappedContents?.AsAdam(entity, fieldName);
/// <inheritdoc /> public PermissionCheckBase TypePermissions(IAppIdentity appIdentity, IContentType targetType, IEntity targetItem, ILog parentLog, IContainer module = null) => new DnnPermissionCheck(parentLog, targetType, targetItem, module, portal: PortalSettings.Current, appIdentity: appIdentity);
/// <inheritdoc /> public PermissionCheckBase ItemPermissions(IAppIdentity appIdentity, IEntity targetItem, ILog parentLog, IContainer module = null) => new DnnPermissionCheck(parentLog, targetItem: targetItem, instance: module, portal: PortalSettings.Current, appIdentity: appIdentity);
public View(IEntity templateEntity, string[] languageCodes, ILog parentLog) : base(templateEntity, languageCodes, parentLog, "Sxc.View") { }
/// <summary> /// Helper to prepare a quick-info about 1 content type /// </summary> /// <param name="allCTs"></param> /// <param name="staticName"></param> /// <param name="maybeEntity"></param> /// <returns></returns> private dynamic MiniCTSpecs(IEnumerable <IContentType> allCTs, string staticName, IEntity maybeEntity) { var found = allCTs.FirstOrDefault(ct => ct.StaticName == staticName); return(new { StaticName = staticName, Id = found?.ContentTypeId ?? 0, Name = (found == null)? "no content type": found.Name, DemoId = maybeEntity?.EntityId ?? 0, DemoTitle = maybeEntity?.GetBestTitle() ?? "" }); }