/// <summary> /// Gets the taxes. /// </summary> /// <returns></returns> public static CatalogTaxDto GetTaxCategories() { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalog-taxcategory", CatalogConfiguration.Instance.ApplicationId.ToString()); CatalogTaxDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogTaxDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = CatalogDataHelper.CreateDataCommand(); cmd.CommandText = "ecf_TaxCategory"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.DataSet = new CatalogTaxDto(); cmd.TableMapping = DataHelper.MapTables("TaxCategory"); DataResult results = DataService.LoadDataSet(cmd); dto = (CatalogTaxDto)results.DataSet; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogSchemaTimeout); } return(dto); }
/// <summary> /// Loads the meta class cached. /// </summary> /// <param name="context">The context.</param> /// <param name="metaClassName">Name of the meta class.</param> /// <returns></returns> public static MetaClass LoadMetaClassCached(MetaDataContext context, string metaClassName) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogschema", "metadata-s", metaClassName); // load list of MetaFields for MetaClass MetaClass metaClass = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { metaClass = (MetaClass)cachedObject; } if (metaClass == null) { metaClass = MetaClass.Load(context, metaClassName); if (metaClass == null) { return(null); } // Insert to the cache collection CatalogCache.Insert(cacheKey, metaClass, CatalogConfiguration.Instance.Cache.CatalogSchemaTimeout); } return(metaClass); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { SearchFilter.Items.Clear(); SearchFilter.Items.Add(new ListItem(RM.GetString("GENERAL_ALL_PRODUCTS"), "")); string cacheKey = CatalogCache.CreateCacheKey("mc-catalogentry-list"); // check cache first object cachedObject = CatalogCache.Get(cacheKey); MetaClassCollection metaClasses = null; MetaClass catalogEntry = MetaHelper.LoadMetaClassCached(CatalogContext.MetaDataContext, "CatalogEntry"); if (catalogEntry != null) { metaClasses = catalogEntry.ChildClasses; } if (metaClasses != null) { foreach (MetaClass metaClass in metaClasses) { SearchFilter.Items.Add(new ListItem(metaClass.FriendlyName, metaClass.Name)); } } SearchFilter.DataBind(); Search.Text = Request.QueryString["search"]; CommonHelper.SelectListItem(SearchFilter, Request.QueryString["filter"]); }
/// <summary> /// Gets the catalog nodes dto. /// </summary> /// <param name="catalogId">The catalog id.</param> /// <param name="catalogNodeId">The catalog node id.</param> /// <param name="catalogEntryId">The catalog entry id.</param> /// <param name="groupName">Name of the group.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogRelationDto GetCatalogRelationDto(int catalogId, int catalogNodeId, int catalogEntryId, string groupName, CatalogRelationResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalog-relation", responseGroup.CacheKey, catalogId.ToString(), catalogNodeId.ToString(), catalogEntryId.ToString(), groupName); CatalogRelationDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogRelationDto)cachedObject; } // Load the object if (dto == null) { CatalogRelationAdmin admin = new CatalogRelationAdmin(); admin.Load(catalogId, catalogNodeId, catalogEntryId, groupName, responseGroup.ResponseGroups.GetHashCode()); dto = admin.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } dto.AcceptChanges(); return(dto); }
/// <summary> /// Finds the items dto. /// </summary> /// <param name="search">The search.</param> /// <param name="recordsCount">The records count.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogEntryDto FindItemsDto(CatalogSearch search, ref int recordsCount, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = String.Empty; // Only cache results if specified if (search.SearchOptions.CacheResults) { cacheKey = CatalogCache.CreateCacheKey("catalog-entriesdto", responseGroup.CacheKey, search.CacheKey); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { return((CatalogEntryDto)cachedObject); } } CatalogEntryDto dto = FindItemsDto2(search, ref recordsCount, responseGroup); if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, search.SearchOptions.CacheTimeout); } return(dto); }
/// <summary> /// Gets the catalog association dto by entry code. /// </summary> /// <param name="catalogId">The catalog id.</param> /// <param name="catalogEntryCode">The catalog entry code.</param> /// <returns></returns> internal static CatalogAssociationDto GetCatalogAssociationDtoByEntryCode(int catalogId, string catalogEntryCode) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogassociation-catalogId-catalogEntryCode-", catalogId.ToString(), catalogEntryCode); CatalogAssociationDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogAssociationDto)cachedObject; } // Load the object if (dto == null) { CatalogAssociationAdmin admin = new CatalogAssociationAdmin(); admin.LoadByCatalogEntryCode(catalogId, catalogEntryCode); dto = admin.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog nodes dto. /// </summary> /// <param name="assetKey">The asset key.</param> /// <returns></returns> internal static CatalogRelationDto GetCatalogRelationDto(string assetKey) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalog-relation-asset", assetKey); CatalogRelationDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogRelationDto)cachedObject; } // Load the object if (dto == null) { CatalogRelationAdmin admin = new CatalogRelationAdmin(); admin.LoadAsset(assetKey); dto = admin.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog nodes. Results are cached. /// </summary> /// <param name="catalogName">Name of the catalog.</param> /// <param name="parentNodeCode">The parent node code.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogNodes GetCatalogNodes(string catalogName, string parentNodeCode, CatalogNodeResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalognodes-catalogname-code", responseGroup.CacheKey, catalogName, parentNodeCode); CatalogNodes nodes = new CatalogNodes(); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { nodes = (CatalogNodes)cachedObject; } else { CatalogNodeDto dto = GetCatalogNodesDto(catalogName, parentNodeCode, responseGroup); // Load Node if (dto.CatalogNode.Count > 0) { nodes = LoadNodes(dto, null, false, responseGroup); } CatalogCache.Insert(cacheKey, nodes, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout); } return(nodes); }
/// <summary> /// Gets the catalog node. Results are cached. /// </summary> /// <param name="uri">The URI.</param> /// <param name="languageCode">The language code.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogNode GetCatalogNode(string uri, string languageCode, CatalogNodeResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalognode-objects-uri", responseGroup.CacheKey, uri, languageCode); CatalogNode node = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { node = (CatalogNode)cachedObject; } // Load the object if (node == null) { CatalogNodeDto dto = GetCatalogNodeDto(uri, languageCode, responseGroup); // Load node if (dto.CatalogNode.Count > 0) { node = LoadNode(dto.CatalogNode[0], false, responseGroup); } else { node = new CatalogNode(); } CatalogCache.Insert(cacheKey, node, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout); } return(node); }
/// <summary> /// Gets the currency dto. /// </summary> /// <returns></returns> public static CurrencyDto GetCurrencyDto() { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalog-currency", CatalogConfiguration.Instance.ApplicationId.ToString()); CurrencyDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CurrencyDto)cachedObject; } // Load the object if (dto == null) { CurrencyAdmin admin = new CurrencyAdmin(); admin.Load(); dto = admin.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogSchemaTimeout); } dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog entries by catalog dto. /// </summary> /// <returns></returns> internal static CatalogEntryDto GetMerchants() { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogentry-merchants"); CatalogEntryDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogEntryDto)cachedObject; } // Load the object if (dto == null) { CatalogEntryAdmin catalog = new CatalogEntryAdmin(); catalog.LoadMerchants(); dto = catalog.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } //dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog entry by URI dto. /// </summary> /// <param name="uri">The URI.</param> /// <param name="languageCode">The language code.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogEntryDto GetCatalogEntryByUriDto(string uri, string languageCode, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogentry-uri-", responseGroup.CacheKey, uri, languageCode); CatalogEntryDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogEntryDto)cachedObject; } // Load the object if (dto == null) { CatalogEntryAdmin catalog = new CatalogEntryAdmin(); catalog.LoadByUri(uri, languageCode); dto = catalog.CurrentDto; if (dto.CatalogEntry.Count > 0) { LoadEntry(catalog, dto.CatalogEntry[0], responseGroup); } // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogEntryTimeout); } //dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog dto, checks permissions and caches results. /// </summary> /// <param name="siteGuid">The site GUID.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> public static CatalogDto GetCatalogDto(Guid siteGuid, CatalogResponseGroup responseGroup) { /* * // Checks roles first * if (!SecurityManager.CheckPermission(new string[] { CatalogRoles.CatalogAdminRole, CatalogRoles.CatalogManagerRole, CatalogRoles.CatalogViewerRole })) * return new CatalogDto(); * */ // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogs", responseGroup != null ? responseGroup.CacheKey : "", siteGuid.ToString()); CatalogDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogDto)cachedObject; } // Load the object if (dto == null) { CatalogAdmin catalog = new CatalogAdmin(); catalog.Load(siteGuid); dto = catalog.CurrentDto; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } // Continue with security checks and other operations /* * foreach (CatalogDto.CatalogRow row in dto.Catalog.Rows) * { * * // Check Security * IDataReader reader = DataHelper.CreateDataReader(dto.CatalogSecurity, String.Format("CatalogId = -1 or CatalogId = {0}", row.CatalogId)); * PermissionRecordSet recordSet = new PermissionRecordSet(PermissionHelper.ConvertReaderToRecords(reader)); * if (!PermissionManager.CheckPermission(SecurityScope.Catalog.ToString(), Permission.Read, recordSet)) * { * row.Delete(); * continue; * } * * } * */ //dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog entries dto. /// </summary> /// <param name="catalogEntries">The catalog entries.</param> /// <param name="cacheResults">if set to <c>true</c> [cache results].</param> /// <param name="cacheTimeout">The cache timeout.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogEntryDto GetCatalogEntriesDto(int[] catalogEntries, Boolean cacheResults, TimeSpan cacheTimeout, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = String.Empty; if (catalogEntries == null || catalogEntries.Length == 0) { return(null); } // Only cache results if specified if (cacheResults) { cacheKey = CatalogCache.CreateCacheKey("catalog-entriesdto", responseGroup.CacheKey, CreateCacheKey(catalogEntries)); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { return((CatalogEntryDto)cachedObject); } } Guid searchGuid = Guid.NewGuid(); CatalogEntryAdmin catalog = new CatalogEntryAdmin(); catalog.InsertSearchResults(searchGuid, catalogEntries); catalog.LoadSearchResults(searchGuid); CatalogEntryDto dto = catalog.CurrentDto; if (dto.CatalogEntry.Count > 0) { LoadEntry(catalog, dto.CatalogEntry[0], responseGroup); } if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, cacheTimeout); } return(dto); }
/// <summary> /// Searches the entries. /// </summary> /// <param name="criteria">The criteria.</param> /// <param name="startIndex">The start index.</param> /// <param name="recordsToRetrieve">The records to retrieve.</param> /// <param name="count">The count.</param> /// <param name="responseGroup">The response group.</param> /// <param name="cacheResults">if set to <c>true</c> [cache results].</param> /// <param name="cacheTimeout">The cache timeout.</param> /// <returns></returns> public virtual Entries SearchEntries(CatalogEntrySearchCriteria criteria, int startIndex, int recordsToRetrieve, out int count, CatalogEntryResponseGroup responseGroup, bool cacheResults, TimeSpan cacheTimeout) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = String.Empty; // Only cache results if specified if (cacheResults) { cacheKey = CatalogCache.CreateCacheKey("seach-catalog-entries", responseGroup.CacheKey, criteria.CacheKey, "start:" + startIndex.ToString(), "end:" + recordsToRetrieve.ToString()); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { Entries cachedEntries = (Entries)cachedObject; count = cachedEntries.TotalResults; return(cachedEntries); } } // Perform Lucene search SearchResults results = SearchEntries(criteria); count = results.TotalCount; // Get IDs we need int[] resultIndexes = results.GetIntResults(startIndex, recordsToRetrieve + 5); // we add padding here to accomodate entries that might have been deleted since last indexing // Retrieve actual entry objects, with no caching Entries entries = CatalogContext.Current.GetCatalogEntries(resultIndexes, false, new TimeSpan(), responseGroup); entries.TotalResults = count; if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, entries, cacheTimeout); } return(entries); }
/// <summary> /// Finds the items. Results can be cached. Caching parameters are specified in CatalogSearch variable. /// </summary> /// <param name="search">The search.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static Entries FindItems(CatalogSearch search, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = String.Empty; // Only cache results if specified if (search.SearchOptions.CacheResults) { cacheKey = CatalogCache.CreateCacheKey("catalog-entries", responseGroup.CacheKey, search.CacheKey); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { return((Entries)cachedObject); } } int recordsCount = 0; CatalogSearchOptions opt = search.SearchOptions; CatalogEntryDto dto = FindItemsDto2(search, ref recordsCount, responseGroup); Entries items = new Entries(); if (dto.CatalogEntry.Count > 0) { items = LoadEntries(dto, null, true, responseGroup); } items.TotalResults = recordsCount; items.TotalPages = (int)Math.Ceiling((decimal)recordsCount / opt.RecordsToRetrieve); if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, items, search.SearchOptions.CacheTimeout); } return(items); }
/// <summary> /// Retrieves table containing nodes and entries from the specified catalog and catagory. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="responseGroup">The response group.</param> /// <returns> /// DataTable with the following fields: /// ID, Name, Type, Code, StartDate, EndDate, IsActive, SortOrder, RowNumber. /// If returnTotalCount is true, [RecordCount] is returned in the last column of the output table. /// </returns> internal static DataTable GetCatalogItemsTable(ItemSearchParameters parameters, CatalogNodeResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogitemslist", responseGroup.CacheKey, parameters.CatalogId.ToString(), parameters.ParentNodeId.ToString(), parameters.OrderByClause, parameters.RecordsToRetrieve.ToString(), parameters.StartingRecord.ToString(), parameters.ReturnTotalCount.ToString(), parameters.ReturnInactive.ToString()); DataTable table = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { table = (DataTable)cachedObject; } // Load the object if (table == null) { DataCommand cmd = CatalogDataHelper.CreateDataCommand(); cmd.CommandText = String.Format("[ecf_CatalogNodesList]"); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("CatalogId", parameters.CatalogId, DataParameterType.Int)); cmd.Parameters.Add(new DataParameter("CatalogNodeId", parameters.ParentNodeId, DataParameterType.Int)); cmd.Parameters.Add(new DataParameter("OrderClause", parameters.OrderByClause, DataParameterType.NVarChar, 100)); cmd.Parameters.Add(new DataParameter("StartingRec", parameters.StartingRecord, DataParameterType.Int)); cmd.Parameters.Add(new DataParameter("NumRecords", parameters.RecordsToRetrieve, DataParameterType.Int)); cmd.Parameters.Add(new DataParameter("ReturnInactive", parameters.ReturnInactive, DataParameterType.Bit)); cmd.Parameters.Add(new DataParameter("ReturnTotalCount", parameters.ReturnTotalCount, DataParameterType.Bit)); table = DataService.LoadTable(cmd); if (table != null) { // Insert to the cache collection CatalogCache.Insert(cacheKey, table, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout); } } return(table); }
/// <summary> /// Gets the catalog entries. /// </summary> /// <param name="catalogEntries">The catalog entries.</param> /// <param name="cacheResults">if set to <c>true</c> [cache results].</param> /// <param name="cacheTimeout">The cache timeout.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static Entries GetCatalogEntries(int[] catalogEntries, bool cacheResults, TimeSpan cacheTimeout, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = String.Empty; if (catalogEntries == null || catalogEntries.Length == 0) { return(new Entries()); } // Only cache results if specified if (cacheResults) { cacheKey = CatalogCache.CreateCacheKey("catalog-entries", responseGroup.CacheKey, CreateCacheKey(catalogEntries)); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { return((Entries)cachedObject); } } CatalogEntryDto dto = GetCatalogEntriesDto(catalogEntries, false, new TimeSpan(), responseGroup); Entries items = new Entries(); if (dto.CatalogEntry.Count > 0) { items = LoadEntries(dto, null, true, responseGroup); } if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, items, cacheTimeout); } return(items); }
/// <summary> /// Gets the facets. /// </summary> /// <param name="cacheResults">if set to <c>true</c> [cache results].</param> /// <param name="cacheTimeout">The cache timeout.</param> /// <returns></returns> public virtual FacetGroup[] GetFacets(bool cacheResults, TimeSpan cacheTimeout) { NameValueCollection querystring = HttpContext.Current.Request.QueryString; string cacheKey = String.Empty; CatalogEntrySearchCriteria criteria = CreateSearchCriteria(querystring["search"], null); if (cacheResults) { // Only cache results if specified cacheKey = CatalogCache.CreateCacheKey("search-catalog-facets", criteria.CacheKey); // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { return((FacetGroup[])cachedObject); } } FacetGroup[] groups = null; if (_Results != null) { groups = _Results.FacetGroups; } else { groups = SearchEntries(criteria).FacetGroups; } if (!String.IsNullOrEmpty(cacheKey)) // cache results { // Insert to the cache collection CatalogCache.Insert(cacheKey, groups, cacheTimeout); } return(groups); }
/// <summary> /// Gets the catalog node dto. /// </summary> /// <param name="uri">The URI.</param> /// <param name="languageCode">The language code.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogNodeDto GetCatalogNodeDto(string uri, string languageCode, CatalogNodeResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalognode-uri", responseGroup.CacheKey, languageCode.ToString(), uri); CatalogNodeDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogNodeDto)cachedObject; } // Load the object if (dto == null) { CatalogNodeAdmin catalog = new CatalogNodeAdmin(); catalog.LoadByUri(uri, languageCode); dto = catalog.CurrentDto; if (dto.CatalogNode.Count > 0) { foreach (CatalogNodeDto.CatalogNodeRow row in dto.CatalogNode.Rows) { LoadNode(catalog, row, responseGroup); } } // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout); } //dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog entries by catalog dto. /// </summary> /// <param name="catalogName">Name of the catalog.</param> /// <param name="parentNodeCode">The parent node code.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogEntryDto GetCatalogEntriesByCatalogDto(string catalogName, string parentNodeCode, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogentries-catalogname", responseGroup.CacheKey, catalogName, parentNodeCode); CatalogEntryDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogEntryDto)cachedObject; } // Load the object if (dto == null) { CatalogEntryAdmin catalog = new CatalogEntryAdmin(); catalog.LoadByCatalogNodeCode(catalogName, parentNodeCode); dto = catalog.CurrentDto; if (dto.CatalogEntry.Count > 0) { foreach (CatalogEntryDto.CatalogEntryRow row in dto.CatalogEntry.Rows) { LoadEntry(catalog, row, responseGroup); } } // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogCollectionTimeout); } //dto.AcceptChanges(); return(dto); }
/// <summary> /// Gets the catalog entries dto. /// </summary> /// <param name="parentEntryId">The parent entry id.</param> /// <param name="entryType">Type of the entry.</param> /// <param name="relationType">Type of the relation.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> internal static CatalogEntryDto GetCatalogEntriesDto(int parentEntryId, string entryType, string relationType, CatalogEntryResponseGroup responseGroup) { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalogrelatedentries", responseGroup.CacheKey, parentEntryId.ToString(), entryType.ToString(), relationType.ToString()); CatalogEntryDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogEntryDto)cachedObject; } // Load the object if (dto == null) { CatalogEntryAdmin catalog = new CatalogEntryAdmin(); catalog.LoadChildren(parentEntryId, entryType, relationType); dto = catalog.CurrentDto; if (dto.CatalogEntry.Count > 0) { foreach (CatalogEntryDto.CatalogEntryRow row in dto.CatalogEntry.Rows) { LoadEntry(catalog, row, responseGroup); } } // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogEntryTimeout); } //dto.AcceptChanges(); return(dto); }