Пример #1
0
Файл: Audit.cs Проект: pcstx/OA
        /// <summary>
        /// Returns moderation audit entries for provided user ID and moderator action.
        /// Records are returned in a controled amount through records pagination.
        /// </summary>
        /// <param name="userID">A valid user ID as an integer.</param>
        /// <param name="action">Filter audit trail by moderation action.</param>
        /// <param name="pageIndex">Number of the current page.</param>
        /// <param name="pageSize">Number of records contained by the current page.</param>
        /// <param name="returnRecordCount">Returns also total number of entries if true.</param>
        /// <param name="cacheable">Store in cache also if true.</param>
        /// <param name="flush">Reset previous cached version if true.</param>
        /// <returns>Collection of audit entries incapsulated into ModerationAuditSet.</returns>
        public static AuditSet GetAuditHistoryForUser(int userID, ModeratorActions action, int pageIndex, int pageSize, bool returnRecordCount, bool cacheable, bool flush)
        {
            string cacheKey = string.Format( "AuditHistoryForUser-{0}-{1}-{2}-{3}-{4}", userID, action.ToString(), CSContext.Current.SiteSettings.SettingsID, pageIndex, pageSize );
            HttpContext context = HttpContext.Current;
            AuditSet collection;

            if (flush) {
                CSCache.Remove(cacheKey);
                context.Items[cacheKey] = null;
            }

            // Get the summary from context
            //
            collection = context.Items[cacheKey] as AuditSet;
            if(collection != null)
                return collection;

            // Get the summary from cache
            //
            collection = CSCache.Get(cacheKey) as AuditSet;
            if (collection == null) {
                collection = CommonDataProvider.Instance().GetAuditHistoryForUser( userID, action, pageIndex, pageSize, returnRecordCount );

            // Does not need to be cached. Revisit API in 1.2 - SW
            //                if (cacheable)
            //                    CSCache.Insert(cacheKey, collection, 10 * CSCache.MinuteFactor );
            }

            context.Items[cacheKey] = collection;

            return collection;
        }
Пример #2
0
 /// <summary>
 /// Gets a localized description for provided ModeratorAction.
 /// </summary>
 public static string FormatModeratorAction(ModeratorActions action)
 {
     return ResourceManager.GetString( "Utility_ModeratorActions_" + action.ToString() );
 }