/// <summary>
        /// Install all activity types specified by the activity log type provider
        /// </summary>
        /// <param name="activityLogTypeProvider">The activity log type provider.</param>
        /// <param name="reInstall">Should the provider be reinstalled (add new types or update existing)</param>
        /// <remarks></remarks>
        public void InstallActivityLogTypes(IActivityLogTypeProvider activityLogTypeProvider, bool reInstall = false)
        {
            var providerName = activityLogTypeProvider.GetType().Name;

            if (reInstall)
                _installedActivityLogProviderCollection.Remove(Query<ActivityLogTypeProviderInstalled>.EQ(x => x.Name, providerName));

            if(_installedActivityLogProviderCollection.Count(Query<ActivityLogTypeProviderInstalled>.EQ(x => x.Name, providerName)) > 0)
                return;

            _installedActivityLogProviderCollection.Insert(new ActivityLogTypeProviderInstalled { Name = providerName });

            foreach (var activityLogType in activityLogTypeProvider.GetActivityLogTypes())
            {
                var existing = _activityLogTypeCollection.FindOne(Query.And(Query<ActivityLogType>.EQ(x => x.SystemKeyword, activityLogType.SystemKeyword)));

                if(existing == null)
                    existing = new ActivityLogType();

                existing.SystemKeyword = activityLogType.SystemKeyword;
                existing.Name = activityLogType.Name;
                existing.Enabled = activityLogType.Enabled;

                if(existing.Id == ObjectId.Empty)
                    _activityLogTypeCollection.Insert(existing);
                else
                    _activityLogTypeCollection.Update(Query<ActivityLogType>.EQ(x => x.Id, existing.Id), Update<ActivityLogType>.Replace(existing));
            }
        }
示例#2
0
 public static ActivityLogType MakeClone(ActivityLogType another)
 {
     return another == null ? null : another.MakeClone();
 }
        /// <summary>
        /// Updates an activity log type item
        /// </summary>
        /// <param name="activityLogType">Activity log type item</param>
        public virtual void UpdateActivityType(ActivityLogType activityLogType)
        {
            if (activityLogType == null)
                throw new ArgumentNullException("activityLogType");

            _activityLogTypeRepository.Update(activityLogType);
            _cacheManager.RemoveByPattern(ACTIVITYTYPE_PATTERN_KEY);
        }
示例#4
0
 public static ActivityLogTypeModel ToModel(this ActivityLogType entity)
 {
     return(entity.MapTo <ActivityLogType, ActivityLogTypeModel>());
 }
示例#5
0
 public static ActivityLogTypeModel ToModel(this ActivityLogType entity)
 {
     return(Mapper.Map <ActivityLogType, ActivityLogTypeModel>(entity));
 }
 /// <summary>
 /// Updates an activity log type item
 /// </summary>
 /// <param name="activityLogType">Activity log type item</param>
 /// <returns>A task that represents the asynchronous operation</returns>
 public virtual async Task UpdateActivityTypeAsync(ActivityLogType activityLogType)
 {
     await _activityLogTypeRepository.UpdateAsync(activityLogType);
 }