Пример #1
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);
        }
Пример #2
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;
 }