Exemplo n.º 1
0
        /// <summary>
        /// Inserts an activity log item
        /// </summary>
        /// <param name="customer">Customer</param>
        /// <param name="systemKeyword">System keyword</param>
        /// <param name="comment">Comment</param>
        /// <param name="entity">Entity</param>
        /// <returns>Activity log item</returns>
        public virtual ActivityLog InsertActivity(Customer customer, string systemKeyword, string comment, BaseEntity entity = null)
        {
            if (customer == null)
            {
                return(null);
            }

            //try to get activity log type by passed system keyword
            ActivityLogTypeForCaching activityLogType = GetAllActivityTypesCached().FirstOrDefault(type => type.SystemKeyword.Equals(systemKeyword));

            if (!activityLogType?.Enabled ?? true)
            {
                return(null);
            }

            //insert log item
            ActivityLog logItem = new ActivityLog
            {
                ActivityLogTypeId = activityLogType.Id,
                EntityId          = entity?.Id,
                EntityName        = entity?.GetUnproxiedEntityType().Name,
                CustomerId        = customer.Id,
                Comment           = CommonHelper.EnsureMaximumLength(comment ?? string.Empty, 4000),
                CreatedOnUtc      = DateTime.UtcNow,
                IpAddress         = _webHelper.GetCurrentIpAddress()
            };

            _activityLogRepository.Insert(logItem);

            return(logItem);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all activity log types (class for caching)
        /// </summary>
        /// <returns>Activity log types</returns>
        protected virtual IList <ActivityLogTypeForCaching> GetAllActivityTypesCached()
        {
            var result           = new List <ActivityLogTypeForCaching>();
            var activityLogTypes = GetAllActivityTypes();

            foreach (var alt in activityLogTypes)
            {
                var altForCaching = new ActivityLogTypeForCaching
                {
                    Id            = alt.Id,
                    SystemKeyword = alt.SystemKeyword,
                    Name          = alt.Name,
                    Enabled       = alt.Enabled
                };
                result.Add(altForCaching);
            }
            return(result);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets all activity log types (class for caching)
 /// </summary>
 /// <returns>Activity log types</returns>
 protected virtual IList <ActivityLogTypeForCaching> GetAllActivityTypesCached()
 {
     //cache
     return(_cacheManager.Get(NopLoggingDefaults.ActivityTypeAllCacheKey, () =>
     {
         var result = new List <ActivityLogTypeForCaching>();
         var activityLogTypes = GetAllActivityTypes();
         foreach (var alt in activityLogTypes)
         {
             var altForCaching = new ActivityLogTypeForCaching
             {
                 Id = alt.Id,
                 SystemKeyword = alt.SystemKeyword,
                 Name = alt.Name,
                 Enabled = alt.Enabled
             };
             result.Add(altForCaching);
         }
         return result;
     }));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets all activity log types (class for caching)
        /// </summary>
        protected async Task <IList <ActivityLogTypeForCaching> > GetAllActivityTypesCached()
        {
            return(await _cacheManager.Get(LoggingDefaults.ActivityTypeAllCacheKey, async() =>
            {
                var result = new List <ActivityLogTypeForCaching>();
                var activityLogTypes = await GetAllActivityTypesAsync();
                foreach (var alt in activityLogTypes)
                {
                    var altForCaching = new ActivityLogTypeForCaching
                    {
                        Id = alt.Id,
                        SystemKeyword = alt.SystemKeyword,
                        Name = alt.Name,
                        Enabled = alt.Enabled
                    };
                    result.Add(altForCaching);
                }

                return result;
            }));
        }
Exemplo n.º 5
0
        protected virtual IList <ActivityLogTypeForCaching> GetAllActivityTypesCached()
        {
            string key = string.Format(ACTIVITYTYPE_ALL_KEY);

            return(_cacheManager.Get(key, () =>
            {
                var result = new List <ActivityLogTypeForCaching>();
                var activityLogTypes = GetAllActivityTypes();
                foreach (var alt in activityLogTypes)
                {
                    var altForCaching = new ActivityLogTypeForCaching()
                    {
                        Id = alt.Id,
                        SystemKeyword = alt.SystemKeyword,
                        Name = alt.Name,
                        Enabled = alt.Enabled
                    };
                    result.Add(altForCaching);
                }
                return result;
            }));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets all activity log types (class for caching)
        /// </summary>
        /// <returns>Activity log types</returns>
        protected virtual async Task <IList <ActivityLogTypeForCaching> > GetAllActivityTypesCached()
        {
            //cache
            string key = string.Format(CacheKey.ACTIVITYTYPE_ALL_KEY);

            return(await _cacheManager.GetAsync(key, async() =>
            {
                var result = new List <ActivityLogTypeForCaching>();
                var activityLogTypes = await GetAllActivityTypes();
                foreach (var alt in activityLogTypes)
                {
                    var altForCaching = new ActivityLogTypeForCaching
                    {
                        Id = alt.Id,
                        SystemKeyword = alt.SystemKeyword,
                        Name = alt.Name,
                        Enabled = alt.Enabled
                    };
                    result.Add(altForCaching);
                }
                return result;
            }));
        }
 /// <summary>
 /// Gets all activity log types (class for caching)
 /// </summary>
 /// <returns>Activity log types</returns>
 protected virtual IList<ActivityLogTypeForCaching> GetAllActivityTypesCached()
 {
     //cache
     string key = string.Format(ACTIVITYTYPE_ALL_KEY);
     return _cacheManager.Get(key, () =>
     {
         var result = new List<ActivityLogTypeForCaching>();
         var activityLogTypes = GetAllActivityTypes();
         foreach (var alt in activityLogTypes)
         {
             var altForCaching = new ActivityLogTypeForCaching
             {
                 Id = alt.Id,
                 SystemKeyword = alt.SystemKeyword,
                 Name = alt.Name,
                 Enabled = alt.Enabled
             };
             result.Add(altForCaching);
         }
         return result;
     });
 }