/// <summary>
 /// entity
 /// </summary>
 /// <param name="entity">Entity</param>
 /// <param name="entityEventType">Entity event type</param>
 protected override void ClearCache(NewsComment entity, EntityEventType entityEventType)
 {
     if (entityEventType == EntityEventType.Delete)
     {
         RemoveByPrefix(NopNewsCachingDefaults.NewsCommentsPrefixCacheKey);
     }
 }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 /// <param name="parameters"></param>
 public void FireEvent(EntityEventType ev, object parameters)
 {
     foreach (var listener in m_listeners)
     {
         listener.OnEntityEvent(ev, this, parameters);
     }
 }
        public ICommonMethod Get(EntityEventType type)
        {
            ICommonMethod methodInfo;

            this.infos.TryGetValue(type, out methodInfo);
            return(methodInfo);
        }
Exemple #4
0
 /// <summary>
 /// Clear cache data
 /// </summary>
 /// <param name="entity">Entity</param>
 /// <param name="entityEventType">Entity event type</param>
 protected override void ClearCache(SpecificationAttributeGroup entity, EntityEventType entityEventType)
 {
     if (entityEventType != EntityEventType.Insert)
     {
         RemoveByPrefix(NopCatalogDefaults.SpecificationAttributeGroupByProductPrefix);
     }
 }
        public MethodInfo Get(EntityEventType type)
        {
            MethodInfo methodInfo;

            this.infos.TryGetValue(type, out methodInfo);
            return(methodInfo);
        }
Exemple #6
0
        public void OnEntityEvent(EntityEventType ev, AbstractEntity entity, object parameters)
        {
            if (Done)
            {
                return;
            }

            try
            {
                switch (ev)
                {
                case EntityEventType.FIGHT_KILL:
                    var monster = parameters as MonsterEntity;
                    if (monster != null)
                    {
                        foreach (var killMonster in CurrentStep.Objectives
                                 .OfType <KillMonsterObjective>()
                                 .Where(killMonster => killMonster.MonsterTemplateId == monster.Grade.Template.Id))
                        {
                            UpdateObjective(killMonster.Id, int.Parse, i => i + 1);
                        }
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                Logger.Error("CharacterQuest::OnEntityEvent failed to update quest", e);
            }
        }
        public async void Create_Event(EntityEventType type, int id, string eventDescription)
        {
            string instanceName = Guid.NewGuid().ToString();

            using var context = TestUtilities.GetDbContext(instanceName);
            EventService service = new EventService(context, _mapper);
            await service.CreateEvent(type, id, eventDescription);
        }
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(NewsItem entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Delete)
            {
                RemoveByPrefix(NopNewsDefaults.NewsCommentsNumberPrefix, entity);
            }

            base.ClearCache(entity, entityEventType);
        }
        public async Task <IViewComponentResult> InvokeAsync(EntityEventType eventType, int id)
        {
            EventListViewModel model = new EventListViewModel();

            model.Events = await _eventManager.GetEvents(eventType, id);

            model.Title = $"{eventType} History";
            return(View(model));
        }
Exemple #10
0
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(ProductAttribute entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Insert)
            {
                Remove(NopCatalogDefaults.ProductAttributeValuesByAttributeCacheKey, entity);
            }

            base.ClearCache(entity, entityEventType);
        }
        public void Remove(ClaimsPrincipal who, string key, EntityEventType ignoreHandlers)
        {
            var entity = _container.GetInstance <T>();

            entity._key = key;
            Remove(new EntityRequestContext {
                Who = who, IgnoreHandlers = ignoreHandlers
            }, entity);
        }
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(ReviewType entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Delete)
            {
                RemoveByPrefix(NopCatalogCachingDefaults.ProductReviewReviewTypeMappingAllPrefixCacheKey);
            }

            Remove(NopCatalogCachingDefaults.ReviewTypeAllCacheKey);
        }
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override async Task ClearCacheAsync(ProductAttribute entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Insert)
            {
                await RemoveAsync(NopCatalogDefaults.ProductAttributeValuesByAttributeCacheKey, entity);
            }

            await base.ClearCacheAsync(entity, entityEventType);
        }
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        /// <returns>A task that represents the asynchronous operation</returns>
        protected override async Task ClearCacheAsync(NewsItem entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Delete)
            {
                await RemoveByPrefixAsync(NopNewsDefaults.NewsCommentsNumberPrefix, entity);
            }

            await base.ClearCacheAsync(entity, entityEventType);
        }
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override async Task ClearCacheAsync(SpecificationAttribute entity, EntityEventType entityEventType)
        {
            await RemoveAsync(NopCatalogDefaults.SpecificationAttributesWithOptionsCacheKey);

            if (entityEventType != EntityEventType.Insert)
            {
                await RemoveByPrefixAsync(NopCatalogDefaults.ProductSpecificationAttributeAllByProductPrefix);
                await RemoveByPrefixAsync(NopCatalogDefaults.SpecificationAttributeGroupByProductPrefix);
            }
        }
 public async Task CreateEvent(EntityEventType type, int id, string eventDescription)
 {
     _context.EntityEvents.Add(new EntityEvent()
     {
         EntityId    = id,
         Type        = type,
         Description = eventDescription
     });
     await _context.SaveChangesAsync();
 }
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(SpecificationAttribute entity, EntityEventType entityEventType)
        {
            Remove(NopCatalogDefaults.SpecificationAttributesWithOptionsCacheKey);

            if (entityEventType != EntityEventType.Insert)
            {
                RemoveByPrefix(NopCatalogDefaults.ProductSpecificationAttributeAllByProductPrefix);
                RemoveByPrefix(NopCatalogDefaults.SpecificationAttributeGroupByProductPrefix);
            }
        }
		public void Add(EntityEventType type, MethodInfo methodInfo)
		{
			try
			{
				this.infos.Add(type, methodInfo);
			}
			catch (Exception e)
			{
				throw new Exception($"Add EntityEventType MethodInfo Error: {type}", e);
			}
		}
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(NewsComment entity, EntityEventType entityEventType)
        {
            if (entityEventType != EntityEventType.Delete)
            {
                return;
            }

            var prefix = NopNewsCachingDefaults.NewsCommentsNumberPrefixCacheKey.ToCacheKey(entity.NewsItemId);

            RemoveByPrefix(prefix);
        }
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(ProductAttribute entity, EntityEventType entityEventType)
        {
            if (entityEventType != EntityEventType.Delete)
            {
                return;
            }

            RemoveByPrefix(NopCatalogDefaults.ProductAttributeMappingsPrefixCacheKey);
            RemoveByPrefix(NopCatalogDefaults.ProductAttributeValuesAllPrefixCacheKey);
            RemoveByPrefix(NopCatalogDefaults.ProductAttributeCombinationsAllPrefixCacheKey);
        }
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(NewsComment entity, EntityEventType entityEventType)
        {
            if (entityEventType != EntityEventType.Delete)
            {
                return;
            }

            var prefix = _cacheKeyService.PrepareKeyPrefix(NopNewsDefaults.NewsCommentsNumberPrefixCacheKey, entity.NewsItemId);

            RemoveByPrefix(prefix);
        }
 public void Add(EntityEventType type, MethodInfo methodInfo)
 {
     try
     {
         this.infos.Add(type, methodInfo);
     }
     catch (Exception e)
     {
         throw new Exception($"Add EntityEventType MethodInfo Error: {type}", e);
     }
 }
        public void Register(string name, Assembly assembly)
        {
            this.eventInfo = new Dictionary <Type, EntityTypeInfo>();

            this.assemblies[name] = assembly;

            foreach (Assembly ass in this.assemblies.Values)
            {
                Type[] types = ass.GetTypes();
                foreach (Type type in types)
                {
                    object[] attrs = type.GetCustomAttributes(typeof(EntityEventAttribute), true);
                    if (attrs.Length == 0)
                    {
                        continue;
                    }

                    EntityEventAttribute entityEventAttribute = attrs[0] as EntityEventAttribute;

                    Type type2 = entityEventAttribute.ClassType;

                    if (!this.eventInfo.ContainsKey(type2))
                    {
                        this.eventInfo.Add(type2, new EntityTypeInfo());
                    }

                    foreach (
                        MethodInfo methodInfo in
                        type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public |
                                        BindingFlags.DeclaredOnly))
                    {
                        int n = methodInfo.GetParameters().Length;
                        if (methodInfo.IsStatic)
                        {
                            --n;
                        }
                        string sn = n > 0? $"{methodInfo.Name}{n}" : methodInfo.Name;
                        foreach (string s in Enum.GetNames(typeof(EntityEventType)))
                        {
                            if (s != sn)
                            {
                                continue;
                            }
                            EntityEventType t = EnumHelper.FromString <EntityEventType>(s);
                            this.eventInfo[type2].Add(t, methodInfo);
                            break;
                        }
                    }
                }
            }

            this.Load();
        }
        /// <summary>
        /// Clear cache by entity event type
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        /// <returns>A task that represents the asynchronous operation</returns>
        protected virtual async Task ClearCacheAsync(TEntity entity, EntityEventType entityEventType)
        {
            await RemoveByPrefixAsync(NopEntityCacheDefaults <TEntity> .ByIdsPrefix);
            await RemoveByPrefixAsync(NopEntityCacheDefaults <TEntity> .AllPrefix);

            if (entityEventType != EntityEventType.Insert)
            {
                await RemoveAsync(NopEntityCacheDefaults <TEntity> .ByIdCacheKey, entity);
            }

            await ClearCacheAsync(entity);
        }
        /// <summary>
        /// entity
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override void ClearCache(ProductAttribute entity, EntityEventType entityEventType)
        {
            if (entityEventType == EntityEventType.Delete)
            {
                RemoveByPrefix(NopCatalogCachingDefaults.ProductAttributeMappingsPrefixCacheKey);
                RemoveByPrefix(NopCatalogCachingDefaults.ProductAttributeValuesPrefixCacheKey);
                RemoveByPrefix(NopCatalogCachingDefaults.ProductAttributeCombinationsPrefixCacheKey);
            }

            RemoveByPrefix(NopCatalogCachingDefaults.ProductAttributesAllPrefixCacheKey);

            var cacheKey = NopCatalogCachingDefaults.ProductsByProductAtributeCacheKey.ToCacheKey(entity);
            Remove(cacheKey);
        }
Exemple #26
0
        public virtual string?GetAuditValues(EntityEventType eventType, object?newEntity, string?previousJsonAudit = null)
        {
            var httpContext = _httpContextAccessor.HttpContext;
            int?userId;

            var user = httpContext.User;

            if (!user.Identity.IsAuthenticated)
            {
                userId = null;
            }
            else
            {
                userId = user.Claims.Where(x => x.Type == "UserID").Select(x => x.Value).First().ToInt();
            }

            var auditSourceValues = _auditSourcesProvider.GetAuditSourceValues();

            var auditJArray = new JArray();

            // Update & Delete
            if (eventType == EntityEventType.Update || eventType == EntityEventType.Delete)
            {
                auditJArray = JArray.Parse(previousJsonAudit !);
            }

            // Delete => No NewValues
            if (eventType == EntityEventType.Delete)
            {
                newEntity = null;
            }

            JObject newAuditJObject = JObject.FromObject(new EntityAudit <object?>
            {
                EventType         = eventType,
                ActorUserId       = userId,
                ActDateTime       = DateTime.Now,
                AuditSourceValues = auditSourceValues,
                NewEntity         = newEntity
            }, new JsonSerializer
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.None
            });

            auditJArray.Add(newAuditJObject);

            return(auditJArray.SerializeToJson(true));
        }
        /// <summary>
        /// Creates new instance.
        /// </summary>
        /// <param name="type">Entity type.</param>
        /// <param name="addedItems">Added items.</param>
        /// <param name="removedItems">Removed items.</param>
        public EntityEventArgs(EntityEventType type, IEnumerable <T> addedItems, IEnumerable <T> removedItems)
            : this(type)
        {
            Type = type;

            if (addedItems != null)
            {
                AddedItems = new List <T>(addedItems);
            }

            if (removedItems != null)
            {
                RemovedItems = new List <T>(removedItems);
            }
        }
Exemple #28
0
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override async Task ClearCacheAsync(Manufacturer entity, EntityEventType entityEventType)
        {
            await RemoveByPrefixAsync(NopDiscountDefaults.ManufacturerIdsPrefix);

            if (entityEventType != EntityEventType.Insert)
            {
                await RemoveByPrefixAsync(NopCatalogDefaults.ManufacturersByCategoryPrefix);
            }

            if (entityEventType == EntityEventType.Delete)
            {
                await RemoveAsync(NopCatalogDefaults.SpecificationAttributeOptionsByManufacturerCacheKey, entity);
            }

            await base.ClearCacheAsync(entity, entityEventType);
        }
Exemple #29
0
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        /// <returns>A task that represents the asynchronous operation</returns>
        protected override async Task ClearCacheAsync(Product entity, EntityEventType entityEventType)
        {
            await RemoveByPrefixAsync(NopCatalogDefaults.ProductManufacturersByProductPrefix, entity);
            await RemoveAsync(NopCatalogDefaults.ProductsHomepageCacheKey);
            await RemoveByPrefixAsync(NopCatalogDefaults.ProductPricePrefix, entity);
            await RemoveByPrefixAsync(NopEntityCacheDefaults <ShoppingCartItem> .AllPrefix);
            await RemoveByPrefixAsync(NopCatalogDefaults.FeaturedProductIdsPrefix);

            if (entityEventType == EntityEventType.Delete)
            {
                await RemoveByPrefixAsync(NopCatalogDefaults.FilterableSpecificationAttributeOptionsPrefix);
                await RemoveByPrefixAsync(NopCatalogDefaults.ManufacturersByCategoryPrefix);
            }

            await base.ClearCacheAsync(entity, entityEventType);
        }
        public async void Get_Event_List(EntityEventType type, int id, string eventDescription)
        {
            string instanceName = Guid.NewGuid().ToString();

            using (var context = TestUtilities.GetDbContext(instanceName)) {
                context.EntityEvents.Add(new EntityEvent()
                {
                    EntityId    = id,
                    Type        = type,
                    Description = eventDescription
                });
                await context.SaveChangesAsync();
            }
            using (var context = TestUtilities.GetDbContext(instanceName)) {
                Assert.NotEmpty(await new EventService(context, _mapper).GetEvents <EventItemModel>(id, type));
            }
        }
Exemple #31
0
        /// <summary>
        /// Clear cache data
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <param name="entityEventType">Entity event type</param>
        protected override async Task ClearCacheAsync(Category entity, EntityEventType entityEventType)
        {
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoriesByParentCategoryPrefix, entity);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoriesByParentCategoryPrefix, entity.ParentCategoryId);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoriesChildIdsPrefix, entity);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoriesChildIdsPrefix, entity.ParentCategoryId);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoriesHomepagePrefix);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoryBreadcrumbPrefix);
            await RemoveByPrefixAsync(NopCatalogDefaults.CategoryProductsNumberPrefix);
            await RemoveByPrefixAsync(NopDiscountDefaults.CategoryIdsPrefix);

            if (entityEventType == EntityEventType.Delete)
            {
                await RemoveAsync(NopCatalogDefaults.SpecificationAttributeOptionsByCategoryCacheKey, entity);
            }

            await base.ClearCacheAsync(entity, entityEventType);
        }
Exemple #32
0
 public void OnEntityEvent(object sender, EventArgs e, EntityEventType entityEventType)
 {
     switch (entityEventType)
     {
         case EntityEventType.PropertyChanging:
             OnPropertyChanging(sender, (PropertyChangingEventArgs) e);
             break;
         case EntityEventType.PropertyChanged:
             OnPropertyChanged(sender, (PropertyChangedEventArgs) e);
             break;
         case EntityEventType.CollectionChanging:
             OnCollectionChanging(sender, (NotifyCollectionChangingEventArgs) e);
             break;
         case EntityEventType.CollectionChanged:
             OnCollectionChanged(sender, (NotifyCollectionChangingEventArgs) e);
             break;
     }
 }
		public MethodInfo Get(EntityEventType type)
		{
			MethodInfo methodInfo;
			this.infos.TryGetValue(type, out methodInfo);
			return methodInfo;
		}
Exemple #34
0
        private PlayerMessage GetPlayerMessage(EntityEventType type)
        {
            var message = new PlayerMessage();
            message.EntityEvent = new EntityEvent();
            message.EntityEvent.TimeStamp = gameClient.TimeStamp;
            message.EntityEvent.Type = type;

            return message;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ev"></param>
 /// <param name="parameters"></param>
 public void FireEvent(EntityEventType ev, object parameters)
 {
     foreach (var listener in m_listeners)
         listener.OnEntityEvent(ev, this, parameters);
 }