Пример #1
0
        public static string GetUrlForSearch(SavedUserAssetSearch searchInfo)
        {
            AssetFinder finder = searchInfo.AssetFinder;

            StringBuilder sb = new StringBuilder();

            sb.Append("~/SearchRedirector.ashx?x=1");

            AppendSearchValue(sb, CATEGORY_ID, searchInfo.CurrentCategoryId);
            AppendSearchValue(sb, GENERAL_KEYWORD, finder.GeneralKeyword.Replace("&", " "));

            foreach (var ids in finder.MetadataIds)
            {//add all selected meta value ids for each meta under its
                //own param name
                foreach (var id in ids.Value)
                {
                    AppendSearchValue(sb, "md" + ids.Key, id);
                }
            }

            AppendSearchValue(sb, BRAND_ID, finder.BrandId);
            AppendSearchValue(sb, ASSET_TYPE_ID, finder.AssetTypeId);
            AppendSearchValue(sb, ORIENTATION_ID, m_OrientationDictionary[finder.Orientation]);

            ComplexCriteria criteria = finder.GetSingleComplexCriteria(Asset.Columns.FileSize);

            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}&{2}={3}", FILESIZE_COMPARETYPE, m_CompareTypeDictionary[criteria.CompareType], FILESIZE, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionMonth, CompareType.MoreThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", FROM_PRODUCTION_MONTH, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionYear, CompareType.MoreThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", FROM_PRODUCTION_YEAR, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionMonth, CompareType.LessThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", TO_PRODUCTION_MONTH, criteria.Value);
            }

            criteria = finder.GetSingleComplexCriteria(Asset.Columns.ProductionYear, CompareType.LessThan);
            if (criteria != null)
            {
                sb.AppendFormat("&{0}={1}", TO_PRODUCTION_YEAR, criteria.Value);
            }

            sb.AppendFormat("&{0}={1}", PAGE, searchInfo.Page);
            sb.AppendFormat("&{0}={1}", PAGE_SIZE, searchInfo.PageSize);

            return(sb.ToString());
        }
Пример #2
0
 public void Reset()
 {
     SavedUserAssetSearch       = new SavedUserAssetSearch();
     PersistentLightboxCartInfo = new PersistentLightboxCartInfo();
     LightboxPageSize           = 0;
     CartPageSize            = 0;
     DownloadManagerPageSize = 0;
 }
Пример #3
0
        public static void SetupSearchFromRequest(NameValueCollection request, SavedUserAssetSearch searchInfo)
        {
            if (request[CATEGORY_ID] != null)
            {
                int      categoryId = NumericUtils.ParseInt32(request[CATEGORY_ID], 0);
                Category category   = CategoryCache.Instance.GetById(categoryId);

                if (CurrentUser.CanAccessBrand(category.BrandId))
                {
                    searchInfo.SelectCategory(categoryId);
                }
            }

            if (request[GENERAL_KEYWORD] != null)
            {
                searchInfo.AssetFinder.GeneralKeyword = HttpUtility.UrlDecode(request[GENERAL_KEYWORD]);
            }

            for (int i = 1; i <= Settings.NumberOfMetadataFields; i++)
            {
                string key = "md" + i;

                if (request[key] != null)
                {
                    var metadataIds = NumericUtils.ParseIntList(request[key], ",");

                    if (metadataIds.Count == 0)
                    {
                        return;
                    }

                    foreach (var mId in metadataIds)
                    {
                        Metadata metadata = MetadataCache.Instance.GetById(mId);
                        if (metadata.IsNull)
                        {
                            return;
                        }

                        if (CurrentUser.CanAccessBrand(metadata.BrandId.GetValueOrDefault()))
                        {
                            if (!searchInfo.AssetFinder.MetadataIds.ContainsKey(i))
                            {
                                searchInfo.AssetFinder.MetadataIds.Add(i, new List <int>());
                            }

                            searchInfo.AssetFinder.MetadataIds[i].Add(mId);
                        }
                    }
                }
            }

            if (request[BRAND_ID] != null)
            {
                int brandId = NumericUtils.ParseInt32(request[BRAND_ID], 0);

                if (CurrentUser.CanAccessBrand(brandId))
                {
                    searchInfo.AssetFinder.BrandId = brandId;
                }
            }

            if (request[ASSET_TYPE_ID] != null)
            {
                searchInfo.AssetFinder.AssetTypeId = NumericUtils.ParseInt32(request[ASSET_TYPE_ID], 0);
            }

            if (request[ORIENTATION_ID] != null)
            {
                searchInfo.AssetFinder.Orientation = GetOrientation(request[ORIENTATION_ID]);
            }

            if (request[FILESIZE_COMPARETYPE] != null && request[FILESIZE] != null)
            {
                CompareType compareType = GetCompareType(request[FILESIZE_COMPARETYPE]);
                searchInfo.AssetFinder.AddComplexCriteria(Asset.Columns.FileSize, Decimal.Parse(request[FILESIZE]), compareType);
            }

            if (request[FROM_PRODUCTION_MONTH] != null)
            {
                searchInfo.AssetFinder.AddComplexCriteria(Asset.Columns.ProductionMonth, request[FROM_PRODUCTION_MONTH], CompareType.MoreThan);
            }

            if (request[FROM_PRODUCTION_YEAR] != null)
            {
                searchInfo.AssetFinder.AddComplexCriteria(Asset.Columns.ProductionYear, request[FROM_PRODUCTION_YEAR], CompareType.MoreThan);
            }

            if (request[TO_PRODUCTION_MONTH] != null)
            {
                searchInfo.AssetFinder.AddComplexCriteria(Asset.Columns.ProductionMonth, request[TO_PRODUCTION_MONTH], CompareType.LessThan);
            }

            if (request[TO_PRODUCTION_YEAR] != null)
            {
                searchInfo.AssetFinder.AddComplexCriteria(Asset.Columns.ProductionYear, request[TO_PRODUCTION_YEAR], CompareType.LessThan);
            }

            if (request[PAGE] != null)
            {
                searchInfo.Page = NumericUtils.ParseInt32(request[PAGE], 0);
            }

            if (request[PAGE_SIZE] != null)
            {
                searchInfo.PageSize = NumericUtils.ParseInt32(request[PAGE_SIZE], 0);
            }
        }