Пример #1
0
        /// <summary>
        /// Gets the catalog nodes. Results are cached.
        /// </summary>
        /// <param name="catalogName">Name of the catalog.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodes GetCatalogNodes(string catalogName, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalognodes-catalogname", responseGroup.CacheKey, catalogName);

            CatalogNodes nodes = new CatalogNodes();

            // check cache first
            object cachedObject = CatalogCache.Get(cacheKey);

            if (cachedObject != null)
            {
                nodes = (CatalogNodes)cachedObject;
            }
            else
            {
                CatalogNodeDto dto = GetCatalogNodesDto(catalogName, responseGroup);

                // Load Node
                if (dto.CatalogNode.Count > 0)
                {
                    nodes = LoadNodes(dto, null, false, responseGroup);
                }

                CatalogCache.Insert(cacheKey, nodes, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout);
            }

            return(nodes);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <summary>
        /// Gets the catalog node dto.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodeDto GetCatalogNodeDto(string code, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalognode-code", responseGroup.CacheKey, code.ToString());

            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.Load(code);
                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);
        }
Пример #4
0
        /// <summary>
        /// Loads the nodes.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodes LoadNodes(CatalogNodeDto dto, CatalogNode parent, bool recursive, CatalogNodeResponseGroup responseGroup)
        {
            List <CatalogNode> nodes = new List <CatalogNode>();

            foreach (CatalogNodeDto.CatalogNodeRow childRow in dto.CatalogNode)
            {
                CatalogNode childNode = LoadNode(childRow, recursive, responseGroup);
                childNode.ParentNode = parent;
                nodes.Add(childNode);
            }

            CatalogNodes n = new CatalogNodes();

            n.CatalogNode = nodes.ToArray();
            return(n);
        }
Пример #5
0
        /// <summary>
        /// Loads the node.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNode LoadNode(/*CatalogNodeDto dto,*/ CatalogNodeDto.CatalogNodeRow row, bool recursive, CatalogNodeResponseGroup responseGroup)
        {
            CatalogNode node = null;

            // Load node
            if (row != null)
            {
                node = new CatalogNode(row);
            }
            else
            {
                node = new CatalogNode();
            }

            // Populate children
            if (responseGroup.ContainsGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull) || responseGroup.ContainsGroup(CatalogNodeResponseGroup.ResponseGroup.Children))
            {
                CatalogNodeDto childrenDto = GetCatalogNodesDto(row.CatalogId, row.CatalogNodeId, responseGroup);
                CatalogNodes   nodes       = LoadNodes(childrenDto, node, recursive, responseGroup);
                node.Children = nodes;
            }

            return(node);
        }
Пример #6
0
        /// <summary>
        /// Finds the nodes 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 CatalogNodeDto FindNodesDto(CatalogSearch search, ref int recordsCount, CatalogNodeResponseGroup 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-nodesdto", responseGroup.CacheKey, search.CacheKey);

                // check cache first
                object cachedObject = CatalogCache.Get(cacheKey);

                if (cachedObject != null)
                {
                    return((CatalogNodeDto)cachedObject);
                }
            }

            CatalogNodeDto dto = FindNodesDto2(search, ref recordsCount, responseGroup);

            if (!String.IsNullOrEmpty(cacheKey)) // cache results
            {
                // Insert to the cache collection
                CatalogCache.Insert(cacheKey, dto, search.SearchOptions.CacheTimeout);
            }

            return(dto);
        }
Пример #7
0
        /// <summary>
        /// Finds the nodes dto2.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="recordsCount">The records count.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        private static CatalogNodeDto FindNodesDto2(CatalogSearch search, ref int recordsCount, CatalogNodeResponseGroup responseGroup)
        {
            CatalogNodeDto dto = null;

            Guid searchGuid = Guid.NewGuid();

            // Perform order search
            recordsCount = search.SearchNodes(searchGuid);

            CatalogNodeAdmin admin = new CatalogNodeAdmin();

            // Load results and return them back
            admin.LoadSearchResults(searchGuid);

            dto = admin.CurrentDto;

            if (dto.CatalogNode.Count > 0)
            {
                foreach (CatalogNodeDto.CatalogNodeRow row in dto.CatalogNode.Rows)
                {
                    LoadNode(admin, row, responseGroup);
                }
            }

            /*
             * if (admin.CurrentDto.CatalogNode.Count > 0)
             * {
             *  MetaDataContext.Current = CatalogContext.MetaDataContext;
             *  foreach (CatalogNodeDto.CatalogNodeRow row in admin.CurrentDto.CatalogNode.Rows)
             *      MetaHelper.FillMetaData(row, row.MetaClassId, row.CatalogNodeId, true);
             * }
             * */

            return(admin.CurrentDto);
        }
Пример #8
0
 /// <summary>
 /// Loads the node.
 /// </summary>
 /// <param name="admin">The admin.</param>
 /// <param name="row">The row.</param>
 /// <param name="responseGroup">The response group.</param>
 private static void LoadNode(CatalogNodeAdmin admin, CatalogNodeDto.CatalogNodeRow row, CatalogNodeResponseGroup responseGroup)
 {
     if (responseGroup.ContainsGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull) || responseGroup.ContainsGroup(CatalogNodeResponseGroup.ResponseGroup.Assets))
     {
         // Load Associations
         admin.LoadAssets(row.CatalogNodeId);
     }
 }
Пример #9
0
        /// <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);
        }