Exemplo n.º 1
0
        /// <summary>
        /// Creates an audit log entry for the specified search and
        /// returns the auditassetsearch (which is needed to track
        /// which assets are viewed for this search on a page-by-page basis)
        /// </summary>
        /// <param name="assetFinder">The asset finder being used for the search</param>
        /// <param name="user">The user performing the search</param>
        public static AuditAssetSearch LogSearch(AssetFinder assetFinder, User user)
        {
            if (user.IsNull)
            {
                m_Logger.WarnFormat("Unable to log search; user is null");
                return(AuditAssetSearch.Empty);
            }

            AuditAssetSearch aus = AuditAssetSearch.New();

            aus.SessionId = BusinessHelper.GetCurrentSessionId();
            aus.IpAddress = BusinessHelper.GetCurrentIpAddress();
            aus.UserId    = user.UserId.GetValueOrDefault();
            aus.Date      = DateTime.Now;
            AuditAssetSearch.Update(aus);

            AuditAssetSearchKeyword aask = AuditAssetSearchKeyword.New();

            aask.AuditAssetSearchId = aus.AuditAssetSearchId.GetValueOrDefault();
            aask.SearchKeyword      = assetFinder.GeneralKeyword;
            AuditAssetSearchKeyword.Update(aask);

            int assetCount = Asset.GetCount(assetFinder);

            string notes = string.Format("Searched for '{0}' (Criteria Count: {1}).  Found {2} assets.", assetFinder.GeneralKeyword, assetFinder.FindCriteriaCount, assetCount);

            LogUserAction(user, AuditUserAction.Search, notes);

            return(aus);
        }
Exemplo n.º 2
0
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            // Get base finder
            AssetFinder finder = SearchManager.GetBaseAssetFinder(CurrentUser);

            // Reset the category list if all brands are selected, or if the brand selector has changed
            if (BrandDropDownList1.SelectedId == 0 || finder.BrandId != BrandDropDownList1.SelectedId)
            {
                finder.CategoryIdList.Clear();
                SavedUserAssetSearch.CurrentCategoryId = -1;
            }

            // Set basic criteria
            finder.GeneralKeyword = KeywordsTextBox.Text.Trim();
            finder.BrandId        = BrandDropDownList1.SelectedId;
            finder.AssetTypeId    = AssetTypeDropDownList1.SelectedId;

            MetadataFilters.AddAdvancedSearchCriteria(ref finder);
            AddCategorySearchCriteria();

            // Log the search
            AuditAssetSearch aas = AuditLogManager.LogSearch(finder, CurrentUser);

            // Store the finder and clear the audit ID, as we dont want to audit advanced searches
            SavedUserAssetSearch.AssetFinder        = finder;
            SavedUserAssetSearch.AuditAssetSearchId = aas.AuditAssetSearchId.GetValueOrDefault();
            SavedUserAssetSearch.Page = 1;

            // Redirect to the search results
            // It will pick up the finder from the session to display results
            Response.Redirect("~/SearchResults.aspx", false);
        }