Пример #1
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Gets the preloaded privilege instance representing the privilege with the specified ID.</summary>
        /// <param name="id">The database ID of the privilege.</param>
        /// <returns>The matching Privilege instance.</returns>
        public static Privilege Get(int id)
        {
            Privilege result = privileges[id];

            return(result);
        }
Пример #2
0
        /// <summary>Creates a new Activity instance representing an existing activity with the specified entity and operation.</summary>
        /// <returns>The created Activity object.</returns>
        /// <param name="context">The execution environment context.</param>
        /// <param name="entity">The entity to which the activity relates.</param>
        /// <param name="operation">The operation performed on the entity.</param>
        public static Activity FromEntityAndPrivilege(IfyContext context, Entity entity, EntityOperationType operation)
        {
            var      etype  = EntityType.GetEntityType(entity.GetType());
            var      priv   = Privilege.Get(EntityType.GetEntityTypeFromId(etype.Id), Privilege.GetOperationType(((char)operation).ToString()));
            Activity result = new Activity(context);

            result.Entity       = entity;
            result.EntityTypeId = etype.Id;
            result.Privilege    = priv;
            result.Load();
            return(result);
        }
Пример #3
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Removes the specified privilege from this role.</summary>
        /// <param name="privilege">The privilege to be removed.</param>
        public void ExcludePrivilege(Privilege privilege)
        {
            ExcludePrivileges(new int[] { privilege.Id });
        }
Пример #4
0
 /// <summary>Creates a new Activity instance.</summary>
 /// <param name="context">The execution environment context.</param>
 /// <param name="entity">Entity.</param>
 /// <param name="operation">The name of the operation performed on the entity.</param>
 public Activity(IfyContext context, Entity entity, string operation) : base(context)
 {
     if (entity != null)
     {
         try {
             this.EntityId           = entity.Id;
             this.Entity             = entity;
             this.EntityIdentifier   = entity.Identifier;
             this.ActivityEntityType = EntityType.GetEntityType(entity.GetType());
             this.EntityTypeId       = (this.ActivityEntityType.Id != 0 ? this.ActivityEntityType.Id : this.ActivityEntityType.TopTypeId);
             this.DomainId           = entity.DomainId;
             this.Privilege          = Privilege.Get(EntityType.GetEntityTypeFromId(this.EntityTypeId), Privilege.GetOperationType(operation));
         } catch (Exception e) {
             var t = e;
         }
     }
     this.OwnerId = entity.OwnerId;
 }
Пример #5
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Adds the specified privilege to this role.</summary>
        /// <param name="privilege">The privilege to be added.</param>
        /// <param name="removeOthers">Whether or not all existing privileges are removed before adding the specified privilege is added. The default is <c>false</c>.</param>
        public void IncludePrivilege(Privilege privilege, bool removeOthers = false)
        {
            IncludePrivileges(new int[] { privilege.Id });
        }