예제 #1
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);
        }
예제 #2
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);
     }
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <summary>
        /// Saves the catalog node.
        /// </summary>
        /// <param name="dto">The dto.</param>
        internal static void SaveCatalogNode(CatalogNodeDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto", String.Format("CatalogNodeDto can not be null"));
            }

            //TODO: check concurrency when updating the records

            //TODO: need to check security roles here,
            // The procedure will be following:
            // 1. Retrieve the record from the database for each category that is about to be updated
            // 2. Check Write permissions (if failed generate the error and exit)
            // 3. Otherwise proceed to update
            // 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(CatalogScope.Catalog, Permission.Read, recordSet))
             *  {
             *      row.Delete();
             *      continue;
             *  }
             * }
             * */


            CatalogNodeAdmin admin = new CatalogNodeAdmin(dto);

            EventContext.Instance.RaiseNodeUpdatingEvent(dto, new NodeEventArgs("updating"));
            admin.Save();
            EventContext.Instance.RaiseNodeUpdatedEvent(dto, new NodeEventArgs("updated"));
        }